kbasic 0.1.33__tar.gz → 0.1.34__tar.gz
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.
- {kbasic-0.1.33 → kbasic-0.1.34}/PKG-INFO +1 -1
- {kbasic-0.1.33 → kbasic-0.1.34}/pyproject.toml +1 -1
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/parsing.py +16 -2
- {kbasic-0.1.33 → kbasic-0.1.34}/README.md +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/Tex.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/__init__.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/array.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/audio/__init__.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/audio/lib/Caroline Rose - year of the slug - 01 everything in its right place.wav +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/audio/lib/success.mp3 +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/audio/sound.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/bar.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/environment/Keyan.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/environment/__init__.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/environment/anvil.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/environment/defaultPC.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/shell.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/strings.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/typing.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/user_input.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.34}/src/kbasic/vectors.py +0 -0
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
# !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
|
|
4
4
|
#pysim imports
|
|
5
5
|
from kbasic.user_input import yesno
|
|
6
|
+
from kbasic.typing import Array, Number
|
|
6
7
|
#nonpysim imports
|
|
7
|
-
from
|
|
8
|
+
from time import time
|
|
9
|
+
from datetime import datetime
|
|
10
|
+
from typing import Self, Optional, Callable
|
|
8
11
|
from numpy import ndarray
|
|
9
12
|
from glob import glob
|
|
10
13
|
from shutil import copy, move, copytree, rmtree
|
|
@@ -49,7 +52,10 @@ def could_be_path(path: str) -> bool:
|
|
|
49
52
|
bool: True if the first two members of the path are valid else False.
|
|
50
53
|
"""
|
|
51
54
|
return isdir('/'.join(path.split('/')[:2]))
|
|
52
|
-
|
|
55
|
+
def default_log_formater(msg: str) -> str:
|
|
56
|
+
return f"{str(datetime.now())}: {msg}"
|
|
57
|
+
def delta_log_formater(msg: str, start_time: Number) -> str:
|
|
58
|
+
return f"Δt: {(time()-start_time)*1e6:.1f} μs | {msg}"
|
|
53
59
|
# !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
|
|
54
60
|
# >-|===|> Classes <|===|-<
|
|
55
61
|
# !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
|
|
@@ -115,6 +121,14 @@ class File:
|
|
|
115
121
|
with open(self.path, 'w+') as file:
|
|
116
122
|
if not file.writable: raise PermissionError(f"attempted to save unwritable file: {self.path}")
|
|
117
123
|
file.writelines("\n".join(self.lines))
|
|
124
|
+
class Log(File):
|
|
125
|
+
def __init__(self, path: str | Self, verbose: bool = False, fmt: Callable[str] = default_log_formater):
|
|
126
|
+
File.__init__(self, path, verbose=verbose)
|
|
127
|
+
self.fmt = fmt
|
|
128
|
+
def __call__(self, msg: Array[str]|str, *args, **kwds):
|
|
129
|
+
match msg:
|
|
130
|
+
case str(): self.lines.append(self.fmt(msg, *args, **kwds))
|
|
131
|
+
case _ if type(msg) in Array.types: self.lines += [self.fmt(m, *args, **kwds) for m in msg]
|
|
118
132
|
class TOML(File):
|
|
119
133
|
def __init__(self, path: str, verbose: bool = False):
|
|
120
134
|
File.__init__(self, path, verbose=verbose)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|