|
12 | 12 | from tkinter.filedialog import askdirectory |
13 | 13 | #from tkinter.messagebox import askyesno |
14 | 14 | kritaHomeDir = "" |
15 | | -savedConfig = tempfile.gettempdir()+"/kritaHomeDirSave.py" |
| 15 | +savedConfig = os.path.join(tempfile.gettempdir(), 'kritaHomeDirSave.py') |
16 | 16 | if os.path.isfile(savedConfig): |
17 | | -# isToLoadSavedConfig = askyesno("use previous config", f"Krita source path config was found in {savedConfig}, would you like to use it?") |
| 17 | +# isToLoadSavedConfig = askyesno("found previous config", f"Krita source path config was found in {savedConfig}, would you like to use it?") |
18 | 18 | # if isToLoadSavedConfig: |
19 | 19 | m = SourceFileLoader("myModule", savedConfig).load_module() |
20 | 20 | kritaHomeDir = getattr(m, "kritaHomeDir") |
|
221 | 221 | indentspace = indentspace0 |
222 | 222 |
|
223 | 223 |
|
224 | | - |
225 | | - exportFile.write(f"{indentspace}\"\"\" " + classCommentsOutput + " \"\"\"" + "\n\n") |
| 224 | + exportFile.write(f"{indentspace}\"\"\"<{currentFile.name}>\n") |
| 225 | + exportFile.write(f"{indentspace}" + classCommentsOutput + f"{indentspace}\"\"\"" + "\n\n") |
226 | 226 |
|
227 | 227 |
|
228 | 228 |
|
|
236 | 236 | #we save the line of the previous function to get exactly range between signatures of the methods |
237 | 237 | previousFunctionLineNumber = -1 |
238 | 238 | isInBlockComment = False |
239 | | - fnPattern = re.compile("\(.*\)") |
| 239 | + fnPattern = re.compile(r"\(.*\)") |
240 | 240 | for j, line in enumerate(allFileLines): |
241 | 241 | if line.__contains__('*/'): |
242 | 242 | isInBlockComment = False |
|
252 | 252 |
|
253 | 253 | line = line.strip() # strip white beginning and trailing white space |
254 | 254 |
|
255 | | - def removeCharactersWithinLimiters(input: str, limitBegin: str, limitEnd) -> str: |
| 255 | +# def removeCharactersWithinLimiters(input: str, limitBegin: str, limitEnd) -> str: |
| 256 | +# output: str = "" |
| 257 | +# |
| 258 | +# areWeWithinLimiters = False |
| 259 | +# i = -1 |
| 260 | +# for char in input: |
| 261 | +# i += 1 |
| 262 | +# if char == limitBegin: |
| 263 | +# areWeWithinLimiters = True |
| 264 | +# continue |
| 265 | +# if char == limitEnd: |
| 266 | +# areWeWithinLimiters = False |
| 267 | +# |
| 268 | +# if not areWeWithinLimiters: |
| 269 | +# output += char |
| 270 | +# return output |
| 271 | +# |
| 272 | +# line = removeCharactersWithinLimiters(line, '<', '>') |
| 273 | + def removeSpacesWithinLimiters(input: str, limitBegin: str, limitEnd: str) -> str: |
256 | 274 | output: str = "" |
257 | | - |
258 | | - areWeWithinLimiters = False |
| 275 | + isWithinLimiters = False |
259 | 276 | i = -1 |
| 277 | + |
260 | 278 | for char in input: |
261 | 279 | i += 1 |
262 | 280 | if char == limitBegin: |
263 | | - areWeWithinLimiters = True |
| 281 | + isWithinLimiters = True |
| 282 | + elif char == limitEnd: |
| 283 | + isWithinLimiters = False |
| 284 | + |
| 285 | + if isWithinLimiters and char == ' ': |
264 | 286 | continue |
265 | | - if char == limitEnd: |
266 | | - areWeWithinLimiters = False |
267 | | - |
268 | | - if not areWeWithinLimiters: |
| 287 | + else: |
269 | 288 | output += char |
| 289 | + |
270 | 290 | return output |
271 | | - |
272 | | - line = removeCharactersWithinLimiters(line, '<', '>') |
| 291 | + |
| 292 | + |
| 293 | + line = removeSpacesWithinLimiters(line, '<', '>') |
| 294 | + line = line.replace('<', '[').replace('>', ']') |
273 | 295 |
|
274 | 296 | for match in re.finditer(fnPattern, line): |
275 | 297 | if line.strip()[0][0] != "*": # this means it is part of a comments |
@@ -311,10 +333,14 @@ def removeCharactersWithinLimiters(input: str, limitBegin: str, limitEnd) -> str |
311 | 333 | returnType = functionList.split(' ')[0] |
312 | 334 | if returnType == "void": |
313 | 335 | returnType = "None" |
314 | | - elif returnType == "QString": |
315 | | - returnType = "str" |
316 | | - elif returnType == "QList": |
317 | | - returnType = "list" |
| 336 | + #elif returnType == "QString": |
| 337 | + # returnType = "str" |
| 338 | + elif 'Qstring[' in returnType: |
| 339 | + returnType = returnType.replace('QString', 'str') |
| 340 | + #elif returnType == "QList": |
| 341 | + # returnType = "list" |
| 342 | + elif 'QList[' in returnType: |
| 343 | + returnType = returnType.replace('QList', 'list') |
318 | 344 | # elif returnType.__len__()>0: |
319 | 345 | # returnType = returnType + "()" |
320 | 346 | functionList = functionList.split(' ')[1] |
@@ -433,7 +459,8 @@ def formatParamForDocString(paramName: str, paramType: str) -> str: |
433 | 459 |
|
434 | 460 | functionCommentsOutput = f"{newLine}{indentspace8}{functionCommentsOutput}{newLine}{indentspace8}{parameterPartOfComment}{formatParamForDocString('return', returnType)}{newLine}" |
435 | 461 |
|
436 | | - exportFile.write(f"{indentspace8}\"\"\" " + functionCommentsOutput + f"{indentspace8}\"\"\"\n\n" ) |
| 462 | + exportFile.write(f"{indentspace8}\"\"\"<{currentFile.name}>\n") |
| 463 | + exportFile.write(f"{indentspace8}" + functionCommentsOutput + f"{indentspace8}\"\"\"\n\n" ) |
437 | 464 | # exportFile.write(f"{indentspace8}return {returnType}\n\n" ) |
438 | 465 |
|
439 | 466 |
|
|
0 commit comments