pydan 2.2__tar.gz → 2.4__tar.gz

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.
Files changed (20) hide show
  1. usr/local/lib/python3.8/dist-packages/pydan/__pycache__/__init__.cpython-38.pyc +0 -0
  2. usr/local/lib/python3.8/dist-packages/pydan/__pycache__/jdata.cpython-38.pyc +0 -0
  3. usr/local/lib/python3.8/dist-packages/pydan/__pycache__/run.cpython-38.pyc +0 -0
  4. usr/local/lib/python3.8/dist-packages/pydan/__pycache__/script.cpython-38.pyc +0 -0
  5. usr/local/lib/python3.8/dist-packages/pydan/__pycache__/utils.cpython-38.pyc +0 -0
  6. {pydan-2.2/src → usr/local/lib/python3.8/dist-packages/pydan}/jdata.py +20 -14
  7. {pydan-2.2 → usr/local/lib/python3.8/dist-packages/pydan-2.4.egg-info}/PKG-INFO +1 -1
  8. {pydan-2.2/pydan.egg-info → usr/local/lib/python3.8/dist-packages/pydan-2.4.egg-info}/requires.txt +1 -1
  9. pydan-2.2/pydan.egg-info/PKG-INFO +0 -13
  10. pydan-2.2/setup.cfg +0 -4
  11. pydan-2.2/setup.py +0 -30
  12. pydan-2.2/test/test-jdata-replacevars.py +0 -62
  13. pydan-2.2/test/test-jdata.py +0 -65
  14. {pydan-2.2/src → usr/local/lib/python3.8/dist-packages/pydan}/__init__.py +0 -0
  15. {pydan-2.2/src → usr/local/lib/python3.8/dist-packages/pydan}/run.py +0 -0
  16. {pydan-2.2/src → usr/local/lib/python3.8/dist-packages/pydan}/script.py +0 -0
  17. {pydan-2.2/src → usr/local/lib/python3.8/dist-packages/pydan}/utils.py +0 -0
  18. {pydan-2.2/pydan.egg-info → usr/local/lib/python3.8/dist-packages/pydan-2.4.egg-info}/SOURCES.txt +0 -0
  19. {pydan-2.2/pydan.egg-info → usr/local/lib/python3.8/dist-packages/pydan-2.4.egg-info}/dependency_links.txt +0 -0
  20. {pydan-2.2/pydan.egg-info → usr/local/lib/python3.8/dist-packages/pydan-2.4.egg-info}/top_level.txt +0 -0
