Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
Mauricio Baeza | 9e374568fc | |
Mauricio Baeza | db57e3f6cd | |
Mauricio Baeza | ae1d2a1720 | |
Mauricio Baeza | ed56332bdd | |
Mauricio Baeza | bac1512063 |
|
@ -11,4 +11,6 @@ docs/
|
|||
virtual/
|
||||
|
||||
|
||||
- Update library easymacro.py
|
||||
*.po~
|
||||
|
||||
|
|
16
CHANGELOG
16
CHANGELOG
|
@ -1,16 +1,30 @@
|
|||
v 0.6.0 [15-nov-2019]
|
||||
---------------------
|
||||
- Call by code
|
||||
|
||||
|
||||
v 0.5.0 [10-nov-2019]
|
||||
---------------------
|
||||
- Update library easymacro.py
|
||||
- Update library zaz.py
|
||||
|
||||
|
||||
v 0.4.0 [27-sep-2019]
|
||||
---------------------
|
||||
- Update library easymacro.py
|
||||
- Add icon in command button
|
||||
|
||||
|
||||
v 0.3.0 [18-sep-2019]
|
||||
---------------------
|
||||
- Add support for generate barcode by code
|
||||
|
||||
|
||||
v 0.2.1 [16-sep-2019]
|
||||
|
||||
---------------------
|
||||
- Fix #1
|
||||
|
||||
|
||||
v 0.2.0 [14-sep-2019]
|
||||
---------------------
|
||||
- Add support for spanish
|
||||
|
|
|
@ -22,6 +22,11 @@ Barcodes provided
|
|||
* qrcode
|
||||
|
||||
|
||||
Requirements:
|
||||
|
||||
LibreOffice 6.2+ with support for Python macros
|
||||
|
||||
|
||||
Thanks!
|
||||
|
||||
https://gitlab.com/mauriciobaeza/zaz
|
||||
|
@ -36,9 +41,9 @@ https://github.com/lincolnloop/python-qrcode
|
|||
|
||||
This extension have a cost of maintenance of 1 euro every year.
|
||||
|
||||
BCH: `1RPLWHJW34p7pMQV1ft4x7eWhAYw69Dsb`
|
||||
BCH: `qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d`
|
||||
|
||||
BTC: `3Fe4JuADrAK8Qs7GDAxbSXR8E54avwZJLW`
|
||||
BTC: `3FhiXcXmAesmQzrNEngjHFnvaJRhU1AGWV`
|
||||
|
||||
|
||||
* [Look the wiki](https://gitlab.com/mauriciobaeza/zaz-barcode/wikis/home)
|
||||
|
|
28
conf.py
28
conf.py
|
@ -26,7 +26,7 @@ import logging
|
|||
TYPE_EXTENSION = 1
|
||||
|
||||
# ~ https://semver.org/
|
||||
VERSION = '0.4.0'
|
||||
VERSION = '0.6.0'
|
||||
|
||||
# ~ Your great extension name, not used spaces
|
||||
NAME = 'ZAZBarCode'
|
||||
|
@ -318,6 +318,9 @@ PATHS = {
|
|||
'regmerge': '/usr/lib/libreoffice/program/regmerge',
|
||||
'soffice': ('soffice', PROGRAM, FILE_TEST),
|
||||
'install': ('unopkg', 'add', '-v', '-f', '-s'),
|
||||
'profile': '/home/mau/.config/libreoffice/4/user',
|
||||
'gettext': PATH_PYGETTEXT,
|
||||
'msgmerge': PATH_MSGMERGE,
|
||||
}
|
||||
|
||||
|
||||
|
@ -540,20 +543,6 @@ FILE_ADDONS = f"""<?xml version='1.0' encoding='UTF-8'?>
|
|||
"""
|
||||
|
||||
|
||||
NODE_ADDONS = '\n <manifest:file-entry manifest:full-path="Addons.xcu" manifest:media-type="application/vnd.sun.star.configuration-data"/>'
|
||||
if TYPE_EXTENSION > 1:
|
||||
NODE_ADDONS = f'\n <manifest:file-entry manifest:full-path="{FILES["rdb"]}" manifest:media-type="application/vnd.sun.star.uno-typelibrary;type=RDB"/>'
|
||||
if TYPE_EXTENSION == 3:
|
||||
NODE_ADDONS += '\n <manifest:file-entry manifest:full-path="CalcAddIn.xcu" manifest:media-type="application/vnd.sun.star.configuration-data"/>'
|
||||
|
||||
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"/>
|
||||
<manifest:file-entry manifest:full-path="Office/{FILES['shortcut']}" manifest:media-type="application/vnd.sun.star.configuration-data"/>{NODE_ADDONS}
|
||||
</manifest:manifest>
|
||||
"""
|
||||
|
||||
|
||||
FILE_UPDATE = ''
|
||||
if URL_XML_UPDATE:
|
||||
FILE_UPDATE = f"""<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
@ -738,9 +727,16 @@ FILE_SHORTCUTS = f"""<?xml version="1.0" encoding="UTF-8"?>
|
|||
"""
|
||||
|
||||
|
||||
DATA_MANIFEST = [FILES['py'], f"Office/{FILES['shortcut']}", 'Addons.xcu']
|
||||
if TYPE_EXTENSION > 1:
|
||||
DATA_MANIFEST.append(FILES['rdb'])
|
||||
if TYPE_EXTENSION == 3:
|
||||
DATA_MANIFEST.append('CalcAddIn.xcu')
|
||||
|
||||
|
||||
DATA = {
|
||||
'py': FILE_PY,
|
||||
'manifest': FILE_MANIFEST,
|
||||
'manifest': DATA_MANIFEST,
|
||||
'description': FILE_DESCRIPTION,
|
||||
'addons': FILE_ADDONS,
|
||||
'update': FILE_UPDATE,
|
||||
|
|
3293
easymacro.py
3293
easymacro.py
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -5,10 +5,10 @@
|
|||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<identifier value="net.elmau.zaz.BarCode" />
|
||||
<version value="0.4.0" />
|
||||
<version value="0.6.0" />
|
||||
|
||||
<update-download>
|
||||
<src xlink:href="https://gitlab.com/mauriciobaeza/zaz-barcode/raw/master/files/ZAZBarCode_v0.4.0.oxt"/>
|
||||
<src xlink:href="https://gitlab.com/mauriciobaeza/zaz-barcode/raw/master/files/ZAZBarCode_v0.6.0.oxt"/>
|
||||
</update-download>
|
||||
<release-notes>
|
||||
</release-notes>
|
||||
|
|
|
@ -1,6 +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"/>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" manifest:version="1.2">
|
||||
<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>
|
||||
|
|
|
@ -15,15 +15,7 @@ TITLE = 'ZAZ BarCode'
|
|||
QR = 'qrcode'
|
||||
|
||||
|
||||
p, *_ = app.get_info_path(__file__)
|
||||
path_locales = app.join(p, 'locales')
|
||||
try:
|
||||
lang = gettext.translation('base', path_locales, languages=[app.LANG])
|
||||
lang.install()
|
||||
_ = lang.gettext
|
||||
except Exception as e:
|
||||
from gettext import gettext as _
|
||||
app.error(e)
|
||||
_ = app.install_locales(__file__)
|
||||
|
||||
|
||||
class Controllers(object):
|
||||
|
@ -31,6 +23,10 @@ class Controllers(object):
|
|||
def __init__(self, dlg):
|
||||
self.d = dlg
|
||||
|
||||
def listbox_item_changed(self, event):
|
||||
self.d.text.set_focus()
|
||||
return
|
||||
|
||||
def button_action(self, event):
|
||||
if not self.d.listbox.value:
|
||||
self.d.listbox.set_focus()
|
||||
|
@ -48,28 +44,32 @@ class Controllers(object):
|
|||
|
||||
|
||||
class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
||||
IMAGES = 'images'
|
||||
|
||||
def __init__(self, ctx):
|
||||
self.ctx = ctx
|
||||
self._data = ''
|
||||
self._type = ''
|
||||
self.path_ext = app.get_path_extension(ID_EXTENSION)
|
||||
self.IMAGES = app.join(self.path_ext, self.IMAGES)
|
||||
self._ask = False
|
||||
self._path = ''
|
||||
|
||||
def execute(self, args):
|
||||
data = app.property_to_dict(args)
|
||||
self._type = data['Type'].lower()
|
||||
self._data = data['Data']
|
||||
|
||||
if data['Type'] == QR:
|
||||
factory = svg.SvgImage
|
||||
img = qrcode.make(data['Data'], image_factory=factory)
|
||||
img.save(data['Path'])
|
||||
if 'Path' in data:
|
||||
if not self._type == QR:
|
||||
p, _, n, _ = app.get_info_path(data['Path'])
|
||||
data['Path'] = app.join(p, n)
|
||||
else:
|
||||
try:
|
||||
generate(data['Type'].lower(), data['Data'], output=data['Path'])
|
||||
except Exception as e:
|
||||
app.debug(str(e))
|
||||
return
|
||||
data['Path'] = ''
|
||||
|
||||
result = self._create_code(data['Path'])
|
||||
if result:
|
||||
app.error(result)
|
||||
self._path = ''
|
||||
|
||||
return self._path
|
||||
|
||||
def trigger(self, args):
|
||||
self._type = args
|
||||
|
@ -78,19 +78,28 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
|||
|
||||
doc = app.get_document()
|
||||
getattr(self, '_insert_in_{}'.format(doc.type))(doc)
|
||||
app.kill(self._path)
|
||||
return
|
||||
|
||||
def _create_code(self, tmp_file):
|
||||
def _create_code(self, path=''):
|
||||
if not path:
|
||||
path = app.get_temp_file(True)
|
||||
if self._type == QR:
|
||||
factory = svg.SvgImage
|
||||
img = qrcode.make(self._data, image_factory=factory)
|
||||
img.save(tmp_file.name)
|
||||
img = qrcode.make(self._data, border=2, image_factory=factory)
|
||||
img.save(path)
|
||||
else:
|
||||
try:
|
||||
generate(self._type, self._data, output=tmp_file)
|
||||
path = generate(self._type, self._data, output=path)
|
||||
except Exception as e:
|
||||
app.error(e)
|
||||
return str(e)
|
||||
return ''
|
||||
|
||||
if app.is_created(path):
|
||||
self._path = path
|
||||
return ''
|
||||
|
||||
return _('Not generated')
|
||||
|
||||
def _get_values(self):
|
||||
self._type = ''
|
||||
|
@ -98,6 +107,7 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
|||
if dlg.open():
|
||||
self._data = dlg.text.value.strip()
|
||||
self._type = dlg.listbox.value
|
||||
self._ask = True
|
||||
return True
|
||||
|
||||
return False
|
||||
|
@ -111,55 +121,42 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
|||
self._show_error(msg)
|
||||
return
|
||||
|
||||
tf = app.get_temp_file()
|
||||
result = self._create_code(tf)
|
||||
result = self._create_code()
|
||||
if result:
|
||||
tf.close()
|
||||
self._show_error(result)
|
||||
return
|
||||
|
||||
cell = cell.offset()
|
||||
if app.IS_WIN:
|
||||
tf.close()
|
||||
cell.insert_image(tf.name)
|
||||
tf.close()
|
||||
if not self._ask:
|
||||
cell = cell.offset(0, 1)
|
||||
|
||||
cell.insert_image(self._path)
|
||||
return
|
||||
|
||||
def _insert_in_writer(self, doc):
|
||||
doc = app.get_document()
|
||||
sel = app.get_selection()
|
||||
if not self._data:
|
||||
sel = app.get_selection()
|
||||
self._data = sel.string
|
||||
if not self._data:
|
||||
msg = _('Select data')
|
||||
self._show_error(msg)
|
||||
return
|
||||
|
||||
tf = app.get_temp_file()
|
||||
result = self._create_code(tf)
|
||||
result = self._create_code()
|
||||
if result:
|
||||
tf.close()
|
||||
self._show_error(result)
|
||||
return
|
||||
|
||||
if app.IS_WIN:
|
||||
tf.close()
|
||||
doc.insert_image(tf.name)
|
||||
tf.close()
|
||||
doc.insert_image(self._path)
|
||||
return
|
||||
|
||||
def _insert_in_draw(self, doc):
|
||||
tf = app.get_temp_file()
|
||||
result = self._create_code(tf)
|
||||
result = self._create_code()
|
||||
if result:
|
||||
tf.close()
|
||||
self._show_error(result)
|
||||
return
|
||||
|
||||
if app.IS_WIN:
|
||||
tf.close()
|
||||
doc.insert_image(tf.name)
|
||||
tf.close()
|
||||
doc.insert_image(self._path)
|
||||
return
|
||||
|
||||
def _insert_in_impress(self, doc):
|
||||
|
@ -181,6 +178,7 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
|||
}
|
||||
dlg = app.create_dialog(args)
|
||||
dlg.events = Controllers(dlg)
|
||||
dlg.id_extension = ID_EXTENSION
|
||||
|
||||
args = {
|
||||
'Type': 'Label',
|
||||
|
@ -233,7 +231,7 @@ class ZAZBarCode(unohelper.Base, XJob, XJobExecutor):
|
|||
'Label': _('~Insert Barcode'),
|
||||
'Width': 70,
|
||||
'Height': 15,
|
||||
'ImageURL': app.join(self.IMAGES, 'qr.png'),
|
||||
'ImageURL': 'qr.png',
|
||||
'ImagePosition': 1,
|
||||
}
|
||||
dlg.add_control(args)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<description xmlns="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:d="http://openoffice.org/extensions/description/2006">
|
||||
<identifier value="net.elmau.zaz.BarCode" />
|
||||
<version value="0.4.0" />
|
||||
<version value="0.6.0" />
|
||||
<display-name>
|
||||
<name lang="en">ZAZ Bar Code</name>
|
||||
<name lang="es">ZAZ Códigos de Barras</name>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2019-09-14 14:23-0500\n"
|
||||
"POT-Creation-Date: 2019-11-10 15:06-0600\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -15,34 +15,38 @@ msgstr ""
|
|||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: source/ZAZBarCode.py:38
|
||||
#: source/ZAZBarCode.py:29
|
||||
msgid "Select barcode type"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:43
|
||||
#: source/ZAZBarCode.py:34
|
||||
msgid "Data field is mandatory"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:95 source/ZAZBarCode.py:117
|
||||
#: source/ZAZBarCode.py:91
|
||||
msgid "Not generated"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:109 source/ZAZBarCode.py:135
|
||||
msgid "Select data"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:149
|
||||
#: source/ZAZBarCode.py:171
|
||||
msgid ""
|
||||
"Error in: {}\n"
|
||||
"\n"
|
||||
"{}"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:167
|
||||
#: source/ZAZBarCode.py:189
|
||||
msgid "~Select barcode type"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:179
|
||||
#: source/ZAZBarCode.py:201
|
||||
msgid "~Capture data for barcode"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:212
|
||||
#: source/ZAZBarCode.py:234
|
||||
msgid "~Insert Barcode"
|
||||
msgstr ""
|
||||
|
||||
|
|
Binary file not shown.
|
@ -5,45 +5,49 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2019-09-14 14:23-0500\n"
|
||||
"PO-Revision-Date: 2019-09-14 14:45-0500\n"
|
||||
"POT-Creation-Date: 2019-11-10 15:06-0600\n"
|
||||
"PO-Revision-Date: 2019-11-10 15:15-0600\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: en\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
"X-Generator: Poedit 2.2.1\n"
|
||||
"Last-Translator: \n"
|
||||
"X-Generator: Poedit 2.2.4\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: en\n"
|
||||
|
||||
#: source/ZAZBarCode.py:38
|
||||
#: source/ZAZBarCode.py:29
|
||||
msgid "Select barcode type"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:43
|
||||
#: source/ZAZBarCode.py:34
|
||||
msgid "Data field is mandatory"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:95 source/ZAZBarCode.py:117
|
||||
#: source/ZAZBarCode.py:91
|
||||
msgid "Not generated"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:109 source/ZAZBarCode.py:135
|
||||
msgid "Select data"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:149
|
||||
#: source/ZAZBarCode.py:171
|
||||
msgid ""
|
||||
"Error in: {}\n"
|
||||
"\n"
|
||||
"{}"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:167
|
||||
#: source/ZAZBarCode.py:189
|
||||
msgid "~Select barcode type"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:179
|
||||
#: source/ZAZBarCode.py:201
|
||||
msgid "~Capture data for barcode"
|
||||
msgstr ""
|
||||
|
||||
#: source/ZAZBarCode.py:212
|
||||
#: source/ZAZBarCode.py:234
|
||||
msgid "~Insert Barcode"
|
||||
msgstr ""
|
||||
|
|
Binary file not shown.
|
@ -5,31 +5,35 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2019-09-14 14:23-0500\n"
|
||||
"PO-Revision-Date: 2019-09-20 19:21+0200\n"
|
||||
"POT-Creation-Date: 2019-11-10 15:06-0600\n"
|
||||
"PO-Revision-Date: 2019-11-12 13:30-0600\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: eo\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
"X-Generator: Poedit 2.0.6\n"
|
||||
"Last-Translator: \n"
|
||||
"X-Generator: Poedit 2.2.4\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: eo\n"
|
||||
|
||||
#: source/ZAZBarCode.py:38
|
||||
#: source/ZAZBarCode.py:29
|
||||
msgid "Select barcode type"
|
||||
msgstr "Elektu strikodan tipon"
|
||||
|
||||
#: source/ZAZBarCode.py:43
|
||||
#: source/ZAZBarCode.py:34
|
||||
msgid "Data field is mandatory"
|
||||
msgstr "Datumkampo estas deviga"
|
||||
|
||||
#: source/ZAZBarCode.py:95 source/ZAZBarCode.py:117
|
||||
#: source/ZAZBarCode.py:91
|
||||
msgid "Not generated"
|
||||
msgstr "Ne eligata"
|
||||
|
||||
#: source/ZAZBarCode.py:109 source/ZAZBarCode.py:135
|
||||
msgid "Select data"
|
||||
msgstr "Elektu datumojn"
|
||||
|
||||
#: source/ZAZBarCode.py:149
|
||||
#: source/ZAZBarCode.py:171
|
||||
msgid ""
|
||||
"Error in: {}\n"
|
||||
"\n"
|
||||
|
@ -39,14 +43,14 @@ msgstr ""
|
|||
"\n"
|
||||
"{}"
|
||||
|
||||
#: source/ZAZBarCode.py:167
|
||||
#: source/ZAZBarCode.py:189
|
||||
msgid "~Select barcode type"
|
||||
msgstr "~Elektu strikodan tipon"
|
||||
|
||||
#: source/ZAZBarCode.py:179
|
||||
#: source/ZAZBarCode.py:201
|
||||
msgid "~Capture data for barcode"
|
||||
msgstr "~Kaptu datumojn por strikodo"
|
||||
|
||||
#: source/ZAZBarCode.py:212
|
||||
#: source/ZAZBarCode.py:234
|
||||
msgid "~Insert Barcode"
|
||||
msgstr "~Enmetu Strikodon"
|
||||
|
|
Binary file not shown.
|
@ -5,31 +5,35 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2019-09-14 14:23-0500\n"
|
||||
"PO-Revision-Date: 2019-09-14 14:44-0500\n"
|
||||
"POT-Creation-Date: 2019-11-10 15:06-0600\n"
|
||||
"PO-Revision-Date: 2019-11-10 15:07-0600\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: es\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
"X-Generator: Poedit 2.2.1\n"
|
||||
"Last-Translator: \n"
|
||||
"X-Generator: Poedit 2.2.4\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: es\n"
|
||||
|
||||
#: source/ZAZBarCode.py:38
|
||||
#: source/ZAZBarCode.py:29
|
||||
msgid "Select barcode type"
|
||||
msgstr "Seleccione el tipo de código de barras"
|
||||
|
||||
#: source/ZAZBarCode.py:43
|
||||
#: source/ZAZBarCode.py:34
|
||||
msgid "Data field is mandatory"
|
||||
msgstr "Los datos son obligatorios"
|
||||
|
||||
#: source/ZAZBarCode.py:95 source/ZAZBarCode.py:117
|
||||
#: source/ZAZBarCode.py:91
|
||||
msgid "Not generated"
|
||||
msgstr "No generado"
|
||||
|
||||
#: source/ZAZBarCode.py:109 source/ZAZBarCode.py:135
|
||||
msgid "Select data"
|
||||
msgstr "Seleccione los datos"
|
||||
|
||||
#: source/ZAZBarCode.py:149
|
||||
#: source/ZAZBarCode.py:171
|
||||
msgid ""
|
||||
"Error in: {}\n"
|
||||
"\n"
|
||||
|
@ -39,14 +43,14 @@ msgstr ""
|
|||
"\n"
|
||||
"{}"
|
||||
|
||||
#: source/ZAZBarCode.py:167
|
||||
#: source/ZAZBarCode.py:189
|
||||
msgid "~Select barcode type"
|
||||
msgstr "~Tipo de código de barras"
|
||||
|
||||
#: source/ZAZBarCode.py:179
|
||||
#: source/ZAZBarCode.py:201
|
||||
msgid "~Capture data for barcode"
|
||||
msgstr "~Datos del código de barras"
|
||||
|
||||
#: source/ZAZBarCode.py:212
|
||||
#: source/ZAZBarCode.py:234
|
||||
msgid "~Insert Barcode"
|
||||
msgstr "~Insertar Código"
|
||||
|
|
|
@ -19,11 +19,6 @@ from barcode.upc import UPCA
|
|||
from barcode.itf import ITF
|
||||
from barcode.version import version # noqa: F401
|
||||
|
||||
try:
|
||||
_strbase = basestring # lint:ok
|
||||
except NameError:
|
||||
_strbase = str
|
||||
|
||||
|
||||
__BARCODE_MAP = dict(
|
||||
ean8=EAN8,
|
||||
|
@ -73,7 +68,7 @@ def generate(name, code, writer=None, output=None, writer_options=None,
|
|||
barcode = get(name, code, writer, options)
|
||||
if pil:
|
||||
return barcode.render(writer_options, text)
|
||||
if isinstance(output, _strbase):
|
||||
if isinstance(output, str):
|
||||
fullname = barcode.save(output, options, text)
|
||||
return fullname
|
||||
else:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
245
zaz.py
245
zaz.py
|
@ -19,15 +19,21 @@
|
|||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import zipfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from shutil import copyfile
|
||||
from subprocess import call
|
||||
import zipfile
|
||||
from xml.etree import ElementTree as ET
|
||||
from xml.dom.minidom import parseString
|
||||
|
||||
|
||||
from conf import (
|
||||
DATA,
|
||||
DIRS,
|
||||
DOMAIN,
|
||||
EXTENSION,
|
||||
FILES,
|
||||
INFO,
|
||||
|
@ -37,6 +43,84 @@ from conf import (
|
|||
log)
|
||||
|
||||
|
||||
class LiboXML(object):
|
||||
TYPES = {
|
||||
'py': 'application/vnd.sun.star.uno-component;type=Python',
|
||||
'zip': 'application/binary',
|
||||
'xcu': 'application/vnd.sun.star.configuration-data',
|
||||
'rdb': 'application/vnd.sun.star.uno-typelibrary;type=RDB',
|
||||
'xcs': 'application/vnd.sun.star.configuration-schema',
|
||||
'help': 'application/vnd.sun.star.help',
|
||||
'component': 'application/vnd.sun.star.uno-components',
|
||||
}
|
||||
NAME_SPACES = {
|
||||
'manifest_version': '1.2',
|
||||
'manifest': 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0',
|
||||
'xmlns:loext': 'urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0',
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
self._manifest = None
|
||||
self._paths = []
|
||||
|
||||
def _save_path(self, attr):
|
||||
self._paths.append(attr['{{{}}}full-path'.format(self.NAME_SPACES['manifest'])])
|
||||
return
|
||||
|
||||
def _clean(self, name, nodes):
|
||||
has_words = re.compile('\\w')
|
||||
|
||||
if not re.search(has_words, str(nodes.tail)):
|
||||
nodes.tail = ''
|
||||
if not re.search(has_words, str(nodes.text)):
|
||||
nodes.text = ''
|
||||
|
||||
for node in nodes:
|
||||
if name == 'manifest':
|
||||
self._save_path(node.attrib)
|
||||
if not re.search(has_words, str(node.tail)):
|
||||
node.tail = ''
|
||||
if not re.search(has_words, str(node.text)):
|
||||
node.text = ''
|
||||
return
|
||||
|
||||
def new_manifest(self, data):
|
||||
attr = {
|
||||
'manifest:version': self.NAME_SPACES['manifest_version'],
|
||||
'xmlns:manifest': self.NAME_SPACES['manifest'],
|
||||
'xmlns:loext': self.NAME_SPACES['xmlns:loext'],
|
||||
}
|
||||
self._manifest = ET.Element('manifest:manifest', attr)
|
||||
return self.add_data_manifest(data)
|
||||
|
||||
def parse_manifest(self, data):
|
||||
ET.register_namespace('manifest', self.NAME_SPACES['manifest'])
|
||||
self._manifest = ET.fromstring(data)
|
||||
data = {'xmlns:loext': self.NAME_SPACES['xmlns:loext']}
|
||||
self._manifest.attrib.update(**data)
|
||||
self._clean('manifest', self._manifest)
|
||||
return
|
||||
|
||||
def add_data_manifest(self, data):
|
||||
node_name = 'manifest:file-entry'
|
||||
attr = {
|
||||
'manifest:full-path': '',
|
||||
'manifest:media-type': '',
|
||||
}
|
||||
for path in data:
|
||||
if path in self._paths:
|
||||
continue
|
||||
ext = path.split('.')[-1]
|
||||
attr['manifest:full-path'] = path
|
||||
attr['manifest:media-type'] = self.TYPES.get(ext, '')
|
||||
ET.SubElement(self._manifest, node_name, attr)
|
||||
return self._get_xml(self._manifest)
|
||||
|
||||
def _get_xml(self, doc):
|
||||
xml = parseString(ET.tostring(doc, encoding='utf-8'))
|
||||
return xml.toprettyxml(indent=' ', encoding='utf-8').decode('utf-8')
|
||||
|
||||
|
||||
def _exists(path):
|
||||
return os.path.exists(path)
|
||||
|
||||
|
@ -55,6 +139,19 @@ def _save(path, data):
|
|||
return
|
||||
|
||||
|
||||
def _get_files(path, filters=''):
|
||||
paths = []
|
||||
if filters in ('*', '*.*'):
|
||||
filters = ''
|
||||
for folder, _, files in os.walk(path):
|
||||
if filters:
|
||||
pattern = re.compile(r'\.(?:{})$'.format(filters), re.IGNORECASE)
|
||||
paths += [_join(folder, f) for f in files if pattern.search(f)]
|
||||
else:
|
||||
paths += files
|
||||
return paths
|
||||
|
||||
|
||||
def _compress_oxt():
|
||||
log.info('Compress OXT extension...')
|
||||
|
||||
|
@ -222,8 +319,11 @@ def _update_files():
|
|||
target = _join(path_source, 'pythonpath', source)
|
||||
copyfile(source, target)
|
||||
|
||||
xml = LiboXML()
|
||||
|
||||
path = _join(path_source, DIRS['meta'], FILES['manifest'])
|
||||
_save(path, DATA['manifest'])
|
||||
data = xml.new_manifest(DATA['manifest'])
|
||||
_save(path, data)
|
||||
|
||||
path = _join(path_source, DIRS['office'])
|
||||
_mkdir(path)
|
||||
|
@ -265,7 +365,138 @@ def _new():
|
|||
return
|
||||
|
||||
|
||||
def _get_info_path(path):
|
||||
path, filename = os.path.split(path)
|
||||
name, extension = os.path.splitext(filename)
|
||||
return (path, filename, name, extension)
|
||||
|
||||
|
||||
def _zip_embed(source, files):
|
||||
PATH = 'Scripts/python/'
|
||||
EASYMACRO = 'easymacro.'
|
||||
|
||||
p, f, name, e = _get_info_path(source)
|
||||
now = datetime.now().strftime('_%Y%m%d_%H%M%S')
|
||||
path_source = _join(p, name + now + e)
|
||||
copyfile(source, path_source)
|
||||
target = source
|
||||
|
||||
with zipfile.PyZipFile(EASYMACRO + 'zip', mode='w') as zf:
|
||||
zf.writepy(EASYMACRO + 'py')
|
||||
|
||||
xml = LiboXML()
|
||||
|
||||
path_easymacro = PATH + EASYMACRO + 'zip'
|
||||
names = [f[1] for f in files] + [path_easymacro]
|
||||
nodes = []
|
||||
with zipfile.ZipFile(target, 'w', compression=zipfile.ZIP_DEFLATED) as zt:
|
||||
with zipfile.ZipFile(path_source, compression=zipfile.ZIP_DEFLATED) as zs:
|
||||
for name in zs.namelist():
|
||||
if FILES['manifest'] in name:
|
||||
path_manifest = name
|
||||
xml_manifest = zs.open(name).read()
|
||||
elif name in names:
|
||||
continue
|
||||
else:
|
||||
zt.writestr(name, zs.open(name).read())
|
||||
|
||||
data = []
|
||||
for path, name in files:
|
||||
data.append(name)
|
||||
zt.write(path, name)
|
||||
|
||||
zt.write(EASYMACRO + 'zip', path_easymacro)
|
||||
data.append(path_easymacro)
|
||||
|
||||
xml.parse_manifest(xml_manifest)
|
||||
xml_manifest = xml.add_data_manifest(data)
|
||||
zt.writestr(path_manifest, xml_manifest)
|
||||
|
||||
os.unlink(EASYMACRO + 'zip')
|
||||
return
|
||||
|
||||
|
||||
def _embed(args):
|
||||
PATH = 'Scripts/python'
|
||||
PYTHONPATH = 'pythonpath'
|
||||
|
||||
doc = args.document
|
||||
if not doc:
|
||||
msg = '-d/--document Path file to embed is mandatory'
|
||||
log.error(msg)
|
||||
return
|
||||
if not _exists(doc):
|
||||
msg = 'Path file not exists'
|
||||
log.error(msg)
|
||||
return
|
||||
|
||||
files = []
|
||||
if args.files:
|
||||
files = args.files.split(',')
|
||||
source = _join(PATHS['profile'], PATH)
|
||||
content = os.listdir(source)
|
||||
if PYTHONPATH in content:
|
||||
content.remove(PYTHONPATH)
|
||||
|
||||
if files:
|
||||
files = [(_join(source, f), _join(PATH, f)) for f in files if f in content]
|
||||
else:
|
||||
files = [(_join(source, f), _join(PATH, f)) for f in content]
|
||||
|
||||
_zip_embed(doc, files)
|
||||
|
||||
log.info('Embedded macros successfully...')
|
||||
return
|
||||
|
||||
|
||||
def _locales(args):
|
||||
EASYMACRO = 'easymacro.py'
|
||||
|
||||
if args.files:
|
||||
files = args.files.split(',')
|
||||
else:
|
||||
files = _get_files(DIRS['source'], 'py')
|
||||
paths = ' '.join([f for f in files if not EASYMACRO in f])
|
||||
path_pot = _join(DIRS['source'], DIRS['locales'], '{}.pot'.format(DOMAIN))
|
||||
call([PATHS['gettext'], '-o', path_pot, paths])
|
||||
log.info('POT generate successfully...')
|
||||
return
|
||||
|
||||
|
||||
def _update():
|
||||
path_locales = _join(DIRS['source'], DIRS['locales'])
|
||||
path_pot = _join(DIRS['source'], DIRS['locales'], '{}.pot'.format(DOMAIN))
|
||||
if not _exists(path_pot):
|
||||
log.error('Not exists file POT...')
|
||||
return
|
||||
|
||||
files = _get_files(path_locales, 'po')
|
||||
if not files:
|
||||
log.error('First, generate files PO...')
|
||||
return
|
||||
|
||||
for f in files:
|
||||
call([PATHS['msgmerge'], '-U', f, path_pot])
|
||||
log.info('\tUpdate: {}'.format(f))
|
||||
|
||||
log.info('Locales update successfully...')
|
||||
return
|
||||
|
||||
|
||||
|
||||
def main(args):
|
||||
if args.update:
|
||||
_update()
|
||||
return
|
||||
|
||||
if args.locales:
|
||||
_locales(args)
|
||||
return
|
||||
|
||||
if args.embed:
|
||||
_embed(args)
|
||||
return
|
||||
|
||||
if args.new:
|
||||
_new()
|
||||
return
|
||||
|
@ -279,7 +510,7 @@ def main(args):
|
|||
if args.install:
|
||||
_install_and_test()
|
||||
|
||||
log.info('Extension make sucesfully...')
|
||||
log.info('Extension make successfully...')
|
||||
return
|
||||
|
||||
|
||||
|
@ -290,6 +521,14 @@ def _process_command_line_arguments():
|
|||
default=False, required=False)
|
||||
parser.add_argument('-n', '--new', dest='new', action='store_true',
|
||||
default=False, required=False)
|
||||
parser.add_argument('-e', '--embed', dest='embed', action='store_true',
|
||||
default=False, required=False)
|
||||
parser.add_argument('-d', '--document', dest='document', default='')
|
||||
parser.add_argument('-f', '--files', dest='files', default='')
|
||||
parser.add_argument('-l', '--locales', dest='locales', action='store_true',
|
||||
default=False, required=False)
|
||||
parser.add_argument('-u', '--update', dest='update', action='store_true',
|
||||
default=False, required=False)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue