copy file is a choice
This commit is contained in:
parent
a55f1a33ac
commit
b9ce012062
1 changed files with 24 additions and 5 deletions
|
@ -31,7 +31,7 @@ def check_project_data(d):
|
|||
return
|
||||
|
||||
|
||||
def import_toml(path, file):
|
||||
def import_toml(path, file, copy_file=True):
|
||||
"""
|
||||
Import a project decribed by a .toml file.
|
||||
|
||||
|
@ -63,10 +63,29 @@ def import_toml(path, file):
|
|||
write_measurement(path, ensemble, measurement, uuid,
|
||||
project['code'], md['param_file'])
|
||||
print(mname + " imported.")
|
||||
if not os.path.exists(path + "/toml_imports/" + uuid):
|
||||
os.makedirs(path + "/toml_imports/" + uuid)
|
||||
import_file = "toml_imports/" + uuid + "/import.toml"
|
||||
shutil.copy(file, )
|
||||
if not os.path.exists(os.path.join(path, "toml_imports", uuid)):
|
||||
os.makedirs(os.path.join(path, "toml_imports", uuid))
|
||||
if copy_file:
|
||||
import_file = os.path.join(path, "toml_imports", uuid, file)
|
||||
shutil.copy(file, import_file)
|
||||
dl.save(path + import_file, message="Import using " + import_file, dataset=path)
|
||||
print("Imported project, file copied to " + import_file)
|
||||
return
|
||||
|
||||
|
||||
def reimport_project(path, uuid):
|
||||
"""
|
||||
Reimport an existing project using the files that are already available for this project.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
path: str
|
||||
Path to repository
|
||||
uuid: str
|
||||
uuid of the project that is to be reimported.
|
||||
"""
|
||||
config_path = "/".join([path, "import_scripts", uuid])
|
||||
for p, filenames, dirnames in os.walk(config_path):
|
||||
for fname in filenames:
|
||||
import_toml(path, os.path.join(config_path, fname), copy_file=False)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue