kbasic 0.1.33__tar.gz → 0.1.35__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.35}/PKG-INFO +1 -1
- {kbasic-0.1.33 → kbasic-0.1.35}/pyproject.toml +1 -1
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/parsing.py +20 -2
- {kbasic-0.1.33 → kbasic-0.1.35}/README.md +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/Tex.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/__init__.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/array.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/audio/__init__.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/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.35}/src/kbasic/audio/lib/success.mp3 +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/audio/sound.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/bar.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/environment/Keyan.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/environment/__init__.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/environment/anvil.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/environment/defaultPC.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/shell.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/strings.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/typing.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/src/kbasic/user_input.py +0 -0
- {kbasic-0.1.33 → kbasic-0.1.35}/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
|
# !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
|
|
@@ -77,6 +83,7 @@ class File:
|
|
|
77
83
|
self.parent = Folder(parentpath)
|
|
78
84
|
self.grandparent = self.parent.parent
|
|
79
85
|
self.greatgrandparent = self.parent.parent.parent
|
|
86
|
+
self.lines = []
|
|
80
87
|
def __repr__(self) -> str: return self.path
|
|
81
88
|
def __str__(self) -> str: return "\n".join(self.lines)
|
|
82
89
|
def __add__(self, other):
|
|
@@ -115,6 +122,17 @@ class File:
|
|
|
115
122
|
with open(self.path, 'w+') as file:
|
|
116
123
|
if not file.writable: raise PermissionError(f"attempted to save unwritable file: {self.path}")
|
|
117
124
|
file.writelines("\n".join(self.lines))
|
|
125
|
+
class Log(File):
|
|
126
|
+
def __init__(self, path: str | Self, verbose: bool = False, fmt: Callable[str] = default_log_formater):
|
|
127
|
+
File.__init__(self, path, verbose=verbose)
|
|
128
|
+
self.fmt = fmt
|
|
129
|
+
def __call__(self, msg: Array[str]|str, *args, **kwds):
|
|
130
|
+
match msg:
|
|
131
|
+
case str(): output = [self.fmt(msg, *args, **kwds)]
|
|
132
|
+
case _ if type(msg) in Array.types: output = [self.fmt(m, *args, **kwds) for m in msg]
|
|
133
|
+
if self.verbose: print(output)
|
|
134
|
+
self.lines += output
|
|
135
|
+
self.save(interactive=False)
|
|
118
136
|
class TOML(File):
|
|
119
137
|
def __init__(self, path: str, verbose: bool = False):
|
|
120
138
|
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
|