aboutsummaryrefslogtreecommitdiff
path: root/scripts/shadacat.py
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2019-07-29 04:43:28 +0200
committerDaniel Hahler <git@thequod.de>2019-07-29 22:14:23 +0200
commit97ce776e7ba68d1966fddba475b11e85a6c53420 (patch)
tree4497a57464593e468d152eb7272717f6039f35a3 /scripts/shadacat.py
parentbae02eb3968be1c9677283d030fbbe6dd02cb180 (diff)
downloadrneovim-97ce776e7ba68d1966fddba475b11e85a6c53420.tar.gz
rneovim-97ce776e7ba68d1966fddba475b11e85a6c53420.tar.bz2
rneovim-97ce776e7ba68d1966fddba475b11e85a6c53420.zip
scripts: autopep8
Diffstat (limited to 'scripts/shadacat.py')
-rwxr-xr-xscripts/shadacat.py110
1 files changed, 55 insertions, 55 deletions
diff --git a/scripts/shadacat.py b/scripts/shadacat.py
index 522379aad4..89846427a5 100755
--- a/scripts/shadacat.py
+++ b/scripts/shadacat.py
@@ -12,27 +12,27 @@ import msgpack
class EntryTypes(Enum):
- Unknown = -1
- Missing = 0
- Header = 1
- SearchPattern = 2
- SubString = 3
- HistoryEntry = 4
- Register = 5
- Variable = 6
- GlobalMark = 7
- Jump = 8
- BufferList = 9
- LocalMark = 10
- Change = 11
+ Unknown = -1
+ Missing = 0
+ Header = 1
+ SearchPattern = 2
+ SubString = 3
+ HistoryEntry = 4
+ Register = 5
+ Variable = 6
+ GlobalMark = 7
+ Jump = 8
+ BufferList = 9
+ LocalMark = 10
+ Change = 11
def strtrans_errors(e):
- if not isinstance(e, UnicodeDecodeError):
- raise NotImplementedError('don’t know how to handle {0} error'.format(
- e.__class__.__name__))
- return '<{0:x}>'.format(reduce((lambda a, b: a*0x100+b),
- list(e.object[e.start:e.end]))), e.end
+ if not isinstance(e, UnicodeDecodeError):
+ raise NotImplementedError('don’t know how to handle {0} error'.format(
+ e.__class__.__name__))
+ return '<{0:x}>'.format(reduce((lambda a, b: a*0x100+b),
+ list(e.object[e.start:e.end]))), e.end
codecs.register_error('strtrans', strtrans_errors)
@@ -56,54 +56,54 @@ ctable = {
def mnormalize(o):
- return ctable.get(type(o), idfunc)(o)
+ return ctable.get(type(o), idfunc)(o)
fname = sys.argv[1]
try:
- filt = sys.argv[2]
+ filt = sys.argv[2]
except IndexError:
- filt = lambda entry: True
+ def filt(entry): return True
else:
- _filt = filt
- filt = lambda entry: eval(_filt, globals(), {'entry': entry})
+ _filt = filt
+ def filt(entry): return eval(_filt, globals(), {'entry': entry})
poswidth = len(str(os.stat(fname).st_size or 1000))
class FullEntry(dict):
- def __init__(self, val):
- self.__dict__.update(val)
+ def __init__(self, val):
+ self.__dict__.update(val)
with open(fname, 'rb') as fp:
- unpacker = msgpack.Unpacker(file_like=fp, read_size=1)
- max_type = max(typ.value for typ in EntryTypes)
- while True:
- try:
- pos = fp.tell()
- typ = unpacker.unpack()
- except msgpack.OutOfData:
- break
- else:
- timestamp = unpacker.unpack()
- time = datetime.fromtimestamp(timestamp)
- length = unpacker.unpack()
- if typ > max_type:
- entry = fp.read(length)
- typ = EntryTypes.Unknown
- else:
- entry = unpacker.unpack()
- typ = EntryTypes(typ)
- full_entry = FullEntry({
- 'value': entry,
- 'timestamp': timestamp,
- 'time': time,
- 'length': length,
- 'pos': pos,
- 'type': typ,
- })
- if not filt(full_entry):
- continue
- print('%*u %13s %s %5u %r' % (
- poswidth, pos, typ.name, time.isoformat(), length, mnormalize(entry)))
+ unpacker = msgpack.Unpacker(file_like=fp, read_size=1)
+ max_type = max(typ.value for typ in EntryTypes)
+ while True:
+ try:
+ pos = fp.tell()
+ typ = unpacker.unpack()
+ except msgpack.OutOfData:
+ break
+ else:
+ timestamp = unpacker.unpack()
+ time = datetime.fromtimestamp(timestamp)
+ length = unpacker.unpack()
+ if typ > max_type:
+ entry = fp.read(length)
+ typ = EntryTypes.Unknown
+ else:
+ entry = unpacker.unpack()
+ typ = EntryTypes(typ)
+ full_entry = FullEntry({
+ 'value': entry,
+ 'timestamp': timestamp,
+ 'time': time,
+ 'length': length,
+ 'pos': pos,
+ 'type': typ,
+ })
+ if not filt(full_entry):
+ continue
+ print('%*u %13s %s %5u %r' % (
+ poswidth, pos, typ.name, time.isoformat(), length, mnormalize(entry)))