@@ -196,7 +196,7 @@ def replacevarsold(d, varlist, unknownempty=False, emptyremove=False, unknownnul
196
196
  __debugiter=__debugiter+1
197
197
  for i in d[k]:
198
198
  for di in range(0,__debugiter): print(" ", end="")
199
- print(f"* item {i}")
199
+ #print(f"* item {i}")
200
200
  o[k].append(replacevarsold(i, varlist, unknownempty=unknownempty, emptyremove=emptyremove, unknownnull=unknownnull, emptynull=emptynull, __debugiter=__debugiter))
201
201
  continue
202
202
  else:
@@ -226,7 +226,8 @@ def replacevarsold(d, varlist, unknownempty=False, emptyremove=False, unknownnul
226
226
  else: val="null"
227
227
  else:
228
228
  continue
229
- if d[k]==f"${sk}$":
229
+ #if d[k]==f"${sk}$": # python 3.6
230
+ if d[k]=="$"+sk+"$": # python 3.6
230
231
  # si el valor es exacto ("$var$"), reemplazamos por el tipo de objeto de varlist
231
232
  d[k]=val
232
233
  else:
@@ -264,7 +265,8 @@ def replacevars(data, varlist, flags=[], __debugiter=0):
264
265
  for k,v in data.items():
265
266
  if __debug:
266
267
  for di in range(0,__debugiter): print(" ", end="")
267
- print(f"\033[33m- Item '{k}' [{type(data[k]).__name__}]\033[0m")
268
+ #print(f"\033[33m- Item '{k}' [{type(data[k]).__name__}]\033[0m") # python 3.6
269
+ print("\033[33m- Item '"+k+"' ["+type(data[k]).__name__+"]\033[0m") # python 3.6
268
270
  if type(v)==str:
269
271
  r=replacevars_str(v, varlist, __debugiter=__debugiter)
270
272
  add=True
@@ -288,7 +290,8 @@ def replacevars(data, varlist, flags=[], __debugiter=0):
288
290
  for k in data:
289
291
  if __debug:
290
292
  for di in range(0,__debugiter): print(" ", end="")
291
- print(f"\033[33m- Item '{k}' [{type(k).__name__}]\033[0m")
293
+ #print(f"\033[33m- Item '{k}' [{type(k).__name__}]\033[0m")
294
+ print("\033[33m- Item '"+k+"' ["+type(k).__name__+"]\033[0m")
292
295
  oi=replacevars(k, varlist, flags=flags, __debugiter=__debugiter)
293
296
  o.append(oi)
294
297
  return o
@@ -302,7 +305,8 @@ def replacevars(data, varlist, flags=[], __debugiter=0):
302
305
  for k in data:
303
306
  if __debug:
304
307
  for di in range(0,__debugiter): print(" ", end="")
305
- print(f"\033[33m- Item '{k}' [{type(k).__name__}]\033[0m")
308
+ #print(f"\033[33m- Item '{k}' [{type(k).__name__}]\033[0m")
309
+ print("\033[33m- Item '"+k+"' ["+type(k).__name__+"]\033[0m")
306
310
  oi=replacevars(k, varlist, flags=flags, __debugiter=__debugiter)
307
311
  o.add(oi)
308
312
  return o
@@ -310,7 +314,8 @@ def replacevars(data, varlist, flags=[], __debugiter=0):
310
314
  # unknown!
311
315
  if __debug:
312
316
  for di in range(0,__debugiter): print(" ", end="")
313
- print(f"\033[1;31m¿{type(data).__name__}?\033[0m")
317
+ #print(f"\033[1;31m¿{type(data).__name__}?\033[0m")
318
+ print("\033[1;31m¿"+type(data).__name__+"?\033[0m")
314
319
  return data
315
320
 
316
321
  # for k in d:
@@ -339,7 +344,8 @@ def replacevars_str(data, varlist, __debugiter=0):
339
344
  #__debug=True
340
345
  if __debug:
341
346
  for di in range(0,__debugiter+1): print(" ", end="")
342
- print(f"\033[34mreplacevars2_str: '{data}'\033[0m", end="")
347
+ #print(f"\033[34mreplacevars2_str: '{data}'\033[0m", end="")
348
+ print("\033[34mreplacevars2_str: '"+data+"'\033[0m", end="")
343
349
  out=data
344
350
  p=re.compile("\\$([a-zA-Z0-9_]*)\\$")
345
351
  vars=p.findall(data)
@@ -354,7 +360,7 @@ def replacevars_str(data, varlist, __debugiter=0):
354
360
  # Hay variables
355
361
  for sk in vars:
356
362
  if __debug:
357
- print(f" (repl {sk})", end="")
363
+ print(" (repl "+sk+")", end="")
358
364
  if sk not in varlist: continue
359
365
  val=varlist.get(sk)
360
366
  #if val is None:
@@ -367,7 +373,7 @@ def replacevars_str(data, varlist, __debugiter=0):
367
373
  # continue
368
374
 
369
375
  # TODO: no borrar variables que no existen!
370
- if data==f"${sk}$":
376
+ if data=="$"+sk+"$":
371
377
  # si el valor es exacto ("$var$"), reemplazamos por el tipo de objeto de varlist
372
378
  out=val
373
379
  else:
@@ -377,7 +383,7 @@ def replacevars_str(data, varlist, __debugiter=0):
377
383
  #if(out=="$null$" and emptynull): out=None
378
384
  #if(out=="$null$"): out=None
379
385
  #if(out=="" and emptyremove): out=None # ???? TODO
380
- if __debug: print(f"\033[34m -> '{out}' [{type(out).__name__}]\033[0m")
386
+ if __debug: print("\033[34m -> '"+out+"' ["+type(out).__name__+"]\033[0m")
381
387
  return out
382
388
  #}}}
383
389
 
@@ -545,7 +551,7 @@ def json_parser_hook(js):
545
551
  dt=dt.replace(tzinfo=timezone.utc)
546
552
  out[key]=dt
547
553
  continue
548
- except: pass
554
+ except Exception: pass
549
555
  # Hora con timezone con milisegundos
550
556
  try:
551
557
  dt=re.sub("Z$", "UTC",value)
@@ -553,17 +559,17 @@ def json_parser_hook(js):
553
559
  dt=dt.replace(tzinfo=timezone.utc)
554
560
  out[key]=dt
555
561
  continue
556
- except: pass
562
+ except Exception: pass
557
563
  # Hora sin timezone sin milisegundos
558
564
  try:
559
565
  out[key]=datetime.strptime(value, "%Y-%m-%dT%H:%M:%S")
560
566
  continue
561
- except: pass
567
+ except Exception: pass
562
568
  # Hora sin timezone con milisegundos
563
569
  try:
564
570
  out[key]=datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f")
565
571
  continue
566
- except: pass
572
+ except Exception: pass
567
573
  return out
568
574
 
569
575
  # dict -> json
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: pydan
3
- Version: 2.2
3
+ Version: 2.4
4
4
  Summary: Python3 Data Utils
5
5
  Home-page: UNKNOWN
6
6
  Author: Jose Biosca Martín
@@ -1,5 +1,5 @@
1
1
  colored_traceback
2
2
  dicttoxml
3
+ ruamel.yaml
3
4
  setproctitle
4
- setuptools
5
5
  xmltodict
@@ -1,13 +0,0 @@
1
- Metadata-Version: 1.2
2
- Name: pydan
3
- Version: 2.2
4
- Summary: Python3 Data Utils
5
- Home-page: UNKNOWN
6
- Author: Jose Biosca Martín
7
- Author-email: jbiosca@zone-sys.net
8
- License: UNKNOWN
9
- Description: UNKNOWN
10
- Platform: UNKNOWN
11
- Classifier: Development Status :: 5 - Production/Stable
12
- Classifier: License :: OSI Approved :: MIT License
13
- Requires-Python: >=3.6
pydan-2.2/setup.cfg DELETED
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
pydan-2.2/setup.py DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- from setuptools import setup
4
-
5
- setup(
6
- name="pydan",
7
- version='2.2',
8
- description='Python3 Data Utils',
9
- author='Jose Biosca Martín',
10
- author_email='jbiosca@zone-sys.net',
11
- #url='https://zone-sys.net/',
12
- python_requires='>=3.6',
13
- #packages=["lib"],
14
- packages=["pydan"],
15
- package_dir={"pydan": "src"},
16
- #py_modules=['ivscript', 'jdata', 'josen', 'run']
17
- install_requires=[
18
- 'setuptools',
19
- 'setproctitle',
20
- 'colored_traceback',
21
- 'dicttoxml',
22
- 'xmltodict',
23
- # 'ruamel.yaml',
24
- ],
25
- classifiers=[
26
- 'Development Status :: 5 - Production/Stable',
27
- "License :: OSI Approved :: MIT License",
28
- #'Topic :: Software development',
29
- ],
30
- )
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- #from pydan import jdata
4
-
5
- import sys
6
- sys.path.append('..')
7
- from src import jdata
8
-
9
- ret=0
10
-
11
- # Comprobamos reemplazo de multiples variables en un string
12
- data={"numbers":"$n1$,$n2$,$n3$,$nx$"}
13
- repl=jdata.replacevars(data, {"n1":"one", "n2":"two", "n3":"three", "n4":"four"})
14
- if repl["numbers"]!="one,two,three,$nx$":
15
- print("ERROR reemplazando multiples variables en un mismo string")
16
- print(repl["numbers"])
17
- ret=1
18
- else:
19
- print("OK: Reemplazo de multiples variables en un mismo string")
20
-
21
- # Comprobamos reemplazo de distintos tipos de datos
22
- data={
23
- "rep_str":"$str$",
24
- "rep_num":"$num$",
25
- "rep_list":"$list$",
26
- "rep_dict":"$dict$",
27
- "rep_null":"$null$",
28
- "rep_empty":"$empty$",
29
- "rep_unk":"$unk$",
30
- "ori_empty":"",
31
- "ori_null":None,
32
- "ori_list": [ "a", "b" ],
33
- "ori_dict": { "ori_a":0, "ori_b":1 },
34
- }
35
- repl=jdata.replacevars(data, {"str":"str", "num":1, "list":["a","b"], "dict":{"a":0,"b":1},"null":None,"empty":""})
36
- repljson=jdata.tojson(repl)
37
- if repljson!='{"rep_str":"str","rep_num":1,"rep_list":["a","b"],"rep_dict":{"a":0,"b":1},"rep_null":null,"rep_empty":"","rep_unk":"$unk$","ori_empty":"","ori_null":null,"ori_list":["a","b"],"ori_dict":{"ori_a":0,"ori_b":1}}':
38
- print("Error reemplazando distintos tipos de datos")
39
- jdata.colprint(data, "Original")
40
- jdata.colprint(repl, "Replaced")
41
- exit(1)
42
- print("OK: Reemplazo de diferentes tipos de datos")
43
-
44
- # Comprobamos borrado de variables con reemplazo a null
45
- data={
46
- "rep_str":"$str$",
47
- "rep_num":"$num$",
48
- "rep_list":"$list$",
49
- "rep_dict":"$dict$",
50
- "x_rep_null":"$null$",
51
- "x_rep_empty":"$empty$",
52
- "x_rep_unk":"$unk$",
53
- "ori_empty":"",
54
- "ori_null":None,
55
- "ori_list": [ "a", "b" ],
56
- "ori_dict": { "ori_a":0, "ori_b":1 },
57
- }
58
- repl=jdata.replacevars(data, {"str":"str", "num":1, "list":["a","b"], "dict":{"a":0,"b":1},"null":None,"empty":""}, flags=["nullremove","emptyremove", "unkremove"])
59
- #jdata.colprint(data, "Original")
60
- jdata.colprint(repl, "Replaced")
61
-
62
- exit(ret)
@@ -1,65 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- from datetime import date,datetime,timezone,timedelta
4
- #import time
5
- import collections
6
- import re
7
-
8
- import sys
9
- sys.path.insert(1, '../src')
10
- import jdata
11
-
12
- # Some test dates
13
- utc=datetime(2020,8,20,10,20,30)
14
- utcoffset = round((datetime.now()-datetime.utcnow()).total_seconds())
15
- loc=utc+timedelta(seconds=utcoffset)
16
- unix=utc.timestamp()
17
- #utc=datetime.now(timezone.utc)
18
- #loc=datetime.now().replace(microsecond=0)
19
- #unix=utc.timestamp()
20
-
21
- # Test object creation
22
- data={}
23
- data["none"]=None
24
- data["str"]="String"
25
- data["bool"]=True
26
- data["num"]=42
27
- data["float"]=4.2
28
- data["date"]={"local":loc,"utc":utc,"unix":unix}
29
- data["list"]=["a1","a2","a3"]
30
- data["dict"]={"x":20,"y":22}
31
- data["complex"]=[{"var":"uno","val":1},{"var":"dos","val":2}]
32
-
33
- # Pretty print
34
- jdata.colprint(data, "data")
35
-
36
- # Convertimos a json
37
- jsonverify='{"none":null,"str":"String","bool":true,"num":42,"float":4.2,"date":{"local":"2020-08-20T12:20:30","utc":"2020-08-20T10:20:30","unix":1597911630.0},"list":["a1","a2","a3"],"dict":{"x":20,"y":22},"complex":[{"var":"uno","val":1},{"var":"dos","val":2}]}'
38
- json=jdata.tojson(data)
39
- if json!=jsonverify:
40
- print("Error converting data to json!")
41
- print("converted: "+json)
42
- print("should be: "+jsonverify)
43
- print
44
- exit(1)
45
- jdata.colprint(json, "json")
46
-
47
- # Convertimos otra vez a dict
48
- data2=jdata.fromjson(json)
49
- if data!=data2:
50
- print("Error converting json to data!")
51
- exit(1)
52
-
53
- # Guardamos y leemos fichero json
54
- jdata.writejson(data,"test.json", tabs=1)
55
- data2=jdata.readjson("test.json")
56
- if data!=data2:
57
- print("Error writing or reading json!")
58
- exit(1)
59
-
60
- # Guardamos y leemos fichero yaml
61
- jdata.writeyaml(data,"test.yaml")
62
- data2=jdata.readyaml("test.yaml")
63
- if data!=data2:
64
- print("Error writing or reading yaml!")
65
- exit(1)