Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
python-handel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bliss
python-handel
Commits
af054e37
Commit
af054e37
authored
Aug 30, 2017
by
Vincent Michel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add file interface
parent
cde1223f
Pipeline
#888
failed with stages
in 1 minute and 10 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
handel/interface.py
handel/interface.py
+21
-0
tests/test_interface.py
tests/test_interface.py
+12
-0
No files found.
handel/interface.py
View file @
af054e37
...
...
@@ -2,6 +2,9 @@
from
__future__
import
absolute_import
import
os
import
configparser
import
numpy
from
.error
import
check_error
...
...
@@ -346,3 +349,21 @@ def get_handel_version():
# int xiaMemStatistics(unsigned long *total, unsigned long *current, unsigned long *peak);
# void xiaMemSetCheckpoint(void);
# void xiaMemLeaks(char *);
# Files
def
get_config_files
(
path
):
"""Return all the ini files in path (including subdirectories)."""
return
[
os
.
path
.
join
(
dp
,
f
)
for
dp
,
dn
,
fn
in
os
.
walk
(
path
)
for
f
in
fn
if
f
.
endswith
(
'.ini'
)]
def
get_config
(
filename
):
"""Read and return the given config file as a dictionary."""
config
=
configparser
.
ConfigParser
(
comment_prefixes
=
[
'START'
,
'END'
,
'#'
,
'*****'
])
config
.
read
(
filename
)
return
{
key
:
dict
(
section
)
for
key
,
section
in
config
.
items
()}
tests/test_interface.py
View file @
af054e37
...
...
@@ -456,3 +456,15 @@ def test_get_handel_version(interface):
assert
interface
.
get_handel_version
()
==
(
1
,
2
,
3
)
m
.
assert_called_once
()
# xiaGetVersionInfo does not return an error code
# Files
def
test_get_config_files
(
interface
):
assert
interface
.
get_config_files
(
'.'
)
==
[
'./xmap.ini'
]
def
test_get_config
(
interface
):
filename
=
interface
.
get_config_files
(
'.'
)[
0
]
d
=
interface
.
get_config
(
filename
)
assert
d
[
'detector definitions'
][
'alias'
]
==
'detector1'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment