Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DCT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
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
graintracking
DCT
Commits
860f436e
Commit
860f436e
authored
11 years ago
by
Nicola Vigano
Browse files
Options
Downloads
Patches
Plain Diff
Python: reformatted to be more PEP compliant
Signed-off-by:
Nicola Vigano
<
nicola.vigano@esrf.fr
>
parent
0bec5d30
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dct_launch.py
+2
-5
2 additions, 5 deletions
dct_launch.py
zUtil_Python/dct_batch.py
+40
-37
40 additions, 37 deletions
zUtil_Python/dct_batch.py
zUtil_Python/dct_compile_matlab_functions.py
+3
-3
3 additions, 3 deletions
zUtil_Python/dct_compile_matlab_functions.py
with
45 additions
and
45 deletions
dct_launch.py
+
2
−
5
View file @
860f436e
...
@@ -27,11 +27,8 @@ class DCTLauncher(object):
...
@@ -27,11 +27,8 @@ class DCTLauncher(object):
cmd
=
args
[
1
]
cmd
=
args
[
1
]
if
cmd
in
(
"
-h
"
,
"
--help
"
):
if
cmd
in
(
"
-h
"
,
"
--help
"
):
self
.
command
=
"
help
"
self
.
command
=
"
help
"
elif
cmd
in
(
"
matlab
"
,
"
update
"
,
"
compile_mex
"
,
"
compile_matlab
"
,
\
"
update_conf
"
,
"
make
"
,
"
publish
"
):
self
.
command
=
cmd
else
:
else
:
raise
ValueError
(
"
Command
'
%s
'
not recognized
"
%
cmd
)
self
.
command
=
cmd
self
.
args
=
args
[
2
:]
self
.
args
=
args
[
2
:]
self
.
initialized
=
True
self
.
initialized
=
True
...
@@ -56,7 +53,7 @@ class DCTLauncher(object):
...
@@ -56,7 +53,7 @@ class DCTLauncher(object):
elif
self
.
command
==
"
publish
"
:
elif
self
.
command
==
"
publish
"
:
self
.
_launchPublish
()
self
.
_launchPublish
()
else
:
else
:
raise
ValueError
(
"
N
ot recognized
command
: %s
"
%
self
.
command
)
raise
ValueError
(
"
Command n
ot recognized:
'
%s
'
"
%
self
.
command
)
def
_launchMatlab
(
self
):
def
_launchMatlab
(
self
):
from
zUtil_Python.dct_compile_matlab_functions
import
FunctionsBuilder
from
zUtil_Python.dct_compile_matlab_functions
import
FunctionsBuilder
...
...
This diff is collapsed.
Click to expand it.
zUtil_Python/dct_batch.py
+
40
−
37
View file @
860f436e
...
@@ -7,6 +7,7 @@ Created on May 2, 2013
...
@@ -7,6 +7,7 @@ Created on May 2, 2013
import
re
import
re
import
fnmatch
import
fnmatch
import
os
import
os
import
sys
import
dct_io_xml
import
dct_io_xml
...
@@ -18,20 +19,20 @@ class DCTBatchConf(dct_io_xml.DCTXMLBase):
...
@@ -18,20 +19,20 @@ class DCTBatchConf(dct_io_xml.DCTXMLBase):
etree
=
dct_io_xml
.
ET
.
ElementTree
(
tree
)
etree
=
dct_io_xml
.
ET
.
ElementTree
(
tree
)
etree
.
write
(
xml_file
,
pretty_print
=
True
)
etree
.
write
(
xml_file
,
pretty_print
=
True
)
conf
=
DCTBatchConf
(
xml_file
,
read_only
=
False
)
conf
=
DCTBatchConf
(
xml_file
,
read_only
=
False
)
conf
.
fix
S
tructure
()
conf
.
fix
_s
tructure
()
return
conf
return
conf
def
__init__
(
self
,
xml_file
=
os
.
path
.
join
(
"
zUtil_Conf
"
,
"
batch-dev-conf.xml
"
),
read_only
=
True
):
def
__init__
(
self
,
xml_file
=
os
.
path
.
join
(
"
zUtil_Conf
"
,
"
batch-dev-conf.xml
"
),
read_only
=
True
):
dct_io_xml
.
DCTXMLBase
.
__init__
(
self
,
xml_file
)
dct_io_xml
.
DCTXMLBase
.
__init__
(
self
,
xml_file
)
self
.
read_only
=
read_only
self
.
read_only
=
read_only
def
fix
S
tructure
(
self
):
def
fix
_s
tructure
(
self
):
if
self
.
tree
.
find
(
"
options
"
)
is
None
:
if
self
.
tree
.
find
(
"
options
"
)
is
None
:
dct_io_xml
.
ET
.
SubElement
(
self
.
tree
.
getroot
(),
"
options
"
)
dct_io_xml
.
ET
.
SubElement
(
self
.
tree
.
getroot
(),
"
options
"
)
if
self
.
tree
.
find
(
"
functions
"
)
is
None
:
if
self
.
tree
.
find
(
"
functions
"
)
is
None
:
dct_io_xml
.
ET
.
SubElement
(
self
.
tree
.
getroot
(),
"
functions
"
)
dct_io_xml
.
ET
.
SubElement
(
self
.
tree
.
getroot
(),
"
functions
"
)
def
get
P
ath
(
self
,
xml_path
,
base_dir
,
base_node
=
None
):
def
get
_p
ath
(
self
,
xml_path
,
base_dir
,
base_node
=
None
):
if
base_node
is
None
:
if
base_node
is
None
:
node
=
self
.
tree
.
find
(
xml_path
)
node
=
self
.
tree
.
find
(
xml_path
)
else
:
else
:
...
@@ -44,10 +45,10 @@ class DCTBatchConf(dct_io_xml.DCTXMLBase):
...
@@ -44,10 +45,10 @@ class DCTBatchConf(dct_io_xml.DCTXMLBase):
else
:
else
:
raise
ValueError
(
"
No path defined for
'
%s
"
%
xml_path
)
raise
ValueError
(
"
No path defined for
'
%s
"
%
xml_path
)
def
get
BinD
ir
(
self
,
base_dir
):
def
get
_bin_d
ir
(
self
,
base_dir
):
return
self
.
get
P
ath
(
"
options/binaries/path
"
,
base_dir
)
return
self
.
get
_p
ath
(
"
options/binaries/path
"
,
base_dir
)
def
add
F
unction
(
self
,
name
,
path
,
is_absolute
=
False
):
def
add
_f
unction
(
self
,
name
,
path
,
is_absolute
=
False
):
if
self
.
read_only
is
True
:
if
self
.
read_only
is
True
:
raise
ValueError
(
"
File %s is open in read only mode
"
%
self
.
xmlFile
)
raise
ValueError
(
"
File %s is open in read only mode
"
%
self
.
xmlFile
)
...
@@ -56,30 +57,32 @@ class DCTBatchConf(dct_io_xml.DCTXMLBase):
...
@@ -56,30 +57,32 @@ class DCTBatchConf(dct_io_xml.DCTXMLBase):
funcs
=
self
.
tree
.
find
(
"
functions
"
)
funcs
=
self
.
tree
.
find
(
"
functions
"
)
func
=
dct_io_xml
.
ET
.
SubElement
(
funcs
,
"
function
"
,
{
"
name
"
:
name
})
func
=
dct_io_xml
.
ET
.
SubElement
(
funcs
,
"
function
"
,
{
"
name
"
:
name
})
path
N
ode
=
func
.
find
(
"
path
"
)
path
_n
ode
=
func
.
find
(
"
path
"
)
if
path
N
ode
is
None
:
if
path
_n
ode
is
None
:
path
N
ode
=
dct_io_xml
.
ET
.
SubElement
(
func
,
"
path
"
)
path
_n
ode
=
dct_io_xml
.
ET
.
SubElement
(
func
,
"
path
"
)
path
N
ode
.
text
=
path
path
_n
ode
.
text
=
path
if
is_absolute
is
True
:
if
is_absolute
is
True
:
path
N
ode
.
attrib
[
"
absolute
"
]
=
"
true
"
path
_n
ode
.
attrib
[
"
absolute
"
]
=
"
true
"
else
:
else
:
path
N
ode
.
attrib
[
"
absolute
"
]
=
"
false
"
path
_n
ode
.
attrib
[
"
absolute
"
]
=
"
false
"
self
.
save
()
self
.
save
()
def
get
F
unctions
(
self
,
base_dir
):
def
get
_f
unctions
(
self
,
base_dir
):
functions
=
{}
functions
=
{}
nodes
=
self
.
tree
.
findall
(
"
functions/function
"
)
nodes
=
self
.
tree
.
findall
(
"
functions/function
"
)
for
node
in
nodes
:
for
node
in
nodes
:
functions
[
node
.
attrib
.
get
(
"
name
"
)]
=
self
.
get
P
ath
(
"
path
"
,
base_dir
,
base_node
=
node
)
functions
[
node
.
attrib
.
get
(
"
name
"
)]
=
self
.
get
_p
ath
(
"
path
"
,
base_dir
,
base_node
=
node
)
return
functions
return
functions
class
DCTBatch
(
object
):
class
DCTBatch
(
object
):
def
__init__
(
self
,
dct_dir
=
""
,
dev_mode
=
False
):
def
__init__
(
self
,
dct_dir
=
""
,
dev_mode
=
False
):
if
dct_dir
is
""
:
if
dct_dir
is
""
:
dct_dir
=
os
.
getcwd
()
dct_dir
=
os
.
path
.
dirname
(
sys
.
argv
[
0
])
if
os
.
path
.
basename
(
dct_dir
)
==
"
zUtil_Python
"
:
dct_dir
=
os
.
path
.
basename
(
dct_dir
)
self
.
dct_dir
=
dct_dir
self
.
dct_dir
=
dct_dir
devel_conf_path
=
os
.
path
.
join
(
self
.
dct_dir
,
"
zUtil_Conf
"
,
"
batch-dev-conf.xml
"
);
devel_conf_path
=
os
.
path
.
join
(
self
.
dct_dir
,
"
zUtil_Conf
"
,
"
batch-dev-conf.xml
"
);
...
@@ -93,41 +96,41 @@ class DCTBatch(object):
...
@@ -93,41 +96,41 @@ class DCTBatch(object):
self
.
user_conf
=
DCTBatchConf
(
xml_file
=
user_conf_path
,
read_only
=
False
)
self
.
user_conf
=
DCTBatchConf
(
xml_file
=
user_conf_path
,
read_only
=
False
)
# We assume system configuration is always consistent, so we only
# We assume system configuration is always consistent, so we only
# check user configuration
# check user configuration
self
.
user_conf
.
fix
S
tructure
()
self
.
user_conf
.
fix
_s
tructure
()
except
:
except
:
self
.
user_conf
=
DCTBatchConf
.
getNewFile
(
user_conf_path
)
self
.
user_conf
=
DCTBatchConf
.
getNewFile
(
user_conf_path
)
def
auto
D
etect
F
unctions
(
self
,
user
=
True
):
def
auto
_d
etect
_f
unctions
(
self
,
user
=
True
):
simple
M
atch
=
'
OAR_make
'
simple
_m
atch
=
'
OAR_make
'
search
P
attern
=
re
.
compile
(
'
[^%]*\s*
'
+
simple
M
atch
+
"
\s*\(\s*
'
.*
'"
)
search
_p
attern
=
re
.
compile
(
'
[^%]*\s*
'
+
simple
_m
atch
+
"
\s*\(\s*
'
.*
'"
)
files
L
ist
=
[]
files
_l
ist
=
[]
for
root
,
dir_name
,
file_names
in
os
.
walk
(
self
.
dct_dir
):
for
root
,
dir_name
,
file_names
in
os
.
walk
(
self
.
dct_dir
):
for
file_name
in
file_names
:
for
file_name
in
file_names
:
if
fnmatch
.
fnmatch
(
file_name
,
'
*.m
'
):
if
fnmatch
.
fnmatch
(
file_name
,
'
*.m
'
):
files
L
ist
.
append
((
root
,
file_name
))
files
_l
ist
.
append
((
root
,
file_name
))
# First creating list of file matching methods name
# First creating list of file matching methods name
m
F
iles
=
{}
m
_f
iles
=
{}
for
dir_path
,
file_name
in
files
L
ist
:
for
dir_path
,
file_name
in
files
_l
ist
:
filepath
=
os
.
path
.
join
(
dir_path
,
file_name
)
filepath
=
os
.
path
.
join
(
dir_path
,
file_name
)
m
F
iles
[
file_name
[:
-
2
]]
=
filepath
m
_f
iles
[
file_name
[:
-
2
]]
=
filepath
# Then looking for complex regexp inside matching files
# Then looking for complex regexp inside matching files
for
dir_path
,
file_name
in
m
F
iles
.
iteritems
():
for
dir_path
,
file_name
in
m
_f
iles
.
iteritems
():
filepath
=
os
.
path
.
join
(
dir_path
,
file_name
)
filepath
=
os
.
path
.
join
(
dir_path
,
file_name
)
fid
=
open
(
filepath
,
'
r
'
)
fid
=
open
(
filepath
,
'
r
'
)
for
line
in
fid
:
for
line
in
fid
:
if
simple
M
atch
in
line
:
if
simple
_m
atch
in
line
:
matched
=
search
P
attern
.
search
(
line
)
matched
=
search
_p
attern
.
search
(
line
)
if
matched
:
if
matched
:
function_name
=
matched
.
group
().
split
(
"'"
)[
1
]
function_name
=
matched
.
group
().
split
(
"'"
)[
1
]
self
.
add
F
unction
(
m
F
iles
[
function_name
],
user
)
self
.
add
_f
unction
(
m
_f
iles
[
function_name
],
user
)
fid
.
close
()
fid
.
close
()
def
add
F
unction
(
self
,
path
,
user
=
True
):
def
add
_f
unction
(
self
,
path
,
user
=
True
):
name
=
os
.
path
.
basename
(
path
)
name
=
os
.
path
.
basename
(
path
)
name
=
name
[
0
:
-
2
]
name
=
name
[
0
:
-
2
]
...
@@ -137,20 +140,20 @@ class DCTBatch(object):
...
@@ -137,20 +140,20 @@ class DCTBatch(object):
rel_path
=
abs_path
[
len
(
abs_dct_path
)
+
1
:]
rel_path
=
abs_path
[
len
(
abs_dct_path
)
+
1
:]
if
user
is
True
:
if
user
is
True
:
self
.
user_conf
.
add
F
unction
(
name
,
rel_path
)
self
.
user_conf
.
add
_f
unction
(
name
,
rel_path
)
else
:
else
:
self
.
dev_conf
.
add
F
unction
(
name
,
rel_path
)
self
.
dev_conf
.
add
_f
unction
(
name
,
rel_path
)
def
get
BinD
ir
(
self
):
def
get
_bin_d
ir
(
self
):
try
:
try
:
bin_path
=
self
.
user_conf
.
get
BinD
ir
(
self
.
dct_dir
)
bin_path
=
self
.
user_conf
.
get
_bin_d
ir
(
self
.
dct_dir
)
except
ValueError
:
except
ValueError
:
bin_path
=
self
.
dev_conf
.
get
BinD
ir
(
self
.
dct_dir
)
bin_path
=
self
.
dev_conf
.
get
_bin_d
ir
(
self
.
dct_dir
)
return
bin_path
return
bin_path
def
get
F
unctions
(
self
):
def
get
_f
unctions
(
self
):
functions
=
self
.
dev_conf
.
get
F
unctions
(
self
.
dct_dir
)
functions
=
self
.
dev_conf
.
get
_f
unctions
(
self
.
dct_dir
)
functions
.
update
(
self
.
user_conf
.
get
F
unctions
(
self
.
dct_dir
))
functions
.
update
(
self
.
user_conf
.
get
_f
unctions
(
self
.
dct_dir
))
return
functions
return
functions
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
zUtil_Python/dct_compile_matlab_functions.py
+
3
−
3
View file @
860f436e
...
@@ -118,12 +118,12 @@ class FunctionsBuilder(object):
...
@@ -118,12 +118,12 @@ class FunctionsBuilder(object):
batch
=
dct_batch
.
DCTBatch
(
self
.
dct_dir
)
batch
=
dct_batch
.
DCTBatch
(
self
.
dct_dir
)
if
self
.
scan_sources
is
True
:
if
self
.
scan_sources
is
True
:
self
.
out
.
printSubJob
(
"
Finding functions that may be compiled, from:
'
%s
'"
%
self
.
dct_dir
)
self
.
out
.
printSubJob
(
"
Finding functions that may be compiled, from:
'
%s
'"
%
self
.
dct_dir
)
batch
.
auto
D
etect
F
unctions
()
batch
.
auto
_d
etect
_f
unctions
()
self
.
out
.
printSubJob
(
"
Functions available for compilation:
"
)
self
.
out
.
printSubJob
(
"
Functions available for compilation:
"
)
funcs
=
batch
.
get
F
unctions
()
funcs
=
batch
.
get
_f
unctions
()
for
function
in
funcs
:
for
function
in
funcs
:
self
.
out
.
printSubSubJob
(
function
,
funcs
[
function
])
self
.
out
.
printSubSubJob
(
function
,
funcs
[
function
])
bin_dir
=
batch
.
get
BinD
ir
()
bin_dir
=
batch
.
get
_bin_d
ir
()
self
.
out
.
printSubJob
(
"
Adding information about functions..
"
)
self
.
out
.
printSubJob
(
"
Adding information about functions..
"
)
for
function
in
funcs
:
for
function
in
funcs
:
outpath
=
os
.
path
.
join
(
bin_dir
,
function
)
outpath
=
os
.
path
.
join
(
bin_dir
,
function
)
...
...
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