|
46 | 46 | logger = logging.getLogger(__name__) |
47 | 47 |
|
48 | 48 |
|
49 | | -# =============================================================================================== # |
| 49 | +## |
50 | 50 | # Checker Functions |
51 | | -# =============================================================================================== # |
| 51 | +## |
52 | 52 |
|
53 | 53 | def checkStringNone(value: Any, default: str | None) -> str | None: |
54 | 54 | """Check if a variable is a string or a None.""" |
@@ -131,9 +131,9 @@ def checkPath(value: Any, default: Path) -> Path: |
131 | 131 | return default |
132 | 132 |
|
133 | 133 |
|
134 | | -# =============================================================================================== # |
| 134 | +## |
135 | 135 | # Validator Functions |
136 | | -# =============================================================================================== # |
| 136 | +## |
137 | 137 |
|
138 | 138 | def isHandle(value: Any) -> bool: |
139 | 139 | """Check if a string is a valid novelWriter handle. |
@@ -204,9 +204,9 @@ def checkIntTuple(value: int, valid: tuple | list | set, default: int) -> int: |
204 | 204 | return default |
205 | 205 |
|
206 | 206 |
|
207 | | -# =============================================================================================== # |
| 207 | +## |
208 | 208 | # Formatting Functions |
209 | | -# =============================================================================================== # |
| 209 | +## |
210 | 210 |
|
211 | 211 | def formatInt(value: int) -> str: |
212 | 212 | """Formats an integer with k, M, G etc.""" |
@@ -250,9 +250,9 @@ def formatTime(t: int) -> str: |
250 | 250 | return "ERROR" |
251 | 251 |
|
252 | 252 |
|
253 | | -# =============================================================================================== # |
| 253 | +## |
254 | 254 | # String Functions |
255 | | -# =============================================================================================== # |
| 255 | +## |
256 | 256 |
|
257 | 257 | def simplified(text: str) -> str: |
258 | 258 | """Take a string and strip leading and trailing whitespaces, and |
@@ -371,9 +371,9 @@ def numberToRoman(value: int, toLower: bool = False) -> str: |
371 | 371 | return roman.lower() if toLower else roman |
372 | 372 |
|
373 | 373 |
|
374 | | -# =============================================================================================== # |
| 374 | +## |
375 | 375 | # Encoder Functions |
376 | | -# =============================================================================================== # |
| 376 | +## |
377 | 377 |
|
378 | 378 | def jsonEncode(data: dict | list | tuple, n: int = 0, nmax: int = 0) -> str: |
379 | 379 | """Encode a dictionary, list or tuple as a json object or array, and |
@@ -463,9 +463,9 @@ def indentChildren(elem, level): |
463 | 463 | return |
464 | 464 |
|
465 | 465 |
|
466 | | -# =============================================================================================== # |
| 466 | +## |
467 | 467 | # File and File System Functions |
468 | | -# =============================================================================================== # |
| 468 | +## |
469 | 469 |
|
470 | 470 | def readTextFile(path: str | Path) -> str: |
471 | 471 | """Read the content of a text file in a robust manner.""" |
@@ -507,9 +507,9 @@ def openExternalPath(path: Path) -> bool: |
507 | 507 | return False |
508 | 508 |
|
509 | 509 |
|
510 | | -# =============================================================================================== # |
| 510 | +## |
511 | 511 | # Classes |
512 | | -# =============================================================================================== # |
| 512 | +## |
513 | 513 |
|
514 | 514 | class NWConfigParser(ConfigParser): |
515 | 515 | """Common: Adapted Config Parser |
|
0 commit comments