Commit af76369d authored by Kiste's avatar Kiste
Browse files

Replace YAML config with JSON

parent b6e9666c
{
"path": "/home/user/studip",
"user": "user",
"password": "passphrase",
"blacklist": [
"Veranstaltung 1",
"Veranstaltung 2"
],
"allsemesters": false
}
path: /home/user/studip
user: user
#password:
blacklist:
- Veranstaltung 1a
allsemesters: true
......@@ -13,8 +13,7 @@ setup(
packages=['studsauger'],
install_requires=[
'keyring',
'requests',
'PyYAML'
'requests'
],
entry_points={
'console_scripts': [
......
# -*- coding: utf-8 -*-
import argparse
import json
import os
import keyring
import yaml
from .logik import logik
def main():
......@@ -13,7 +13,7 @@ def main():
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('-a', '--allsemesters', help='Alle Semester statt nur dem aktuellen', action="store_true")
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')
parser.add_argument('-c', '--config', help='JSON-Konfigurationsdatei, wird ohne Angabe in $XDG_CONFIG_HOME/studsauger/config.json oder $HOME/.config/studsauger/config.json gesucht')
args = parser.parse_args()
configpath = None
......@@ -24,18 +24,15 @@ def main():
print('Die Konfigurationsdatei "' + args.config + '" existiert nicht!')
exit(1)
elif 'XDG_CONFIG_HOME' in os.environ:
if os.path.isfile(os.environ['XDG_CONFIG_HOME'] + '/studsauger/config.yaml'):
configpath = os.environ['XDG_CONFIG_HOME'] + '/studsauger/config.yaml'
if os.path.isfile(os.environ['XDG_CONFIG_HOME'] + '/studsauger/config.json'):
configpath = os.environ['XDG_CONFIG_HOME'] + '/studsauger/config.json'
elif 'HOME' in os.environ:
if os.path.isfile(os.environ['HOME'] + '/.config/studsauger/config.yaml'):
configpath = os.environ['HOME'] + '/.config/studsauger/config.yaml'
if os.path.isfile(os.environ['HOME'] + '/.config/studsauger/config.json'):
configpath = os.environ['HOME'] + '/.config/studsauger/config.json'
if configpath:
with open(configpath, 'r') as stream:
try:
config = yaml.load(stream)
except yaml.YAMLError as exc:
print(exc)
config = json.load(stream)
else:
config = {}
......
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