Fix #1
This commit is contained in:
parent
6439b19859
commit
2621f934e2
60
conf.py
60
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"""<?xml version="1.0" encoding="UTF-8"?>
|
||||
<manifest:manifest>
|
||||
<manifest:file-entry manifest:full-path="{FILES['py']}" manifest:media-type="application/vnd.sun.star.uno-component;type=Python"/>{NODE_ADDONS}
|
||||
<manifest:file-entry manifest:full-path="{FILES['py']}" manifest:media-type="application/vnd.sun.star.uno-component;type=Python"/>
|
||||
<manifest:file-entry manifest:full-path="Office/{FILES['shortcut']}" manifest:media-type="application/vnd.sun.star.configuration-data"/>{NODE_ADDONS}
|
||||
</manifest:manifest>
|
||||
"""
|
||||
|
||||
|
@ -686,6 +690,55 @@ FILE_ADDIN = f"""<?xml version="1.0" encoding="UTF-8"?>
|
|||
</oor:component-data>"""
|
||||
|
||||
|
||||
NODE_SHORTCUT = """ {0}<node oor:name="{1}" oor:op="fuse">
|
||||
{0}<prop oor:name="Command">
|
||||
{0}<value xml:lang="en-US">service:{2}?{3}</value>
|
||||
{0}</prop>
|
||||
{0}</node>
|
||||
"""
|
||||
|
||||
|
||||
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 = ' <node oor:name="Global">\n'
|
||||
NODE_SHORTCUTS += '\n'.join(node_global)
|
||||
NODE_SHORTCUTS += ' </node>'
|
||||
if node_module:
|
||||
NODE_SHORTCUTS += ' <node oor:name="Modules">\n'
|
||||
for c, n in node_module.items():
|
||||
NODE_SHORTCUTS += ' <node oor:name="{}">\n'.format(CONTEXT[c])
|
||||
NODE_SHORTCUTS += '\n'.join(n)
|
||||
NODE_SHORTCUTS += ' </node>\n'
|
||||
NODE_SHORTCUTS += ' </node>'
|
||||
|
||||
FILE_SHORTCUTS = f"""<?xml version="1.0" encoding="UTF-8"?>
|
||||
<oor:component-data
|
||||
xmlns:oor="http://openoffice.org/2001/registry"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
oor:name="Accelerators"
|
||||
oor:package="org.openoffice.Office">
|
||||
<node oor:name="PrimaryKeys">
|
||||
{NODE_SHORTCUTS}
|
||||
</node>
|
||||
</oor:component-data>
|
||||
"""
|
||||
|
||||
|
||||
DATA = {
|
||||
'py': FILE_PY,
|
||||
'manifest': FILE_MANIFEST,
|
||||
|
@ -694,6 +747,7 @@ DATA = {
|
|||
'update': FILE_UPDATE,
|
||||
'idl': FILE_IDL,
|
||||
'addin': FILE_ADDIN,
|
||||
'shortcut': FILE_SHORTCUTS,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<manifest:manifest>
|
||||
<manifest:file-entry manifest:full-path="ZAZBarCode.py" manifest:media-type="application/vnd.sun.star.uno-component;type=Python"/>
|
||||
<manifest:file-entry manifest:full-path="Office/Accelerators.xcu" manifest:media-type="application/vnd.sun.star.configuration-data"/>
|
||||
<manifest:file-entry manifest:full-path="Addons.xcu" manifest:media-type="application/vnd.sun.star.configuration-data"/>
|
||||
</manifest:manifest>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<oor:component-data
|
||||
xmlns:oor="http://openoffice.org/2001/registry"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
oor:name="Accelerators"
|
||||
oor:package="org.openoffice.Office">
|
||||
<node oor:name="PrimaryKeys">
|
||||
<node oor:name="Modules">
|
||||
<node oor:name="com.sun.star.sheet.SpreadsheetDocument">
|
||||
<node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse">
|
||||
<prop oor:name="Command">
|
||||
<value xml:lang="en-US">service:net.elmau.zaz.BarCode?ask</value>
|
||||
</prop>
|
||||
</node>
|
||||
</node>
|
||||
<node oor:name="com.sun.star.text.TextDocument">
|
||||
<node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse">
|
||||
<prop oor:name="Command">
|
||||
<value xml:lang="en-US">service:net.elmau.zaz.BarCode?ask</value>
|
||||
</prop>
|
||||
</node>
|
||||
</node>
|
||||
<node oor:name="com.sun.star.presentation.PresentationDocument">
|
||||
<node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse">
|
||||
<prop oor:name="Command">
|
||||
<value xml:lang="en-US">service:net.elmau.zaz.BarCode?ask</value>
|
||||
</prop>
|
||||
</node>
|
||||
</node>
|
||||
<node oor:name="com.sun.star.drawing.DrawingDocument">
|
||||
<node oor:name="I_SHIFT_MOD1_MOD2" oor:op="fuse">
|
||||
<prop oor:name="Command">
|
||||
<value xml:lang="en-US">service:net.elmau.zaz.BarCode?ask</value>
|
||||
</prop>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</oor:component-data>
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
18
zaz.py
18
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue