Start, end refactory
This commit is contained in:
parent
fede099f4b
commit
bca321404f
|
@ -2340,43 +2340,6 @@ def get_control_model(control):
|
|||
return services[control]
|
||||
|
||||
|
||||
def add_listeners(events, control, name=''):
|
||||
listeners = {
|
||||
'addActionListener': EventsButton,
|
||||
'addMouseListener': EventsMouse,
|
||||
'addItemListener': EventsItem,
|
||||
'addFocusListener': EventsFocus,
|
||||
'addKeyListener': EventsKey,
|
||||
'addTabListener': EventsTab,
|
||||
}
|
||||
if hasattr(control, 'obj'):
|
||||
control = contro.obj
|
||||
# ~ debug(control.ImplementationName)
|
||||
is_grid = control.ImplementationName == 'stardiv.Toolkit.GridControl'
|
||||
is_link = control.ImplementationName == 'stardiv.Toolkit.UnoFixedHyperlinkControl'
|
||||
is_roadmap = control.ImplementationName == 'stardiv.Toolkit.UnoRoadmapControl'
|
||||
|
||||
for key, value in listeners.items():
|
||||
if hasattr(control, key):
|
||||
if is_grid and key == 'addMouseListener':
|
||||
control.addMouseListener(EventsMouseGrid(events, name))
|
||||
continue
|
||||
if is_link and key == 'addMouseListener':
|
||||
control.addMouseListener(EventsMouseLink(events, name))
|
||||
continue
|
||||
if is_roadmap and key == 'addItemListener':
|
||||
control.addItemListener(EventsItemRoadmap(events, name))
|
||||
continue
|
||||
|
||||
getattr(control, key)(listeners[key](events, name))
|
||||
|
||||
if is_grid:
|
||||
controllers = EventsGrid(events, name)
|
||||
control.addSelectionListener(controllers)
|
||||
control.Model.GridDataModel.addGridDataListener(controllers)
|
||||
return
|
||||
|
||||
|
||||
class WriterTable(ObjectBase):
|
||||
|
||||
def __init__(self, obj):
|
||||
|
@ -3282,10 +3245,6 @@ class LOWindow(object):
|
|||
return
|
||||
|
||||
|
||||
# ~ Python >= 3.7
|
||||
# ~ def __getattr__(name):
|
||||
|
||||
|
||||
def create_window(kwargs):
|
||||
return LOWindow(**kwargs)
|
||||
|
||||
|
@ -3564,21 +3523,6 @@ def get_epoch():
|
|||
return int(time.mktime(n.timetuple()))
|
||||
|
||||
|
||||
# ~ Export ok
|
||||
def start():
|
||||
global _start
|
||||
_start = now()
|
||||
log.info(_start)
|
||||
return
|
||||
|
||||
|
||||
# ~ Export ok
|
||||
def end():
|
||||
global _start
|
||||
e = now()
|
||||
return str(e - _start).split('.')[0]
|
||||
|
||||
|
||||
# ~ Export ok
|
||||
def render(template, data):
|
||||
s = Template(template)
|
||||
|
|
|
@ -165,6 +165,7 @@ DESKTOP = os.environ.get('DESKTOP_SESSION', '')
|
|||
INFO_DEBUG = f"{sys.version}\n\n{platform.platform()}\n\n" + '\n'.join(sys.path)
|
||||
|
||||
_MACROS = {}
|
||||
_start = 0
|
||||
|
||||
SECONDS_DAY = 60 * 60 * 24
|
||||
DIR = {
|
||||
|
@ -643,6 +644,23 @@ def set_config(key, value, prefix='conf'):
|
|||
return result
|
||||
|
||||
|
||||
def start():
|
||||
global _start
|
||||
_start = now()
|
||||
info(_start)
|
||||
return
|
||||
|
||||
|
||||
def end(get_seconds=False):
|
||||
global _start
|
||||
e = now()
|
||||
td = e - _start
|
||||
result = str(td)
|
||||
if get_seconds:
|
||||
result = td.total_seconds()
|
||||
return result
|
||||
|
||||
|
||||
def _get_key(password):
|
||||
from cryptography.hazmat.primitives import hashes
|
||||
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
||||
|
|
Loading…
Reference in New Issue