Commit 1c3a6d1a authored by Mattia Rizzolo's avatar Mattia Rizzolo

make possible to start without version file

Signed-off-by: Mattia Rizzolo's avatarMattia Rizzolo <mattia@debian.org>
parent cd25203c
......@@ -29,9 +29,27 @@ def is_root_valid(path):
print(")he specified root directory doesn't exist, please create it.")
return False
required_files = ["config.json", "details.json", "version"]
# version file
file = path / 'version'
if not file.exists():
if not (path/'branches').exists() and not (path/'details.json').exists():
print('No version file found, and this seems an empty root, creating')
with open(file, 'w') as f:
f.write(ROOT_DIR_VERSION)
else:
print('Non-empty root missing version file.')
return False
elif not file.is_file():
print('There is a version non-file conflicting with the expectations.')
return False
else:
with open(file) as f:
ver = f.read().strip()
if ver != ROOT_DIR_VERSION:
print('Found wrong version ', ver)
return False
# make sure a branches directory is available:
# branches directory
dir = path / 'branches'
if not dir.exists():
print('Creating the branches directory...')
......@@ -40,14 +58,12 @@ def is_root_valid(path):
print('There is a branches file conflicting with the expected directory')
return False
# TODO make possible to start without these two files
required_files = ["config.json", "details.json"]
for file in required_files:
file = path / file
if not (file.exists() and file.is_file()):
print("The required file %s does not exist" % file)
return False
with (path / "version").open("r") as f:
if f.read().strip() != ROOT_DIR_VERSION:
return False
return True
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment