kbasic 0.1.38__tar.gz → 0.1.39__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.
Files changed (26) hide show
  1. {kbasic-0.1.38 → kbasic-0.1.39}/PKG-INFO +1 -1
  2. {kbasic-0.1.38 → kbasic-0.1.39}/pyproject.toml +1 -1
  3. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/parsing/basic.py +25 -7
  4. {kbasic-0.1.38 → kbasic-0.1.39}/README.md +0 -0
  5. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/Tex.py +0 -0
  6. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/__init__.py +0 -0
  7. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/array.py +0 -0
  8. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/audio/__init__.py +0 -0
  9. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/audio/lib/Caroline Rose - year of the slug - 01 everything in its right place.wav +0 -0
  10. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/audio/lib/success.mp3 +0 -0
  11. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/audio/sound.py +0 -0
  12. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/bar.py +0 -0
  13. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/environment/Keyan.py +0 -0
  14. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/environment/__init__.py +0 -0
  15. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/environment/anvil.py +0 -0
  16. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/environment/defaultPC.py +0 -0
  17. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/parsing/__init__.py +0 -0
  18. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/parsing/log.py +0 -0
  19. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/parsing/parser.py +0 -0
  20. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/parsing/toml.py +0 -0
  21. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/parsing/utils.py +0 -0
  22. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/shell.py +0 -0
  23. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/strings.py +0 -0
  24. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/typing.py +0 -0
  25. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/user_input.py +0 -0
  26. {kbasic-0.1.38 → kbasic-0.1.39}/src/kbasic/vectors.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: kbasic
3
- Version: 0.1.38
3
+ Version: 0.1.39
4
4
  Summary: Keyan's basic utility functions.
5
5
  Author: Keyan Gootkin
6
6
  Author-email: Keyan Gootkin <keyangootkin@gmail.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "kbasic"
3
- version = "0.1.38"
3
+ version = "0.1.39"
4
4
  description = "Keyan's basic utility functions."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -3,13 +3,14 @@
3
3
  # >-|===|> Imports <|===|-<
4
4
  # !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
5
5
  from os import remove
6
- from os.path import split, splitext, splitroot, exists, isdir, isfile
6
+ from os.path import split, splitext, splitroot, exists, isdir, isfile, abspath
7
7
  from shutil import copy, move, copytree, rmtree
8
8
  from typing import Self, Optional
9
9
  from glob import glob
10
10
  from pathlib import Path as builtinPath
11
11
  from kbasic.parsing.utils import ensure_path
12
12
  from kbasic.user_input import yesno
13
+ from kbasic.typing import Array
13
14
 
14
15
  # !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
15
16
  # >-|===|> Definitions <|===|-<
@@ -37,7 +38,7 @@ class File:
37
38
  if type(path)==type(self):
38
39
  self = path
39
40
  return None
40
- self.path: str = str(builtinPath(path).resolve())
41
+ self.path: str = abspath(str(builtinPath(path).resolve()))
41
42
  self.master = master if not isinstance(master, str) else File(master)
42
43
  self.verbose = verbose
43
44
  self.loaded: bool = False
@@ -45,10 +46,9 @@ class File:
45
46
  self.title, self.extension = splitext(self.name)
46
47
  self.drive, self.root, _ = splitroot(self.path)
47
48
  self.parent = Folder(parentpath)
48
- self.grandparent = self.parent.parent
49
- self.greatgrandparent = self.parent.parent.parent
50
49
  self.lines = []
51
- def __repr__(self) -> str: return self.path
50
+ def __repr__(self) -> str:
51
+ return self.path
52
52
  def __str__(self) -> str:
53
53
  if not self.loaded: self.read()
54
54
  return "\n".join(self.lines)
@@ -73,6 +73,10 @@ class File:
73
73
  bool: _description_
74
74
  """
75
75
  return exists(self.path)
76
+ @property
77
+ def writeable(self) -> bool:
78
+ """whether or not we can write this type of file with this object"""
79
+ return self.extension in unreadable_file_types
76
80
  def copy(self, destination:str):
77
81
  """_summary_
78
82
 
@@ -112,7 +116,7 @@ class File:
112
116
  def load(self) -> None:
113
117
  """docstring"""
114
118
  self.read()
115
- def save(self, interactive=True):
119
+ def save(self, interactive=True) -> None:
116
120
  """summary"""
117
121
  if interactive and not yesno(
118
122
  f"Are you sure you want to permanently overwrite {self.path}?\n"
@@ -124,15 +128,26 @@ class File:
124
128
  f"attempted to save unwritable file: {self.path}"
125
129
  )
126
130
  file.writelines("\n".join(self.lines))
131
+ def write(self, text: str | Array, interactive=False) -> None:
132
+ """add text to this File.lines then save the file"""
133
+ match text:
134
+ case str():
135
+ self.lines.append(text)
136
+ case _ if type(text) in Array.types:
137
+ self.lines += list(text)
138
+ case _:
139
+ raise TypeError(f"must supply either string or an array of strings\nwas given text of type: {type(text)}")
140
+ self.save(interactive=interactive)
127
141
 
128
142
  class Folder:
129
143
  def __init__(
130
144
  self, path: str|Self,
131
145
  master: Optional[Self] = None
132
146
  ) -> None:
147
+ if path is None: return None
133
148
  if type(path)==type(self):
134
149
  path = path.path
135
- self.path = str()
150
+ self.path = abspath(str(builtinPath(path).resolve()))
136
151
  self.master = master if not isinstance(master, str) else Folder(master)
137
152
  self.parentpath, self.name = split(self.path)
138
153
  def __repr__(self) -> str: return self.path
@@ -161,6 +176,9 @@ class Folder:
161
176
  def __radd__(self, other):
162
177
  if other==0: return [self]
163
178
  return self.__add__(other)
179
+ def __div__(self, other):
180
+ match other:
181
+ case str(): return Path(f"{self.path}/{other}")
164
182
  @property
165
183
  def parent(self) -> Self:
166
184
  """summary"""
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