Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.

Commit bd4aab5

Browse files
committed
Support custom settings files
1 parent 7d286f8 commit bd4aab5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ __pycache__
66
.DS_Store
77
logs
88
project/settings_local.py
9+
project/*_settings.py
910
project/game/ai/common
1011

1112
tests_validate_hand.py

project/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ def parse_args_and_set_up_settings():
4343
default=settings.AI_PACKAGE,
4444
help='AI package')
4545

46+
parser.add_option('-s', '--settings',
47+
type='string',
48+
default=None,
49+
help='Settings file name (without path, just file name without extension)')
50+
4651
opts, _ = parser.parse_args()
4752

4853
settings.USER_ID = opts.user_id
@@ -51,6 +56,13 @@ def parse_args_and_set_up_settings():
5156
settings.WAITING_GAME_TIMEOUT_MINUTES = opts.timeout
5257
settings.AI_PACKAGE = opts.ai
5358

59+
if opts.settings:
60+
module = __import__(opts.settings)
61+
for key, value in vars(module).items():
62+
# let's use only upper case settings
63+
if key.isupper():
64+
settings.__setattr__(key, value)
65+
5466
# it is important to reload bot class
5567
settings.load_ai_class()
5668

0 commit comments

Comments
 (0)