Skip to content

Instantly share code, notes, and snippets.

@altendky
Forked from AlecTaylor/ex.py
Last active June 6, 2018 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save altendky/df74405c0f6d58fa2ca15bfcc7a3fe20 to your computer and use it in GitHub Desktop.
Save altendky/df74405c0f6d58fa2ca15bfcc7a3fe20 to your computer and use it in GitHub Desktop.
epoch2stat = {
key: val
for key, val in iteritems({
k: tuple(
(lambda stats: stats)(
tuple(imap(itemgetter(1), v))
)
)
for k, v in groupby(sorted(
imap(
lambda l: (l[0], l[1]),
ifilter(
None,
imap(
lambda l: (
lambda fst: (
lambda three: (
(
int(three),
l.rstrip()[l.rfind(':') + 2:],
)
if (
three is not None
and three.isdigit()
and int(three[0]) < 4
else None
)
)(
l[fst - 3:fst]
if fst > -1
else None
)
)(l.rfind(']')),
infile,
),
),
),
key=itemgetter(0),
),
itemgetter(0),
))
})
if val and len(val) == 2
}
# -----
def a():
return groupby(sorted(
imap(
lambda l: (l[0], l[1]),
ifilter(
None,
imap(
lambda l: (
lambda fst: (
lambda three: (
(
int(three),
l.rstrip()[l.rfind(':') + 2:],
)
if (
three is not None
and three.isdigit()
and int(three[0]) < 4
else None
)
)(
l[fst - 3:fst]
if fst > -1
else None
)
)(l.rfind(']')),
infile,
),
),
),
key=itemgetter(0),
),
itemgetter(0),
))
def b(grouped):
for k, v in grouped:
v = tuple(imap(itemgetter(1), v))
if len(v) == 2:
yield (k, v)
epoch2stat = dict(b(a()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment