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 +2 -0
- radboy/HealthLog/HealthLog.py +108 -0
- radboy/HealthLog/__pycache__/HealthLog.cpython-313.pyc +0 -0
- radboy/__init__.py +1 -1
- radboy/__pycache__/__init__.cpython-313.pyc +0 -0
- radboy/preloader/preloader.py +5 -0
- radboy/preloader/preloader_func.py +1265 -1005
- {radboy-0.0.720.dist-info → radboy-0.0.722.dist-info}/METADATA +1 -1
- {radboy-0.0.720.dist-info → radboy-0.0.722.dist-info}/RECORD +11 -11
- {radboy-0.0.720.dist-info → radboy-0.0.722.dist-info}/WHEEL +0 -0
- {radboy-0.0.720.dist-info → radboy-0.0.722.dist-info}/top_level.txt +0 -0
|
@@ -30,450 +30,450 @@ unit_registry=pint.UnitRegistry()
|
|
|
30
30
|
import math
|
|
31
31
|
|
|
32
32
|
def volume():
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
33
|
+
with localcontext() as ctx:
|
|
34
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
35
|
+
#print(f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow}")
|
|
36
|
+
height=Prompt.__init2__(None,func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} height?: ",helpText="height=1",data="dec.dec")
|
|
37
|
+
if height is None:
|
|
38
|
+
return
|
|
39
|
+
elif height in ['d',]:
|
|
40
|
+
height=Decimal('1')
|
|
41
|
+
|
|
42
|
+
width=Prompt.__init2__(None,func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} width?: ",helpText="width=1 ",data="dec.dec")
|
|
43
|
+
if width is None:
|
|
44
|
+
return
|
|
45
|
+
elif width in ['d',]:
|
|
46
|
+
width=Decimal('1')
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
length=Prompt.__init2__(None,func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} length?: ",helpText="length=1",data="dec.dec")
|
|
51
|
+
if length is None:
|
|
52
|
+
return
|
|
53
|
+
elif length in ['d',]:
|
|
54
|
+
length=Decimal('1')
|
|
55
|
+
|
|
56
|
+
return length*width*height
|
|
57
57
|
|
|
58
58
|
def volume_pint():
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
59
|
+
with localcontext() as ctx:
|
|
60
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
61
|
+
height=Prompt.__init2__(None,func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} height?: ",helpText="height=1",data="string")
|
|
62
|
+
if height is None:
|
|
63
|
+
return
|
|
64
|
+
elif height in ['d',]:
|
|
65
|
+
height='1'
|
|
66
|
+
|
|
67
|
+
width=Prompt.__init2__(None,func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} width?: ",helpText="width=1 ",data="string")
|
|
68
|
+
if width is None:
|
|
69
|
+
return
|
|
70
|
+
elif width in ['d',]:
|
|
71
|
+
width='1'
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
length=Prompt.__init2__(None,func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} length?: ",helpText="length=1",data="string")
|
|
76
|
+
if length is None:
|
|
77
|
+
return
|
|
78
|
+
elif length in ['d',]:
|
|
79
|
+
length='1'
|
|
80
|
+
|
|
81
|
+
return unit_registry.Quantity(length)*unit_registry.Quantity(width)*unit_registry.Quantity(height)
|
|
82
82
|
|
|
83
83
|
def inductance_pint():
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
84
|
+
with localcontext() as ctx:
|
|
85
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
86
|
+
relative_permeability=Prompt.__init2__(None,func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} relative_permeability?: ",helpText="relative_permeability(air)=1",data="string")
|
|
87
|
+
if relative_permeability is None:
|
|
88
|
+
return
|
|
89
|
+
elif relative_permeability in ['d',]:
|
|
90
|
+
relative_permeability='1'
|
|
91
|
+
relative_permeability=float(relative_permeability)
|
|
92
|
+
|
|
93
|
+
turns_of_wire_on_coil=Prompt.__init2__(None,func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} turns_of_wire_on_coil?: ",helpText="turns_of_wire_on_coil=1",data="string")
|
|
94
|
+
if turns_of_wire_on_coil is None:
|
|
95
|
+
return
|
|
96
|
+
elif turns_of_wire_on_coil in ['d',]:
|
|
97
|
+
turns_of_wire_on_coil='1'
|
|
98
|
+
turns_of_wire_on_coil=int(turns_of_wire_on_coil)
|
|
99
|
+
|
|
100
|
+
#convert to meters
|
|
101
|
+
core_cross_sectional_area_meters=Prompt.__init2__(None,func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} core_cross_sectional_area_meters?: ",helpText="core_cross_sectional_area_meters=1",data="string")
|
|
102
|
+
if core_cross_sectional_area_meters is None:
|
|
103
|
+
return
|
|
104
|
+
elif core_cross_sectional_area_meters in ['d',]:
|
|
105
|
+
core_cross_sectional_area_meters='1m'
|
|
106
|
+
try:
|
|
107
|
+
core_cross_sectional_area_meters=unit_registry.Quantity(core_cross_sectional_area_meters).to("meters")
|
|
108
|
+
except Exception as e:
|
|
109
|
+
print(e,"defaulting to meters")
|
|
110
|
+
core_cross_sectional_area_meters=unit_registry.Quantity(f"{core_cross_sectional_area_meters} meters")
|
|
111
|
+
|
|
112
|
+
length_of_coil_meters=Prompt.__init2__(None,func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} length_of_coil_meters?: ",helpText="length_of_coil_meters=1",data="string")
|
|
113
|
+
if length_of_coil_meters is None:
|
|
114
|
+
return
|
|
115
|
+
elif length_of_coil_meters in ['d',]:
|
|
116
|
+
length_of_coil_meters='1m'
|
|
117
|
+
try:
|
|
118
|
+
length_of_coil_meters=unit_registry.Quantity(length_of_coil_meters).to('meters')
|
|
119
|
+
except Exception as e:
|
|
120
|
+
print(e,"defaulting to meters")
|
|
121
|
+
length_of_coil_meters=unit_registry.Quantity(f"{length_of_coil_meters} meters")
|
|
122
|
+
|
|
123
|
+
numerator=((turns_of_wire_on_coil**2)*core_cross_sectional_area_meters)
|
|
124
|
+
f=relative_permeability*(numerator/length_of_coil_meters)*1.26e-6
|
|
125
|
+
f=unit_registry.Quantity(f"{f.magnitude} H")
|
|
126
|
+
return f
|
|
127
127
|
|
|
128
128
|
def resonant_inductance():
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
129
|
+
with localcontext() as ctx:
|
|
130
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
131
|
+
hertz=1e9
|
|
132
|
+
while True:
|
|
133
|
+
try:
|
|
134
|
+
hertz=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} frequency in hertz[530 kilohertz]? ",helpText="frequency in hertz",data="string")
|
|
135
|
+
if hertz is None:
|
|
136
|
+
return
|
|
137
|
+
elif hertz in ['d','']:
|
|
138
|
+
hertz="530 megahertz"
|
|
139
|
+
print(hertz)
|
|
140
|
+
x=unit_registry.Quantity(hertz)
|
|
141
|
+
if x:
|
|
142
|
+
hertz=x.to("hertz")
|
|
143
|
+
else:
|
|
144
|
+
hertz=1e6
|
|
145
|
+
break
|
|
146
|
+
except Exception as e:
|
|
147
|
+
print(e)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
while True:
|
|
151
|
+
try:
|
|
152
|
+
capacitance=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} capacitance[365 picofarads]? ",helpText="capacitance in farads",data="string")
|
|
153
|
+
if capacitance is None:
|
|
154
|
+
return
|
|
155
|
+
elif capacitance in ['d',]:
|
|
156
|
+
capacitance="365 picofarads"
|
|
157
|
+
x=unit_registry.Quantity(capacitance)
|
|
158
|
+
if x:
|
|
159
|
+
x=x.to("farads")
|
|
160
|
+
farads=x.magnitude
|
|
161
|
+
break
|
|
162
|
+
except Exception as e:
|
|
163
|
+
print(e)
|
|
164
|
+
|
|
165
|
+
inductance=1/(decc(4*math.pi**2)*decc(hertz.magnitude**2,cf=13)*decc(farads,cf=13))
|
|
166
|
+
|
|
167
|
+
L=unit_registry.Quantity(inductance,"henry")
|
|
168
|
+
return L
|
|
169
169
|
|
|
170
170
|
def air_coil_cap():
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
171
|
+
with localcontext() as ctx:
|
|
172
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
173
|
+
'''C = 1 / (4π²f²L)'''
|
|
174
|
+
while True:
|
|
175
|
+
try:
|
|
176
|
+
frequency=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} frequency? ",helpText="frequency",data="string")
|
|
177
|
+
if frequency is None:
|
|
178
|
+
return
|
|
179
|
+
elif frequency in ['d',]:
|
|
180
|
+
frequency="1410 kilohertz"
|
|
181
|
+
x=unit_registry.Quantity(frequency)
|
|
182
|
+
if x:
|
|
183
|
+
x=x.to("hertz")
|
|
184
|
+
frequency=decc(x.magnitude**2)
|
|
185
|
+
break
|
|
186
|
+
except Exception as e:
|
|
187
|
+
print(e)
|
|
188
|
+
|
|
189
|
+
while True:
|
|
190
|
+
try:
|
|
191
|
+
inductance=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} inductance(356 microhenry): ",helpText="coil inductance",data="string")
|
|
192
|
+
if inductance is None:
|
|
193
|
+
return
|
|
194
|
+
elif inductance in ['d',]:
|
|
195
|
+
inductance="356 microhenry"
|
|
196
|
+
x=unit_registry.Quantity(inductance)
|
|
197
|
+
if x:
|
|
198
|
+
x=x.to("henry")
|
|
199
|
+
inductance=decc(x.magnitude,cf=20)
|
|
200
|
+
break
|
|
201
|
+
except Exception as e:
|
|
202
|
+
print(e)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
farads=1/(inductance*frequency*decc(4*math.pi**2))
|
|
207
|
+
return unit_registry.Quantity(farads,"farad")
|
|
208
208
|
|
|
209
209
|
def air_coil():
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
210
|
+
with localcontext() as ctx:
|
|
211
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
212
|
+
'''
|
|
213
|
+
The formula for inductance - using toilet rolls, PVC pipe etc. can be well approximated by:
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
0.394 * r2 * N2
|
|
217
|
+
Inductance L = ________________
|
|
218
|
+
( 9 *r ) + ( 10 * Len)
|
|
219
|
+
Here:
|
|
220
|
+
N = number of turns
|
|
221
|
+
r = radius of the coil i.e. form diameter (in cm.) divided by 2
|
|
222
|
+
Len = length of the coil - again in cm.
|
|
223
|
+
L = inductance in uH.
|
|
224
|
+
* = multiply by
|
|
225
|
+
'''
|
|
226
|
+
while True:
|
|
227
|
+
try:
|
|
228
|
+
diameter=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} diameter in cm [2 cm]? ",helpText="diamater of coil",data="string")
|
|
229
|
+
if diameter is None:
|
|
230
|
+
return
|
|
231
|
+
elif diameter in ['d',]:
|
|
232
|
+
diameter="2 cm"
|
|
233
|
+
x=unit_registry.Quantity(diameter)
|
|
234
|
+
if x:
|
|
235
|
+
x=x.to("centimeter")
|
|
236
|
+
diameter=x.magnitude
|
|
237
|
+
break
|
|
238
|
+
except Exception as e:
|
|
239
|
+
print(e)
|
|
240
|
+
radius=decc(diameter/2)
|
|
241
|
+
while True:
|
|
242
|
+
try:
|
|
243
|
+
length=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} length in cm [2 cm]? ",helpText="length of coil",data="string")
|
|
244
|
+
if length is None:
|
|
245
|
+
return
|
|
246
|
+
elif length in ['d',]:
|
|
247
|
+
length="2 cm"
|
|
248
|
+
x=unit_registry.Quantity(length)
|
|
249
|
+
if x:
|
|
250
|
+
x=x.to("centimeter")
|
|
251
|
+
length=x.magnitude
|
|
252
|
+
break
|
|
253
|
+
except Exception as e:
|
|
254
|
+
print(e)
|
|
255
|
+
while True:
|
|
256
|
+
try:
|
|
257
|
+
turns=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} number of turns? ",helpText="turns of wire",data="integer")
|
|
258
|
+
if turns is None:
|
|
259
|
+
return
|
|
260
|
+
elif turns in ['d',]:
|
|
261
|
+
turns=1
|
|
262
|
+
LTop=decc(0.394)*decc(radius**2)*decc(turns**2)
|
|
263
|
+
LBottom=(decc(9)*radius)+decc(length*10)
|
|
264
|
+
L=LTop/LBottom
|
|
265
|
+
print(pint.Quantity(L,'microhenry'))
|
|
266
|
+
different_turns=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} use a different number of turns?",helpText="yes or no",data="boolean")
|
|
267
|
+
if different_turns is None:
|
|
268
|
+
return
|
|
269
|
+
elif different_turns in ['d',True]:
|
|
270
|
+
continue
|
|
271
|
+
break
|
|
272
|
+
except Exception as e:
|
|
273
|
+
print(e)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
return pint.Quantity(L,'microhenry')
|
|
277
277
|
|
|
278
278
|
def circumference_diameter():
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
279
|
+
with localcontext() as ctx:
|
|
280
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
281
|
+
radius=0
|
|
282
|
+
while True:
|
|
283
|
+
try:
|
|
284
|
+
diameter=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} diameter unit[4 cm]? ",helpText="diamater with unit",data="string")
|
|
285
|
+
if diameter is None:
|
|
286
|
+
return
|
|
287
|
+
elif diameter in ['d',]:
|
|
288
|
+
diameter="4 cm"
|
|
289
|
+
x=unit_registry.Quantity(diameter)
|
|
290
|
+
radius=pint.Quantity(decc(x.magnitude/2),x.units)
|
|
291
|
+
break
|
|
292
|
+
except Exception as e:
|
|
293
|
+
print(e)
|
|
294
|
+
if isinstance(radius,pint.registry.Quantity):
|
|
295
|
+
result=decc(2*math.pi)*decc(radius.magnitude)
|
|
296
|
+
|
|
297
|
+
return pint.Quantity(result,radius.units)
|
|
298
|
+
else:
|
|
299
|
+
return
|
|
300
300
|
|
|
301
301
|
def circumference_radius():
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
302
|
+
with localcontext() as ctx:
|
|
303
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
304
|
+
radius=0
|
|
305
|
+
while True:
|
|
306
|
+
try:
|
|
307
|
+
diameter=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} radius unit[2 cm]? ",helpText="radius with unit",data="string")
|
|
308
|
+
if diameter is None:
|
|
309
|
+
return
|
|
310
|
+
elif diameter in ['d',]:
|
|
311
|
+
diameter="2 cm"
|
|
312
|
+
x=unit_registry.Quantity(diameter)
|
|
313
|
+
radius=pint.Quantity(decc(x.magnitude),x.units)
|
|
314
|
+
break
|
|
315
|
+
except Exception as e:
|
|
316
|
+
print(e)
|
|
317
|
+
if isinstance(radius,pint.registry.Quantity):
|
|
318
|
+
result=decc(2*math.pi)*decc(radius.magnitude)
|
|
319
|
+
|
|
320
|
+
return pint.Quantity(result,radius.units)
|
|
321
|
+
else:
|
|
322
|
+
return
|
|
323
323
|
|
|
324
324
|
def area_of_circle_radius():
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
325
|
+
with localcontext() as ctx:
|
|
326
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
327
|
+
'''
|
|
328
|
+
A = πr²
|
|
329
|
+
'''
|
|
330
|
+
radius=0
|
|
331
|
+
while True:
|
|
332
|
+
try:
|
|
333
|
+
diameter=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} radius unit[2 cm]? ",helpText="radius with unit",data="string")
|
|
334
|
+
if diameter is None:
|
|
335
|
+
return
|
|
336
|
+
elif diameter in ['d',]:
|
|
337
|
+
diameter="2 cm"
|
|
338
|
+
x=unit_registry.Quantity(diameter)
|
|
339
|
+
radius=pint.Quantity(decc(x.magnitude),x.units)
|
|
340
|
+
break
|
|
341
|
+
except Exception as e:
|
|
342
|
+
print(e)
|
|
343
|
+
if isinstance(radius,pint.registry.Quantity):
|
|
344
|
+
result=decc(math.pi)*decc(radius.magnitude**2)
|
|
345
|
+
|
|
346
|
+
return pint.Quantity(result,radius.units)
|
|
347
|
+
else:
|
|
348
|
+
return
|
|
349
349
|
|
|
350
350
|
def lc_frequency():
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
351
|
+
with localcontext() as ctx:
|
|
352
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
353
|
+
inductance=None
|
|
354
|
+
capacitance=None
|
|
355
|
+
while True:
|
|
356
|
+
try:
|
|
357
|
+
inductance=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} inductance(356 microhenry): ",helpText="coil inductance",data="string")
|
|
358
|
+
if inductance is None:
|
|
359
|
+
return
|
|
360
|
+
elif inductance in ['d',]:
|
|
361
|
+
inductance="356 microhenry"
|
|
362
|
+
x=unit_registry.Quantity(inductance)
|
|
363
|
+
if x:
|
|
364
|
+
x=x.to("henry")
|
|
365
|
+
inductance=decc(x.magnitude,cf=20)
|
|
366
|
+
break
|
|
367
|
+
except Exception as e:
|
|
368
|
+
print(e)
|
|
369
|
+
while True:
|
|
370
|
+
try:
|
|
371
|
+
capacitance=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} capacitance[365 picofarads]? ",helpText="capacitance in farads",data="string")
|
|
372
|
+
if capacitance is None:
|
|
373
|
+
return
|
|
374
|
+
elif capacitance in ['d',]:
|
|
375
|
+
capacitance="365 picofarads"
|
|
376
|
+
x=unit_registry.Quantity(capacitance)
|
|
377
|
+
if x:
|
|
378
|
+
x=x.to("farads")
|
|
379
|
+
farads=decc(x.magnitude,cf=20)
|
|
380
|
+
break
|
|
381
|
+
except Exception as e:
|
|
382
|
+
print(e)
|
|
383
|
+
frequency=1/(decc(2*math.pi)*decc(math.sqrt(farads*inductance),cf=20))
|
|
384
|
+
return unit_registry.Quantity(frequency,"hertz")
|
|
385
385
|
|
|
386
386
|
def area_of_circle_diameter():
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
387
|
+
with localcontext() as ctx:
|
|
388
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
389
|
+
'''
|
|
390
|
+
A = πr²
|
|
391
|
+
'''
|
|
392
|
+
radius=0
|
|
393
|
+
while True:
|
|
394
|
+
try:
|
|
395
|
+
diameter=Control(func=FormBuilderMkText,ptext=f"{Fore.light_green}Precision {ctx.prec}{Fore.light_yellow} diameter unit[4 cm]? ",helpText="diamater value with unit",data="string")
|
|
396
|
+
if diameter is None:
|
|
397
|
+
return
|
|
398
|
+
elif diameter in ['d',]:
|
|
399
|
+
diameter="4 cm"
|
|
400
|
+
x=unit_registry.Quantity(diameter)
|
|
401
|
+
radius=pint.Quantity(decc(x.magnitude/2),x.units)
|
|
402
|
+
break
|
|
403
|
+
except Exception as e:
|
|
404
|
+
print(e)
|
|
405
|
+
if isinstance(radius,pint.registry.Quantity):
|
|
406
|
+
result=decc(math.pi)*decc(radius.magnitude**2)
|
|
407
|
+
|
|
408
|
+
return pint.Quantity(result,radius.units)
|
|
409
|
+
else:
|
|
410
|
+
return
|
|
411
411
|
|
|
412
412
|
|
|
413
413
|
def area_triangle():
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
414
|
+
with localcontext() as ctx:
|
|
415
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
416
|
+
height=None
|
|
417
|
+
base=None
|
|
418
|
+
'''
|
|
419
|
+
A=hbb/2
|
|
420
|
+
'''
|
|
421
|
+
while True:
|
|
422
|
+
try:
|
|
423
|
+
base=Control(func=FormBuilderMkText,ptext="base",helpText="base width",data="string")
|
|
424
|
+
if base is None:
|
|
425
|
+
return
|
|
426
|
+
elif base in ['d',]:
|
|
427
|
+
base=unit_registry.Quantity('1')
|
|
428
|
+
else:
|
|
429
|
+
base=unit_registry.Quantity(base)
|
|
430
|
+
break
|
|
431
|
+
except Exception as e:
|
|
432
|
+
print(e)
|
|
433
|
+
try:
|
|
434
|
+
base=Control(func=FormBuilderMkText,ptext="base no units",helpText="base width,do not include units",data="dec.dec")
|
|
435
|
+
if base is None:
|
|
436
|
+
return
|
|
437
|
+
elif base in ['d',]:
|
|
438
|
+
base=decc(1)
|
|
439
|
+
break
|
|
440
|
+
except Exception as e:
|
|
441
|
+
continue
|
|
442
|
+
|
|
443
|
+
while True:
|
|
444
|
+
try:
|
|
445
|
+
height=Control(func=FormBuilderMkText,ptext="height",helpText="height width",data="string")
|
|
446
|
+
if height is None:
|
|
447
|
+
return
|
|
448
|
+
elif height in ['d',]:
|
|
449
|
+
height=unit_registry.Quantity('1')
|
|
450
|
+
else:
|
|
451
|
+
height=unit_registry.Quantity(height)
|
|
452
|
+
break
|
|
453
|
+
except Exception as e:
|
|
454
|
+
print(e)
|
|
455
|
+
try:
|
|
456
|
+
height=Control(func=FormBuilderMkText,ptext="height no units",helpText="height width, do not include units",data="dec.dec")
|
|
457
|
+
if height is None:
|
|
458
|
+
return
|
|
459
|
+
elif height in ['d',]:
|
|
460
|
+
height=decc(1)
|
|
461
|
+
break
|
|
462
|
+
except Exception as e:
|
|
463
|
+
continue
|
|
464
|
+
print(type(height),height,type(base))
|
|
465
|
+
if isinstance(height,decimal.Decimal) and isinstance(base,decimal.Decimal):
|
|
466
|
+
return decc((height*base)/decc(2))
|
|
467
|
+
elif isinstance(height,pint.Quantity) and isinstance(base,pint.Quantity):
|
|
468
|
+
return ((height.to(base)*base)/2)
|
|
469
|
+
elif isinstance(height,pint.Quantity) and isinstance(base,decimal.Decimal):
|
|
470
|
+
return ((height*unit_registry.Quantity(base,height.units))/2)
|
|
471
|
+
elif isinstance(height,decimal.Decimal) and isinstance(base,pint.Quantity):
|
|
472
|
+
return ((unit_registry.Quantity(height,base.units)*base)/2)
|
|
473
473
|
|
|
474
474
|
class Taxable:
|
|
475
|
-
|
|
476
|
-
|
|
475
|
+
def general_taxable(self):
|
|
476
|
+
taxables=[
|
|
477
477
|
"Alcoholic beverages",
|
|
478
478
|
"Books and publications",
|
|
479
479
|
"Cameras and film",
|
|
@@ -496,8 +496,8 @@ class Taxable:
|
|
|
496
496
|
"Soaps or detergents",
|
|
497
497
|
"Sporting goods",
|
|
498
498
|
"Tobacco products",
|
|
499
|
-
|
|
500
|
-
|
|
499
|
+
]
|
|
500
|
+
nontaxables=[
|
|
501
501
|
"Baby formulas (such as Isomil)",
|
|
502
502
|
"Cooking wine",
|
|
503
503
|
"Energy bars (such as PowerBars)",
|
|
@@ -512,9 +512,9 @@ liquid or frozen form.""",
|
|
|
512
512
|
"Pedialyte",
|
|
513
513
|
"Telephone cards (see Prepaid telephone debit cards and prepaid wireless cards)",
|
|
514
514
|
"Water—Bottled noncarbonated, non-effervescent drinking water",
|
|
515
|
-
|
|
515
|
+
]
|
|
516
516
|
|
|
517
|
-
|
|
517
|
+
taxables_2=[
|
|
518
518
|
"Alcoholic beverages",
|
|
519
519
|
'''Carbonated beverages, including semi-frozen beverages
|
|
520
520
|
containing carbonation, such as slushies (see Carbonated fruit
|
|
@@ -526,625 +526,633 @@ juices)''',
|
|
|
526
526
|
"Tobacco products",
|
|
527
527
|
"non-human food",
|
|
528
528
|
"Kombucha tea (if >= 0.5% alcohol by volume and/or is not naturally effervescent)",
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
529
|
+
]
|
|
530
|
+
for i in taxables_2:
|
|
531
|
+
if i not in taxables:
|
|
532
|
+
taxables.append(i)
|
|
533
|
+
|
|
534
|
+
ttl=[]
|
|
535
|
+
for i in taxables:
|
|
536
|
+
ttl.append(i)
|
|
537
|
+
for i in nontaxables:
|
|
538
|
+
ttl.append(i)
|
|
539
|
+
htext=[]
|
|
540
|
+
cta=len(ttl)
|
|
541
|
+
ttl=sorted(ttl,key=str)
|
|
542
|
+
for num,i in enumerate(ttl):
|
|
543
|
+
htext.append(std_colorize(i,num,cta))
|
|
544
|
+
htext='\n'.join(htext)
|
|
545
|
+
while True:
|
|
546
|
+
print(htext)
|
|
547
|
+
select=Control(func=FormBuilderMkText,ptext="Please select all indexes that apply to item?",helpText=htext,data="list")
|
|
548
|
+
if select is None:
|
|
549
|
+
return
|
|
550
|
+
for i in select:
|
|
551
|
+
try:
|
|
552
|
+
index=int(i)
|
|
553
|
+
if ttl[index] in taxables:
|
|
554
|
+
return True
|
|
555
|
+
except Exception as e:
|
|
556
|
+
print(e)
|
|
557
|
+
return False
|
|
558
|
+
def kombucha(self):
|
|
559
|
+
'''determine if kombucha is taxable'''
|
|
560
|
+
fd={
|
|
561
|
+
'Exceeds 0.5% ABV':{
|
|
562
|
+
'default':False,
|
|
563
|
+
'type':'boolean',
|
|
564
|
+
},
|
|
565
|
+
'Is it Naturally Effervescent?':{
|
|
566
|
+
'default':False,
|
|
567
|
+
'type':'boolean',
|
|
568
|
+
},
|
|
569
|
+
|
|
570
|
+
}
|
|
571
|
+
data=FormBuilder(data=fd)
|
|
572
|
+
if data is None:
|
|
573
|
+
return
|
|
574
|
+
else:
|
|
575
|
+
if data['Exceeds 0.5% ABV']:
|
|
576
|
+
return True
|
|
577
|
+
|
|
578
|
+
if not data['Is it Naturally Effervescent?']:
|
|
579
|
+
return True
|
|
580
|
+
|
|
581
|
+
return False
|
|
582
|
+
|
|
583
583
|
#tax rate tools go here
|
|
584
584
|
def AddNewTaxRate(excludes=['txrt_id','DTOE']):
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
585
|
+
with localcontext() as ctx:
|
|
586
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
587
|
+
with Session(ENGINE) as session:
|
|
588
|
+
'''AddNewTaxRate() -> None
|
|
589
|
+
|
|
590
|
+
add a new taxrate to db.'''
|
|
591
|
+
tr=TaxRate()
|
|
592
|
+
session.add(tr)
|
|
593
|
+
session.commit()
|
|
594
|
+
session.refresh(tr)
|
|
595
|
+
fields={i.name:{
|
|
596
|
+
'default':getattr(tr,i.name),
|
|
597
|
+
'type':str(i.type).lower()} for i in tr.__table__.columns if i.name not in excludes
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
601
|
+
if fd is None:
|
|
602
|
+
session.delete(tr)
|
|
603
|
+
return
|
|
604
|
+
for k in fd:
|
|
605
|
+
setattr(tr,k,fd[k])
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
session.add(tr)
|
|
609
|
+
session.commit()
|
|
610
|
+
session.refresh(tr)
|
|
611
|
+
print(tr)
|
|
612
|
+
return tr.TaxRate
|
|
613
613
|
|
|
614
614
|
def GetTaxRate(excludes=['txrt_id','DTOE']):
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
615
|
+
with localcontext() as ctx:
|
|
616
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
617
|
+
with Session(ENGINE) as session:
|
|
618
|
+
'''GetTaxRate() -> TaxRate:Decimal
|
|
619
|
+
|
|
620
|
+
search for and return a Decimal/decc
|
|
621
|
+
taxrate for use by prompt.
|
|
622
|
+
'''
|
|
623
|
+
tr=TaxRate()
|
|
624
|
+
fields={i.name:{
|
|
625
|
+
'default':getattr(tr,i.name),
|
|
626
|
+
'type':str(i.type).lower()} for i in tr.__table__.columns if i.name not in excludes
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec} ; GetTaxRate Search -> ")
|
|
630
|
+
if fd is None:
|
|
631
|
+
return
|
|
632
|
+
for k in fd:
|
|
633
|
+
setattr(tr,k,fd[k])
|
|
634
|
+
#and_
|
|
635
|
+
filte=[]
|
|
636
|
+
for k in fd:
|
|
637
|
+
if fd[k] is not None:
|
|
638
|
+
if isinstance(fd[k],str):
|
|
639
|
+
filte.append(getattr(TaxRate,k).icontains(fd[k]))
|
|
640
|
+
else:
|
|
641
|
+
filte.append(getattr(tr,k)==fd[k])
|
|
642
|
+
|
|
643
|
+
results=session.query(TaxRate).filter(and_(*filte)).all()
|
|
644
|
+
ct=len(results)
|
|
645
|
+
htext=[]
|
|
646
|
+
for num,i in enumerate(results):
|
|
647
|
+
m=std_colorize(i,num,ct)
|
|
648
|
+
print(m)
|
|
649
|
+
htext.append(m)
|
|
650
|
+
htext='\n'.join(htext)
|
|
651
|
+
if ct < 1:
|
|
652
|
+
print(f"{Fore.light_red}There is nothing to work on in TaxRates that match your criteria.{Style.reset}")
|
|
653
|
+
return
|
|
654
|
+
while True:
|
|
655
|
+
select=Control(func=FormBuilderMkText,ptext="Which index to return for tax rate[NAN=0.0000]?",helpText=htext,data="integer")
|
|
656
|
+
print(select)
|
|
657
|
+
if select is None:
|
|
658
|
+
return
|
|
659
|
+
elif isinstance(select,str) and select.upper() in ['NAN',]:
|
|
660
|
+
return 0
|
|
661
|
+
elif select in ['d',]:
|
|
662
|
+
return results[0].TaxRate
|
|
663
|
+
else:
|
|
664
|
+
if index_inList(select,results):
|
|
665
|
+
return results[select].TaxRate
|
|
666
|
+
else:
|
|
667
|
+
continue
|
|
668
668
|
|
|
669
669
|
def price_by_tax(total=False):
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
670
|
+
with localcontext() as ctx:
|
|
671
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
672
|
+
fields={
|
|
673
|
+
'price':{
|
|
674
|
+
'default':0,
|
|
675
|
+
'type':'dec.dec'
|
|
676
|
+
},
|
|
677
|
+
'rate':{
|
|
678
|
+
'default':GetTaxRate(),
|
|
679
|
+
'type':'dec.dec'
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec} ; Tax on Price ->")
|
|
683
|
+
if fd is None:
|
|
684
|
+
return
|
|
685
|
+
else:
|
|
686
|
+
price=fd['price']
|
|
687
|
+
rate=fd['rate']
|
|
688
|
+
if price is None:
|
|
689
|
+
price=0
|
|
690
|
+
if fd['rate'] is None:
|
|
691
|
+
rate=0
|
|
692
|
+
if total == False:
|
|
693
|
+
return decc(price,cf=4)*decc(rate,cf=4)
|
|
694
|
+
else:
|
|
695
|
+
return (decc(price,cf=4)*decc(rate,cf=4))+decc(price,cf=4)
|
|
696
696
|
|
|
697
697
|
def price_plus_crv_by_tax(total=False):
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
698
|
+
with localcontext() as ctx:
|
|
699
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
700
|
+
fields={
|
|
701
|
+
'price':{
|
|
702
|
+
'default':0,
|
|
703
|
+
'type':'dec.dec'
|
|
704
|
+
},
|
|
705
|
+
'crv_total_for_pkg':{
|
|
706
|
+
'default':0,
|
|
707
|
+
'type':'dec.dec',
|
|
708
|
+
},
|
|
709
|
+
'rate':{
|
|
710
|
+
'default':GetTaxRate(),
|
|
711
|
+
'type':'dec.dec'
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec};Tax on (Price+CRV)")
|
|
715
|
+
if fd is None:
|
|
716
|
+
return
|
|
717
|
+
else:
|
|
718
|
+
price=fd['price']
|
|
719
|
+
rate=fd['rate']
|
|
720
|
+
crv=fd['crv_total_for_pkg']
|
|
721
|
+
if price is None:
|
|
722
|
+
price=0
|
|
723
|
+
if crv is None:
|
|
724
|
+
crv=0
|
|
725
|
+
if fd['rate'] is None:
|
|
726
|
+
rate=0
|
|
727
|
+
if total == False:
|
|
728
|
+
return (decc(price,cf=4)+decc(crv,cf=4))*decc(rate,cf=4)
|
|
729
|
+
else:
|
|
730
|
+
return (price+crv)+((decc(price,cf=4)+decc(crv,cf=4))*decc(rate,cf=4))
|
|
731
731
|
|
|
732
732
|
def DeleteTaxRate(excludes=['txrt_id','DTOE']):
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
733
|
+
with Session(ENGINE) as session:
|
|
734
|
+
'''DeleteTaxRate() -> None
|
|
735
|
+
|
|
736
|
+
search for and delete selected
|
|
737
|
+
taxrate.
|
|
738
|
+
'''
|
|
739
|
+
'''AddNewTaxRate() -> None
|
|
740
|
+
|
|
741
|
+
add a new taxrate to db.'''
|
|
742
|
+
tr=TaxRate()
|
|
743
|
+
fields={i.name:{
|
|
744
|
+
'default':getattr(tr,i.name),
|
|
745
|
+
'type':str(i.type).lower()} for i in tr.__table__.columns if i.name not in excludes
|
|
746
|
+
}
|
|
747
|
+
fd=FormBuilder(data=fields)
|
|
748
|
+
if fd is None:
|
|
749
|
+
return
|
|
750
|
+
for k in fd:
|
|
751
|
+
setattr(tr,k,fd[k])
|
|
752
|
+
#and_
|
|
753
|
+
filte=[]
|
|
754
|
+
for k in fd:
|
|
755
|
+
if fd[k] is not None:
|
|
756
|
+
if isinstance(fd[k],str):
|
|
757
|
+
filte.append(getattr(TaxRate,k).icontains(fd[k]))
|
|
758
|
+
else:
|
|
759
|
+
filte.append(getattr(tr,k)==fd[k])
|
|
760
|
+
session.commit()
|
|
761
|
+
|
|
762
|
+
results=session.query(TaxRate).filter(and_(*filte)).all()
|
|
763
|
+
ct=len(results)
|
|
764
|
+
htext=[]
|
|
765
|
+
for num,i in enumerate(results):
|
|
766
|
+
m=std_colorize(i,num,ct)
|
|
767
|
+
print(m)
|
|
768
|
+
htext.append(m)
|
|
769
|
+
htext='\n'.join(htext)
|
|
770
|
+
if ct < 1:
|
|
771
|
+
print(f"{Fore.light_red}There is nothing to work on in TaxRates that match your criteria.{Style.reset}")
|
|
772
|
+
return
|
|
773
|
+
while True:
|
|
774
|
+
select=Control(func=FormBuilderMkText,ptext="Which index to delete?",helpText=htext,data="integer")
|
|
775
|
+
print(select)
|
|
776
|
+
if select is None:
|
|
777
|
+
print(f"{Fore.light_yellow}Nothing was deleted!{Style.reset}")
|
|
778
|
+
return
|
|
779
|
+
elif isinstance(select,str) and select.upper() in ['NAN',]:
|
|
780
|
+
print(f"{Fore.light_yellow}Nothing was deleted!{Style.reset}")
|
|
781
|
+
return 0
|
|
782
|
+
elif select in ['d',]:
|
|
783
|
+
print(f"{Fore.light_yellow}Nothing was deleted!{Style.reset}")
|
|
784
|
+
return
|
|
785
|
+
else:
|
|
786
|
+
if index_inList(select,results):
|
|
787
|
+
session.delete(results[select])
|
|
788
|
+
session.commit()
|
|
789
|
+
return
|
|
790
|
+
else:
|
|
791
|
+
continue
|
|
792
792
|
|
|
793
793
|
def EditTaxRate(excludes=['txrt_id','DTOE']):
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
794
|
+
'''DeleteTaxRate() -> None
|
|
795
|
+
|
|
796
|
+
search for and delete selected
|
|
797
|
+
taxrate.
|
|
798
|
+
'''
|
|
799
|
+
tr=TaxRate()
|
|
800
|
+
fields={i.name:{
|
|
801
|
+
'default':getattr(tr,i.name),
|
|
802
|
+
'type':str(i.type).lower()} for i in tr.__table__.columns if i.name not in excludes
|
|
803
|
+
}
|
|
804
|
+
fd=FormBuilder(data=fields)
|
|
805
|
+
if fd is None:
|
|
806
|
+
return
|
|
807
|
+
for k in fd:
|
|
808
|
+
setattr(tr,k,fd[k])
|
|
809
|
+
#and_
|
|
810
|
+
filte=[]
|
|
811
|
+
for k in fd:
|
|
812
|
+
if fd[k] is not None:
|
|
813
|
+
if isinstance(fd[k],str):
|
|
814
|
+
filte.append(getattr(TaxRate,k).icontains(fd[k]))
|
|
815
|
+
else:
|
|
816
|
+
filte.append(getattr(tr,k)==fd[k])
|
|
817
|
+
with Session(ENGINE) as session:
|
|
818
|
+
results=session.query(TaxRate).filter(and_(*filte)).all()
|
|
819
|
+
ct=len(results)
|
|
820
|
+
htext=[]
|
|
821
|
+
for num,i in enumerate(results):
|
|
822
|
+
m=std_colorize(i,num,ct)
|
|
823
|
+
print(m)
|
|
824
|
+
htext.append(m)
|
|
825
|
+
htext='\n'.join(htext)
|
|
826
|
+
if ct < 1:
|
|
827
|
+
print(f"{Fore.light_red}There is nothing to work on in TaxRates that match your criteria.{Style.reset}")
|
|
828
|
+
return
|
|
829
|
+
while True:
|
|
830
|
+
select=Control(func=FormBuilderMkText,ptext="Which index to edit?",helpText=htext,data="integer")
|
|
831
|
+
print(select)
|
|
832
|
+
if select is None:
|
|
833
|
+
print(f"{Fore.light_yellow}Nothing was deleted!{Style.reset}")
|
|
834
|
+
return
|
|
835
|
+
elif isinstance(select,str) and select.upper() in ['NAN',]:
|
|
836
|
+
print(f"{Fore.light_yellow}Nothing was deleted!{Style.reset}")
|
|
837
|
+
return 0
|
|
838
|
+
elif select in ['d',]:
|
|
839
|
+
print(f"{Fore.light_yellow}Nothing was deleted!{Style.reset}")
|
|
840
|
+
return
|
|
841
|
+
else:
|
|
842
|
+
if index_inList(select,results):
|
|
843
|
+
fields={i.name:{
|
|
844
|
+
'default':getattr(results[select],i.name),
|
|
845
|
+
'type':str(i.type).lower()} for i in results[select].__table__.columns if i.name not in excludes
|
|
846
|
+
}
|
|
847
|
+
fd=FormBuilder(data=fields)
|
|
848
|
+
for k in fd:
|
|
849
|
+
setattr(results[select],k,fd[k])
|
|
850
|
+
session.commit()
|
|
851
|
+
session.refresh(results[select])
|
|
852
|
+
print(results[select])
|
|
853
|
+
return
|
|
854
|
+
else:
|
|
855
|
+
continue
|
|
856
856
|
|
|
857
857
|
def heronsFormula():
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
858
|
+
with localcontext() as ctx:
|
|
859
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
860
|
+
'''
|
|
861
|
+
Calculate the semi-perimeter (s): Add the lengths of the three sides and divide by 2.
|
|
862
|
+
s = (a + b + c) / 2
|
|
863
|
+
'''
|
|
864
|
+
fields={
|
|
865
|
+
'side 1':{
|
|
866
|
+
'default':1,
|
|
867
|
+
'type':'dec.dec'
|
|
868
|
+
},
|
|
869
|
+
'side 2':{
|
|
870
|
+
'default':1,
|
|
871
|
+
'type':'dec.dec'
|
|
872
|
+
},
|
|
873
|
+
'side 3':{
|
|
874
|
+
'default':1,
|
|
875
|
+
'type':'dec.dec'
|
|
876
|
+
},
|
|
877
|
+
}
|
|
878
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
879
|
+
if fd is None:
|
|
880
|
+
return
|
|
881
|
+
|
|
882
|
+
s=(fd['side 1']+fd['side 2']+fd['side 3'])/2
|
|
883
|
+
'''Apply Heron's formula: Substitute the semi-perimeter (s) and the side lengths (a, b, and c) into the formula:
|
|
884
|
+
Area = √(s(s-a)(s-b)(s-c))'''
|
|
885
|
+
Area=math.sqrt(s*(s-fd['side 1'])*(s-fd['side 2'])*(s-fd['side 3']))
|
|
886
|
+
return Area
|
|
887
887
|
|
|
888
888
|
def volumeCylinderRadius():
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
889
|
+
with localcontext() as ctx:
|
|
890
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
891
|
+
'''
|
|
892
|
+
Volume of a cylinder: Used for cylindrical storage bins, silos, or tanks.(V=pi r^{2}h)
|
|
893
|
+
'''
|
|
894
|
+
fields={
|
|
895
|
+
'height':{
|
|
896
|
+
'default':1,
|
|
897
|
+
'type':'dec.dec'
|
|
898
|
+
},
|
|
899
|
+
'radius':{
|
|
900
|
+
'default':1,
|
|
901
|
+
'type':'dec.dec'
|
|
902
|
+
},
|
|
903
|
+
}
|
|
904
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
905
|
+
if fd is None:
|
|
906
|
+
return
|
|
907
|
+
|
|
908
|
+
volume=Decimal(math.pi)*(fd['radius']**2)*fd['height']
|
|
909
|
+
return volume
|
|
910
910
|
|
|
911
911
|
def volumeCylinderDiameter():
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
912
|
+
with localcontext() as ctx:
|
|
913
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
914
|
+
'''
|
|
915
|
+
Volume of a cylinder: Used for cylindrical storage bins, silos, or tanks.(V=pi r^{2}h)
|
|
916
|
+
'''
|
|
917
|
+
fields={
|
|
918
|
+
'height':{
|
|
919
|
+
'default':1,
|
|
920
|
+
'type':'dec.dec'
|
|
921
|
+
},
|
|
922
|
+
'diameter':{
|
|
923
|
+
'default':1,
|
|
924
|
+
'type':'dec.dec'
|
|
925
|
+
},
|
|
926
|
+
}
|
|
927
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
928
|
+
if fd is None:
|
|
929
|
+
return
|
|
930
|
+
|
|
931
|
+
volume=Decimal(math.pi)*((fd['diameter']/2)**2)*fd['height']
|
|
932
|
+
return volume
|
|
933
933
|
|
|
934
934
|
def volumeConeRadius():
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
935
|
+
with localcontext() as ctx:
|
|
936
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
937
|
+
'''
|
|
938
|
+
Volume of a cylinder: Used for cylindrical storage bins, silos, or tanks.(V=pi r^{2}h)
|
|
939
|
+
'''
|
|
940
|
+
fields={
|
|
941
|
+
'height':{
|
|
942
|
+
'default':1,
|
|
943
|
+
'type':'dec.dec'
|
|
944
|
+
},
|
|
945
|
+
'radius':{
|
|
946
|
+
'default':1,
|
|
947
|
+
'type':'dec.dec'
|
|
948
|
+
},
|
|
949
|
+
}
|
|
950
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
951
|
+
if fd is None:
|
|
952
|
+
return
|
|
953
|
+
|
|
954
|
+
volume=Decimal(1/3)*(Decimal(math.pi)*(fd['radius']**2)*fd['height'])
|
|
955
|
+
return volume
|
|
956
956
|
|
|
957
957
|
def volumeConeDiameter():
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
958
|
+
with localcontext() as ctx:
|
|
959
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
960
|
+
'''
|
|
961
|
+
Volume of a cylinder: Used for cylindrical storage bins, silos, or tanks.(V=pi r^{2}h)
|
|
962
|
+
'''
|
|
963
|
+
fields={
|
|
964
|
+
'height':{
|
|
965
|
+
'default':1,
|
|
966
|
+
'type':'dec.dec'
|
|
967
|
+
},
|
|
968
|
+
'diameter':{
|
|
969
|
+
'default':1,
|
|
970
|
+
'type':'dec.dec'
|
|
971
|
+
},
|
|
972
|
+
}
|
|
973
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
974
|
+
if fd is None:
|
|
975
|
+
return
|
|
976
|
+
|
|
977
|
+
volume=Decimal(1/3)*(Decimal(math.pi)*((fd['diameter']/2)**2)*fd['height'])
|
|
978
|
+
return volume
|
|
979
979
|
|
|
980
980
|
def volumeHemisphereRadius():
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
981
|
+
with localcontext() as ctx:
|
|
982
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
983
|
+
'''
|
|
984
|
+
Volume of a hemisphere = (2/3) x 3.14 x r3
|
|
985
|
+
'''
|
|
986
|
+
fields={
|
|
987
|
+
'radius':{
|
|
988
|
+
'default':1,
|
|
989
|
+
'type':'dec.dec'
|
|
990
|
+
},
|
|
991
|
+
}
|
|
992
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
993
|
+
if fd is None:
|
|
994
|
+
return
|
|
995
|
+
|
|
996
|
+
volume=Decimal(2/3)*Decimal(math.pi)*(fd['radius']**3)
|
|
997
|
+
return volume
|
|
998
998
|
|
|
999
999
|
def volumeHemisphereDiameter():
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1000
|
+
with localcontext() as ctx:
|
|
1001
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
1002
|
+
'''
|
|
1003
|
+
Volume of a hemisphere = (2/3) x 3.14 x r3
|
|
1004
|
+
'''
|
|
1005
|
+
fields={
|
|
1006
|
+
'diameter':{
|
|
1007
|
+
'default':1,
|
|
1008
|
+
'type':'dec.dec'
|
|
1009
|
+
},
|
|
1010
|
+
}
|
|
1011
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
1012
|
+
if fd is None:
|
|
1013
|
+
return
|
|
1014
|
+
|
|
1015
|
+
volume=Decimal(2/3)*Decimal(math.pi)*((fd['diameter']/2)**3)
|
|
1016
|
+
return volume
|
|
1017
1017
|
|
|
1018
1018
|
def areaCircleDiameter():
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1019
|
+
with localcontext() as ctx:
|
|
1020
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
1021
|
+
'''
|
|
1022
|
+
Volume of a hemisphere = (2/3) x 3.14 x r3
|
|
1023
|
+
'''
|
|
1024
|
+
fields={
|
|
1025
|
+
'diameter':{
|
|
1026
|
+
'default':1,
|
|
1027
|
+
'type':'dec.dec'
|
|
1028
|
+
},
|
|
1029
|
+
}
|
|
1030
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
1031
|
+
if fd is None:
|
|
1032
|
+
return
|
|
1033
|
+
|
|
1034
|
+
volume=Decimal(math.pi)*((fd['diameter']/2)**2)
|
|
1035
|
+
return volume
|
|
1036
1036
|
|
|
1037
1037
|
|
|
1038
1038
|
def areaCircleRadius():
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1039
|
+
with localcontext() as ctx:
|
|
1040
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
1041
|
+
'''
|
|
1042
|
+
Volume of a hemisphere = (2/3) x 3.14 x r3
|
|
1043
|
+
'''
|
|
1044
|
+
fields={
|
|
1045
|
+
'radius':{
|
|
1046
|
+
'default':1,
|
|
1047
|
+
'type':'dec.dec'
|
|
1048
|
+
},
|
|
1049
|
+
}
|
|
1050
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
1051
|
+
if fd is None:
|
|
1052
|
+
return
|
|
1053
|
+
|
|
1054
|
+
volume=Decimal(math.pi)*((fd['radius'])**2)
|
|
1055
|
+
return volume
|
|
1056
1056
|
|
|
1057
1057
|
###newest
|
|
1058
1058
|
def circumferenceCircleRadiu():
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1059
|
+
#get the circumference of a circle using radius
|
|
1060
|
+
with localcontext() as ctx:
|
|
1061
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
1062
|
+
'''
|
|
1063
|
+
2πr
|
|
1064
|
+
'''
|
|
1065
|
+
fields={
|
|
1066
|
+
'radius':{
|
|
1067
|
+
'default':1,
|
|
1068
|
+
'type':'dec.dec'
|
|
1069
|
+
},
|
|
1070
|
+
}
|
|
1071
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
1072
|
+
if fd is None:
|
|
1073
|
+
return
|
|
1074
|
+
|
|
1075
|
+
circumference=2*Deimal(math.pi)*fd['radius']
|
|
1076
|
+
return circumference
|
|
1077
1077
|
|
|
1078
1078
|
def circumferenceCircleDiameter():
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1079
|
+
#get the circumference of a circle using diameter
|
|
1080
|
+
with localcontext() as ctx:
|
|
1081
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
1082
|
+
'''
|
|
1083
|
+
2π(d/2)
|
|
1084
|
+
'''
|
|
1085
|
+
fields={
|
|
1086
|
+
'diameter':{
|
|
1087
|
+
'default':1,
|
|
1088
|
+
'type':'dec.dec'
|
|
1089
|
+
},
|
|
1090
|
+
}
|
|
1091
|
+
fd=FormBuilder(data=fields,passThruText=f"Precision {ctx.prec}")
|
|
1092
|
+
if fd is None:
|
|
1093
|
+
return
|
|
1094
|
+
|
|
1095
|
+
circumference=2*Deimal(math.pi)*Decimal(fd['diameter']/2)
|
|
1096
|
+
return circumference
|
|
1097
1097
|
|
|
1098
1098
|
def sudokuCandidates():
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1099
|
+
#get the circumference of a circle using diameter
|
|
1100
|
+
with localcontext() as ctx:
|
|
1101
|
+
ctx.prec=int(db.detectGetOrSet("lsbld ROUNDTO default",4,setValue=False,literal=True))
|
|
1102
|
+
'''
|
|
1103
|
+
2π(d/2)
|
|
1104
|
+
'''
|
|
1105
|
+
gameSymbols=Control(func=FormBuilderMkText,ptext="Game symbols [123456789]",helpText="123456789",data="string")
|
|
1106
|
+
if gameSymbols in ['NaN',None,]:
|
|
1107
|
+
return
|
|
1108
|
+
elif gameSymbols in ['d',]:
|
|
1109
|
+
gameSymbols='123456789'
|
|
1110
|
+
|
|
1111
|
+
fields={
|
|
1112
|
+
'Symbols for Row':{
|
|
1113
|
+
'default':'',
|
|
1114
|
+
'type':'string'
|
|
1115
|
+
},
|
|
1116
|
+
'Symbols for Column':{
|
|
1117
|
+
'default':'',
|
|
1118
|
+
'type':'string'
|
|
1119
|
+
},
|
|
1120
|
+
'Symbols for Cell':{
|
|
1121
|
+
'default':'',
|
|
1122
|
+
'type':'string'
|
|
1123
|
+
},
|
|
1124
|
+
'Symbols for Right-Diagnal':{
|
|
1125
|
+
'default':'',
|
|
1126
|
+
'type':'string'
|
|
1127
|
+
},
|
|
1128
|
+
'Symbols for Left-Diagnal':{
|
|
1129
|
+
'default':'',
|
|
1130
|
+
'type':'string'
|
|
1131
|
+
},
|
|
1132
|
+
}
|
|
1133
|
+
loop=True
|
|
1134
|
+
while loop:
|
|
1135
|
+
fd=FormBuilder(data=fields,passThruText=f"Sudoku Candidates? ")
|
|
1136
|
+
if fd is None:
|
|
1137
|
+
return
|
|
1138
|
+
|
|
1139
|
+
sString=[]
|
|
1140
|
+
for i in fd:
|
|
1141
|
+
if isinstance(fd[i],str):
|
|
1142
|
+
sString.append(fd[i])
|
|
1143
|
+
sString=' '.join(sString)
|
|
1144
|
+
cd=[]
|
|
1145
|
+
for i in gameSymbols:
|
|
1146
|
+
if i not in sString:
|
|
1147
|
+
cd.append(i)
|
|
1148
|
+
print(cd)
|
|
1149
|
+
loop=Control(func=FormBuilderMkText,ptext="Again?",helpText="yes or no/boolean",data="boolean")
|
|
1150
|
+
if loop in ['NaN',None]:
|
|
1151
|
+
return
|
|
1152
|
+
elif loop in ['d',True]:
|
|
1153
|
+
loop=True
|
|
1154
|
+
else:
|
|
1155
|
+
return cd
|
|
1148
1156
|
'''
|
|
1149
1157
|
Ellipse: area=πab
|
|
1150
1158
|
, where 2a
|
|
@@ -1164,4 +1172,256 @@ Cylinder: vol=πr2h
|
|
|
1164
1172
|
Cone: vol=πr2h/3
|
|
1165
1173
|
, lateral area=πrr2+h2−−−−−−√
|
|
1166
1174
|
, total surface area=πrr2+h2−−−−−−√+πr2
|
|
1167
|
-
'''
|
|
1175
|
+
'''
|
|
1176
|
+
|
|
1177
|
+
class candidates:
|
|
1178
|
+
def __new__(self,test=False):
|
|
1179
|
+
n=None
|
|
1180
|
+
symbols=[i for i in '123456789']
|
|
1181
|
+
none_symbol='0'
|
|
1182
|
+
|
|
1183
|
+
if test:
|
|
1184
|
+
pzl={
|
|
1185
|
+
'l1':[1,n,9,n,n,3,7,n,8],
|
|
1186
|
+
'l2':[n,n,4,n,n,n,3,n,2],
|
|
1187
|
+
'l3':[3,n,5,n,6,8,1,9,4],
|
|
1188
|
+
'l4':[6,n,7,8,1,n,n,n,n],
|
|
1189
|
+
'l5':[9,3,1,n,n,n,5,8,n],
|
|
1190
|
+
'l6':[n,n,2,3,n,n,6,n,n],
|
|
1191
|
+
'l7':[n,n,8,n,n,5,n,3,n],
|
|
1192
|
+
'l8':[4,n,3,n,8,6,n,1,n],
|
|
1193
|
+
'l9':[n,9,6,n,n,n,n,n,7],
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
def mkpuzl():
|
|
1198
|
+
while True:
|
|
1199
|
+
done={}
|
|
1200
|
+
htext=[]
|
|
1201
|
+
symbols='123456789'
|
|
1202
|
+
ct=len(symbols)
|
|
1203
|
+
for num,i in enumerate(symbols):
|
|
1204
|
+
htext.append(std_colorize(i,num,ct))
|
|
1205
|
+
done[f'l{num+1}']={
|
|
1206
|
+
'default':[],
|
|
1207
|
+
'type':'list'
|
|
1208
|
+
}
|
|
1209
|
+
finished=FormBuilder(data=done,passThruText=f"enter chars. of {symbols}, use 0 to represent an unfilled cell: Must be 9-Long")
|
|
1210
|
+
if finished is None:
|
|
1211
|
+
return None
|
|
1212
|
+
else:
|
|
1213
|
+
for i in finished:
|
|
1214
|
+
if len(finished[i]) != 9:
|
|
1215
|
+
continue
|
|
1216
|
+
for num,ii in enumerate(finished[i]):
|
|
1217
|
+
if ii == '0':
|
|
1218
|
+
finished[i][num]=n
|
|
1219
|
+
return finished
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
#select a list of 9 symbols for ln#
|
|
1223
|
+
#symbol is 0, then symbol is None
|
|
1224
|
+
#append list to final list
|
|
1225
|
+
#for 9lines of 9elements per 1 line as a dict of 9 keys with 9 lists that are 9 elements long
|
|
1226
|
+
if not test:
|
|
1227
|
+
pzl=mkpuzl()
|
|
1228
|
+
|
|
1229
|
+
while True:
|
|
1230
|
+
#print(pzl)
|
|
1231
|
+
if pzl is None:
|
|
1232
|
+
return
|
|
1233
|
+
mapped={
|
|
1234
|
+
'block1=':{
|
|
1235
|
+
'rows':[0,1,2],
|
|
1236
|
+
'columns':[0,1,2]
|
|
1237
|
+
},
|
|
1238
|
+
'block2':{
|
|
1239
|
+
'rows':[0,1,2],
|
|
1240
|
+
'columns':[3,4,5]
|
|
1241
|
+
},
|
|
1242
|
+
'block3':{
|
|
1243
|
+
'rows':[0,1,2],
|
|
1244
|
+
'columns':[4,5,6]
|
|
1245
|
+
},
|
|
1246
|
+
'block4':{
|
|
1247
|
+
'rows':[3,4,5],
|
|
1248
|
+
'columns':[0,1,2]
|
|
1249
|
+
},
|
|
1250
|
+
'block5':{
|
|
1251
|
+
'rows':[3,4,5],
|
|
1252
|
+
'columns':[3,4,5]
|
|
1253
|
+
},
|
|
1254
|
+
'block6':{
|
|
1255
|
+
'rows':[3,4,5],
|
|
1256
|
+
'columns':[6,7,8]
|
|
1257
|
+
},
|
|
1258
|
+
'block7':{
|
|
1259
|
+
'rows':[6,7,8],
|
|
1260
|
+
'columns':[0,1,2]
|
|
1261
|
+
},
|
|
1262
|
+
'block8':{
|
|
1263
|
+
'rows':[6,7,8],
|
|
1264
|
+
'columns':[3,4,5]
|
|
1265
|
+
},
|
|
1266
|
+
'block9':{
|
|
1267
|
+
'rows':[6,7,8],
|
|
1268
|
+
'columns':[6,7,8]
|
|
1269
|
+
},
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
def rx2idx(line,column,x_limit=9,y_limit=9):
|
|
1273
|
+
return ((x_limit*line)-(y_limit-column))
|
|
1274
|
+
|
|
1275
|
+
def desired(block_x=[1,4],block_y=[1,4],num=''):
|
|
1276
|
+
iblock_x=block_x
|
|
1277
|
+
iblock_x[-1]+=1
|
|
1278
|
+
|
|
1279
|
+
iblock_y=block_y
|
|
1280
|
+
iblock_y[-1]+=1
|
|
1281
|
+
for i in range(*iblock_x):
|
|
1282
|
+
for x in range(*iblock_y):
|
|
1283
|
+
#print(f'block{num}',rx2idx(i,x))
|
|
1284
|
+
yield rx2idx(i,x)
|
|
1285
|
+
|
|
1286
|
+
rgrid=[
|
|
1287
|
+
[[1,3],[1,3]],[[1,3],[4,6]],[[1,3],[7,9]],
|
|
1288
|
+
[[4,6],[1,3]],[[4,6],[4,6]],[[4,6],[7,9]],
|
|
1289
|
+
[[7,9],[1,3]],[[7,9],[4,6]],[[7,9],[7,9]],
|
|
1290
|
+
]
|
|
1291
|
+
grid={}
|
|
1292
|
+
for num,y in enumerate(rgrid):
|
|
1293
|
+
grid[f'block{num+1}']=[i for i in desired(y[0],y[1],num+1)]
|
|
1294
|
+
|
|
1295
|
+
#grid=mkgrid()
|
|
1296
|
+
def characters_row(row):
|
|
1297
|
+
tmp=''
|
|
1298
|
+
for i in row:
|
|
1299
|
+
if i!=None:
|
|
1300
|
+
tmp+=str(i)
|
|
1301
|
+
return tmp
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
def characters_column(rows,column):
|
|
1305
|
+
tmp=''
|
|
1306
|
+
x=[]
|
|
1307
|
+
for r in rows:
|
|
1308
|
+
c=rows[r][column]
|
|
1309
|
+
if c is not None:
|
|
1310
|
+
if not isinstance(c,list):
|
|
1311
|
+
tmp+=str(c)
|
|
1312
|
+
return tmp
|
|
1313
|
+
|
|
1314
|
+
def characters_block(pzl,mapped,ttl):
|
|
1315
|
+
tmp=''
|
|
1316
|
+
zz=[]
|
|
1317
|
+
for i in pzl:
|
|
1318
|
+
zz.extend(pzl[i])
|
|
1319
|
+
ttl+=1
|
|
1320
|
+
#print(ttl,'ttl')
|
|
1321
|
+
for i in grid:
|
|
1322
|
+
if ttl in grid[i]:
|
|
1323
|
+
for x in grid[i]:
|
|
1324
|
+
#print(x-1)
|
|
1325
|
+
if zz[x-1] is not None:
|
|
1326
|
+
tmp+=str(zz[x-1])
|
|
1327
|
+
|
|
1328
|
+
#back to the drawng board
|
|
1329
|
+
return tmp
|
|
1330
|
+
|
|
1331
|
+
def display_candidates(pzl):
|
|
1332
|
+
ttl=0
|
|
1333
|
+
newStart=None
|
|
1334
|
+
while True:
|
|
1335
|
+
ttl=0
|
|
1336
|
+
for numRow in enumerate(pzl):
|
|
1337
|
+
for COL in range(len(pzl[numRow[-1]])):
|
|
1338
|
+
if ttl > 81:
|
|
1339
|
+
ttl=0
|
|
1340
|
+
filled=''
|
|
1341
|
+
tmp=[]
|
|
1342
|
+
ROW=[i for i in reversed(numRow)]
|
|
1343
|
+
consumed=f"{characters_row(pzl[ROW[0]])}{characters_column(pzl,COL)}{characters_block(pzl,mapped,ttl)}"
|
|
1344
|
+
tmpl=[]
|
|
1345
|
+
for x in stre(consumed)/1:
|
|
1346
|
+
if x not in tmpl:
|
|
1347
|
+
tmpl.append(x)
|
|
1348
|
+
tmpl=sorted(tmpl)
|
|
1349
|
+
fmsg=f'''Percent(({ttl}/80)*100)->{(ttl/80)*100:.2f} RowCol({Fore.orange_red_1}R={ROW[-1]},{Fore.light_steel_blue}C={COL})
|
|
1350
|
+
{Fore.light_green}Reduced("{consumed}")->"{''.join(tmpl)}"'''
|
|
1351
|
+
symbol_string=f"""{fmsg}{Fore.light_yellow}
|
|
1352
|
+
NoneSymbol({none_symbol}){Fore.light_steel_blue}
|
|
1353
|
+
SYMBOL({pzl[numRow[-1]][COL]})
|
|
1354
|
+
ROWS({ROW[-1]}): {characters_row(pzl[ROW[0]])}
|
|
1355
|
+
COLUMN({COL}): {characters_column(pzl,COL)}
|
|
1356
|
+
BLOCK: '{characters_block(pzl,mapped,ttl)}' """
|
|
1357
|
+
for char in symbols:
|
|
1358
|
+
if char not in tmpl:
|
|
1359
|
+
tmp.append(char)
|
|
1360
|
+
candidates=', '.join(tmp)
|
|
1361
|
+
color=''
|
|
1362
|
+
color_end=''
|
|
1363
|
+
if len(candidates) == 1:
|
|
1364
|
+
color=f"{Fore.light_green}"
|
|
1365
|
+
color_end=f"{Style.reset}"
|
|
1366
|
+
if pzl[numRow[-1]][COL] != candidates and pzl[numRow[-1]][COL] is not None:
|
|
1367
|
+
filled=f"{Fore.orange_red_1}AlreadyFilled({pzl[numRow[-1]][COL]}){Style.reset}"
|
|
1368
|
+
color_end=filled+color_end
|
|
1369
|
+
candidates=''
|
|
1370
|
+
elif len(candidates) <= 0:
|
|
1371
|
+
color=f"{Fore.light_red}"
|
|
1372
|
+
if pzl[numRow[-1]][COL] is not None:
|
|
1373
|
+
filled=f"{Fore.orange_red_1}AlreadyFilled({pzl[numRow[-1]][COL]}){Style.reset}"
|
|
1374
|
+
color_end=filled+color_end
|
|
1375
|
+
else:
|
|
1376
|
+
color_end=f"{filled} No candidates were found!{Style.reset}"
|
|
1377
|
+
elif len(candidates) >= 1:
|
|
1378
|
+
color=f"{Fore.light_cyan}"
|
|
1379
|
+
color_end=f"{Style.reset}"
|
|
1380
|
+
if pzl[numRow[-1]][COL] != candidates and pzl[numRow[-1]][COL] is not None:
|
|
1381
|
+
filled=f"{Fore.orange_red_1}AlreadyFilled({pzl[numRow[-1]][COL]}){Style.reset}"
|
|
1382
|
+
color_end=filled+color_end
|
|
1383
|
+
candidates=''
|
|
1384
|
+
ttl+=1
|
|
1385
|
+
if newStart is not None:
|
|
1386
|
+
if ttl < newStart:
|
|
1387
|
+
continue
|
|
1388
|
+
else:
|
|
1389
|
+
newStart=None
|
|
1390
|
+
print(symbol_string)
|
|
1391
|
+
print(f"{color}CANDIDATES: {color_end}",candidates)
|
|
1392
|
+
|
|
1393
|
+
page=Control(func=lambda text,data:FormBuilderMkText(text,data,passThru=['goto',],PassThru=True),ptext="Next?",helpText="yes or no,",data="boolean")
|
|
1394
|
+
if page in [None,'NaN']:
|
|
1395
|
+
return
|
|
1396
|
+
elif page in ['d',]:
|
|
1397
|
+
pass
|
|
1398
|
+
elif page in ['goto']:
|
|
1399
|
+
breakMe=False
|
|
1400
|
+
while True:
|
|
1401
|
+
stopAt=Control(func=FormBuilderMkText,ptext="Goto where?",helpText="0-81",data="integer")
|
|
1402
|
+
if stopAt in ['NaN',None]:
|
|
1403
|
+
return
|
|
1404
|
+
elif stopAt in [i for i in range(0,82)]:
|
|
1405
|
+
newStart=stopAt
|
|
1406
|
+
breakMe=True
|
|
1407
|
+
break
|
|
1408
|
+
else:
|
|
1409
|
+
print("between 0 and 81")
|
|
1410
|
+
continue
|
|
1411
|
+
if breakMe:
|
|
1412
|
+
break
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
|
|
1416
|
+
print('ROW and COL/COLUM are 0/zero-indexed!')
|
|
1417
|
+
display_candidates(pzl)
|
|
1418
|
+
control=Control(func=FormBuilderMkText,ptext="new data/nd,re-run/rr[default]",helpText='',data="string")
|
|
1419
|
+
if control in [None,'NaN']:
|
|
1420
|
+
return
|
|
1421
|
+
elif control in ['d','rr','re-run','re run']:
|
|
1422
|
+
continue
|
|
1423
|
+
elif control in ['new data','new-data','nd']:
|
|
1424
|
+
pzl=mkpuzl()
|
|
1425
|
+
continue
|
|
1426
|
+
else:
|
|
1427
|
+
continue
|