pathlibutil 0.3.4__tar.gz → 0.3.5__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
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: pathlibutil
3
- Version: 0.3.4
3
+ Version: 0.3.5
4
4
  Summary: inherits from pathlib.Path with methods for hashing, copying, deleting and more
5
5
  License: MIT
6
6
  Keywords: pathlib,hashlib,shutil,urllib.parse,json,urlpath
@@ -1,9 +1,7 @@
1
1
  import os
2
2
  import pathlib
3
3
  import sys
4
- from typing import Generator, TypeVar
5
-
6
- _Path = TypeVar("_Path", bound=pathlib.Path)
4
+ from typing import Generator
7
5
 
8
6
 
9
7
  class BasePath(pathlib.Path):
@@ -19,7 +17,7 @@ class BasePath(pathlib.Path):
19
17
  )
20
18
 
21
19
  @classmethod
22
- def expand(cls, file: str) -> Generator[_Path, None, None]:
20
+ def expand(cls, file: str) -> Generator["BasePath", None, None]:
23
21
  """
24
22
  yields only Path object of file names that exists. Supports glob patterns in
25
23
  filename as wildcards.
@@ -9,7 +9,7 @@ import sys
9
9
  from datetime import datetime, timedelta
10
10
  from typing import Callable, Dict, Generator, List, Literal, Set, Tuple, Union
11
11
 
12
- from pathlibutil.base import BasePath, _Path
12
+ from pathlibutil.base import BasePath
13
13
  from pathlibutil.types import ByteInt, StatResult, TimeInt, _stat_result, byteint
14
14
 
15
15
 
@@ -130,7 +130,7 @@ class Path(BasePath):
130
130
 
131
131
  return True
132
132
 
133
- def __enter__(self) -> _Path:
133
+ def __enter__(self) -> "Path":
134
134
  """
135
135
  Contextmanager to changes the current working directory.
136
136
  """
@@ -175,7 +175,7 @@ class Path(BasePath):
175
175
 
176
176
  return super().stat(**kwargs).st_size
177
177
 
178
- def copy(self, dst: str, exist_ok: bool = True, **kwargs) -> _Path:
178
+ def copy(self, dst: str, exist_ok: bool = True, **kwargs) -> "Path":
179
179
  """
180
180
  Copies the file or directory to a destination directory, if it is missing it
181
181
  will be created.
@@ -227,7 +227,7 @@ class Path(BasePath):
227
227
 
228
228
  shutil.rmtree(self, **kwargs)
229
229
 
230
- def move(self, dst: str) -> _Path:
230
+ def move(self, dst: str) -> "Path":
231
231
  """
232
232
  Moves the file or directory into the destination directory.
233
233
 
@@ -247,7 +247,7 @@ class Path(BasePath):
247
247
  return self.__class__(_path)
248
248
 
249
249
  @staticmethod
250
- def _find_archive_format(filename: _Path) -> str:
250
+ def _find_archive_format(filename: "Path") -> str:
251
251
  """
252
252
  Searches for a file the correct archive format.
253
253
  """
@@ -273,7 +273,7 @@ class Path(BasePath):
273
273
 
274
274
  def make_archive(
275
275
  self, archivename: str, *, exists_ok: bool = False, **kwargs
276
- ) -> _Path:
276
+ ) -> "Path":
277
277
  """
278
278
  Creates an archive file (eg. zip) and returns the path to the archive.
279
279
 
@@ -296,7 +296,7 @@ class Path(BasePath):
296
296
  Path('test.zpy')
297
297
  """
298
298
 
299
- def _archive_exists(file: str, exists_ok: bool) -> _Path:
299
+ def _archive_exists(file: str, exists_ok: bool) -> "Path":
300
300
  """
301
301
  Returns a `Path` object of the archive file or raises a `FileExistsError`
302
302
  If `exists_ok` is `True` the file will be deleted.
@@ -311,7 +311,7 @@ class Path(BasePath):
311
311
 
312
312
  return file
313
313
 
314
- def _archive_filename(expect: Path, real: str) -> _Path:
314
+ def _archive_filename(expect: Path, real: str) -> "Path":
315
315
  """
316
316
  Check if the expected archive filename matches the real filename.
317
317
  If not try to rename the real filename.
@@ -346,7 +346,7 @@ class Path(BasePath):
346
346
 
347
347
  return _archive_filename(_filename, _archive)
348
348
 
349
- def unpack_archive(self, extract_dir: str, **kwargs) -> _Path:
349
+ def unpack_archive(self, extract_dir: str, **kwargs) -> "Path":
350
350
  """
