radboy 0.0.720__py3-none-any.whl → 0.0.722__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 radboy might be problematic. Click here for more details.

radboy/DB/rad_types.py CHANGED
@@ -57,6 +57,8 @@ class dec1(TDecimal):
57
57
  value=f"{value:.3f}"
58
58
  return super().__new__(self,value)
59
59
 
60
+ def chunker(l,size):
61
+ return [l[i:i+size] for i in range(0,len(l),int(size))]
60
62
 
61
63
  class stre(str):
62
64
  '''String Extended to include operators for some useful functionality.'''
@@ -57,6 +57,104 @@ class HealthLogUi:
57
57
  session.refresh(hl)
58
58
  print(std_colorize(f"Updated {hl}",0,1))
59
59
 
60
+ def search(self):
61
+ with localcontext() as CTX:
62
+ with Session(ENGINE) as session:
63
+ fields={
64
+ i.name:{
65
+ 'default':None,
66
+ 'type':str(i.type).lower()
67
+ } for i in HealthLog.__table__.columns
68
+ }
69
+ fd=FormBuilder(data=fields,passThruText="Your Search Terms `showkeys` and `gotoi` are useful.")
70
+ if fd is None:
71
+ return
72
+ FD={}
73
+ for i in fd:
74
+ if fd[i] is not None:
75
+ FD[i]=fd[i]
76
+ fd=FD
77
+ filte=[]
78
+ for i in fd:
79
+ if isinstance(fd[i],str):
80
+ filte.append(getattr(HealthLog,i).icontains(fd[i]))
81
+ else:
82
+ filte.append(getattr(HealthLog,i)==fd[i])
83
+ query=session.query(HealthLog).filter(and_(*filte))
84
+ ordered=orderQuery(query,HealthLog.DTOE)
85
+ lo={
86
+ 'limit':{
87
+ 'default':10,
88
+ 'type':'integer',
89
+ },
90
+ 'offset':{
91
+ 'type':'integer',
92
+ 'default':0,
93
+ }
94
+ }
95
+ lod=FormBuilder(data=lo,passThruText="Limit your results?")
96
+ if lod is None:
97
+ return
98
+
99
+ loq=limitOffset(query,lod['limit'],lod['offset'])
100
+ results=loq.all()
101
+ ct=len(results)
102
+ if len(results) < 1:
103
+ print("No Results!")
104
+ return
105
+ for num,i in enumerate(results):
106
+ view=[]
107
+ for x in i.__table__.columns:
108
+ if getattr(i,str(x.name)) not in [None]:
109
+ view.append(f'{Fore.green_3b}{Style.bold}{str(x.name)}{Fore.deep_sky_blue_1}={Fore.sea_green_2}{str(getattr(i,str(x.name)))}{Style.reset}')
110
+ msg=f"{'|'.join(view)}"
111
+ print(std_colorize(msg,num,ct))
112
+
113
+ def searchText(self):
114
+ filte=[]
115
+ with localcontext() as CTX:
116
+ with Session(ENGINE) as session:
117
+ query=session.query(HealthLog)
118
+ fields=[i for i in HealthLog.__table__.columns if str(i.type).lower() in ['string','varchar','char','text']]
119
+
120
+ term=Control(func=FormBuilderMkText,ptext="What are you searching?",helpText="just text is searched.",data="string")
121
+ if term in [None,'NaN','d']:
122
+ return
123
+ else:
124
+ filte=[]
125
+ for i in fields:
126
+ filte.append((getattr(HealthLog,i.name).icontains(term)))
127
+
128
+ query=session.query(HealthLog).filter(or_(*filte))
129
+ ordered=orderQuery(query,HealthLog.DTOE)
130
+ lo={
131
+ 'limit':{
132
+ 'default':10,
133
+ 'type':'integer',
134
+ },
135
+ 'offset':{
136
+ 'type':'integer',
137
+ 'default':0,
138
+ }
139
+ }
140
+ lod=FormBuilder(data=lo,passThruText="Limit your results?")
141
+ if lod is None:
142
+ return
143
+
144
+ loq=limitOffset(query,lod['limit'],lod['offset'])
145
+ results=loq.all()
146
+ ct=len(results)
147
+ if len(results) < 1:
148
+ print("No Results!")
149
+ return
150
+ for num,i in enumerate(results):
151
+ view=[]
152
+ for x in i.__table__.columns:
153
+ if getattr(i,str(x.name)) not in [None]:
154
+ view.append(f'{Fore.green_3b}{Style.bold}{str(x.name)}{Fore.deep_sky_blue_1}={Fore.sea_green_2}{str(getattr(i,str(x.name)))}{Style.reset}')
155
+ msg=f"{'|'.join(view)}"
156
+ print(std_colorize(msg,num,ct))
157
+
60
158
  def new_health_log(self):
61
159
  with Session(ENGINE) as session:
62
160
  hl=HealthLog()
@@ -919,6 +1017,16 @@ class HealthLogUi:
919
1017
  'exec':lambda self=self:self.export_log_field(fields=['BloodSugar','BloodSugarUnitName','LongActingInsulinName','LongActingInsulinTaken','LongActingInsulinUnitName','ShortActingInsulinName','ShortActingInsulinTaken','ShortActingInsulinUnitName','HeartRate','HeartRateUnitName','DrugConsumed','DrugQtyConsumed','DrugQtyConsumedUnitName','CarboHydrateIntake','CarboHydrateIntakeUnitName','Comments',],not_none=['Comments',])
920
1018
  },
921
1019
  str(uuid1()):{
1020
+ 'cmds':generate_cmds(startcmd=['sch','search'],endCmd=['specific','spec','spcfc','finer']),
1021
+ 'desc':'search with formbuilder with just equals/icontains',
1022
+ 'exec':lambda self=self:self.search()
1023
+ },
1024
+ str(uuid1()):{
1025
+ 'cmds':generate_cmds(startcmd=['sch','search'],endCmd=['text','txt','str','t']),
1026
+ 'desc':'search with text only fields by term',
1027
+ 'exec':lambda self=self:self.searchText()
1028
+ },
1029
+ str(uuid1()):{
922
1030
  'cmds':['ordered and recieved','oar','ordered and rxd','ordered & rxd','ordered & recieved','o&r'],
923
1031
  'desc':'ordered and recieved journal',
924
1032
  'exec':lambda self=self:OrderAndRxdUi()
radboy/__init__.py CHANGED
@@ -1 +1 @@
1
- VERSION='0.0.720'
1
+ VERSION='0.0.722'
Binary file
@@ -150,6 +150,11 @@ Here:
150
150
  'desc':f'obtain candidates for sudoku cell',
151
151
  'exec':lambda: sudokuCandidates(),
152
152
  },
153
+ f'{uuid1()}':{
154
+ 'cmds':[i for i in generate_cmds(startcmd=['sudoku',],endCmd=['candidates auto','cda'])],
155
+ 'desc':f'obtain candidates for sudoku cell for the whole grid',
156
+ 'exec':lambda: candidates(),
157
+ },
153
158
  f'{uuid1()}':{
154
159
  'cmds':['herons formula','hrns fmla'],
155
160
  'desc':f'''