aboutsummaryrefslogtreecommitdiff
path: root/scripts/shadacat.py
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2015-10-23 10:11:59 -0400
committerJustin M. Keyes <justinkz@gmail.com>2015-10-23 10:11:59 -0400
commitde4cb766ca381c09fd3f938136c1932ebf008f63 (patch)
tree70aac7d6e7abc1d0cfc0e7635c6a95dbfbe48237 /scripts/shadacat.py
parente38cbb93670272d0da15c60222a123b88ec55002 (diff)
parentfc2bb200f75ab9650c1c35463bcc2be9008632c9 (diff)
downloadrneovim-de4cb766ca381c09fd3f938136c1932ebf008f63.tar.gz
rneovim-de4cb766ca381c09fd3f938136c1932ebf008f63.tar.bz2
rneovim-de4cb766ca381c09fd3f938136c1932ebf008f63.zip
Merge pull request #3490 from ZyX-I/fix-3472
Fix local marks saving/restoring with ShaDa
Diffstat (limited to 'scripts/shadacat.py')
-rwxr-xr-xscripts/shadacat.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/shadacat.py b/scripts/shadacat.py
index 4ff493bfbc..2f2cf19f9d 100755
--- a/scripts/shadacat.py
+++ b/scripts/shadacat.py
@@ -60,9 +60,22 @@ def mnormalize(o):
fname = sys.argv[1]
+try:
+ filt = sys.argv[2]
+except IndexError:
+ filt = lambda entry: True
+else:
+ _filt = filt
+ filt = lambda entry: 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)
+
+
with open(fname, 'rb') as fp:
unpacker = msgpack.Unpacker(file_like=fp, read_size=1)
max_type = max(typ.value for typ in EntryTypes)
@@ -82,5 +95,15 @@ with open(fname, 'rb') as fp:
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)))