Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository 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
FSL
fslpy
Commits
ec2e18aa
Commit
ec2e18aa
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Add "name" property to the FileTree class
parent
9f344c6d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/filetree/filetree.py
+16
-3
16 additions, 3 deletions
fsl/utils/filetree/filetree.py
with
16 additions
and
3 deletions
fsl/utils/filetree/filetree.py
+
16
−
3
View file @
ec2e18aa
...
@@ -25,12 +25,14 @@ class FileTree(object):
...
@@ -25,12 +25,14 @@ class FileTree(object):
- ``variables``: dictionary mapping variables in the templates to specific values (variables set to None are explicitly unset)
- ``variables``: dictionary mapping variables in the templates to specific values (variables set to None are explicitly unset)
- ``sub_trees``: filename trees describing specific sub-directories
- ``sub_trees``: filename trees describing specific sub-directories
- ``parent``: parent FileTree, of which this sub-tree is a sub-directory
- ``parent``: parent FileTree, of which this sub-tree is a sub-directory
- ``name``: descriptive name of the tree
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
templates
:
Dict
[
str
,
str
],
templates
:
Dict
[
str
,
str
],
variables
:
Dict
[
str
,
Any
],
variables
:
Dict
[
str
,
Any
],
sub_trees
:
Dict
[
str
,
"
FileTree
"
]
=
None
,
sub_trees
:
Dict
[
str
,
"
FileTree
"
]
=
None
,
parent
:
Optional
[
"
FileTree
"
]
=
None
):
parent
:
Optional
[
"
FileTree
"
]
=
None
,
name
:
str
=
None
):
"""
"""
Creates a new filename tree.
Creates a new filename tree.
"""
"""
...
@@ -40,6 +42,7 @@ class FileTree(object):
...
@@ -40,6 +42,7 @@ class FileTree(object):
sub_trees
=
{}
sub_trees
=
{}
self
.
sub_trees
=
sub_trees
self
.
sub_trees
=
sub_trees
self
.
_parent
=
parent
self
.
_parent
=
parent
self
.
_name
=
name
@property
@property
def
parent
(
self
,
):
def
parent
(
self
,
):
...
@@ -48,6 +51,15 @@ class FileTree(object):
...
@@ -48,6 +51,15 @@ class FileTree(object):
"""
"""
return
self
.
_parent
return
self
.
_parent
@property
def
name
(
self
,
):
"""
Name of this ``FileTree``, or ``None`` if it has no name.
"""
return
self
.
_name
@property
@property
def
all_variables
(
self
,
):
def
all_variables
(
self
,
):
"""
"""
...
@@ -384,6 +396,7 @@ class FileTree(object):
...
@@ -384,6 +396,7 @@ class FileTree(object):
raise
ValueError
(
"
Name of sub_tree {short_name} used multiple times in {tree_name}.tree
"
.
format
(
**
locals
()))
raise
ValueError
(
"
Name of sub_tree {short_name} used multiple times in {tree_name}.tree
"
.
format
(
**
locals
()))
sub_trees
[
short_name
]
=
sub_tree
sub_trees
[
short_name
]
=
sub_tree
sub_tree
.
_name
=
sub_tree
.
_name
+
'
[
'
+
short_name
+
'
]
'
elif
'
=
'
in
line
:
elif
'
=
'
in
line
:
key
,
value
=
line
.
split
(
'
=
'
)
key
,
value
=
line
.
split
(
'
=
'
)
if
len
(
key
.
split
())
!=
1
:
if
len
(
key
.
split
())
!=
1
:
...
@@ -413,7 +426,7 @@ class FileTree(object):
...
@@ -413,7 +426,7 @@ class FileTree(object):
templates
[
short_name
]
=
str
(
current_filename
)
templates
[
short_name
]
=
str
(
current_filename
)
file_variables
.
update
(
variables
)
file_variables
.
update
(
variables
)
res
=
get_registered
(
tree_name
,
cls
)(
templates
,
variables
=
file_variables
,
sub_trees
=
sub_trees
)
res
=
get_registered
(
tree_name
,
cls
)(
templates
,
variables
=
file_variables
,
sub_trees
=
sub_trees
,
name
=
tree_name
)
for
tree
in
sub_trees
.
values
():
for
tree
in
sub_trees
.
values
():
tree
.
_parent
=
res
tree
.
_parent
=
res
return
res
return
res
...
...
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