Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EdosL0Util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
SIPS
EdosL0Util
Commits
7212be6f
Commit
7212be6f
authored
7 years ago
by
Bruce Flynn
Browse files
Options
Downloads
Patches
Plain Diff
Fix cmp for py3
parent
dfdc0232
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
edosl0util/merge.py
+19
-10
19 additions, 10 deletions
edosl0util/merge.py
tests/test_merge.py
+32
-0
32 additions, 0 deletions
tests/test_merge.py
with
51 additions
and
10 deletions
edosl0util/merge.py
+
19
−
10
View file @
7212be6f
...
...
@@ -8,18 +8,22 @@
4. Write
"""
import
os
import
logging
import
os
from
collections
import
deque
,
OrderedDict
from
functools
import
total_ordering
LOG
=
logging
.
getLogger
(
__name__
)
VIIRS_APID_ORDER
=
(
826
,
821
)
+
tuple
(
range
(
800
,
821
))
+
tuple
(
range
(
822
,
826
))
VIIRS_APID_ORDER
=
(
826
,
821
)
+
tuple
(
range
(
800
,
821
))
+
tuple
(
range
(
822
,
826
))
@total_ordering
class
_Ptr
(
object
):
"""
Represents one or more packets that share the same time timecode and apid.
"""
def
__init__
(
self
,
fobj
,
timecode
,
apid
,
offset
,
size
):
self
.
fobj
=
fobj
self
.
timecode
=
timecode
...
...
@@ -30,17 +34,22 @@ class _Ptr(object):
def
__repr__
(
self
):
attrs
=
'
'
.
join
(
'
{}={}
'
.
format
(
k
,
v
)
for
k
,
v
in
sorted
(
vars
(
self
).
items
())
if
not
k
.
startswith
(
'
_
'
))
'
{}={}
'
.
format
(
k
,
v
)
for
k
,
v
in
sorted
(
vars
(
self
).
items
())
if
not
k
.
startswith
(
'
_
'
))
return
'
<{:s} {:s}>
'
.
format
(
self
.
__class__
.
__name__
,
attrs
)
def
__cmp__
(
self
,
that
):
return
cmp
(
(
self
.
timecode
,
self
.
apid
),
(
that
.
timecode
,
that
.
apid
)
)
def
__eq__
(
self
,
that
):
return
(
self
.
timecode
.
day_segmented_timecode
(),
self
.
apid
)
\
==
(
that
.
timecode
.
day_segmented_timecode
(),
that
.
apid
)
def
__ne__
(
self
,
that
):
return
not
self
==
that
def
__lt__
(
self
,
that
):
return
(
self
.
timecode
.
day_segmented_timecode
(),
self
.
apid
)
\
<
(
that
.
timecode
.
day_segmented_timecode
(),
that
.
apid
)
# instances with same timecode/apid/size will compare the same
def
__hash__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_merge.py
0 → 100644
+
32
−
0
View file @
7212be6f
from
operator
import
eq
,
lt
,
gt
import
pytest
from
edosl0util
import
merge
,
headers
class
Test_Ptr
:
@pytest.mark.parametrize
(
'
d1,d2,op
'
,
[
[(
0
,
0
),
(
0
,
0
),
eq
],
[(
1
,
0
),
(
0
,
0
),
gt
],
[(
0
,
1
),
(
0
,
0
),
gt
],
[(
1
,
1
),
(
0
,
0
),
gt
],
[(
0
,
0
),
(
1
,
0
),
lt
],
[(
0
,
0
),
(
0
,
1
),
lt
],
[(
0
,
0
),
(
1
,
1
),
lt
],
])
def
test_ordering
(
self
,
d1
,
d2
,
op
):
time1
,
apid1
=
d1
ptr1
=
merge
.
_Ptr
(
open
(
'
/dev/null
'
,
'
r
'
),
headers
.
DaySegmentedTimecode
(
time1
,
0
,
0
),
apid1
,
0
,
0
)
time2
,
apid2
=
d2
ptr2
=
merge
.
_Ptr
(
open
(
'
/dev/null
'
,
'
r
'
),
headers
.
DaySegmentedTimecode
(
time2
,
0
,
0
),
apid2
,
0
,
0
)
assert
op
(
ptr1
,
ptr2
)
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