diff --git a/CHANGELOG b/CHANGELOG
index 2f61d6e..8acdd9c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,4 @@
-v 0.8.0 [06-jun-2021]
+v 0.8.0 [13-jun-2021]
- Update easymacro.py
- Add proxy config
diff --git a/easymacro.py b/easymacro.py
index 2c7d5f3..cbb26a0 100644
--- a/easymacro.py
+++ b/easymacro.py
@@ -2881,6 +2881,23 @@ class LOCalcRange(object):
self.obj.fillAuto(0, source)
return
+ def _cast(self, t, v):
+ if not t:
+ return v
+
+ if t == datetime.date:
+ nv = datetime.date.fromordinal(int(v) + DATE_OFFSET)
+ else:
+ nv = t(v)
+ return nv
+
+ def get_data(self, types):
+ values = [
+ [self._cast(types[i], v) for i, v in enumerate(row)]
+ for row in self.data
+ ]
+ return values
+
class LOWriterStyles(object):
@@ -3944,6 +3961,7 @@ class LODocs(object):
return doc
def __len__(self):
+ # ~ len(self._desktop.Components)
for i, _ in enumerate(self._desktop.Components):
pass
return i + 1
@@ -4713,6 +4731,13 @@ class UnoText(UnoBaseObject):
def value(self, value):
self.model.Text = value
+ @property
+ def echochar(self):
+ return chr(self.model.EchoChar)
+ @echochar.setter
+ def echochar(self, value):
+ self.model.EchoChar = ord(value[0])
+
def validate(self):
return
@@ -5553,6 +5578,11 @@ class LODialog(object):
self.obj.dispose()
return value
+ def set_values(self, data):
+ for k, v in data.items():
+ self._controls[k].value = v
+ return
+
class LOSheets(object):
@@ -6645,48 +6675,6 @@ def get_fonts():
return device.FontDescriptors
-# ~ From request
-# ~ https://github.com/psf/requests/blob/master/requests/structures.py#L15
-class CaseInsensitiveDict(MutableMapping):
-
- def __init__(self, data=None, **kwargs):
- self._store = OrderedDict()
- if data is None:
- data = {}
- self.update(data, **kwargs)
-
- def __setitem__(self, key, value):
- # Use the lowercased key for lookups, but store the actual
- # key alongside the value.
- self._store[key.lower()] = (key, value)
-
- def __getitem__(self, key):
- return self._store[key.lower()][1]
-
- def __delitem__(self, key):
- del self._store[key.lower()]
-
- def __iter__(self):
- return (casedkey for casedkey, mappedvalue in self._store.values())
-
- def __len__(self):
- return len(self._store)
-
- def lower_items(self):
- """Like iteritems(), but with all lowercase keys."""
- values = (
- (lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items()
- )
- return values
-
- # Copy is required
- def copy(self):
- return CaseInsensitiveDict(self._store.values())
-
- def __repr__(self):
- return str(dict(self.items()))
-
-
# ~ https://en.wikipedia.org/wiki/Web_colors
def get_color(value):
COLORS = {
diff --git a/files/ZAZPip_v0.8.0.oxt b/files/ZAZPip_v0.8.0.oxt
index f679fe2..b422fd3 100644
Binary files a/files/ZAZPip_v0.8.0.oxt and b/files/ZAZPip_v0.8.0.oxt differ
diff --git a/source/images/delete.svg b/source/images/delete.svg
new file mode 100755
index 0000000..534460e
--- /dev/null
+++ b/source/images/delete.svg
@@ -0,0 +1,4 @@
+
diff --git a/source/images/save.svg b/source/images/save.svg
new file mode 100644
index 0000000..49811f9
--- /dev/null
+++ b/source/images/save.svg
@@ -0,0 +1,8 @@
+
diff --git a/source/pythonpath/easymacro.py b/source/pythonpath/easymacro.py
index 2c7d5f3..cbb26a0 100644
--- a/source/pythonpath/easymacro.py
+++ b/source/pythonpath/easymacro.py
@@ -2881,6 +2881,23 @@ class LOCalcRange(object):
self.obj.fillAuto(0, source)
return
+ def _cast(self, t, v):
+ if not t:
+ return v
+
+ if t == datetime.date:
+ nv = datetime.date.fromordinal(int(v) + DATE_OFFSET)
+ else:
+ nv = t(v)
+ return nv
+
+ def get_data(self, types):
+ values = [
+ [self._cast(types[i], v) for i, v in enumerate(row)]
+ for row in self.data
+ ]
+ return values
+
class LOWriterStyles(object):
@@ -3944,6 +3961,7 @@ class LODocs(object):
return doc
def __len__(self):
+ # ~ len(self._desktop.Components)
for i, _ in enumerate(self._desktop.Components):
pass
return i + 1
@@ -4713,6 +4731,13 @@ class UnoText(UnoBaseObject):
def value(self, value):
self.model.Text = value
+ @property
+ def echochar(self):
+ return chr(self.model.EchoChar)
+ @echochar.setter
+ def echochar(self, value):
+ self.model.EchoChar = ord(value[0])
+
def validate(self):
return
@@ -5553,6 +5578,11 @@ class LODialog(object):
self.obj.dispose()
return value
+ def set_values(self, data):
+ for k, v in data.items():
+ self._controls[k].value = v
+ return
+
class LOSheets(object):
@@ -6645,48 +6675,6 @@ def get_fonts():
return device.FontDescriptors
-# ~ From request
-# ~ https://github.com/psf/requests/blob/master/requests/structures.py#L15
-class CaseInsensitiveDict(MutableMapping):
-
- def __init__(self, data=None, **kwargs):
- self._store = OrderedDict()
- if data is None:
- data = {}
- self.update(data, **kwargs)
-
- def __setitem__(self, key, value):
- # Use the lowercased key for lookups, but store the actual
- # key alongside the value.
- self._store[key.lower()] = (key, value)
-
- def __getitem__(self, key):
- return self._store[key.lower()][1]
-
- def __delitem__(self, key):
- del self._store[key.lower()]
-
- def __iter__(self):
- return (casedkey for casedkey, mappedvalue in self._store.values())
-
- def __len__(self):
- return len(self._store)
-
- def lower_items(self):
- """Like iteritems(), but with all lowercase keys."""
- values = (
- (lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items()
- )
- return values
-
- # Copy is required
- def copy(self):
- return CaseInsensitiveDict(self._store.values())
-
- def __repr__(self):
- return str(dict(self.items()))
-
-
# ~ https://en.wikipedia.org/wiki/Web_colors
def get_color(value):
COLORS = {
diff --git a/source/pythonpath/main.py b/source/pythonpath/main.py
index 48bc63a..16b0069 100644
--- a/source/pythonpath/main.py
+++ b/source/pythonpath/main.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
+import os
import easymacro as app
@@ -32,6 +33,17 @@ PACKAGES = {
def open_dialog_pip():
dialog = _create_dialog()
+
+ proxy = app.get_config('proxy', {}, TITLE)
+ if proxy:
+ app.debug(proxy)
+ HOST = proxy['txt_proxy_host']
+ PORT = proxy['txt_proxy_port']
+ USER = proxy['txt_proxy_user']
+ PASS = proxy['txt_proxy_pass']
+ os.environ['http_proxy'] = f'http://{USER}:{PASS}@{HOST}:{PORT}'
+ os.environ['https_proxy'] = f'http://{USER}:{PASS}@{HOST}:{PORT}'
+
dialog.open()
return
@@ -300,7 +312,46 @@ class Controllers(object):
return
def cmd_proxy_action(self, event):
- app.msgbox('Config Proxy')
+ dialog = _create_dialog_proxy()
+ data = app.get_config('proxy', {}, TITLE)
+ dialog.set_values(data)
+ dialog.open()
+ return
+
+
+class ControllersProxy(object):
+
+ def __init__(self, dialog):
+ self.d = dialog
+
+ def cmd_proxy_save_action(self, event):
+ data = dict(
+ txt_proxy_host = self.d.txt_proxy_host.value,
+ txt_proxy_port = self.d.txt_proxy_port.value,
+ txt_proxy_user = self.d.txt_proxy_user.value,
+ txt_proxy_pass = self.d.txt_proxy_pass.value,
+ )
+ msg = _('Are you shure save data?')
+ if not app.question(msg):
+ return
+
+ app.set_config('proxy', data, TITLE)
+
+ msg = _('Save data sucesfully')
+ app.msgbox(msg)
+ self.d.close()
+ return
+
+ def cmd_proxy_delete_action(self, event):
+ msg = _("Are you shure delete data?")
+ if not app.question(msg):
+ return
+
+ app.set_config('proxy', {}, TITLE)
+
+ msg = _('Delete data sucesfully')
+ app.msgbox(msg)
+ self.d.close()
return
@@ -573,3 +624,141 @@ def _create_dialog():
dialog.lst_log.visible = False
return dialog
+
+
+def _create_dialog_proxy():
+ args= {
+ 'Name': 'dlg_proxy',
+ 'Title': 'Zaz-Pip - Config Proxy',
+ 'Width': 150,
+ 'Height': 100,
+ }
+ dialog = app.create_dialog(args)
+ dialog.id = ID_EXTENSION
+ dialog.events = ControllersProxy
+
+ args = {
+ 'Type': 'Label',
+ 'Name': 'lbl_proxy_host',
+ 'Label': 'Host: ',
+ 'Width': 40,
+ 'Height': 12,
+ 'Border': 1,
+ 'Align': 2,
+ 'VerticalAlign': 1,
+ 'X': 5,
+ 'Y': 5,
+ }
+ dialog.add_control(args)
+
+ args = {
+ 'Type': 'Text',
+ 'Name': 'txt_proxy_host',
+ 'Width': 95,
+ 'Height': 12,
+ 'Border': 0,
+ }
+ dialog.add_control(args)
+
+ args = {
+ 'Type': 'Label',
+ 'Name': 'lbl_proxy_port',
+ 'Label': 'Port: ',
+ 'Width': 40,
+ 'Height': 12,
+ 'Border': 1,
+ 'Align': 2,
+ 'VerticalAlign': 1,
+ }
+ dialog.add_control(args)
+
+ args = {
+ 'Type': 'Text',
+ 'Name': 'txt_proxy_port',
+ 'Width': 95,
+ 'Height': 12,
+ 'Border': 0,
+ }
+ dialog.add_control(args)
+
+ args = {
+ 'Type': 'Label',
+ 'Name': 'lbl_proxy_user',
+ 'Label': 'User: ',
+ 'Width': 40,
+ 'Height': 12,
+ 'Border': 1,
+ 'Align': 2,
+ 'VerticalAlign': 1,
+ }
+ dialog.add_control(args)
+
+ args = {
+ 'Type': 'Text',
+ 'Name': 'txt_proxy_user',
+ 'Width': 95,
+ 'Height': 12,
+ 'Border': 0,
+ }
+ dialog.add_control(args)
+
+ args = {
+ 'Type': 'Label',
+ 'Name': 'lbl_proxy_pass',
+ 'Label': 'Password: ',
+ 'Width': 40,
+ 'Height': 12,
+ 'Border': 1,
+ 'Align': 2,
+ 'VerticalAlign': 1,
+ }
+ dialog.add_control(args)
+
+ args = {
+ 'Type': 'Text',
+ 'Name': 'txt_proxy_pass',
+ 'Width': 95,
+ 'Height': 12,
+ 'Border': 0,
+ }
+ txt = dialog.add_control(args)
+ txt.echochar = '*'
+
+ args = {
+ 'Type': 'Button',
+ 'Name': 'cmd_proxy_save',
+ 'Label': _('Save'),
+ 'Width': 50,
+ 'Height': 15,
+ 'ImageURL': 'save.svg',
+ 'ImagePosition': 1,
+ 'FocusOnClick': False,
+ }
+ dialog.add_control(args)
+
+ args = {
+ 'Type': 'Button',
+ 'Name': 'cmd_proxy_delete',
+ 'Label': _('Delete'),
+ 'Width': 50,
+ 'Height': 15,
+ 'ImageURL': 'delete.svg',
+ 'ImagePosition': 1,
+ 'FocusOnClick': False,
+ }
+ dialog.add_control(args)
+
+ dialog.txt_proxy_host.move(dialog.lbl_proxy_host, x=5, y=0)
+ dialog.lbl_proxy_port.move(dialog.lbl_proxy_host)
+ dialog.txt_proxy_port.move(dialog.lbl_proxy_port, x=5, y=0)
+ dialog.lbl_proxy_user.move(dialog.lbl_proxy_port)
+ dialog.txt_proxy_user.move(dialog.lbl_proxy_user, x=5, y=0)
+ dialog.lbl_proxy_pass.move(dialog.lbl_proxy_user)
+ dialog.txt_proxy_pass.move(dialog.lbl_proxy_pass, x=5, y=0)
+
+ dialog.cmd_proxy_save.move(dialog.lbl_proxy_pass, y=10)
+ dialog.cmd_proxy_delete.move(dialog.lbl_proxy_pass, y=10)
+ controls = (dialog.cmd_proxy_save, dialog.cmd_proxy_delete)
+ dialog.center(controls)
+
+ return dialog