aboutsummaryrefslogtreecommitdiff
path: root/src/ee/project/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/project/__init__.py')
-rw-r--r--src/ee/project/__init__.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/ee/project/__init__.py b/src/ee/project/__init__.py
index 395d204..c9e02f8 100644
--- a/src/ee/project/__init__.py
+++ b/src/ee/project/__init__.py
@@ -36,12 +36,8 @@ class Project(object):
self.project_dir = project_dir
self._cfg = cfg
- if "project" not in cfg:
- cfg.add_section("project")
-
- project = cfg["project"]
- if "uuid" not in project:
- project["uuid"] = str(uuid.uuid4())
+ project = self.get_or_create_section("project")
+ project["uuid"] = project.get("uuid", str(uuid.uuid4()))
# TODO: read from config
self._suppliers = []
@@ -68,13 +64,19 @@ class Project(object):
def cfg(self):
return self._cfg
+ def get_or_create_section(self, section):
+ try:
+ return self._cfg[section]
+ except KeyError:
+ self._cfg.add_section(section)
+ return self._cfg[section]
+
@property
def uuid(self):
return uuid.UUID(hex=self._cfg["project"]["uuid"])
@classmethod
- def load(cls):
- project_dir = Path(".")
+ def load(cls, project_dir=Path(".")):
cfg = load_config(project_dir)
return Project(project_dir, cfg)