kbasic 0.1.26__tar.gz → 0.1.28__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: kbasic
3
- Version: 0.1.26
3
+ Version: 0.1.28
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.26"
3
+ version = "0.1.28"
4
4
  description = "Keyan's basic utility functions."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -35,7 +35,7 @@ def where_closest(arr:ArrayLike, value: Number) -> int | tuple[int]:
35
35
  _type_: _description_
36
36
  """
37
37
  arr = array(arr)
38
- indices = unravel_index(argmin(absolute(arr-value)))
38
+ indices = unravel_index(argmin(absolute(arr-value)), arr.shape)
39
39
  return indices if len(indices)>1 else indices[0]
40
40
  def where_between(arr:ArrayLike, low: Number, high: Number) -> NDArray:
41
41
  """Find the range of indicies where arr is between low and high
@@ -22,24 +22,24 @@ unreadable_file_types: list[str] = ['.gz', '.tar', '.zip']
22
22
  # >-|===|> Functions <|===|-<
23
23
  # !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
24
24
  def clean_path(path: str) -> str:
25
- """return an absolute, normalized, cleaned path with expanded environment
25
+ """return an absolute, normalzed, cleaned path with expanded environment
26
26
  variables and user characters
27
27
 
28
28
  Args:
29
- path (str): input path string
29
+ path (str): input path sting
30
30
 
31
31
  Returns:
32
32
  str: a path
33
33
  """
34
- return normpath(expanduser(expandvars(path)))
35
- def ensure_path(path: str) -> None:
36
- """make sure that a path exists
34
+ return normpath(expanduser(exandvars(path)))
35
+ def ensure_path(path: str) -> Non:
36
+ """make sure that a path exiss
37
37
 
38
38
  Args:
39
- path (str): the path you want to exist
39
+ path (str): the path you ant to exist
40
40
  """
41
41
  system(f"mkdir -p {path}")
42
- def could_be_path(path: str) -> bool:
42
+ def could_be_path(path: str) -> bol:
43
43
  """determine if this is anywhere close to a valid path
44
44
 
45
45
  Args:
@@ -64,6 +64,9 @@ class File:
64
64
  verbose (bool, optional): should this file be annoying. Defaults to
65
65
  False.
66
66
  """
67
+ if type(path)==type(self):
68
+ self = path
69
+ return None
67
70
  self.path: str = clean_path(path)
68
71
  self.master = master if not isinstance(master, str) else File(master)
69
72
  self.verbose = verbose
@@ -123,6 +126,9 @@ class TOML(File):
123
126
  self.lines = [f"{k}={v}" for k,v in self._attrs.items()]
124
127
  class Folder:
125
128
  def __init__(self, path:str, master=None) -> None:
129
+ if type(path)==type(self):
130
+ self = path
131
+ return None
126
132
  self.path = clean_path(path)
127
133
  self.master = master if not isinstance(master, str) else Folder(master)
128
134
  self.parentpath, self.name = split(self.path)
@@ -169,6 +175,9 @@ class Folder:
169
175
  return None
170
176
  rmtree(self.path)
171
177
 
178
+ # !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
179
+ # >-|===|> Functions <|===|-<
180
+ # !==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==!==
172
181
  def parse(path: str | list[str]) -> Folder | File | list[Folder | File]:
173
182
  """take a path or list of paths and turn them into Folder or File objects as appropriate.
174
183
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes