lyrpy 2024.0.4__py3-none-any.whl → 2025.0.2__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 lyrpy might be problematic. Click here for more details.

Files changed (149) hide show
  1. SRC/LIB/__init__.py +21 -0
  2. SRC/LIB/lyrpy/LUConst.py +358 -0
  3. {lyrpy → SRC/LIB/lyrpy}/LUDateTime.py +2 -4
  4. {lyrpy → SRC/LIB/lyrpy}/LUDecotators.py +2 -3
  5. {lyrpy → SRC/LIB/lyrpy}/LUDict.py +0 -1
  6. {lyrpy → SRC/LIB/lyrpy}/LUDoc.py +4 -3
  7. {lyrpy → SRC/LIB/lyrpy}/LUErrors.py +0 -1
  8. {lyrpy → SRC/LIB/lyrpy}/LUFile.py +115 -61
  9. {lyrpy → SRC/LIB/lyrpy}/LUFileUtils.py +60 -45
  10. {lyrpy → SRC/LIB/lyrpy}/LULog.py +267 -191
  11. {lyrpy → SRC/LIB/lyrpy}/LUObjects.py +4 -4
  12. {lyrpy → SRC/LIB/lyrpy}/LUObjectsYT.py +39 -22
  13. {lyrpy → SRC/LIB/lyrpy}/LUParserARG.py +2 -3
  14. {lyrpy → SRC/LIB/lyrpy}/LUParserINI.py +8 -3
  15. {lyrpy → SRC/LIB/lyrpy}/LUParserREG.py +5 -1
  16. {lyrpy → SRC/LIB/lyrpy}/LUQThread.py +6 -4
  17. {lyrpy → SRC/LIB/lyrpy}/LUQTimer.py +5 -5
  18. {lyrpy → SRC/LIB/lyrpy}/LUSheduler.py +24 -23
  19. SRC/LIB/lyrpy/LUTelegram.py +428 -0
  20. {lyrpy → SRC/LIB/lyrpy}/LUThread.py +7 -6
  21. {lyrpy → SRC/LIB/lyrpy}/LUTimer.py +5 -3
  22. {lyrpy → SRC/LIB/lyrpy}/LUVersion.py +4 -1
  23. {lyrpy → SRC/LIB/lyrpy}/LUYouTube.py +6 -7
  24. {lyrpy → SRC/LIB/lyrpy}/LUos.py +13 -3
  25. SRC/LIB/lyrpy/__init__.py +21 -0
  26. {lyrpy → SRC/LIB/lyrpy}/__main__.py +20 -19
  27. SRC/__init__.py +0 -0
  28. SRC/lyrpy/LUConsole.py +402 -0
  29. SRC/lyrpy/LUConst.py +358 -0
  30. SRC/lyrpy/LUDateTime.py +205 -0
  31. SRC/lyrpy/LUDecotators.py +417 -0
  32. SRC/lyrpy/LUDict.py +116 -0
  33. SRC/lyrpy/LUDoc.py +62 -0
  34. SRC/lyrpy/LUErrors.py +79 -0
  35. SRC/lyrpy/LUFile.py +1228 -0
  36. SRC/lyrpy/LUFileUtils.py +501 -0
  37. SRC/lyrpy/LULog.py +2324 -0
  38. SRC/lyrpy/LUNetwork.py +277 -0
  39. SRC/lyrpy/LUNumUtils.py +305 -0
  40. SRC/lyrpy/LUObjects.py +208 -0
  41. SRC/lyrpy/LUObjectsYT.py +846 -0
  42. SRC/lyrpy/LUParserARG.py +364 -0
  43. SRC/lyrpy/LUParserINI.py +376 -0
  44. SRC/lyrpy/LUParserREG.py +514 -0
  45. SRC/lyrpy/LUProc.py +110 -0
  46. SRC/lyrpy/LUQThread.py +141 -0
  47. SRC/lyrpy/LUQTimer.py +197 -0
  48. SRC/lyrpy/LUSheduler.py +941 -0
  49. SRC/lyrpy/LUStrDecode.py +223 -0
  50. SRC/lyrpy/LUStrUtils.py +633 -0
  51. SRC/lyrpy/LUSupport.py +124 -0
  52. SRC/lyrpy/LUTelegram.py +428 -0
  53. SRC/lyrpy/LUThread.py +177 -0
  54. SRC/lyrpy/LUTimer.py +141 -0
  55. SRC/lyrpy/LUVersion.py +383 -0
  56. SRC/lyrpy/LUYouTube.py +203 -0
  57. SRC/lyrpy/LUos.py +807 -0
  58. lyrpy/LUConst.py → SRC/lyrpy/LUsys.py +12 -10
  59. SRC/lyrpy/__init__.py +21 -0
  60. lyrpy/__init__.py → SRC/lyrpy/__main__.py +2 -3
  61. TESTS/__init__.py +0 -0
  62. TESTS/test_lyrpy.py +4 -0
  63. TESTS/test_main.py +10 -0
  64. __SRC/LIB/__init__.py +0 -0
  65. __SRC/LIB/lyrpy/LUConsole.py +402 -0
  66. __SRC/LIB/lyrpy/LUConst.py +358 -0
  67. __SRC/LIB/lyrpy/LUDateTime.py +205 -0
  68. __SRC/LIB/lyrpy/LUDecotators.py +417 -0
  69. __SRC/LIB/lyrpy/LUDict.py +116 -0
  70. __SRC/LIB/lyrpy/LUDoc.py +62 -0
  71. __SRC/LIB/lyrpy/LUErrors.py +79 -0
  72. __SRC/LIB/lyrpy/LUFile.py +1228 -0
  73. __SRC/LIB/lyrpy/LUFileUtils.py +501 -0
  74. __SRC/LIB/lyrpy/LULog.py +2324 -0
  75. __SRC/LIB/lyrpy/LUNetwork.py +277 -0
  76. __SRC/LIB/lyrpy/LUNumUtils.py +305 -0
  77. __SRC/LIB/lyrpy/LUObjects.py +208 -0
  78. __SRC/LIB/lyrpy/LUObjectsYT.py +846 -0
  79. __SRC/LIB/lyrpy/LUParserARG.py +364 -0
  80. __SRC/LIB/lyrpy/LUParserINI.py +376 -0
  81. __SRC/LIB/lyrpy/LUParserREG.py +514 -0
  82. __SRC/LIB/lyrpy/LUProc.py +110 -0
  83. __SRC/LIB/lyrpy/LUQThread.py +141 -0
  84. __SRC/LIB/lyrpy/LUQTimer.py +197 -0
  85. __SRC/LIB/lyrpy/LUSheduler.py +941 -0
  86. __SRC/LIB/lyrpy/LUStrDecode.py +223 -0
  87. __SRC/LIB/lyrpy/LUStrUtils.py +633 -0
  88. __SRC/LIB/lyrpy/LUSupport.py +124 -0
  89. __SRC/LIB/lyrpy/LUTelegram.py +428 -0
  90. __SRC/LIB/lyrpy/LUThread.py +177 -0
  91. __SRC/LIB/lyrpy/LUTimer.py +141 -0
  92. __SRC/LIB/lyrpy/LUVersion.py +383 -0
  93. __SRC/LIB/lyrpy/LUYouTube.py +203 -0
  94. __SRC/LIB/lyrpy/LUos.py +807 -0
  95. __SRC/LIB/lyrpy/LUsys.py +47 -0
  96. __SRC/LIB/lyrpy/__init__.py +21 -0
  97. __SRC/LIB/lyrpy/__main__.py +20 -0
  98. __SRC/__init__.py +0 -0
  99. ____src/__init__.py +0 -0
  100. ____src/lyrpy/LUConsole.py +402 -0
  101. ____src/lyrpy/LUConst.py +358 -0
  102. ____src/lyrpy/LUDateTime.py +205 -0
  103. ____src/lyrpy/LUDecotators.py +417 -0
  104. ____src/lyrpy/LUDict.py +116 -0
  105. ____src/lyrpy/LUDoc.py +62 -0
  106. ____src/lyrpy/LUErrors.py +79 -0
  107. ____src/lyrpy/LUFile.py +1228 -0
  108. ____src/lyrpy/LUFileUtils.py +501 -0
  109. ____src/lyrpy/LULog.py +2324 -0
  110. ____src/lyrpy/LUNetwork.py +277 -0
  111. ____src/lyrpy/LUNumUtils.py +305 -0
  112. ____src/lyrpy/LUObjects.py +208 -0
  113. ____src/lyrpy/LUObjectsYT.py +846 -0
  114. ____src/lyrpy/LUParserARG.py +364 -0
  115. ____src/lyrpy/LUParserINI.py +376 -0
  116. ____src/lyrpy/LUParserREG.py +514 -0
  117. ____src/lyrpy/LUProc.py +110 -0
  118. ____src/lyrpy/LUQThread.py +141 -0
  119. ____src/lyrpy/LUQTimer.py +197 -0
  120. ____src/lyrpy/LUSheduler.py +941 -0
  121. ____src/lyrpy/LUStrDecode.py +223 -0
  122. ____src/lyrpy/LUStrUtils.py +633 -0
  123. ____src/lyrpy/LUSupport.py +124 -0
  124. ____src/lyrpy/LUTelegram.py +428 -0
  125. ____src/lyrpy/LUThread.py +177 -0
  126. ____src/lyrpy/LUTimer.py +141 -0
  127. ____src/lyrpy/LUVersion.py +383 -0
  128. ____src/lyrpy/LUYouTube.py +203 -0
  129. ____src/lyrpy/LUos.py +807 -0
  130. ____src/lyrpy/LUsys.py +47 -0
  131. ____src/lyrpy/__init__.py +21 -0
  132. ____src/lyrpy/__main__.py +20 -0
  133. lyrpy-2025.0.2.dist-info/METADATA +21 -0
  134. lyrpy-2025.0.2.dist-info/RECORD +145 -0
  135. {lyrpy-2024.0.4.dist-info → lyrpy-2025.0.2.dist-info}/WHEEL +1 -1
  136. lyrpy-2025.0.2.dist-info/top_level.txt +2 -0
  137. lyrpy-2024.0.4.data/data/data/text.txt +0 -1
  138. lyrpy-2024.0.4.dist-info/METADATA +0 -44
  139. lyrpy-2024.0.4.dist-info/RECORD +0 -38
  140. lyrpy-2024.0.4.dist-info/top_level.txt +0 -1
  141. {lyrpy → SRC/LIB/lyrpy}/LUConsole.py +0 -0
  142. {lyrpy → SRC/LIB/lyrpy}/LUNetwork.py +0 -0
  143. {lyrpy → SRC/LIB/lyrpy}/LUNumUtils.py +0 -0
  144. {lyrpy → SRC/LIB/lyrpy}/LUProc.py +0 -0
  145. {lyrpy → SRC/LIB/lyrpy}/LUStrDecode.py +0 -0
  146. {lyrpy → SRC/LIB/lyrpy}/LUStrUtils.py +0 -0
  147. {lyrpy → SRC/LIB/lyrpy}/LUSupport.py +0 -0
  148. {lyrpy → SRC/LIB/lyrpy}/LUsys.py +0 -0
  149. {lyrpy-2024.0.4.dist-info → lyrpy-2025.0.2.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,633 @@
1
+ """LUStrUtils.py"""
2
+ # -*- coding: UTF-8 -*-
3
+ __annotations__ = """
4
+ =======================================================
5
+ Copyright (c) 2023-2024
6
+ Author:
7
+ Lisitsin Y.R.
8
+ Project:
9
+ LU_PY
10
+ Python (LU)
11
+ Module:
12
+ LUStrUtils.py
13
+
14
+ =======================================================
15
+ """
16
+
17
+ #------------------------------------------
18
+ # БИБЛИОТЕКИ python
19
+ #------------------------------------------
20
+ import string
21
+ import codecs
22
+
23
+ #------------------------------------------
24
+ # БИБЛИОТЕКИ сторонние
25
+ #------------------------------------------
26
+
27
+ #------------------------------------------
28
+ # БИБЛИОТЕКИ LU
29
+ #------------------------------------------
30
+
31
+ #---------------------------------------------------------------
32
+ #
33
+ #---------------------------------------------------------------
34
+
35
+ """
36
+ # #import codecs
37
+ #
38
+ # f = codecs.open(filename, 'r', 'cp1251')
39
+ # u = f.read() # now the contents have been transformed to a Unicode string
40
+ # out = codecs.open(output, 'w', 'utf-8')
41
+ # out.write(u) # and now the contents have been output as UTF-8
42
+ """
43
+
44
+ CRLFd = chr(13)+chr(10)
45
+ CRLFx = '\x0d'+'\x0a'
46
+ CRLF = '\r'+'\n'
47
+ """
48
+ \n Newline
49
+ \r Carriage Return
50
+ \r\n Carriage Return + Line Feed
51
+ \v or \x0b Line Tabulation
52
+ \f or \x0c Form Feed
53
+ \x1c File Separator
54
+ \x1d Group Separator
55
+ \x1e Record Separator
56
+ \x85 Next Line (C1 Control Code)
57
+ \u2028 Unicode Line Separator
58
+ \u2029 Unicode Paragraph Separator
59
+ """
60
+
61
+ #---------------------------------------------------------------
62
+ #
63
+ #---------------------------------------------------------------
64
+ TSysCharSet = ()
65
+ TCharSet = ()
66
+
67
+ """
68
+ (vi) Коллекции литералов: коллекции литералов в python включают список, кортеж, словарь и наборы.
69
+ Список []:
70
+ это список элементов, представленных в квадратных скобках с запятыми между ними.
71
+ Эти переменные могут иметь любой тип данных и также могут быть изменены.
72
+ Кортеж ():
73
+ это также список элементов или значений, разделенных запятыми, в круглых скобках.
74
+ Значения могут быть любого типа данных, но не могут быть изменены.
75
+ Словарь {}:
76
+ это неупорядоченный набор пар ключ-значение.
77
+ Set {}:
78
+ это неупорядоченный набор элементов в фигурных скобках ‘{}’.
79
+ """
80
+
81
+ """
82
+ String Operators
83
+ + Operator
84
+ * Operator
85
+ in Operator
86
+ Built-in String Functions
87
+ chr() Converts an integer to a character
88
+ ord() Converts a character to an integer
89
+ len() Returns the length of a string
90
+ str() Returns a string representation of an object
91
+ String Indexing
92
+ 0 1 2 3 4 5
93
+ -6 -5 -4 -3 -2 -1
94
+ String Slicing (Нарезка строк)
95
+ s[2:5]
96
+ Specifying a Stride in a String Slice (Указание шага в фрагменте строки)
97
+ [0:6:2]
98
+ Interpolating Variables Into a String (Интерполяция переменных в строку)
99
+ f'A dog says {var}!'
100
+ Modifying Strings (Изменение строк)
101
+ s = 'foobar'
102
+ s[3] = 'x' не правильно
103
+ s = s[:3] + 'x' + s[4:] правильно
104
+ s = s.replace('b', 'x') правильно
105
+ Built-in String Methods
106
+ Case Conversion
107
+ s.capitalize()
108
+ returns a copy of s with the first character converted to uppercase and all other characters converted to lowercase:
109
+ s.lower()
110
+ returns a copy of s with all alphabetic characters converted to lowercase:
111
+ s.swapcase()
112
+ returns a copy of s with uppercase alphabetic characters converted to lowercase and vice versa:
113
+ s.title()
114
+ returns a copy of s in which the first letter of each word is converted to uppercase and remaining letters are lowercase:
115
+ s.upper()
116
+ returns a copy of s with all alphabetic characters converted to uppercase:
117
+ Find and Replace
118
+ s.count(<sub>[, <start>[, <end>]])
119
+ returns the number of non-overlapping occurrences of substring <sub> in s:
120
+ s.endswith(<suffix>[, <start>[, <end>]])
121
+ returns True if s ends with the specified <suffix> and False otherwise:
122
+ s.find(<sub>[, <start>[, <end>]])
123
+ You can use .find() to see if a Python string contains a particular substring. s.find(<sub>) returns the lowest index in s where substring <sub> is found:
124
+ s.index(<sub>[, <start>[, <end>]])
125
+ This method is identical to .find(), except that it raises an exception if <sub> is not found rather than returning -1:
126
+ s.rfind(<sub>[, <start>[, <end>]])
127
+ returns the highest index in s where substring <sub> is found:
128
+ s.rindex(<sub>[, <start>[, <end>]])
129
+ This method is identical to .rfind(), except that it raises an exception if <sub> is not found rather than returning -1:
130
+ s.startswith(<prefix>[, <start>[, <end>]])
131
+ When you use the Python .startswith() method, s.startswith(<suffix>) returns True if s starts with the specified <suffix> and False otherwise:
132
+ Character Classification
133
+ s.isalnum()
134
+ returns True if s is nonempty and all its characters are alphanumeric (either a letter or a number), and False
135
+ s.isalpha()
136
+ returns True if s is nonempty and all its characters are alphabetic, and False otherwise:
137
+ s.isdigit()
138
+ You can use the .isdigit() Python method to check if your string is made of only digits. s.isdigit() returns True if s is nonempty and all its characters are numeric digits, and False otherwise:
139
+ s.isidentifier()
140
+ returns True if s is a valid Python identifier according to the language definition, and False otherwise:
141
+ s.islower()
142
+ returns True if s is nonempty and all the alphabetic characters it contains are lowercase, and False otherwise. Non-alphabetic characters are ignored:
143
+ s.isprintable()
144
+ returns True if s is empty or all the alphabetic characters it contains are printable. It returns False if s contains at least one non-printable character. Non-alphabetic characters are ignored:
145
+ s.isspace()
146
+ returns True if s is nonempty and all characters are whitespace characters, and False otherwise.
147
+ s.istitle() returns True if s is nonempty, the first alphabetic character of each word is uppercase, and all other alphabetic characters in each word are lowercase. It returns False otherwise:
148
+ s.isupper() returns True if s is nonempty and all the alphabetic characters it contains are uppercase, and False otherwise. Non-alphabetic characters are ignored:
149
+ String Formatting
150
+ s.center(<width>[, <fill>])
151
+ returns a string consisting of s centered in a field of width <width>. By default, padding consists of the ASCII space character:
152
+ s.expandtabs(tabsize=8)
153
+ replaces each tab character ('\t') with spaces. By default, spaces are filled in assuming a tab stop at every eighth column:
154
+ s.ljust(<width>[, <fill>])
155
+ returns a string consisting of s left-justified in a field of width <width>. By default, padding consists of the ASCII space character:
156
+ s.lstrip([<chars>])
157
+ returns a copy of s with any whitespace characters removed from the left end:
158
+ s.replace(<old>, <new>[, <count>])
159
+ In Python, to remove a character from a string, you can use the Python string .replace() method. s.replace(<old>, <new>) returns a copy of s with all occurrences of substring <old> replaced by <new>:
160
+ s.rjust(<width>[, <fill>])
161
+ returns a string consisting of s right-justified in a field of width <width>. By default, padding consists of the ASCII space character:
162
+ s.rstrip([<chars>])
163
+ returns a copy of s with any whitespace characters removed from the right end:
164
+ s.strip([<chars>])
165
+ is essentially equivalent to invoking s.lstrip() and s.rstrip() in succession. Without the <chars> argument, it removes leading and trailing whitespace:
166
+ s.zfill(<width>)
167
+ returns a copy of s left-padded with '0' characters to the specified <width>:
168
+ Converting Between Strings and Lists
169
+ s.join(<iterable>)
170
+ returns the string that results from concatenating the objects in <iterable> separated by s.
171
+ s.partition(<sep>)
172
+ splits s at the first occurrence of string <sep>. The return value is a three-part tuple consisting of:
173
+ s.rpartition(<sep>)
174
+ functions exactly like s.partition(<sep>), except that s is split at the last occurrence of <sep> instead of the first occurrence:
175
+ s.rsplit(sep=None, maxsplit=-1)
176
+ Without arguments, s.rsplit() splits s into substrings delimited by any sequence of whitespace and returns the substrings as a list:
177
+ s.split(sep=None, maxsplit=-1)
178
+ behaves exactly like s.rsplit(), except that if <maxsplit> is specified, splits are counted from the left end of s rather than the right end:
179
+ s.splitlines([<keepends>])
180
+ splits s up into lines and returns them in a list. Any of the following characters or character sequences is considered to constitute a line boundary:
181
+ bytes Objects
182
+ Defining a Literal bytes Object
183
+ b = b'foo bar baz'
184
+ type(b)
185
+ The 'r' prefix may be used on a bytes literal to disable processing of escape sequences, as with strings:
186
+ b = rb'foo\xddbar'
187
+ >>> b
188
+ b'foo\\xddbar'
189
+ Defining a bytes Object With the Built-in bytes() Function
190
+ bytes(<s>, <encoding>)
191
+ converts string <s> to a bytes object, using str.encode() according to the specified <encoding>
192
+ bytes(<size>)
193
+ defines a bytes object of the specified <size>, which must be a positive integer. The resulting bytes object is initialized to null (0x00) bytes:
194
+ bytes(<iterable>)
195
+ defines a bytes object from the sequence of integers generated by <iterable>. <iterable> must be an iterable that generates a sequence of integers n in the range 0 ≤ n ≤ 255:
196
+ Operations on bytes Objects
197
+ The in and not in operators:
198
+ The concatenation (+) and replication (*) operators:
199
+ Indexing and slicing:
200
+ >>> b = b'abcde'
201
+ >>> b[2]
202
+ 99
203
+ >>> b[1:3]
204
+ b'bc'
205
+ Built-in functions:
206
+ len(b)
207
+ min(b)
208
+ max(b)
209
+ bytes.fromhex(<s>)
210
+ returns the bytes object that results from converting each pair of hexadecimal digits in <s> to the corresponding byte value. The hexadecimal digit pairs in <s> may optionally be separated by whitespace, which is ignored:
211
+ b.hex()
212
+ returns the result of converting bytes object b into a string of hexadecimal digit pairs. That is, it does the reverse of .fromhex():
213
+ bytearray Objects
214
+ There is no dedicated syntax built into Python for defining a bytearray literal, like the 'b' prefix that may be used to define a bytes object. A bytearray object is always created using the bytearray() built-in function:
215
+ ba = bytearray('foo.bar.baz', 'UTF-8')
216
+ bytearray(6)
217
+ bytearray(b'\x00\x00\x00\x00\x00\x00')
218
+ bytearray([100, 102, 104, 106, 108])
219
+ bytearray(b'dfhjl')
220
+ bytearray objects are mutable. You can modify the contents of a bytearray object using indexing and slicing:
221
+
222
+ """
223
+ # Алфавиты: все заглавные (A-Z) и строчные (a-z) алфавиты.
224
+
225
+ # Цифры: все цифры 0-9.
226
+ cDigitChars = tuple(string.digits)
227
+ cBrackets = ('(', ')', '[', ']', '{', '}')
228
+ # Специальные символы (пунктуация) ” ‘ l ; : ! ~ @ # $ % ^ ` & * ( ) _ + – = { } [ ] \ .
229
+ cWordDelimitersFull = tuple(string.punctuation)
230
+ cWordDelimiters = ('|', ';')
231
+ cWordDelimiter = '|'
232
+
233
+ #---------------------------------------------------------------
234
+ # PrintableStr
235
+ #---------------------------------------------------------------
236
+ def PrintableStr(s: str) -> str:
237
+ return ''.join(c for c in s if c.isalpha()
238
+ or c.isnumeric() or c.isspace()
239
+ or c in string.printable
240
+ )
241
+
242
+ #---------------------------------------------------------------
243
+ # MakeStr return a string of length N filled with character C. }
244
+ #---------------------------------------------------------------
245
+ def MakeStr (C: str, N: int) -> str:
246
+ """MakeStr"""
247
+ #beginfunction
248
+ LResult = ''
249
+ if (len(C)==1) and (N > 0) and (N < 255):
250
+ LResult = C*N
251
+ return LResult
252
+ #endfunction
253
+
254
+ #---------------------------------------------------------------
255
+ # CharFromSet
256
+ #---------------------------------------------------------------
257
+ def CharFromSet (C: TCharSet) -> str:
258
+ """CharFromSet"""
259
+ #beginfunction
260
+ for i in range(0,255,1):
261
+ if chr(i) in C:
262
+ return chr(i)
263
+ #endif
264
+ #endfor
265
+ return '?'
266
+ #endfunction
267
+
268
+ #--------------------------------------------------------------------
269
+ # AddChar
270
+ #--------------------------------------------------------------------
271
+ def AddChar (APad, AInput, ALength) -> str:
272
+ """AddChar"""
273
+ #beginfunction
274
+ x = len (AInput)
275
+ for i in range (x, ALength, len (APad)):
276
+ AInput = APad + AInput
277
+ #endfor
278
+ LAddChar = AInput
279
+ return LAddChar
280
+ #endfunction
281
+
282
+ #--------------------------------------------------------------------
283
+ # AddCharR
284
+ #--------------------------------------------------------------------
285
+ def AddCharR (APad, AInput, ALength):
286
+ """AddCharR"""
287
+ #beginfunction
288
+ x = len (AInput)
289
+ for i in range (x, ALength, len (APad)):
290
+ AInput = AInput + APad
291
+ #endfor
292
+ LAddCharR = AInput
293
+ return LAddCharR
294
+ #endfunction
295
+
296
+ #---------------------------------------------------------------
297
+ # Trim
298
+ #---------------------------------------------------------------
299
+ def Trim (s: str) -> str:
300
+ """Trim"""
301
+ #beginfunction
302
+ return s.strip()
303
+ #endfunction
304
+
305
+ #---------------------------------------------------------------
306
+ # TrimL
307
+ #---------------------------------------------------------------
308
+ def TrimL (s: str) -> str:
309
+ """TrimL"""
310
+ #beginfunction
311
+ return s.lstrip()
312
+ #endfunction
313
+
314
+ #---------------------------------------------------------------
315
+ # TrimR
316
+ #---------------------------------------------------------------
317
+ def TrimR (s: str) -> str:
318
+ """TrimR"""
319
+ #beginfunction
320
+ return s.rstrip()
321
+ #endfunction
322
+
323
+ #---------------------------------------------------------------
324
+ # TrimChar
325
+ #---------------------------------------------------------------
326
+ def TrimChar (s: str, c: str) -> str:
327
+ """TrimChar"""
328
+ #beginfunction
329
+ return s.strip (c)
330
+ #endfunction
331
+
332
+ #---------------------------------------------------------------
333
+ # TrimCharL
334
+ #---------------------------------------------------------------
335
+ def TrimCharL (s: str, c: str) -> str:
336
+ """TrimCharL"""
337
+ #beginfunction
338
+ return s.lstrip (c)
339
+ #endfunction
340
+
341
+ #---------------------------------------------------------------
342
+ # TrimCharR
343
+ #---------------------------------------------------------------
344
+ def TrimCharR (s: str, c: str) -> str:
345
+ """TrimCharR"""
346
+ #beginfunction
347
+ return s.rstrip (c)
348
+ #endfunction
349
+
350
+ #--------------------------------------------------------------------
351
+ # WordCount
352
+ #--------------------------------------------------------------------
353
+ def WordCount (AString: str, AWordDelims) -> int:
354
+ """WordCount"""
355
+ #beginfunction
356
+ LArray = AString.split (AWordDelims)
357
+ LWordCount = len (LArray)
358
+ return LWordCount
359
+ #endfunction
360
+
361
+ #--------------------------------------------------------------------
362
+ # ExtractWord
363
+ #--------------------------------------------------------------------
364
+ def ExtractWord (i: int, AString: str, AWordDelims):
365
+ """ExtractWord"""
366
+ #beginfunction
367
+ LArray = AString.split (AWordDelims)
368
+ if (i > 0) and (i <= len(LArray) + 1):
369
+ try:
370
+ LExtractWord = LArray [i-1]
371
+ except IndexError as ERROR:
372
+ LExtractWord = ""
373
+ ...
374
+ else:
375
+ LExtractWord = ""
376
+ #endif
377
+ return LExtractWord
378
+ #endfunction
379
+
380
+ #--------------------------------------------------------------------
381
+ # ExistWord
382
+ #--------------------------------------------------------------------
383
+ def ExistWord (AString: str, AWordDelims, AWord: str):
384
+ """ExistWord"""
385
+ #beginfunction
386
+ n = WordCount (AString, AWordDelims)
387
+ for i in range (1, n+1, 1):
388
+ s = ExtractWord (i, AString, AWordDelims)
389
+ if AWord.upper() == s.upper ():
390
+ return True
391
+ #endif
392
+ #endfor
393
+ return False
394
+ #endfunction
395
+
396
+ #---------------------------------------------------------------
397
+ # GetParamFromString
398
+ #---------------------------------------------------------------
399
+ def GetParamFromString (AParamName: str, AParamValues: str,
400
+ AParamNames: (), AWordDelims: TCharSet) -> str:
401
+ """GetParamFromString"""
402
+ #beginfunction
403
+ LResult = ''
404
+ i = 0
405
+ for ParamName in AParamNames:
406
+ i = i + 1
407
+ if ParamName.upper() == AParamName.upper():
408
+ LResult = Trim (ExtractWord (i, AParamValues, AWordDelims))
409
+ return LResult
410
+ #endif
411
+ #endfor
412
+ return LResult
413
+ #endfunction
414
+
415
+ #---------------------------------------------------------------
416
+ # SetParamToString
417
+ #---------------------------------------------------------------
418
+ def SetParamToString (AParamName: str, AParamValues: str,
419
+ AParamNames: (), AWordDelims: TCharSet, AValue: str):
420
+ """SetParamToString"""
421
+ #beginfunction
422
+ LStroka = AParamValues
423
+ s = ''
424
+ i = 0
425
+ for ParamName in AParamNames:
426
+ i = i + 1
427
+ if ParamName.upper() == AParamName.upper():
428
+ s = s + AValue
429
+ else:
430
+ s = s + ExtractWord (i, LStroka, AWordDelims)
431
+ #endif
432
+ if i != len(AParamNames):
433
+ s = s + CharFromSet (AWordDelims)
434
+ #endif
435
+ #endfor
436
+ return s
437
+ #endfunction
438
+
439
+ #---------------------------------------------------------------
440
+ # DelChars
441
+ #---------------------------------------------------------------
442
+ def DelChars (s: str, c: str) -> str:
443
+ """DelChars"""
444
+ #beginfunction
445
+ LResult = s.replace(c, '')
446
+ return LResult
447
+ #endfunction
448
+
449
+ #---------------------------------------------------------------
450
+ # DelSpace
451
+ #---------------------------------------------------------------
452
+ def DelSpaces (s: str) -> str:
453
+ """DelSpaces"""
454
+ #beginfunction
455
+ LResult = DelChars(s, ' ')
456
+ return LResult
457
+ #endfunction
458
+
459
+ #---------------------------------------------------------------
460
+ # ReplaceChars
461
+ #---------------------------------------------------------------
462
+ def ReplaceChars (s, sOld, sNew: str) -> str:
463
+ """ReplaceChars"""
464
+ #beginfunction
465
+ LResult = s.replace (sOld, sNew)
466
+ return LResult
467
+ #endfunction
468
+
469
+ #---------------------------------------------------------------
470
+ # CenterStr
471
+ #---------------------------------------------------------------
472
+ def CenterStr (s: str, c: str, ALen: int) -> str:
473
+ """CenterStr"""
474
+ #beginfunction
475
+ return s.center (len(s)+ALen, c)
476
+ #endfunction
477
+
478
+ #---------------------------------------------------------------
479
+ # strtobool
480
+ #---------------------------------------------------------------
481
+ def strtobool (val: str):
482
+ """Convert a string representation of truth to true (1) or false (0).
483
+ True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
484
+ are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
485
+ 'val' is anything else.
486
+ """
487
+ #beginfunction
488
+ if val.lower() in ('y', 'yes', 't', 'true', 'on', '1'):
489
+ return 1
490
+ elif val.lower() in ('n', 'no', 'f', 'false', 'off', '0'):
491
+ return 0
492
+ else:
493
+ raise ValueError("invalid truth value %r" % (val,))
494
+ #endif
495
+ #endfunction
496
+
497
+ #---------------------------------------------------------------
498
+ # booltostr
499
+ #---------------------------------------------------------------
500
+ def booltostr (val: bool) -> str:
501
+ """booltostr"""
502
+ #beginfunction
503
+ if val:
504
+ return '1'
505
+ else:
506
+ return '0'
507
+ #endif
508
+ #endfunction
509
+
510
+ """
511
+ function IsWild (InputStr, Wilds: string; IgnoreCase: Boolean): Boolean;
512
+
513
+ function SearchNext (var Wilds: string): Integer;
514
+ { looking for next *, returns position and string until position }
515
+ begin
516
+ Result := Pos ('*', Wilds);
517
+ if Result > 0 then
518
+ Wilds := Copy (Wilds, 1, Result - 1);
519
+ end;
520
+
521
+ var
522
+ CWild, CInputWord: Integer; { counter for positions }
523
+ I, LenHelpWilds: Integer;
524
+ MaxInputWord, MaxWilds: Integer; { Length of InputStr and Wilds }
525
+ HelpWilds: string;
526
+ begin
527
+ if Wilds = InputStr then
528
+ begin
529
+ Result := True;
530
+ Exit;
531
+ end;
532
+ repeat { delete '**', because '**' = '*' }
533
+ I := Pos ('**', Wilds);
534
+ if I > 0 then
535
+ Wilds := Copy (Wilds, 1, I - 1) + '*' + Copy (Wilds, I + 2, MaxInt);
536
+ until I = 0;
537
+ if Wilds = '*' then
538
+ begin { for fast end, if Wilds only '*' }
539
+ Result := True;
540
+ Exit;
541
+ end;
542
+ MaxInputWord := Length (InputStr);
543
+ MaxWilds := Length (Wilds);
544
+ if IgnoreCase then
545
+ begin { upcase all letters }
546
+ InputStr := AnsiUpperCase (InputStr);
547
+ Wilds := AnsiUpperCase (Wilds);
548
+ end;
549
+ if (MaxWilds = 0) or (MaxInputWord = 0) then
550
+ begin
551
+ Result := False;
552
+ Exit;
553
+ end;
554
+ CInputWord := 1;
555
+ CWild := 1;
556
+ Result := True;
557
+ repeat
558
+ if InputStr[CInputWord] = Wilds[CWild] then
559
+ begin { equal letters }
560
+ { goto next letter }
561
+ Inc (CWild);
562
+ Inc (CInputWord);
563
+ Continue;
564
+ end;
565
+ if Wilds[CWild] = '?' then
566
+ begin { equal to '?' }
567
+ { goto next letter }
568
+ Inc (CWild);
569
+ Inc (CInputWord);
570
+ Continue;
571
+ end;
572
+ if Wilds[CWild] = '*' then
573
+ begin { handling of '*' }
574
+ HelpWilds := Copy (Wilds, CWild + 1, MaxWilds);
575
+ I := SearchNext (HelpWilds);
576
+ LenHelpWilds := Length (HelpWilds);
577
+ if I = 0 then
578
+ begin
579
+ { no '*' in the rest, compare the ends }
580
+ if HelpWilds = '' then
581
+ Exit; { '*' is the last letter }
582
+ { check the rest for equal Length and no '?' }
583
+ for I := 0 to LenHelpWilds - 1 do
584
+ begin
585
+ if (HelpWilds[LenHelpWilds - I] <> InputStr
586
+ [MaxInputWord - I]) and
587
+ (HelpWilds[LenHelpWilds - I] <> '?') then
588
+ begin
589
+ Result := False;
590
+ Exit;
591
+ end;
592
+ end;
593
+ Exit;
594
+ end;
595
+ { handle all to the next '*' }
596
+ Inc (CWild, 1 + LenHelpWilds);
597
+ I := FindPart (HelpWilds, Copy(InputStr, CInputWord, MaxInt));
598
+ if I = 0 then
599
+ begin
600
+ Result := False;
601
+ Exit;
602
+ end;
603
+ CInputWord := I + LenHelpWilds;
604
+ Continue;
605
+ end;
606
+ Result := False;
607
+ Exit;
608
+ until (CInputWord > MaxInputWord) or (CWild > MaxWilds);
609
+ { no completed evaluation }
610
+ if CInputWord <= MaxInputWord then
611
+ Result := False;
612
+ if (CWild <= MaxWilds) and (Wilds[MaxWilds] <> '*') then
613
+ Result := False;
614
+ end;
615
+ """
616
+
617
+ #---------------------------------------------------------
618
+ # main
619
+ #---------------------------------------------------------
620
+ def main ():
621
+ #beginfunction
622
+ ...
623
+ #endfunction
624
+
625
+ #---------------------------------------------------------
626
+ #
627
+ #---------------------------------------------------------
628
+ #beginmodule
629
+ if __name__ == "__main__":
630
+ main()
631
+ #endif
632
+
633
+ #endmodule