Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
e6383e2e
Unverified
Commit
e6383e2e
authored
5 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
ENH: make rerun an argument
parent
0709f919
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/export_related.py
+1
-1
1 addition, 1 deletion
src/caosadvancedtools/export_related.py
src/caosadvancedtools/import_from_xml.py
+7
-7
7 additions, 7 deletions
src/caosadvancedtools/import_from_xml.py
with
8 additions
and
8 deletions
src/caosadvancedtools/export_related.py
+
1
−
1
View file @
e6383e2e
...
...
@@ -118,7 +118,7 @@ def main(rec_id):
xml
=
etree
.
tounicode
(
cont
.
to_xml
(
local_serialization
=
True
),
pretty_print
=
True
)
with
open
(
"
test.txt
"
,
"
w
"
)
as
fi
:
with
open
(
"
caosdb_data.xml
"
,
"
w
"
)
as
fi
:
fi
.
write
(
xml
)
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/import_from_xml.py
+
7
−
7
View file @
e6383e2e
...
...
@@ -33,9 +33,6 @@ from tempfile import NamedTemporaryFile
import
caosdb
as
db
from
caosmodels.data_model
import
DataModel
from
lxml
import
etree
RERUN
=
False
def
create_dummy_file
(
text
=
"
Please ask the administrator for this file.
"
):
...
...
@@ -47,7 +44,7 @@ def create_dummy_file(text="Please ask the administrator for this file."):
return
tmpfile
.
name
def
main
(
filename
):
def
main
(
filename
,
rerun
=
False
):
cont
=
db
.
Container
()
with
open
(
filename
)
as
fi
:
cont
=
cont
.
from_xml
(
fi
.
read
())
...
...
@@ -78,7 +75,7 @@ def main(filename):
new_files
=
[]
print
(
files
)
if
not
RERUN
:
if
not
rerun
:
for
fi
in
files
:
new
=
db
.
File
(
file
=
fi
.
file
,
path
=
fi
.
path
,
name
=
fi
.
name
,
id
=
fi
.
id
,
description
=
fi
.
description
)
...
...
@@ -110,7 +107,7 @@ def main(filename):
# insert files
if
not
RERUN
:
if
not
rerun
:
for
i
,
el
in
enumerate
(
files
):
print
(
el
)
r
=
el
.
insert
(
unique
=
False
)
...
...
@@ -137,6 +134,9 @@ def main(filename):
def
defineParser
():
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
parser
.
add_argument
(
"
file
"
,
help
=
'
file to be imported
'
)
parser
.
add_argument
(
"
--rerun
"
,
help
=
'
if this script is run at least a
'
'
second time and files are already inserted
'
,
action
=
"
store_true
"
)
return
parser
...
...
@@ -145,4 +145,4 @@ if __name__ == "__main__":
parser
=
defineParser
()
args
=
parser
.
parse_args
()
main
(
args
.
file
)
main
(
args
.
file
,
args
.
rerun
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment