-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#16: Added a hacky approach to directory configuration.
- Loading branch information
Showing
3 changed files
with
62 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,45 @@ | ||
import os.path | ||
|
||
|
||
UNIVERSE_PATH = os.path.abspath("data/universe/") | ||
UNIVERSE_FILE = os.path.join(UNIVERSE_PATH, "universe.json") | ||
STAR_SYSTEM_PATH = os.path.join(UNIVERSE_PATH, "star_systems") | ||
CELESTIAL_PATH = os.path.join(UNIVERSE_PATH, "celestials") | ||
USER_DIR_PATH = "data/users/" | ||
USER_FILE_PATH = USER_DIR_PATH + "%s.user.json" | ||
PLAYER_DIR_PATH = "data/players/" | ||
PLAYER_FILE_PATH = PLAYER_DIR_PATH + "%s.mobile.json" | ||
class _PathConfig(object): | ||
def __init__(self, data_path): | ||
self.data_path = os.path.abspath(data_path) | ||
|
||
@property | ||
def data_dir(self): | ||
return self.data_path | ||
|
||
@property | ||
def universe_dir(self): | ||
return os.path.join(self.data_dir, "universe") | ||
|
||
@property | ||
def universe_file(self): | ||
return os.path.join(self.universe_dir, "universe.json") | ||
|
||
@property | ||
def star_system_dir(self): | ||
return os.path.join(self.universe_dir, "star_systems") | ||
|
||
@property | ||
def celestial_dir(self): | ||
return os.path.join(self.universe_dir, "celestials") | ||
|
||
@property | ||
def user_dir(self): | ||
return os.path.join(self.data_dir, "users") | ||
|
||
@property | ||
def user_file_pattern(self): | ||
return os.path.join(self.user_dir, "%s.user.json") | ||
|
||
@property | ||
def player_dir(self): | ||
return os.path.join(self.data_dir, "players") | ||
|
||
@property | ||
def player_file_pattern(self): | ||
return os.path.join(self.player_dir, "%s.mobile.json") | ||
|
||
|
||
path = _PathConfig("data") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters