Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F11222520
Utils.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
Utils.py
View Options
import
os
def
mkoutdir
(
outdir
):
"Function to make output directories"
if
not
os
.
path
.
exists
(
outdir
):
try
:
os
.
makedirs
(
outdir
)
except
:
msg
=
"Can't make output directory '
%s
'"
%
outdir
raise
Exception
(
msg
)
if
not
os
.
access
(
outdir
,
os
.
W_OK
):
msg
=
"Can't write to output directory '
%s
'"
%
outdir
raise
Exception
(
msg
)
def
writeOutputHier
(
output
,
h
):
"Choose output file name and dir"
hparts
=
h
.
strip
(
"/"
)
.
split
(
"/"
)
ana
=
"ANALYSIS"
# if opts.HIER_OUTPUT:
outdir
=
os
.
path
.
join
(
'.'
,
ana
)
# ana = "_".join(hparts[:-1]) if len(hparts) > 1 else "ANALYSIS"
# outdir = os.path.join(opts.OUTDIR, ana)
# outfile = '%s.dat' % hparts[-1]
# else:
# outdir = opts.OUTDIR
# outfile = '%s.dat' % "_".join(hparts)
# # outdir = opts.OUTDIR
# # outfile=output
mkoutdir
(
outdir
)
outfilepath
=
os
.
path
.
join
(
outdir
,
output
)
f
=
open
(
outfilepath
,
'w'
)
for
item
in
output
:
f
.
write
(
str
(
item
)
+
"
\n
"
)
#f.write(output)
f
.
close
()
def
writeOutput
(
output
,
h
):
mkoutdir
(
"ANALYSIS"
)
f
=
open
(
"./ANALYSIS/"
+
h
,
'w'
)
for
item
in
output
:
f
.
write
(
str
(
item
)
+
"
\n
"
)
f
.
close
()
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Wed, May 14, 12:02 PM (1 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5092438
Default Alt Text
Utils.py (1 KB)
Attached To
rCONTURHG conturhg
Event Timeline
Log In to Comment