daplapath 2.0.2__tar.gz → 2.0.3__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.1
2
2
  Name: daplapath
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: A pathlib.Path class for dapla
5
5
  License: MIT
6
6
  Author: ort
@@ -29,9 +29,8 @@ try:
29
29
  except ImportError:
30
30
  pass
31
31
 
32
-
33
32
  # regex with the prefix '_v' followed by an integer of any length
34
- VERSION_PATTERN = r"_v(\d+)"
33
+ VERSION_PATTERN = r"_v(\d+)\."
35
34
  VERSION_PREFIX = "_v"
36
35
 
37
36
  # regex with the prefix '_p' followed by four length integer (year) and OPTIONALLY month and date, separated by '-'
@@ -269,11 +268,16 @@ class Path(str, _PathBase):
269
268
  """Returns a PathSeries of all versions of the file."""
270
269
  files_in_folder: Iterable[Path] = self.parent.glob("**", recursive=False)
271
270
 
271
+ if self.version_number:
272
+ start, _, end = re.split(self._version_pattern, self)
273
+ else:
274
+ start, end = self.stem, self.suffix
275
+
272
276
  # create boolean mask. With numpy to make it work with both pandas and list
273
277
  arr = np.array(files_in_folder)
274
- is_version_of_this_file = (
275
- np_str_contains(arr, self.versionless_stem)
276
- ) & np_str_endswith(arr, self.suffix)
278
+ is_version_of_this_file = (np_str_contains(arr, start)) & (
279
+ np_str_endswith(arr, end)
280
+ )
277
281
  if not include_versionless:
278
282
  is_version_of_this_file &= np_str_matches(arr, self._version_pattern)
279
283
 
@@ -505,7 +509,7 @@ class Path(str, _PathBase):
505
509
  @property
506
510
  def versionless_stem(self) -> str:
507
511
  """Return the file stem before the version pattern."""
508
- return str(re.sub(self._version_pattern, "", self._path.stem))
512
+ return self.__class__(re.split(self._version_pattern, self._path.name)[0]).stem
509
513
 
510
514
  @property
511
515
  def parent(self) -> "Path":
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "daplapath"
3
- version = "2.0.2"
3
+ version = "2.0.3"
4
4
  description = "A pathlib.Path class for dapla"
5
5
  authors = ["ort <ort@ssb.no>"]
6
6
  license = "MIT"
File without changes
File without changes