summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
authorSimon <vesspa0330@gmail.com>2025-01-19 22:19:44 -0500
committerSimon <vesspa0330@gmail.com>2025-01-19 22:19:44 -0500
commit1b52142591bd5ee6504d9fd488712181041ecc05 (patch)
tree1a8924c5c42fb0f7a149e6574d2d043043df67a3 /test.py
parentf85b5db7a46d137f88a1e5a548fcd2133ef53d16 (diff)
made a huge overhaul to the input validation system, it is not fully
implemented across all formats yet though. file input and output support is partially implemented too. just saving for progress
Diffstat (limited to 'test.py')
-rw-r--r--test.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/test.py b/test.py
new file mode 100644
index 0000000..1127e35
--- /dev/null
+++ b/test.py
@@ -0,0 +1,67 @@
+def extractValues(color, numValues, isHex = False) :
+ print(color)
+ i = 0
+ tempValue = ''
+ extractedValues = []
+
+ if isHex :
+ # search for hex values
+ hexCharacters = ['a', 'b', 'c', 'd', 'e', 'f']
+ while i < len(color) :
+ if (color[i].isnumeric()) or (color[i] in hexCharacters) :
+ tempValue += color[i]
+ else :
+ tempValue = ''
+ if len(tempValue) == 6 :
+ extractedValues.append(tempValue)
+ tempValue = ''
+ if len(extractedValues) == numValues :
+ break
+ i = i + 1
+
+ if (len(extractedValues) != numValues) and (len(tempValue) == 6) :
+ extractedValues.append(tempValue)
+
+ else :
+ # search for decimal values
+ while i < len(color) :
+ if color[i].isnumeric() or color[i] == '.' :
+ tempValue += color[i]
+ elif len(tempValue) > 0 :
+ extractedValues.append(tempValue)
+ tempValue = ''
+ if len(extractedValues) == numValues :
+ break
+ i = i + 1
+
+ if (len(extractedValues) != numValues) and (len(tempValue) > 0) :
+ extractedValues.append(tempValue)
+
+ if len(extractedValues) != numValues :
+ print(f'Could not extract the desired number of values from input. Values requested: {numValues}, values extracted: {len(extractedValues)}, {extractedValues}')
+ return False
+
+ print(extractedValues)
+ return
+
+def main() :
+
+ # hexcolor1 = '123abc'
+ # hexcolor2 = 'zx123abc def654'
+ # hexcolor3 = 'test sentence with hex in it: 123456, 654321, abc123, aefacd'
+
+ # extractValues(hexcolor1, 1, True)
+ # extractValues(hexcolor2, 1, True)
+ # extractValues(hexcolor2, 2, True)
+ # extractValues(hexcolor3, 4, True)
+
+ color1 = 'cmy(123, ba12.4, 51 )'
+ color2 = 't3st 123 456'
+ color3 = '1.23 word 3,2 1.34'
+
+ extractValues(color1, 3)
+
+
+
+if __name__ == '__main__' :
+ main() \ No newline at end of file