widpath 0.1.0__tar.gz → 0.1.1__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.4
2
2
  Name: widpath
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: A hierarchical file path resolver for WID-based storage
5
5
  Author-email: "sheng.SMLH" <sheng@smlh.com>
6
6
  Project-URL: Homepage, https://github.com/yourusername/widpath
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "widpath"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  description = "A hierarchical file path resolver for WID-based storage"
9
9
  authors = [
10
10
  { name = "sheng.SMLH", email = "sheng@smlh.com" }
@@ -1,9 +1,11 @@
1
1
  from pathlib import Path
2
2
 
3
3
  class WidPathResolver:
4
- def __init__(self, size: int = 2, separator: str = "/"):
4
+ def __init__(self, root='.', size: int = 2, separator: str = "/"):
5
+ assert(size>0)
5
6
  self.size = size
6
7
  self.separator = separator
8
+ self.root=Path(root)
7
9
 
8
10
  def _split_wid(self, wid: str):
9
11
  return [wid[i:i + self.size] for i in range(0, len(wid), self.size)]
@@ -16,9 +18,9 @@ class WidPathResolver:
16
18
  max_level = self.get_max_level(wid)
17
19
  level = min(max(level, 0), max_level)
18
20
  if level >= max_level:
19
- return Path(self.separator.join(parts[:max_level+1]) + ".json")
21
+ return self.root / Path(self.separator.join(parts[:max_level+1]) + ".json")
20
22
  else:
21
- return Path(self.separator.join(parts[:level+1]) + ".json")
23
+ return self.root / Path(self.separator.join(parts[:level+1]) + ".json")
22
24
 
23
25
  def get_file_path(self, wid: str) -> Path:
24
26
  min_level = 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: widpath
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: A hierarchical file path resolver for WID-based storage
5
5
  Author-email: "sheng.SMLH" <sheng@smlh.com>
6
6
  Project-URL: Homepage, https://github.com/yourusername/widpath
File without changes
File without changes
File without changes
File without changes
File without changes