create config on init
This commit is contained in:
parent
d5a48b91f0
commit
057f214e33
1 changed files with 31 additions and 8 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
|
from configparser import ConfigParser
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import datalad.api as dl
|
import datalad.api as dl
|
||||||
import os
|
import os
|
||||||
|
import tracker as tr
|
||||||
|
|
||||||
|
|
||||||
def _create_db(db):
|
def _create_db(db):
|
||||||
|
|
@ -34,19 +36,40 @@ def _create_db(db):
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
def _create_config(path):
|
||||||
|
"""
|
||||||
|
Create the config file for backlogger.
|
||||||
|
|
||||||
|
"""
|
||||||
|
config = ConfigParser()
|
||||||
|
config['core'] = {
|
||||||
|
'version': '1.0',
|
||||||
|
'db_path': os.path.join(path, 'backlogger.db'),
|
||||||
|
'projects_path': os.path.join(path, 'projects'),
|
||||||
|
'archive_path': os.path.join(path, 'archive'),
|
||||||
|
'toml_imports_path': os.path.join(path, 'toml_imports'),
|
||||||
|
'import_scripts_path': os.path.join(path, 'import_scripts'),
|
||||||
|
'tracker': 'datalad',
|
||||||
|
'cached': True,
|
||||||
|
}
|
||||||
|
with open(os.path.join(path, '.corrlib'), 'w') as configfile:
|
||||||
|
config.write(configfile)
|
||||||
|
|
||||||
|
|
||||||
def create(path):
|
def create(path):
|
||||||
"""
|
"""
|
||||||
Create folder of backlogs.
|
Create folder of backlogs.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
dl.create(path)
|
dl.create(path)
|
||||||
_create_db(path + '/backlogger.db')
|
_create_db(os.path.join(path, 'backlogger.db'))
|
||||||
os.chmod(path + '/backlogger.db', 0o666) # why does this not work?
|
os.chmod(os.path.join(path, 'backlogger.db'), 0o666) # why does this not work?
|
||||||
os.makedirs(path + '/projects')
|
_create_config(path)
|
||||||
os.makedirs(path + '/archive')
|
os.makedirs(os.path.join(path, 'projects'))
|
||||||
os.makedirs(path + '/toml_imports')
|
os.makedirs(os.path.join(path, 'archive'))
|
||||||
os.makedirs(path + '/import_scripts/template.py')
|
os.makedirs(os.path.join(path, 'toml_imports'))
|
||||||
with open(path + "/.gitignore", "w") as fp:
|
os.makedirs(os.path.join(path, 'import_scripts/template.py'))
|
||||||
|
with open(os.path.join(path, ".gitignore"), "w") as fp:
|
||||||
fp.write(".cache")
|
fp.write(".cache")
|
||||||
fp.close()
|
fp.close()
|
||||||
dl.save(path, dataset=path, message="Initialize backlogger directory.")
|
tr.save(path, message="Initialized correlator library", dataset=path)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue