Commit 1026146f authored by Kiste's avatar Kiste
Browse files

Make config file path configurable

parent a5fe9402
......@@ -18,13 +18,29 @@ parser.add_argument('-p', '--path', help='Pfad für lokalen Dateibaum')
parser.add_argument('-u', '--user', help='Stud.IP Benutzername')
parser.add_argument('-pw', '--password', help='Stud.IP Passwort')
parser.add_argument('-b', '--blacklist', help='Blacklist für Veranstaltungen, mehrmals angeben für mehrere Veranstaltungen', action='append')
parser.add_argument('-c', '--config', help='YAML-Konfigurationsdatei, wird ohne Angabe in $XDG_CONFIG_HOME/studsauger/config.yaml oder $HOME/.config/studsauger/config.yaml gesucht')
args = parser.parse_args()
with open('config.yaml', 'r') as stream:
try:
config = yaml.load(stream)
except yaml.YAMLError as exc:
print(exc)
configpath = None
if args.config:
if os.path.isfile(args.config):
configpath = args.config
else:
print('Die Konfigurationsdatei ' + args.config + ' existiert nicht!')
exit(1)
elif os.path.isfile(os.environ['XDG_CONFIG_HOME'] + '/studsauger/config.yaml'):
configpath = os.environ['XDG_CONFIG_HOME'] + '/studsauger/config.yaml'
elif os.path.isfile(os.environ['HOME'] + '/.config/studsauger/config.yaml'):
configpath = os.environ['HOME'] + '/.config/studsauger/config.yaml'
if configpath:
with open(configpath, 'r') as stream:
try:
config = yaml.load(stream)
except yaml.YAMLError as exc:
print(exc)
else:
config = {}
if args.path:
path = args.path
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment