Compare commits

..

No commits in common. "c1e451b5ce3f9dbe9ede41d6bfb21430f4581087" and "0643bdf1bff1bc9cd64f87dfa9c3bf1198e86974" have entirely different histories.

4 changed files with 16 additions and 39 deletions

View file

@ -375,9 +375,8 @@
" }}} " }}}
" Python {{{ " Python {{{
hi! link pythonClass Type hi! link pythonBuiltinType Type
hi! link pythonBuiltinType pythonClass hi! link pythonExClass Type
hi! link pythonExClass pythonClass
hi! link pythonBuiltinObj pythonFunction hi! link pythonBuiltinObj pythonFunction
hi! link pythonClassVar Variable hi! link pythonClassVar Variable
" }}} " }}}

View file

@ -14,11 +14,7 @@
endif endif
Plug 'Raimondi/delimitMate' Plug 'Raimondi/delimitMate'
Plug 'tpope/vim-repeat' Plug 'tpope/vim-repeat'
" if g:vim_ide Plug 'tpope/vim-commentary'
Plug 'tomtom/tcomment_vim'
" else
" Plug 'tpope/vim-commentary'
" endif
Plug 'tpope/vim-surround' Plug 'tpope/vim-surround'
Plug 'Yggdroot/indentLine' Plug 'Yggdroot/indentLine'
Plug 'idbrii/detectindent' Plug 'idbrii/detectindent'

View file

@ -233,18 +233,6 @@ set commentstring=//%s
noremap <leader>s s noremap <leader>s s
noremap <leader>S S noremap <leader>S S
" Remove the mappings that I won't use
let g:tcomment_maps = 0
nmap <silent> gc <Plug>TComment_gc
nmap <silent> gcc <Plug>TComment_gcc
nmap <silent> gC <Plug>TComment_gcb
" The default block commenting mapping refuses to work on a single line, as
" a workaround I give it another empty one to work with.
nmap <silent> gCC m'o<Esc>''<Plug>TComment_gcb+
xnoremap <silent> gc :TCommentMaybeInline<CR>
xnoremap <silent> gC :TCommentBlock<CR>
" }}} " }}}

View file

@ -8,42 +8,36 @@ from sys import stdout
import base64 import base64
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
encoding_names = ["utf8", "base16", "base32", "base64", "base85"] parser.add_argument(
parser.add_argument("--encoding", "-e", choices=encoding_names, default="utf8") "--encode",
parser.add_argument("--key-encoding", choices=encoding_names, default=None) "-e",
parser.add_argument("--value-encoding", choices=encoding_names, default=None) choices=["utf8", "base16", "base32", "base64", "base85"],
default="utf8",
)
parser.add_argument("db_path", type=Path) parser.add_argument("db_path", type=Path)
cli_args = parser.parse_args() cli_args = parser.parse_args()
def bytes_to_json(b: bytes, encoding: str) -> Union[str, list[int]]: def bytes_to_json(b: bytes) -> Union[str, list[int]]:
if encoding == "utf8": if cli_args.encode == "utf8":
try: try:
return b.decode("utf8") return b.decode("utf8")
except UnicodeDecodeError: except UnicodeDecodeError:
return list(b) return list(b)
elif encoding == "base16": elif cli_args.encode == "base16":
return base64.b16encode(b).decode("ascii") return base64.b16encode(b).decode("ascii")
elif encoding == "base32": elif cli_args.encode == "base32":
return base64.b32encode(b).decode("ascii") return base64.b32encode(b).decode("ascii")
elif encoding == "base64": elif cli_args.encode == "base64":
return base64.b64encode(b).decode("ascii") return base64.b64encode(b).decode("ascii")
elif encoding == "base85": elif cli_args.encode == "base85":
return base64.b85encode(b).decode("ascii") return base64.b85encode(b).decode("ascii")
else: else:
assert False assert False
key_encoding: str = cli_args.key_encoding or cli_args.encoding
value_encoding: str = cli_args.value_encoding or cli_args.encoding
db = plyvel.DB(str(cli_args.db_path), create_if_missing=False) db = plyvel.DB(str(cli_args.db_path), create_if_missing=False)
with db.iterator() as iterator: with db.iterator() as iterator:
for key, value in iterator: for key, value in iterator:
json.dump( json.dump({"key": bytes_to_json(key), "value": bytes_to_json(value)}, stdout)
{
"key": bytes_to_json(key, key_encoding),
"value": bytes_to_json(value, value_encoding),
},
stdout,
)
stdout.write("\n") stdout.write("\n")