doFolder 2.2.0__tar.gz → 2.2.2__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.
- {dofolder-2.2.0/src/doFolder.egg-info → dofolder-2.2.2}/PKG-INFO +1 -1
- {dofolder-2.2.0 → dofolder-2.2.2}/pyproject.toml +1 -1
- {dofolder-2.2.0 → dofolder-2.2.2}/src/doFolder/__init__.py +15 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/src/doFolder/compare.py +3 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/src/doFolder/fileSystem.py +37 -7
- {dofolder-2.2.0 → dofolder-2.2.2/src/doFolder.egg-info}/PKG-INFO +1 -1
- {dofolder-2.2.0 → dofolder-2.2.2}/LICENSE +0 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/README.md +0 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/setup.cfg +0 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/src/doFolder/enums.py +0 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/src/doFolder/exception.py +0 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/src/doFolder/globalType.py +0 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/src/doFolder/path.py +0 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/src/doFolder.egg-info/SOURCES.txt +0 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/src/doFolder.egg-info/dependency_links.txt +0 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/src/doFolder.egg-info/requires.txt +0 -0
- {dofolder-2.2.0 → dofolder-2.2.2}/src/doFolder.egg-info/top_level.txt +0 -0
|
@@ -14,9 +14,24 @@ example:
|
|
|
14
14
|
:license: MulanPSL-2.0, see LICENSE for more details.
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
from .fileSystem import File, Directory, ItemType, UnExistsMode, Folder, createItem, isDir
|
|
18
19
|
from .path import Path
|
|
19
20
|
from . import compare
|
|
21
|
+
|
|
22
|
+
__version__="unknown"
|
|
23
|
+
def __initVersion():
|
|
24
|
+
global __version__ # pylint: disable=global-statement
|
|
25
|
+
try:
|
|
26
|
+
assert "." not in __name__
|
|
27
|
+
from importlib.metadata import version # pylint: disable=import-outside-toplevel
|
|
28
|
+
|
|
29
|
+
__version__ = version(__name__)
|
|
30
|
+
except: # pylint: disable=bare-except
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
__initVersion()
|
|
20
35
|
__all__ = [
|
|
21
36
|
"File",
|
|
22
37
|
"Directory",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
2
|
This module provides apis to compare file system items and determine differences between them.
|
|
3
|
+
|
|
4
|
+
.. versionadded:: 2.0.0
|
|
3
5
|
"""
|
|
4
6
|
|
|
5
7
|
from dataclasses import dataclass, field
|
|
@@ -32,6 +34,7 @@ class Difference:
|
|
|
32
34
|
|
|
33
35
|
def toFlat(self) -> "_tt.Tuple[Difference,...]":
|
|
34
36
|
"""Converts the differences from tree structure to a flat tuple.
|
|
37
|
+
|
|
35
38
|
Returns:
|
|
36
39
|
_tt.Tuple[Difference,...]: A tuple containing the difference.
|
|
37
40
|
"""
|
|
@@ -89,6 +89,8 @@ def toFileSystemItem(fr: "FileSystemItemLike") -> "FileSystemItem":
|
|
|
89
89
|
|
|
90
90
|
Returns:
|
|
91
91
|
FileSystemItem: The converted FileSystemItem object.
|
|
92
|
+
|
|
93
|
+
.. versionadded:: 2.2.0
|
|
92
94
|
"""
|
|
93
95
|
if isinstance(fr, FileSystemItemBase):
|
|
94
96
|
return fr
|
|
@@ -101,6 +103,8 @@ class FileSystemItemBase(_tt.abc.ABC):
|
|
|
101
103
|
|
|
102
104
|
Attributes:
|
|
103
105
|
path (Path): The path to the file or directory. :no-index:
|
|
106
|
+
|
|
107
|
+
.. versionadded:: 2.1.0
|
|
104
108
|
"""
|
|
105
109
|
|
|
106
110
|
path: Path
|
|
@@ -187,7 +191,11 @@ class FileSystemItemBase(_tt.abc.ABC):
|
|
|
187
191
|
return self.itemType == itemType
|
|
188
192
|
|
|
189
193
|
def torch(self):
|
|
190
|
-
"""
|
|
194
|
+
"""
|
|
195
|
+
Create a new file system item .
|
|
196
|
+
|
|
197
|
+
.. versionadded:: 2.2.0
|
|
198
|
+
"""
|
|
191
199
|
self.createSelf()
|
|
192
200
|
|
|
193
201
|
@_tt.abc.abstractmethod
|
|
@@ -297,12 +305,15 @@ class FileSystemItemBase(_tt.abc.ABC):
|
|
|
297
305
|
raise NotImplementedError("delete is not implemented")
|
|
298
306
|
|
|
299
307
|
|
|
300
|
-
|
|
301
308
|
class File(FileSystemItemBase):
|
|
302
309
|
"""
|
|
303
310
|
Represents a file in the file system.
|
|
304
311
|
|
|
305
312
|
Provides methods for file operations such as reading, writing, copying, and deleting.
|
|
313
|
+
|
|
314
|
+
.. versionchanged:: 2.1.0
|
|
315
|
+
class File is no longer the base class of the file system,
|
|
316
|
+
but a subclass of FileSystemItemBase.
|
|
306
317
|
"""
|
|
307
318
|
|
|
308
319
|
@property
|
|
@@ -406,6 +417,8 @@ class File(FileSystemItemBase):
|
|
|
406
417
|
|
|
407
418
|
Returns:
|
|
408
419
|
Any: The parsed JSON content.
|
|
420
|
+
|
|
421
|
+
.. versionadded:: 2.0.3
|
|
409
422
|
"""
|
|
410
423
|
with self.open("r", encoding=encoding) as file:
|
|
411
424
|
return json.load(file, **kw)
|
|
@@ -442,6 +455,8 @@ class File(FileSystemItemBase):
|
|
|
442
455
|
default (callable, optional): Custom serialization function. Defaults to None.
|
|
443
456
|
sort_keys (bool, optional): Sort keys in the output. Defaults to False.
|
|
444
457
|
**kw: Additional arguments for the json.dump function.
|
|
458
|
+
|
|
459
|
+
.. versionadded:: 2.0.3
|
|
445
460
|
"""
|
|
446
461
|
with self.open("w", encoding=encoding) as file:
|
|
447
462
|
json.dump(
|
|
@@ -466,6 +481,12 @@ class Directory(FileSystemItemBase):
|
|
|
466
481
|
|
|
467
482
|
Provides methods for directory operations such as creating,
|
|
468
483
|
deleting, copying, and iterating over contents.
|
|
484
|
+
|
|
485
|
+
.. versionadded:: 2.0.0
|
|
486
|
+
|
|
487
|
+
.. versionchanged:: 2.1.0
|
|
488
|
+
class Directory is no longer a subclass of File,
|
|
489
|
+
but directly inherits from FileSystemItemBase.
|
|
469
490
|
"""
|
|
470
491
|
|
|
471
492
|
@property
|
|
@@ -509,11 +530,13 @@ class Directory(FileSystemItemBase):
|
|
|
509
530
|
"""
|
|
510
531
|
_shutil.move(self.path, target)
|
|
511
532
|
self.path = Path(target)
|
|
533
|
+
|
|
512
534
|
def iterdir(self):
|
|
513
535
|
"""
|
|
514
536
|
Iterate over the files and directories in this directory.
|
|
515
537
|
"""
|
|
516
538
|
return self.path.iterdir()
|
|
539
|
+
|
|
517
540
|
def __iter__(self) -> "_tt.Iterator[FileSystemItem]":
|
|
518
541
|
"""
|
|
519
542
|
Iterate over the files and directories in this directory.
|
|
@@ -891,15 +914,22 @@ class Directory(FileSystemItemBase):
|
|
|
891
914
|
|
|
892
915
|
|
|
893
916
|
FileSystemItem = _tt.Union[File, Directory]
|
|
917
|
+
"""
|
|
918
|
+
.. versionadded:: 2.1.0
|
|
919
|
+
"""
|
|
920
|
+
|
|
894
921
|
|
|
895
922
|
FileSystemItemLike = _tt.Union[_tt.Pathable, "FileSystemItem"]
|
|
923
|
+
"""
|
|
924
|
+
.. versionadded:: 2.2.0
|
|
925
|
+
"""
|
|
896
926
|
|
|
897
927
|
|
|
898
|
-
|
|
928
|
+
|
|
929
|
+
@_deprecated("Use Directory instead", version="2.0")
|
|
899
930
|
class Folder(Directory):
|
|
900
931
|
"""
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
This class is deprecated and will be removed in a future release. Use `Directory` instead.
|
|
932
|
+
.. deprecated:: 2.0
|
|
933
|
+
This class is only designed to ensure the convenience for users to migrate from 1.0 to here.
|
|
934
|
+
In the new code, use "class Directory" instead
|
|
905
935
|
"""
|
|
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
|
|
File without changes
|
|
File without changes
|