diff --git a/conf.py b/conf.py index 92bb509..614eab2 100644 --- a/conf.py +++ b/conf.py @@ -114,7 +114,7 @@ CONTEXT = { # ~ SHIFT is mapped to Shift on all platforms. # ~ MOD1 is mapped to Ctrl on Windows/Linux, while it is mapped to Cmd on Mac. # ~ MOD2 is mapped to Alt on all platforms. -# ~ For example: Shift+Ctrl+Alt+M -> M_SHIFT_MOD1_MOD2 +# ~ For example: Shift+Ctrl+Alt+T -> T_SHIFT_MOD1_MOD2 PARENT = 'OfficeMenuBar' MENU_MAIN = { 'en': 'ZAZ BarCode', @@ -127,6 +127,7 @@ MENUS = ( 'context': 'calc,writer,impress,draw', 'icon': 'barcode', 'toolbar': False, + 'shortcut': 'I_SHIFT_MOD1_MOD2', }, { 'title': {'en': 'Insert CODE39', 'es': 'Insertar CODE39'}, @@ -276,8 +277,9 @@ DIRS = { 'images': 'images', 'registration': 'registration', 'files': 'files', - 'pythonpath': True, + 'office': 'Office', 'locales': PATH_LOCALES, + 'pythonpath': True, } @@ -293,6 +295,7 @@ FILES = { 'rdb': f'X{NAME}.rdb', 'update': f'{NAME.lower()}.update.xml', 'addin': 'CalcAddIn.xcu', + 'shortcut': 'Accelerators.xcu', 'easymacro': True, } @@ -545,7 +548,8 @@ if TYPE_EXTENSION == 3: FILE_MANIFEST = f""" - {NODE_ADDONS} + + {NODE_ADDONS} """ @@ -686,6 +690,55 @@ FILE_ADDIN = f""" """ +NODE_SHORTCUT = """ {0} + {0} + {0}service:{2}?{3} + {0} + {0} +""" + + +NODE_SHORTCUTS = '' +if TYPE_EXTENSION == 1: + node_global = [] + node_module = {} + for m in MENUS: + if not m.get('shortcut', ''): + continue + if m['context']: + for c in m['context'].split(','): + if not c in node_module: + node_module[c] = [] + node = NODE_SHORTCUT.format(' ', m['shortcut'], ID, m['argument']) + node_module[c].append(node) + continue + node = NODE_SHORTCUT.format('', m['shortcut'], ID, m['argument']) + node_global.append(node) + if node_global: + NODE_SHORTCUTS = ' \n' + NODE_SHORTCUTS += '\n'.join(node_global) + NODE_SHORTCUTS += ' ' + if node_module: + NODE_SHORTCUTS += ' \n' + for c, n in node_module.items(): + NODE_SHORTCUTS += ' \n'.format(CONTEXT[c]) + NODE_SHORTCUTS += '\n'.join(n) + NODE_SHORTCUTS += ' \n' + NODE_SHORTCUTS += ' ' + +FILE_SHORTCUTS = f""" + + +{NODE_SHORTCUTS} + + +""" + + DATA = { 'py': FILE_PY, 'manifest': FILE_MANIFEST, @@ -694,6 +747,7 @@ DATA = { 'update': FILE_UPDATE, 'idl': FILE_IDL, 'addin': FILE_ADDIN, + 'shortcut': FILE_SHORTCUTS, } diff --git a/easymacro.py b/easymacro.py index 1a3a224..e6ca331 100644 --- a/easymacro.py +++ b/easymacro.py @@ -68,9 +68,6 @@ MSG_LANG = { FILE_NAME_DEBUG = 'zaz-debug.log' LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s' LOG_DATE = '%d/%m/%Y %H:%M:%S' -# ~ LEVEL_ERROR = logging.getLevelName(logging.ERROR) -# ~ LEVEL_DEBUG = logging.getLevelName(logging.DEBUG) -# ~ LEVEL_INFO = logging.getLevelName(logging.INFO) logging.addLevelName(logging.ERROR, '\033[1;41mERROR\033[1;0m') logging.addLevelName(logging.DEBUG, '\x1b[33mDEBUG\033[1;0m') logging.addLevelName(logging.INFO, '\x1b[32mINFO\033[1;0m') diff --git a/files/ZAZBarCode_v0.2.1.oxt b/files/ZAZBarCode_v0.2.1.oxt index eaf82f7..3c23dcc 100644 Binary files a/files/ZAZBarCode_v0.2.1.oxt and b/files/ZAZBarCode_v0.2.1.oxt differ diff --git a/source/META-INF/manifest.xml b/source/META-INF/manifest.xml index 559e3c0..a401fe8 100644 --- a/source/META-INF/manifest.xml +++ b/source/META-INF/manifest.xml @@ -1,5 +1,6 @@ + diff --git a/source/Office/Accelerators.xcu b/source/Office/Accelerators.xcu new file mode 100644 index 0000000..d290b14 --- /dev/null +++ b/source/Office/Accelerators.xcu @@ -0,0 +1,39 @@ + + + + + + + + service:net.elmau.zaz.BarCode?ask + + + + + + + service:net.elmau.zaz.BarCode?ask + + + + + + + service:net.elmau.zaz.BarCode?ask + + + + + + + service:net.elmau.zaz.BarCode?ask + + + + + + diff --git a/source/pythonpath/easymacro.py b/source/pythonpath/easymacro.py index 1a3a224..e6ca331 100644 --- a/source/pythonpath/easymacro.py +++ b/source/pythonpath/easymacro.py @@ -68,9 +68,6 @@ MSG_LANG = { FILE_NAME_DEBUG = 'zaz-debug.log' LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s' LOG_DATE = '%d/%m/%Y %H:%M:%S' -# ~ LEVEL_ERROR = logging.getLevelName(logging.ERROR) -# ~ LEVEL_DEBUG = logging.getLevelName(logging.DEBUG) -# ~ LEVEL_INFO = logging.getLevelName(logging.INFO) logging.addLevelName(logging.ERROR, '\033[1;41mERROR\033[1;0m') logging.addLevelName(logging.DEBUG, '\x1b[33mDEBUG\033[1;0m') logging.addLevelName(logging.INFO, '\x1b[32mINFO\033[1;0m') diff --git a/source/pythonpath/qrcode/main.py b/source/pythonpath/qrcode/main.py index 7317372..5cbc2a8 100644 --- a/source/pythonpath/qrcode/main.py +++ b/source/pythonpath/qrcode/main.py @@ -1,8 +1,12 @@ +import struct +from bisect import bisect_left + from qrcode import constants, exceptions, util from qrcode.image.base import BaseImage -import six -from bisect import bisect_left + +def int2byte(value): + return struct.Struct('>B').pack(value) def make(data=None, **kwargs): @@ -236,7 +240,7 @@ class QRCode(object): self.make() modcount = self.modules_count - codes = [six.int2byte(code).decode('cp437') + codes = [int2byte(code).decode('cp437') for code in (255, 223, 220, 219)] if tty: invert = True @@ -377,7 +381,7 @@ class QRCode(object): data_len = len(data) - for col in six.moves.xrange(self.modules_count - 1, 0, -2): + for col in range(self.modules_count - 1, 0, -2): if col <= 6: col -= 1 diff --git a/zaz.py b/zaz.py index 92c0533..5669ec1 100644 --- a/zaz.py +++ b/zaz.py @@ -20,6 +20,7 @@ import argparse import os import sys +from pathlib import Path from shutil import copyfile from subprocess import call import zipfile @@ -32,6 +33,7 @@ from conf import ( INFO, PATHS, TYPE_EXTENSION, + USE_LOCALES, log) @@ -44,7 +46,7 @@ def _join(*paths): def _mkdir(path): - return os.mkdir(path) + return Path(path).mkdir(parents=True, exist_ok=True) def _save(path, data): @@ -112,6 +114,8 @@ def _create_new_directories(): _mkdir(path) path = _join(path_source, DIRS['registration']) _mkdir(path) + path = _join(path_source, DIRS['office']) + _mkdir(path) if FILES['easymacro'] or DIRS['pythonpath']: path = _join(path_source, 'pythonpath') @@ -221,6 +225,11 @@ def _update_files(): path = _join(path_source, DIRS['meta'], FILES['manifest']) _save(path, DATA['manifest']) + path = _join(path_source, DIRS['office']) + _mkdir(path) + path = _join(path_source, DIRS['office'], FILES['shortcut']) + _save(path, DATA['shortcut']) + path = _join(path_source, FILES['addons']) _save(path, DATA['addons']) @@ -231,6 +240,13 @@ def _update_files(): path = _join(path_source, FILES['addin']) _save(path, DATA['addin']) + if USE_LOCALES: + msg = "Don't forget generate DOMAIN.pot for locales" + log.info(msg) + for lang in EXTENSION['languages']: + path = _join(path_source, DIRS['locales'], lang, 'LC_MESSAGES') + Path(path).mkdir(parents=True, exist_ok=True) + _compile_idl() return