Skip to content

Commit

Permalink
Multiple Config File Support (#771)
Browse files Browse the repository at this point in the history
* Multiple Config File Support

Adds ability to drop config files into the 'configs' dir whilst
developing and have them ignored by git

* Modified .gitignore

* Fixed Example files not being included

* Added warnings to PokeCLI based on config availability
  • Loading branch information
ColeGreenlee authored and dmateusp committed Jul 25, 2016
1 parent fb2cca3 commit c13a400
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
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

0 comments on commit c13a400

Please sign in to comment.