1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-10 10:04:21 +01:00

Merge pull request #35 from pedromaltez/pm/feature/XDG_CONFIG_HOME_support

Respect XDG_CONFIG_HOME if it is set
This commit is contained in:
Viktor Stanchev 2014-11-10 23:47:22 -08:00
commit 18be0be73c
2 changed files with 11 additions and 2 deletions

View File

@ -43,7 +43,10 @@ optional arguments:
## Configuration file
pirate-get will check to see if `$HOME/.config/pirate-get/pirate.cfg` exists. If it does it will use it as its default configuration settings.
You can use a file to override pirate-get's default settings. pirate-get will
first check if `$XDG_CONFIG_HOME/pirate-get/pirate.cfg` exists, then check if
`$HOME/.config/pirate-get/pirate.cfg` exists, and load the first file it finds.
### SaveToFile

View File

@ -80,7 +80,13 @@ def main():
config.set('SaveToFile', 'directory', '~/Dropbox/pirate-get/')
# load user options, to override default ones
config.read([os.path.expanduser('~/.config/pirate-get/pirate.cfg')])
def config_to_load():
if os.path.isfile(os.path.expandvars('$XDG_CONFIG_HOME/pirate-get/pirate.cfg')):
return os.path.expandvars('$XDG_CONFIG_HOME/pirate-get/pirate.cfg')
else:
return os.path.expanduser('~/.config/pirate-get/pirate.cfg')
config.read([config_to_load()])
parser = argparse.ArgumentParser(description='Finds and downloads torrents from the Pirate Bay')
parser.add_argument('-b', dest='browse', action='store_true', help="Display in Browse mode", default=False)