Fix python3 in some Linux distributions
This commit is contained in:
parent
61c3752420
commit
9322cb8a8f
|
@ -1,3 +1,7 @@
|
|||
v 0.4.0 [22-nov-2019]
|
||||
- Update easymacro.py
|
||||
|
||||
|
||||
v 0.3.0 [12-nov-2019]
|
||||
- Update easymacro.py
|
||||
- Test install numpy
|
||||
|
|
|
@ -13,9 +13,9 @@ https://gitlab.com/mauriciobaeza/zaz
|
|||
|
||||
This extension have a cost of maintenance of 1 euro every year.
|
||||
|
||||
BCH: `1RPLWHJW34p7pMQV1ft4x7eWhAYw69Dsb`
|
||||
BCH: `qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d`
|
||||
|
||||
BTC: `3Fe4JuADrAK8Qs7GDAxbSXR8E54avwZJLW`
|
||||
BTC: `3FhiXcXmAesmQzrNEngjHFnvaJRhU1AGWV`
|
||||
|
||||
PayPal :( donate ATT elmau DOT net
|
||||
|
||||
|
|
2
conf.py
2
conf.py
|
@ -26,7 +26,7 @@ import logging
|
|||
TYPE_EXTENSION = 1
|
||||
|
||||
# ~ https://semver.org/
|
||||
VERSION = '0.3.0'
|
||||
VERSION = '0.4.0'
|
||||
|
||||
# ~ Your great extension name, not used spaces
|
||||
NAME = 'ZAZPip'
|
||||
|
|
121
easymacro.py
121
easymacro.py
|
@ -132,7 +132,7 @@ IS_WIN = OS == 'Windows'
|
|||
LOG_NAME = 'ZAZ'
|
||||
CLIPBOARD_FORMAT_TEXT = 'text/plain;charset=utf-16'
|
||||
|
||||
PYTHON = 'python'
|
||||
PYTHON = 'python3'
|
||||
if IS_WIN:
|
||||
PYTHON = 'python.exe'
|
||||
CALC = 'calc'
|
||||
|
@ -450,12 +450,14 @@ def call_dispatch(url, args=()):
|
|||
return
|
||||
|
||||
|
||||
def get_temp_file():
|
||||
def get_temp_file(only_name=False):
|
||||
delete = True
|
||||
if IS_WIN:
|
||||
delete = False
|
||||
return tempfile.NamedTemporaryFile(delete=delete)
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(delete=delete)
|
||||
if only_name:
|
||||
tmp = tmp.name
|
||||
return tmp
|
||||
|
||||
def _path_url(path):
|
||||
if path.startswith('file://'):
|
||||
|
@ -497,6 +499,11 @@ def dict_to_property(values, uno_any=False):
|
|||
return ps
|
||||
|
||||
|
||||
def dict_to_named(values):
|
||||
ps = tuple([NamedValue(n, v) for n, v in values.items()])
|
||||
return ps
|
||||
|
||||
|
||||
def property_to_dict(values):
|
||||
d = {i.Name: i.Value for i in values}
|
||||
return d
|
||||
|
@ -1650,7 +1657,7 @@ class LODrawImpress(LODocument):
|
|||
|
||||
def insert_image(self, path, **kwargs):
|
||||
w = kwargs.get('width', 3000)
|
||||
h = kwargs.get('Height', 1000)
|
||||
h = kwargs.get('Height', 3000)
|
||||
x = kwargs.get('X', 1000)
|
||||
y = kwargs.get('Y', 1000)
|
||||
|
||||
|
@ -1799,6 +1806,15 @@ class LOCellRange(object):
|
|||
def columns(self):
|
||||
return self._obj.Columns.Count
|
||||
|
||||
@property
|
||||
def row(self):
|
||||
a = self.address
|
||||
if hasattr(a, 'Row'):
|
||||
r = a.Row
|
||||
else:
|
||||
r = a.StartRow
|
||||
return r
|
||||
|
||||
@property
|
||||
def rows(self):
|
||||
return self._obj.Rows.Count
|
||||
|
@ -1835,6 +1851,33 @@ class LOCellRange(object):
|
|||
self.sheet.obj.copyRange(self.address, source.range_address)
|
||||
return
|
||||
|
||||
def transpose(self, formula=False):
|
||||
data = self.data
|
||||
if formula:
|
||||
data = self.formula
|
||||
data = tuple(zip(*data))
|
||||
self.clear(1023)
|
||||
self[0,0].copy_from(data, formula=formula)
|
||||
return
|
||||
|
||||
def transpose2(self):
|
||||
# ~ 'Flags': 'A',
|
||||
# ~ 'FormulaCommand': 0,
|
||||
# ~ 'SkipEmptyCells': False,
|
||||
# ~ 'AsLink': False,
|
||||
# ~ 'MoveMode': 4,
|
||||
args = {
|
||||
'Transpose': True,
|
||||
}
|
||||
args = dict_to_property(args)
|
||||
self.select()
|
||||
copy()
|
||||
self.clear(1023)
|
||||
self[0,0].select()
|
||||
call_dispatch('.uno:InsertContents', args)
|
||||
set_clipboard('')
|
||||
return
|
||||
|
||||
def offset(self, row=1, col=0):
|
||||
ra = self.obj.getRangeAddress()
|
||||
col = ra.EndColumn + col
|
||||
|
@ -1937,6 +1980,10 @@ class LOCellRange(object):
|
|||
def auto_format(self, value):
|
||||
self.obj.autoFormat(value)
|
||||
|
||||
def auto_width(self):
|
||||
self.obj.Columns.OptimalWidth = True
|
||||
return
|
||||
|
||||
def insert_image(self, path, **kwargs):
|
||||
s = self.obj.Size
|
||||
w = kwargs.get('width', s.Width)
|
||||
|
@ -2058,6 +2105,22 @@ class LOCellRange(object):
|
|||
found = self.obj.replaceAll(descriptor)
|
||||
return found
|
||||
|
||||
@property
|
||||
def validation(self):
|
||||
return self.obj.Validation
|
||||
@validation.setter
|
||||
def validation(self, values):
|
||||
is_list = False
|
||||
current = self.validation
|
||||
for k, v in values.items():
|
||||
if k == 'Type' and v == 6:
|
||||
is_list = True
|
||||
if k == 'Formula1' and is_list:
|
||||
if isinstance(v, (tuple, list)):
|
||||
v = ';'.join(['"{}"'.format(i) for i in v])
|
||||
setattr(current, k, v)
|
||||
self.obj.Validation = current
|
||||
|
||||
|
||||
class EventsListenerBase(unohelper.Base, XEventListener):
|
||||
|
||||
|
@ -2452,23 +2515,39 @@ class UnoBaseObject(object):
|
|||
return self._model.Width
|
||||
@width.setter
|
||||
def width(self, value):
|
||||
if hasattr(self.model, 'Width'):
|
||||
self.model.Width = value
|
||||
elif hasattr(self.obj, 'PosSize'):
|
||||
self._set_possize('Width', value)
|
||||
self.model.Width = value
|
||||
|
||||
@property
|
||||
def ps_width(self):
|
||||
return self._get_possize('Width')
|
||||
@ps_width.setter
|
||||
def ps_width(self, value):
|
||||
self._set_possize('Width', value)
|
||||
|
||||
@property
|
||||
def height(self):
|
||||
if hasattr(self.model, 'Height'):
|
||||
return self.model.Height
|
||||
ps = self.obj.getPosSize()
|
||||
return ps.Height
|
||||
return self.model.Height
|
||||
@height.setter
|
||||
def height(self, value):
|
||||
if hasattr(self.model, 'Height'):
|
||||
self.model.Height = value
|
||||
elif hasattr(self.obj, 'PosSize'):
|
||||
self._set_possize('Height', value)
|
||||
self.model.Height = value
|
||||
|
||||
@property
|
||||
def ps_height(self):
|
||||
return self._get_possize('Height')
|
||||
@ps_height.setter
|
||||
def ps_height(self, value):
|
||||
self._set_possize('Height', value)
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
ps = self.obj.getPosSize()
|
||||
return (ps.Width, ps.Height)
|
||||
@size.setter
|
||||
def size(self, value):
|
||||
ps = self.obj.getPosSize()
|
||||
ps.Width = value[0]
|
||||
ps.Height = value[1]
|
||||
self.obj.setPosSize(ps.X, ps.Y, ps.Width, ps.Height, SIZE)
|
||||
|
||||
@property
|
||||
def tag(self):
|
||||
|
@ -4213,8 +4292,12 @@ def json_loads(data):
|
|||
|
||||
|
||||
def get_path_extension(id):
|
||||
path = ''
|
||||
pip = CTX.getValueByName('/singletons/com.sun.star.deployment.PackageInformationProvider')
|
||||
path = _path_system(pip.getPackageLocation(id))
|
||||
try:
|
||||
path = _path_system(pip.getPackageLocation(id))
|
||||
except Exception as e:
|
||||
error(e)
|
||||
return path
|
||||
|
||||
|
||||
|
@ -4487,7 +4570,7 @@ def _zippwd(source, target, pwd):
|
|||
|
||||
|
||||
# ~ Export ok
|
||||
def zip(source, target='', mode='w', pwd=''):
|
||||
def zip_files(source, target='', mode='w', pwd=''):
|
||||
if pwd:
|
||||
return _zippwd(source, target, pwd)
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest:manifest manifest:version="1.2" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
|
||||
<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="ZAZPip.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"/>
|
||||
|
|
|
@ -17,6 +17,8 @@ PACKAGES = {
|
|||
'psycopg2-binary': 'ok.png',
|
||||
'peewee': 'ok.png',
|
||||
'numpy': 'ok.png',
|
||||
'pillow': 'ok.png',
|
||||
'pytesseract': 'ok.png',
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,9 +60,7 @@ class Controllers(object):
|
|||
def _install_pip(self):
|
||||
self.d.link_proyect.visible = False
|
||||
self.d.lst_log.visible = True
|
||||
|
||||
with app.get_temp_file() as f:
|
||||
path_pip = f.name
|
||||
path_pip = app.get_temp_file(True)
|
||||
|
||||
self.d.lst_log.insert('Download PIP...')
|
||||
data, err = app.url_open(URL_PIP, verify=False)
|
||||
|
|
|
@ -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.pip" />
|
||||
<version value="0.3.0" />
|
||||
<version value="0.4.0" />
|
||||
<display-name>
|
||||
<name lang="en">ZAZ Pip</name>
|
||||
<name lang="es">ZAZ Pip</name>
|
||||
|
|
|
@ -132,7 +132,7 @@ IS_WIN = OS == 'Windows'
|
|||
LOG_NAME = 'ZAZ'
|
||||
CLIPBOARD_FORMAT_TEXT = 'text/plain;charset=utf-16'
|
||||
|
||||
PYTHON = 'python'
|
||||
PYTHON = 'python3'
|
||||
if IS_WIN:
|
||||
PYTHON = 'python.exe'
|
||||
CALC = 'calc'
|
||||
|
@ -450,12 +450,14 @@ def call_dispatch(url, args=()):
|
|||
return
|
||||
|
||||
|
||||
def get_temp_file():
|
||||
def get_temp_file(only_name=False):
|
||||
delete = True
|
||||
if IS_WIN:
|
||||
delete = False
|
||||
return tempfile.NamedTemporaryFile(delete=delete)
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(delete=delete)
|
||||
if only_name:
|
||||
tmp = tmp.name
|
||||
return tmp
|
||||
|
||||
def _path_url(path):
|
||||
if path.startswith('file://'):
|
||||
|
@ -497,6 +499,11 @@ def dict_to_property(values, uno_any=False):
|
|||
return ps
|
||||
|
||||
|
||||
def dict_to_named(values):
|
||||
ps = tuple([NamedValue(n, v) for n, v in values.items()])
|
||||
return ps
|
||||
|
||||
|
||||
def property_to_dict(values):
|
||||
d = {i.Name: i.Value for i in values}
|
||||
return d
|
||||
|
@ -1650,7 +1657,7 @@ class LODrawImpress(LODocument):
|
|||
|
||||
def insert_image(self, path, **kwargs):
|
||||
w = kwargs.get('width', 3000)
|
||||
h = kwargs.get('Height', 1000)
|
||||
h = kwargs.get('Height', 3000)
|
||||
x = kwargs.get('X', 1000)
|
||||
y = kwargs.get('Y', 1000)
|
||||
|
||||
|
@ -1799,6 +1806,15 @@ class LOCellRange(object):
|
|||
def columns(self):
|
||||
return self._obj.Columns.Count
|
||||
|
||||
@property
|
||||
def row(self):
|
||||
a = self.address
|
||||
if hasattr(a, 'Row'):
|
||||
r = a.Row
|
||||
else:
|
||||
r = a.StartRow
|
||||
return r
|
||||
|
||||
@property
|
||||
def rows(self):
|
||||
return self._obj.Rows.Count
|
||||
|
@ -1835,6 +1851,33 @@ class LOCellRange(object):
|
|||
self.sheet.obj.copyRange(self.address, source.range_address)
|
||||
return
|
||||
|
||||
def transpose(self, formula=False):
|
||||
data = self.data
|
||||
if formula:
|
||||
data = self.formula
|
||||
data = tuple(zip(*data))
|
||||
self.clear(1023)
|
||||
self[0,0].copy_from(data, formula=formula)
|
||||
return
|
||||
|
||||
def transpose2(self):
|
||||
# ~ 'Flags': 'A',
|
||||
# ~ 'FormulaCommand': 0,
|
||||
# ~ 'SkipEmptyCells': False,
|
||||
# ~ 'AsLink': False,
|
||||
# ~ 'MoveMode': 4,
|
||||
args = {
|
||||
'Transpose': True,
|
||||
}
|
||||
args = dict_to_property(args)
|
||||
self.select()
|
||||
copy()
|
||||
self.clear(1023)
|
||||
self[0,0].select()
|
||||
call_dispatch('.uno:InsertContents', args)
|
||||
set_clipboard('')
|
||||
return
|
||||
|
||||
def offset(self, row=1, col=0):
|
||||
ra = self.obj.getRangeAddress()
|
||||
col = ra.EndColumn + col
|
||||
|
@ -1937,6 +1980,10 @@ class LOCellRange(object):
|
|||
def auto_format(self, value):
|
||||
self.obj.autoFormat(value)
|
||||
|
||||
def auto_width(self):
|
||||
self.obj.Columns.OptimalWidth = True
|
||||
return
|
||||
|
||||
def insert_image(self, path, **kwargs):
|
||||
s = self.obj.Size
|
||||
w = kwargs.get('width', s.Width)
|
||||
|
@ -2058,6 +2105,22 @@ class LOCellRange(object):
|
|||
found = self.obj.replaceAll(descriptor)
|
||||
return found
|
||||
|
||||
@property
|
||||
def validation(self):
|
||||
return self.obj.Validation
|
||||
@validation.setter
|
||||
def validation(self, values):
|
||||
is_list = False
|
||||
current = self.validation
|
||||
for k, v in values.items():
|
||||
if k == 'Type' and v == 6:
|
||||
is_list = True
|
||||
if k == 'Formula1' and is_list:
|
||||
if isinstance(v, (tuple, list)):
|
||||
v = ';'.join(['"{}"'.format(i) for i in v])
|
||||
setattr(current, k, v)
|
||||
self.obj.Validation = current
|
||||
|
||||
|
||||
class EventsListenerBase(unohelper.Base, XEventListener):
|
||||
|
||||
|
@ -2452,23 +2515,39 @@ class UnoBaseObject(object):
|
|||
return self._model.Width
|
||||
@width.setter
|
||||
def width(self, value):
|
||||
if hasattr(self.model, 'Width'):
|
||||
self.model.Width = value
|
||||
elif hasattr(self.obj, 'PosSize'):
|
||||
self._set_possize('Width', value)
|
||||
self.model.Width = value
|
||||
|
||||
@property
|
||||
def ps_width(self):
|
||||
return self._get_possize('Width')
|
||||
@ps_width.setter
|
||||
def ps_width(self, value):
|
||||
self._set_possize('Width', value)
|
||||
|
||||
@property
|
||||
def height(self):
|
||||
if hasattr(self.model, 'Height'):
|
||||
return self.model.Height
|
||||
ps = self.obj.getPosSize()
|
||||
return ps.Height
|
||||
return self.model.Height
|
||||
@height.setter
|
||||
def height(self, value):
|
||||
if hasattr(self.model, 'Height'):
|
||||
self.model.Height = value
|
||||
elif hasattr(self.obj, 'PosSize'):
|
||||
self._set_possize('Height', value)
|
||||
self.model.Height = value
|
||||
|
||||
@property
|
||||
def ps_height(self):
|
||||
return self._get_possize('Height')
|
||||
@ps_height.setter
|
||||
def ps_height(self, value):
|
||||
self._set_possize('Height', value)
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
ps = self.obj.getPosSize()
|
||||
return (ps.Width, ps.Height)
|
||||
@size.setter
|
||||
def size(self, value):
|
||||
ps = self.obj.getPosSize()
|
||||
ps.Width = value[0]
|
||||
ps.Height = value[1]
|
||||
self.obj.setPosSize(ps.X, ps.Y, ps.Width, ps.Height, SIZE)
|
||||
|
||||
@property
|
||||
def tag(self):
|
||||
|
@ -4213,8 +4292,12 @@ def json_loads(data):
|
|||
|
||||
|
||||
def get_path_extension(id):
|
||||
path = ''
|
||||
pip = CTX.getValueByName('/singletons/com.sun.star.deployment.PackageInformationProvider')
|
||||
path = _path_system(pip.getPackageLocation(id))
|
||||
try:
|
||||
path = _path_system(pip.getPackageLocation(id))
|
||||
except Exception as e:
|
||||
error(e)
|
||||
return path
|
||||
|
||||
|
||||
|
@ -4487,7 +4570,7 @@ def _zippwd(source, target, pwd):
|
|||
|
||||
|
||||
# ~ Export ok
|
||||
def zip(source, target='', mode='w', pwd=''):
|
||||
def zip_files(source, target='', mode='w', pwd=''):
|
||||
if pwd:
|
||||
return _zippwd(source, target, pwd)
|
||||
|
||||
|
|
Loading…
Reference in New Issue