Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
uyegy
CPUnetPLOT
Commits
6308e60d
Commit
6308e60d
authored
Aug 20, 2014
by
Mario Hock
Browse files
cnlls.py: list matching CNL-files in two columns
parent
da9d6cae
Changes
2
Hide whitespace changes
Inline
Side-by-side
cnl_library.py
View file @
6308e60d
...
...
@@ -192,6 +192,9 @@ class CNLParser:
# Specific getters:
def
get_general_header
(
self
):
return
self
.
header
[
"General"
]
def
get_type
(
self
):
return
self
.
header
[
"General"
][
"Type"
]
...
...
@@ -207,6 +210,9 @@ class CNLParser:
def
get_sysinfo
(
self
):
return
self
.
header
[
"General"
][
"SystemInfo"
]
def
get_hostname
(
self
):
return
self
.
get_sysinfo
()[
"hostname"
]
## MAIN ##
...
...
cnlls.py
0 → 100755
View file @
6308e60d
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
from
cnl_library
import
CNLParser
from
collections
import
defaultdict
,
deque
def
get_begin
(
cnl_file
):
return
cnl_file
.
get_general_header
()[
"Date"
][
1
]
def
are_close
(
cnl_file1
,
cnl_file2
):
t1
=
get_begin
(
cnl_file1
)
t2
=
get_begin
(
cnl_file2
)
return
abs
(
t1
-
t2
)
<
2
def
find_match
(
cnl_file
,
list_of_files
):
for
f
in
list_of_files
:
if
(
are_close
(
cnl_file
,
f
)
):
list_of_files
.
remove
(
f
)
return
f
return
None
## MAIN ##
if
__name__
==
"__main__"
:
import
sys
filenames
=
sorted
(
sys
.
argv
[
1
:]
)
cnl_files
=
defaultdict
(
deque
)
## Parse files and store them in a dict (of lists) according to their hostname.
for
filename
in
filenames
:
cnl_file
=
CNLParser
(
filename
)
hostname
=
cnl_file
.
get_hostname
()
cnl_files
[
hostname
].
append
(
cnl_file
)
## Match.
hostnames
=
sorted
(
cnl_files
.
keys
()
)
left_files
=
cnl_files
[
hostnames
[
0
]]
right_files
=
cnl_files
[
hostnames
[
1
]]
for
left_file
in
left_files
:
matching_file
=
find_match
(
left_file
,
right_files
)
if
(
matching_file
):
print
(
"{} {}"
.
format
(
left_file
.
filename
,
matching_file
.
filename
)
)
else
:
print
(
left_file
.
filename
)
## Print left over right files.
if
(
len
(
right_files
)
>
0
):
print
()
for
f
in
right_files
:
print
(
f
.
filename
)
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