q2rad 0.1.223__py3-none-any.whl → 0.1.225__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of q2rad might be problematic. Click here for more details.
- q2rad/q2rad.py +12 -2
- q2rad/q2raddb.py +24 -2
- q2rad/q2reports.py +34 -2
- q2rad/q2utils.py +1 -0
- q2rad/version.py +1 -1
- {q2rad-0.1.223.dist-info → q2rad-0.1.225.dist-info}/METADATA +1 -1
- {q2rad-0.1.223.dist-info → q2rad-0.1.225.dist-info}/RECORD +10 -10
- {q2rad-0.1.223.dist-info → q2rad-0.1.225.dist-info}/LICENSE +0 -0
- {q2rad-0.1.223.dist-info → q2rad-0.1.225.dist-info}/WHEEL +0 -0
- {q2rad-0.1.223.dist-info → q2rad-0.1.225.dist-info}/entry_points.txt +0 -0
q2rad/q2rad.py
CHANGED
|
@@ -123,6 +123,8 @@ def run_module(module_name=None, _globals={}, _locals={}, script="", import_only
|
|
|
123
123
|
ext_module_name = row["prefix"] + module_name
|
|
124
124
|
if get("modules", f"name='{ext_module_name}'", "name", q2app.q2_app.db_logic) == ext_module_name:
|
|
125
125
|
ext_modules.append(ext_module_name)
|
|
126
|
+
if get("modules", f"name='_{module_name}'", "name", q2app.q2_app.db_logic) == f"_{module_name}":
|
|
127
|
+
ext_modules.append(f"_{module_name}")
|
|
126
128
|
if script:
|
|
127
129
|
code = q2app.q2_app.code_compiler(script)
|
|
128
130
|
if code["code"] is False:
|
|
@@ -1316,6 +1318,10 @@ class Q2RadApp(Q2App):
|
|
|
1316
1318
|
f"""select * from (select * from actions
|
|
1317
1319
|
where name = '{ext_name}{name}' order by seq) qq"""
|
|
1318
1320
|
)
|
|
1321
|
+
ext_actions.append(
|
|
1322
|
+
f"""select * from (select * from actions
|
|
1323
|
+
where name = '_{name}' order by seq) qq"""
|
|
1324
|
+
)
|
|
1319
1325
|
if ext_actions:
|
|
1320
1326
|
ext_select = " union all " + " union all ".join(ext_actions)
|
|
1321
1327
|
else:
|
|
@@ -1412,13 +1418,17 @@ class Q2RadApp(Q2App):
|
|
|
1412
1418
|
if re.findall(r"^\s*import\W*.*", x):
|
|
1413
1419
|
module = x.split("import")[1].strip()
|
|
1414
1420
|
if self.db_logic.get("modules", f"name='{module}'", "name"):
|
|
1415
|
-
x = x.split("import")[0] + f"run_module('{module}', import_only=True)"
|
|
1421
|
+
# x = x.split("import")[0] + f"run_module('{module}', import_only=True)"
|
|
1422
|
+
x = (
|
|
1423
|
+
x.split("import")[0]
|
|
1424
|
+
+ f"run_module('{module}', _globals=globals(), import_only=True)"
|
|
1425
|
+
)
|
|
1416
1426
|
|
|
1417
1427
|
new_script_lines.append(x)
|
|
1418
1428
|
script = "\n".join(new_script_lines)
|
|
1419
1429
|
try:
|
|
1420
1430
|
code = compile(script, f"<{script}>", "exec")
|
|
1421
|
-
return {"code": code, "error": ""}
|
|
1431
|
+
return {"code": code, "error": "", "script": script}
|
|
1422
1432
|
except Exception:
|
|
1423
1433
|
error = sys.exc_info()[1]
|
|
1424
1434
|
msg = []
|
q2rad/q2raddb.py
CHANGED
|
@@ -21,7 +21,10 @@ from q2gui.q2model import Q2CursorModel
|
|
|
21
21
|
from q2gui.q2utils import int_, num
|
|
22
22
|
from q2gui import q2app
|
|
23
23
|
from q2gui.q2dialogs import q2Mess, Q2WaitShow
|
|
24
|
-
import html
|
|
24
|
+
# import html
|
|
25
|
+
import datetime
|
|
26
|
+
import calendar
|
|
27
|
+
|
|
25
28
|
|
|
26
29
|
from q2rad import Q2Form
|
|
27
30
|
from q2gui.q2form import NEW, COPY
|
|
@@ -33,7 +36,6 @@ if "darwin" in sys.platform:
|
|
|
33
36
|
import ssl
|
|
34
37
|
|
|
35
38
|
ssl._create_default_https_context = ssl._create_unverified_context
|
|
36
|
-
import datetime
|
|
37
39
|
|
|
38
40
|
# import errno
|
|
39
41
|
|
|
@@ -173,3 +175,23 @@ def today():
|
|
|
173
175
|
def ensure_empty_pk(table="", row={}, q2_db=None):
|
|
174
176
|
q2_db = get_default_db(q2_db)
|
|
175
177
|
q2_db.ensure_empty_pk(table, row)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def dtoc(date, format_from="%Y-%m-%d", format_to="%d.%m.%Y"):
|
|
181
|
+
return datetime.datetime.strptime(date, format_from).strftime(format_to)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def ctod(date, format_from="%d.%m.%Y", format_to="%Y-%m-%d"):
|
|
185
|
+
return dtoc(date, format_from, format_to)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def first_day_of_month(date):
|
|
189
|
+
_date = datetime.datetime.strptime(date, "%Y-%m-%d")
|
|
190
|
+
_date = _date.replace(day=1)
|
|
191
|
+
return _date.strftime("%Y-%m-%d")
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def last_day_of_month(date):
|
|
195
|
+
_date = datetime.datetime.strptime(date, "%Y-%m-%d")
|
|
196
|
+
_date = _date.replace(day=calendar.monthrange(_date.year, _date.month)[1])
|
|
197
|
+
return _date.strftime("%Y-%m-%d")
|
q2rad/q2reports.py
CHANGED
|
@@ -26,13 +26,18 @@ from q2rad.q2queries import Q2QueryEdit
|
|
|
26
26
|
from q2rad.q2utils import q2cursor, Q2_save_and_run
|
|
27
27
|
from q2gui import q2app
|
|
28
28
|
from q2gui.q2dialogs import Q2WaitShow, q2WaitMax, q2WaitStep, q2working
|
|
29
|
+
from q2rad.q2raddb import *
|
|
30
|
+
from q2rad.q2utils import *
|
|
29
31
|
import json
|
|
30
32
|
import os
|
|
33
|
+
import logging
|
|
34
|
+
import threading
|
|
31
35
|
import gettext
|
|
32
36
|
|
|
33
37
|
from q2rad.q2utils import Q2Form
|
|
34
38
|
|
|
35
39
|
_ = gettext.gettext
|
|
40
|
+
_logger = logging.getLogger(__name__)
|
|
36
41
|
|
|
37
42
|
# TODO: selected rows removing - bug
|
|
38
43
|
|
|
@@ -190,6 +195,10 @@ class Q2RadReport(Q2Report):
|
|
|
190
195
|
q2app.q2_app.process_events()
|
|
191
196
|
|
|
192
197
|
def run(self, output_file="temp/repo.html"):
|
|
198
|
+
from q2rad.q2rad import run_module, run_form, get_form , get_report
|
|
199
|
+
_globals = {}
|
|
200
|
+
_globals.update(locals())
|
|
201
|
+
|
|
193
202
|
output_file = self.prepare_output_file(output_file)
|
|
194
203
|
if not output_file:
|
|
195
204
|
return
|
|
@@ -214,6 +223,27 @@ class Q2RadReport(Q2Report):
|
|
|
214
223
|
|
|
215
224
|
return real_worker
|
|
216
225
|
|
|
226
|
+
if _module := self.report_content.get("module"):
|
|
227
|
+
code = q2app.q2_app.code_compiler(_module)
|
|
228
|
+
if code["code"]:
|
|
229
|
+
_globals.update(globals())
|
|
230
|
+
try:
|
|
231
|
+
exec(code["code"], _globals)
|
|
232
|
+
for key, value in _globals.items():
|
|
233
|
+
self.set_data(value, key)
|
|
234
|
+
except Exception as error:
|
|
235
|
+
from q2rad.q2rad import explain_error
|
|
236
|
+
_logger.error(f"{error}")
|
|
237
|
+
explain_error()
|
|
238
|
+
else:
|
|
239
|
+
msg = code["error"]
|
|
240
|
+
if threading.current_thread() is threading.main_thread():
|
|
241
|
+
q2mess(f"{msg}".replace("\n", "<br>").replace(" ", " "))
|
|
242
|
+
print(f"{msg}")
|
|
243
|
+
print("-" * 25)
|
|
244
|
+
_logger.error(msg)
|
|
245
|
+
return
|
|
246
|
+
|
|
217
247
|
q2working(worker(), "W o r k i n g")
|
|
218
248
|
|
|
219
249
|
super().run(output_file, data=data)
|
|
@@ -364,8 +394,8 @@ class Q2ReportEdit(Q2Form):
|
|
|
364
394
|
self.add_control("rl", "", widget=self.layout_edit, nogrid=1, migrate=0)
|
|
365
395
|
self.add_control("/t", "Query")
|
|
366
396
|
self.add_control("ql", "", widget=self.query_edit, nogrid=1, migrate=0)
|
|
367
|
-
self.add_control("/t", "Setup")
|
|
368
|
-
self.add_control("before_script", "", control="code")
|
|
397
|
+
# self.add_control("/t", "Setup")
|
|
398
|
+
# self.add_control("before_script", "", control="code")
|
|
369
399
|
self.add_control("/t", "Module")
|
|
370
400
|
self.add_control("module", "", control="code")
|
|
371
401
|
self.add_control("/t", "Comment")
|
|
@@ -380,10 +410,12 @@ class Q2ReportEdit(Q2Form):
|
|
|
380
410
|
content_json = content
|
|
381
411
|
self.query_edit.set_content(content_json)
|
|
382
412
|
self.layout_edit.set_content(content_json)
|
|
413
|
+
self.s.module = content_json.get("module", "#")
|
|
383
414
|
|
|
384
415
|
def get_content(self, str_mode=True):
|
|
385
416
|
content = self.query_edit.get_content(str_mode=False)
|
|
386
417
|
content.update(self.layout_edit.get_content(str_mode=False))
|
|
418
|
+
content["module"] = self.s.module
|
|
387
419
|
if str_mode:
|
|
388
420
|
return json.dumps(content, indent=2)
|
|
389
421
|
else:
|
q2rad/q2utils.py
CHANGED
q2rad/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.225"
|
|
@@ -12,14 +12,14 @@ q2rad/q2market.py,sha256=RNXTNv-fFUgbzBGhHPNXlzGjsAHAtz71BRbTErJarNo,2641
|
|
|
12
12
|
q2rad/q2modules.py,sha256=RwemVJwfxth0lBN4K96tKz62VOW71C7CmmKyhIoH5mc,4632
|
|
13
13
|
q2rad/q2packages.py,sha256=y72L1RAw1OgtKGaL8lJ1KHIaers5I6kTZSiphwwrY0M,3808
|
|
14
14
|
q2rad/q2queries.py,sha256=YYJEpC_0rXAV8W_lx2604yqnkooHzheFmDCfqbW02zY,13203
|
|
15
|
-
q2rad/q2rad.py,sha256=
|
|
16
|
-
q2rad/q2raddb.py,sha256=
|
|
17
|
-
q2rad/q2reports.py,sha256=
|
|
15
|
+
q2rad/q2rad.py,sha256=a9xM_aFwx1HVm2dxkZzZYuFyNYjDN86pjH_BlkI2h10,56438
|
|
16
|
+
q2rad/q2raddb.py,sha256=3Tt2HomjR3RuL-lLvXr5MKxOnvQDI7HzjaLg-Ui8Y10,5342
|
|
17
|
+
q2rad/q2reports.py,sha256=tAOm54_P_NN8nRDsZy8N6vbw0YOTNQ_9xtvT6NMG724,86155
|
|
18
18
|
q2rad/q2stylesettings.py,sha256=rEJLyLzsffJEXnMbg9bPB3KHLjYfw-49QgrtcYOfGV0,4769
|
|
19
|
-
q2rad/q2utils.py,sha256=
|
|
20
|
-
q2rad/version.py,sha256=
|
|
21
|
-
q2rad-0.1.
|
|
22
|
-
q2rad-0.1.
|
|
23
|
-
q2rad-0.1.
|
|
24
|
-
q2rad-0.1.
|
|
25
|
-
q2rad-0.1.
|
|
19
|
+
q2rad/q2utils.py,sha256=APe6BIdjDY5B6V_iuy-2oRyh3UPAzc8kJmPZJY5AojA,19767
|
|
20
|
+
q2rad/version.py,sha256=9mU63Yb8C2TsT1KTi0Kc4trGxd9uSqaVsWJ8b-YbpRs,23
|
|
21
|
+
q2rad-0.1.225.dist-info/entry_points.txt,sha256=DmsJQE6f3wYuhdN2h6ARYxSe8_d03paeepfGpdVj5rs,42
|
|
22
|
+
q2rad-0.1.225.dist-info/LICENSE,sha256=JRR3LlR18ghhYXT4G2cWgXmnxRvcuVcKlqncWWK4MRY,10347
|
|
23
|
+
q2rad-0.1.225.dist-info/METADATA,sha256=0JHs4gVMSV_O_3YVFLGUy0QhCcBCsSlRcYYdsLwbTB4,3369
|
|
24
|
+
q2rad-0.1.225.dist-info/WHEEL,sha256=WGfLGfLX43Ei_YORXSnT54hxFygu34kMpcQdmgmEwCQ,88
|
|
25
|
+
q2rad-0.1.225.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|