Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Config File Support #771

Merged
merged 5 commits into from
Jul 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,10 @@ data/catch-ignore.yml
release_config.json
web/userdata.js
location.json

#Multiple config
configs/*
!configs/config.json.example
!configs/release_config.json.example
!config.json.example
!release_config.json.example
2 changes: 1 addition & 1 deletion config.json.example → configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"item_filter": "101,102,103,104",
"evolve_all": "NONE",
"use_lucky_egg": false
}
}
File renamed without changes.
8 changes: 6 additions & 2 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@

def init_config():
parser = argparse.ArgumentParser()
config_file = "config.json"
release_config_json = "release_config.json"
config_file = "configs/config.json"
release_config_json = "configs/release_config.json"
web_dir = "web"

# If config file exists, load variables from json
Expand All @@ -60,8 +60,12 @@ def init_config():
with open(config_arg) as data:
load.update(json.load(data))
elif os.path.isfile(config_file):
logger.log('[x] No config argument specified, checking for /configs/config.json', 'yellow')
with open(config_file) as data:
load.update(json.load(data))
else:
logger.log('[x] Error: No /configs/config.json or specified config', 'red')


# Read passed in Arguments
required = lambda x: not x in load
Expand Down
2 changes: 1 addition & 1 deletion pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _setup_api(self):

# check if the release_config file exists
try:
with open('release_config.json') as file:
with open('configs/release_config.json') as file:
pass
except:
# the file does not exist, warn the user and exit.
Expand Down