Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-imcflibs
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
imcf
python-imcflibs
Commits
b65c5634
Commit
b65c5634
authored
6 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add pathtools.derive_out_dir()
parent
92b9b2f0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/imcflibs/pathtools.py
+30
-0
30 additions, 0 deletions
src/imcflibs/pathtools.py
with
30 additions
and
0 deletions
src/imcflibs/pathtools.py
+
30
−
0
View file @
b65c5634
...
...
@@ -4,6 +4,8 @@ import platform
from
os
import
sep
import
os.path
from
.log
import
LOG
as
log
def
parse_path
(
path
):
"""
Parse a path into its components.
...
...
@@ -150,6 +152,34 @@ def gen_name_from_orig(path, orig_name, tag, suffix):
return
name
def
derive_out_dir
(
in_dir
,
out_dir
):
"""
Derive `out_dir` from its own value and the value of `in_dir`.
In case the supplied value of `out_dir` is one of
'
-
'
or
'
NONE
'
, the
returned value will be set to `in_dir`. Otherwise the value of `out_dir`
will be returned unchanged.
Parameters
----------
in_dir : str
The full path to the input directory.
out_dir : str
Either the full path to an output directory or one of
'
-
'
or
'
NONE
'
.
Returns
-------
str
The full path to the directory to be used for output and temp files.
"""
if
out_dir
in
[
"
-
"
,
"
NONE
"
]:
out_dir
=
in_dir
log
.
info
(
"
No output directory given, using input dir [%s].
"
,
out_dir
)
else
:
log
.
info
(
"
Using directory [%s] for results and temp files.
"
,
out_dir
)
return
out_dir
# pylint: disable-msg=C0103
# we use the variable name 'exists' in its common spelling (lowercase), so
# removing this workaround will be straightforward at a later point
...
...
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