From 922248fa2d4163f7ffb23127d9a1e06de4daa319 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Mon, 4 Jun 2018 22:37:47 +0200 Subject: [PATCH] add script for migrating from short to long keys --- scripts/short-to-long-key.py | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 scripts/short-to-long-key.py diff --git a/scripts/short-to-long-key.py b/scripts/short-to-long-key.py new file mode 100755 index 0000000..b9705ad --- /dev/null +++ b/scripts/short-to-long-key.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +""" +author: deadc0de6 (https://github.com/deadc0de6) +Copyright (c) 2017, deadc0de6 + +transform all short dotfile keys +from the short format to the long +format + +For example ~/.config/awesome/rc.lua + short format: f_rc.lua + long format: f_config_awesome_rc.lua +""" + +from docopt import docopt +import sys +import os +sys.path.append('../dotdrop') +try: + from dotdrop.config import Cfg +except Exception as e: + raise + + +USAGE = """ +short-to-long-key.py + +Usage: + short-to-long-key.py + short-to-long-key.py --help + +Options: + -h --help Show this screen. + +""" + + +def main(): + args = docopt(USAGE) + path = os.path.expanduser(args['']) + + try: + + conf = Cfg(path) + except ValueError as e: + print('error: {}'.format(str(e))) + return False + + conf.short_to_long() + print(conf.dump()) + + +if __name__ == '__main__': + if main(): + sys.exit(0) + sys.exit(1)