Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
plotID_python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plotID
plotID_python
Commits
e2b779f6
Commit
e2b779f6
authored
2 years ago
by
Mayr, Hannes
Browse files
Options
Downloads
Patches
Plain Diff
Resolve "Publish destination directory"
parent
f8f75816
Branches
Branches containing commit
No related tags found
1 merge request
!28
Resolve "Publish destination directory"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/matplotlib_example.py
+1
-1
1 addition, 1 deletion
examples/matplotlib_example.py
plotid/publish.py
+2
-9
2 additions, 9 deletions
plotid/publish.py
tests/test_publish.py
+13
-12
13 additions, 12 deletions
tests/test_publish.py
with
16 additions
and
22 deletions
examples/matplotlib_example.py
+
1
−
1
View file @
e2b779f6
...
@@ -46,6 +46,6 @@ FIGS_AND_IDS = tagplot(FIGS_AS_LIST, 'matplotlib', location='west',
...
@@ -46,6 +46,6 @@ FIGS_AND_IDS = tagplot(FIGS_AS_LIST, 'matplotlib', location='west',
# %% Publish
# %% Publish
publish
(
FIGS_AND_IDS
,
[
'
../README.md
'
,
'
../docs
'
,
'
../LICENSE
'
],
publish
(
FIGS_AND_IDS
,
[
'
../README.md
'
,
'
../docs
'
,
'
../LICENSE
'
],
'
./
data
'
,
'
my_plot
'
)
'
data
'
,
'
my_plot
'
)
# Required arguments: publish(output of tagplot(), list of files,
# Required arguments: publish(output of tagplot(), list of files,
# path to destination folder, name(s) for the resulting images)
# path to destination folder, name(s) for the resulting images)
This diff is collapsed.
Click to expand it.
plotid/publish.py
+
2
−
9
View file @
e2b779f6
...
@@ -42,18 +42,11 @@ class PublishOptions:
...
@@ -42,18 +42,11 @@ class PublishOptions:
self
.
figure
=
figs_and_ids
.
figs
self
.
figure
=
figs_and_ids
.
figs
self
.
figure_ids
=
figs_and_ids
.
figure_ids
self
.
figure_ids
=
figs_and_ids
.
figure_ids
self
.
src_datapaths
=
src_datapaths
self
.
src_datapaths
=
src_datapaths
self
.
dst_path
=
dst_path
self
.
dst_path
=
os
.
path
.
abspath
(
dst_path
)
self
.
plot_names
=
plot_names
self
.
plot_names
=
plot_names
self
.
data_storage
=
kwargs
.
get
(
'
data_storage
'
,
'
individual
'
)
self
.
data_storage
=
kwargs
.
get
(
'
data_storage
'
,
'
individual
'
)
self
.
dst_path_head
,
self
.
dst_dirname
=
os
.
path
.
split
(
self
.
dst_path
)
self
.
dst_path_head
,
self
.
dst_dirname
=
os
.
path
.
split
(
self
.
dst_path
)
# If the second string after os.path.split is empty,
# a trailing slash was given.
# To get the dir name correctly, split the first string again.
if
not
self
.
dst_dirname
:
self
.
dst_path_head
,
self
.
dst_dirname
=
os
.
path
.
split
(
self
.
dst_path_head
)
def
__str__
(
self
):
def
__str__
(
self
):
"""
Representation if an object of this class is printed.
"""
"""
Representation if an object of this class is printed.
"""
return
str
(
self
.
__class__
)
+
"
:
"
+
str
(
self
.
__dict__
)
return
str
(
self
.
__class__
)
+
"
:
"
+
str
(
self
.
__dict__
)
...
@@ -109,7 +102,7 @@ class PublishOptions:
...
@@ -109,7 +102,7 @@ class PublishOptions:
# Check if destination directory is allowed path
# Check if destination directory is allowed path
if
not
os
.
path
.
exists
(
self
.
dst_path_head
):
if
not
os
.
path
.
exists
(
self
.
dst_path_head
):
raise
FileNotFoundError
(
'
The specified destination directory
'
raise
FileNotFoundError
(
'
The specified destination directory
'
'
does not exist.
'
)
f
'
{
self
.
dst_path_head
}
does not exist.
'
)
# Check if plot_name is a string or a list of strings
# Check if plot_name is a string or a list of strings
if
isinstance
(
self
.
plot_names
,
str
):
if
isinstance
(
self
.
plot_names
,
str
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_publish.py
+
13
−
12
View file @
e2b779f6
...
@@ -110,9 +110,13 @@ class TestPublish(unittest.TestCase):
...
@@ -110,9 +110,13 @@ class TestPublish(unittest.TestCase):
publish
(
FIGS_AND_IDS
,
4
,
DST_PATH
,
PIC_NAME
)
publish
(
FIGS_AND_IDS
,
4
,
DST_PATH
,
PIC_NAME
)
def
test_dst_directory
(
self
):
def
test_dst_directory
(
self
):
"""
Test if Error is raised when destination dir does not exist.
"""
"""
Test if Error is raised when the directory above the
destination dir does not exist.
"""
with
self
.
assertRaises
(
FileNotFoundError
):
with
self
.
assertRaises
(
FileNotFoundError
):
publish
(
FIGS_AND_IDS
,
SRC_DIR
,
'
not_existing_folder
'
,
PIC_NAME
)
publish
(
FIGS_AND_IDS
,
SRC_DIR
,
'
not_existing_folder/data
'
,
PIC_NAME
)
def
test_script_exists
(
self
):
def
test_script_exists
(
self
):
"""
"""
...
@@ -251,16 +255,13 @@ class TestPublish(unittest.TestCase):
...
@@ -251,16 +255,13 @@ class TestPublish(unittest.TestCase):
"""
"""
self
.
maxDiff
=
None
self
.
maxDiff
=
None
publish_obj
=
PublishOptions
(
FIGS_AND_IDS
,
SRC_DIR
,
DST_PATH
,
PIC_NAME
)
publish_obj
=
PublishOptions
(
FIGS_AND_IDS
,
SRC_DIR
,
DST_PATH
,
PIC_NAME
)
self
.
assert
Equal
(
str
(
publish_obj
),
self
.
assert
In
(
"
<class
'
plotid.publish.PublishOptions
'
>: {
'
figure
'
:
"
"
<class
'
plotid.publish.PublishOptions
'
>: {
'
figure
'
:
"
"
[<Figure size 640x480 with 0 Axes>, <Figure size
"
"
[<Figure size 640x480 with 0 Axes>, <Figure size
"
"
640x480 with 0 Axes>],
'
figure_ids
'
:
"
"
640x480 with 0 Axes>],
'
figure_ids
'
:
"
"
[
'
MR05_0x63203c6f
'
,
'
MR05_0x63203c70
'
],
"
"
[
'
MR05_0x63203c6f
'
,
'
MR05_0x63203c70
'
],
"
"'
src_datapaths
'
:
'
test_src_folder
'
,
'
dst_path
'
:
"
"'
src_datapaths
'
:
'
test_src_folder
'"
,
"'
test_parent/test_dst_folder
'
,
'
plot_names
'
:
"
str
(
publish_obj
))
"'
test_picture
'
,
'
data_storage
'
:
'
individual
'
,
"
"'
dst_path_head
'
:
'
test_parent
'
,
'
dst_dirname
'
:
"
"'
test_dst_folder
'
}
"
)
def
tearDown
(
self
):
def
tearDown
(
self
):
"""
Delete all files created in setUp.
"""
"""
Delete all files created in setUp.
"""
...
...
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