kbasic 0.3.17__tar.gz → 0.3.18__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.3.17 → kbasic-0.3.18}/PKG-INFO +1 -1
- {kbasic-0.3.17 → kbasic-0.3.18}/pyproject.toml +1 -1
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/parsing/basic.py +15 -20
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/vectors.py +13 -1
- {kbasic-0.3.17 → kbasic-0.3.18}/README.md +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/Tex.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/__init__.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/array.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/audio/__init__.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/audio/lib/Caroline Rose - year of the slug - 01 everything in its right place.wav +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/audio/lib/success.mp3 +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/audio/sound.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/bar.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/environment/Keyan.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/environment/__init__.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/environment/anvil.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/environment/defaultPC.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/parsing/__init__.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/parsing/logging.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/parsing/parser.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/parsing/toml.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/parsing/utils.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/shell.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/strings.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/typing.py +0 -0
- {kbasic-0.3.17 → kbasic-0.3.18}/src/kbasic/user_input.py +0 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"""
|
|
2
|
+
the bulk of kbasics path logic lives here. File and Folder will both work for anything that accepts
|
|
3
|
+
an os.PathLike argument, such as the builtin open function.
|
|
4
|
+
"""
|
|
5
|
+
# !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
|
|
6
|
+
# >-|===|> Imports <|===|-<
|
|
7
|
+
# !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
|
|
8
|
+
from os import remove, system
|
|
9
|
+
from os.path import split, splitext, splitroot, exists, isdir, isfile, abspath, expanduser,\
|
|
10
|
+
expandvars
|
|
8
11
|
from shutil import copy, move, copytree, rmtree
|
|
9
12
|
from typing import Self, Optional
|
|
10
13
|
from glob import glob
|
|
@@ -49,11 +52,8 @@ class File:
|
|
|
49
52
|
self.drive, self.root, _ = splitroot(self.path)
|
|
50
53
|
self.parent = Folder(parentpath)
|
|
51
54
|
self.lines = []
|
|
52
|
-
def __repr__(self) -> str:
|
|
53
|
-
|
|
54
|
-
def __str__(self) -> str:
|
|
55
|
-
if not self.loaded: self.read()
|
|
56
|
-
return "\n".join(self.lines)
|
|
55
|
+
def __repr__(self) -> str: return self.path
|
|
56
|
+
def __str__(self) -> str: return self.path
|
|
57
57
|
def __eq__(self, other) -> bool:
|
|
58
58
|
if type(other) != File: return False
|
|
59
59
|
return (self.path == other.path) & (self.lines == other.lines)
|
|
@@ -89,7 +89,8 @@ class File:
|
|
|
89
89
|
Args:
|
|
90
90
|
destination (str): _description_
|
|
91
91
|
"""
|
|
92
|
-
if destination is None:
|
|
92
|
+
if destination is None:
|
|
93
|
+
destination = str(self.parent / f"{self.title}-copy{self.extension}")
|
|
93
94
|
copy(self.path, destination)
|
|
94
95
|
return File(destination, verbose=self.verbose, master=self)
|
|
95
96
|
def move(self, destination:str):
|
|
@@ -168,13 +169,7 @@ class Folder:
|
|
|
168
169
|
self.master = master if not isinstance(master, str) else Folder(master)
|
|
169
170
|
self.parentpath, self.name = split(self.path)
|
|
170
171
|
def __repr__(self) -> str: return self.path
|
|
171
|
-
def __str__(self) -> str:
|
|
172
|
-
output = []
|
|
173
|
-
for root, dirs, files in walk(self.path):
|
|
174
|
-
level = root.replace(self.path, '').count('/')
|
|
175
|
-
output.append(f'{'----'*level}{basename(root)}')
|
|
176
|
-
for f in files: output.append(f'|{'----'*(level+1)}> {f}')
|
|
177
|
-
return '\n'.join(output)
|
|
172
|
+
def __str__(self) -> str: return self.path
|
|
178
173
|
def __len__(self) -> int: return len(self.children)
|
|
179
174
|
def __iter__(self):
|
|
180
175
|
self.index = 0
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
|
|
2
|
+
# =>> KBASIC.VECTOR <<=
|
|
3
|
+
# !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
|
|
1
4
|
"""Implement vector classes for vector analysis"""
|
|
2
5
|
# !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
|
|
3
6
|
# >-|===|> Imports <|===|-<
|
|
4
7
|
# !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
|
|
5
8
|
from typing import Self
|
|
6
9
|
from collections.abc import Generator
|
|
7
|
-
from functools import total_ordering
|
|
8
10
|
from numpy import array, cos, sin, sqrt, exp, sum
|
|
9
11
|
from kbasic.typing import Number, Array
|
|
10
12
|
|
|
@@ -135,6 +137,8 @@ class VectorBase:
|
|
|
135
137
|
return type(self)(other//c for c in self)
|
|
136
138
|
case Array():
|
|
137
139
|
return type(self)(c2//c1 for c1, c2 in zip(self, other))
|
|
140
|
+
|
|
141
|
+
|
|
138
142
|
class Vector(VectorBase):
|
|
139
143
|
def __new__(cls, *components) -> Self: # the vector factory
|
|
140
144
|
match components:
|
|
@@ -161,11 +165,15 @@ class Vector(VectorBase):
|
|
|
161
165
|
return VectorBase(*components)
|
|
162
166
|
case x:
|
|
163
167
|
raise TypeError(f"given components:\n{components}\nof type: {type(x)}")
|
|
168
|
+
|
|
169
|
+
|
|
164
170
|
class Norm(VectorBase):
|
|
165
171
|
def __init__(self, *components):
|
|
166
172
|
self.components = components
|
|
167
173
|
gen = (x/abs(self) for x in self)
|
|
168
174
|
super().__init__(gen)
|
|
175
|
+
|
|
176
|
+
|
|
169
177
|
class Quaternion(Norm):
|
|
170
178
|
def __init__(self, angle, axis):
|
|
171
179
|
q0 = cos(angle/2)
|
|
@@ -173,6 +181,8 @@ class Quaternion(Norm):
|
|
|
173
181
|
self.axis *= sin(angle/2)
|
|
174
182
|
self.axis *= sqrt(1-q0**2)/abs(self.axis)
|
|
175
183
|
super().__init__(q0, *self.axis.components)
|
|
184
|
+
|
|
185
|
+
|
|
176
186
|
class R2(VectorBase):
|
|
177
187
|
def __init__(self, *components):
|
|
178
188
|
super().__init__(*components)
|
|
@@ -185,6 +195,8 @@ class R2(VectorBase):
|
|
|
185
195
|
r_rotated = r * exp(1j*angle)
|
|
186
196
|
self.__init__(r_rotated.real, r_rotated.imag)
|
|
187
197
|
return self
|
|
198
|
+
|
|
199
|
+
|
|
188
200
|
class R3(VectorBase):
|
|
189
201
|
def __init__(self, *components):
|
|
190
202
|
super().__init__(*components)
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|