351
351
  Unpacks an archive file (eg. zip) into a directory and returns the path to the
352
352
  extracted files.
@@ -405,7 +405,7 @@ class Path(BasePath):
405
405
  """
406
406
  return StatResult(super().stat(**kwargs))
407
407
 
408
- def with_suffix(self, suffix: Union[str, List[str]]) -> _Path:
408
+ def with_suffix(self, suffix: Union[str, List[str]]) -> "Path":
409
409
  """
410
410
  Return a new `Path` with changed suffix or remove it when its an empty
411
411
  string.
@@ -444,8 +444,8 @@ class Path(BasePath):
444
444
  return super(self.__class__, stem).with_suffix(suffix)
445
445
 
446
446
  def relative_to(
447
- self, *other: Union[str, _Path], walk_up: Union[bool, int] = False
448
- ) -> _Path:
447
+ self, *other: Union[str, "Path"], walk_up: Union[bool, int] = False
448
+ ) -> "Path":
449
449
  """
450
450
  Return the relative path to another path identified by the passed
451
451
  arguments. If the operation is not possible (because this is not
@@ -485,7 +485,7 @@ class Path(BasePath):
485
485
  return relative
486
486
 
487
487
  @classmethod
488
- def cwd(cls, *, frozen: Literal[True, False, "_MEIPASS"] = False) -> _Path:
488
+ def cwd(cls, *, frozen: Literal[True, False, "_MEIPASS"] = False) -> "Path":
489
489
  """
490
490
  Return a `Path` object representing the current working directory.
491
491
 
@@ -536,7 +536,7 @@ class Path(BasePath):
536
536
  except Exception:
537
537
  return {}
538
538
 
539
- def _resolve_unc(self) -> _Path:
539
+ def _resolve_unc(self) -> "Path":
540
540
  """
541
541
  Resolve UNC paths to mapped network drives.
542
542
  """
@@ -549,7 +549,7 @@ class Path(BasePath):
549
549
  except KeyError:
550
550
  return self
551
551
 
552
- def resolve(self, strict: bool = False, unc: bool = True) -> _Path:
552
+ def resolve(self, strict: bool = False, unc: bool = True) -> "Path":
553
553
  """
554
554
  Make the path absolute, resolving all symlinks on the way and also normalizing
555
555
  it.
@@ -579,7 +579,7 @@ class Path(BasePath):
579
579
  top_down: bool = True,
580
580
  on_error: Callable[[OSError], object] = None,
581
581
  follow_symlinks: bool = False,
582
- ) -> Generator[Tuple[_Path, List[str], List[str]], None, None]:
582
+ ) -> Generator[Tuple["Path", List[str], List[str]], None, None]:
583
583
  """
584
584
  Walks the directory tree and yields a 3-tuple of (dirpath, dirnames, filenames).
585
585
  """
@@ -602,9 +602,9 @@ class Path(BasePath):
602
602
  self,
603
603
  *,
604
604
  recursive: Union[bool, int] = False,
605
- exclude_dirs: Callable[[_Path], bool] = None,
605
+ exclude_dirs: Callable[["Path"], bool] = None,
606
606
  **kwargs,
607
- ) -> Generator[_Path, None, None]:
607
+ ) -> Generator["Path", None, None]:
608
608
  """
609
609
  Iterates over the files in the directory.
610
610
 
@@ -616,7 +616,7 @@ class Path(BasePath):
616
616
  `exclude_dirs`, e.g.
617
617
 
618
618
  ```python
619
- def exclude_version_control(dirpath: _Path) -> bool:
619
+ def exclude_version_control(dirpath: "Path") -> bool:
620
620
  return dirpath.name in (".git", ".svn", ".hg", ".bzr", "CVS")
621
621
  ```
622
622
  """
@@ -660,7 +660,7 @@ class Path(BasePath):
660
660
  cls,
661
661
  *files: str,
662
662
  duplicates: bool = True,
663
- ) -> Generator[_Path, None, None]:
663
+ ) -> Generator["Path", None, None]:
664
664
  """
665
665
  Yields only Path object of file names that exists. Supports glob patterns in
666
666
  filename as wildcards.
@@ -5,7 +5,7 @@ requires = [ "poetry-core" ]
5
5
 
6
6
  [tool.poetry]
7
7
  name = "pathlibutil"
8
- version = "v0.3.4"
8
+ version = "v0.3.5"
9
9
  description = "inherits from pathlib.Path with methods for hashing, copying, deleting and more"
10
10
  authors = [ "Christoph Dörrer <d-chris@web.de>" ]
11
11
  readme = "README.md"
File without changes
File without changes