rclone-api 1.0.77__py2.py3-none-any.whl → 1.0.78__py2.py3-none-any.whl
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.
- rclone_api/__init__.py +1 -2
- rclone_api/dir_listing.py +10 -0
- rclone_api/file.py +7 -0
- rclone_api/group_files.py +3 -0
- rclone_api/rclone.py +15 -8
- rclone_api/types.py +4 -3
- {rclone_api-1.0.77.dist-info → rclone_api-1.0.78.dist-info}/METADATA +1 -1
- {rclone_api-1.0.77.dist-info → rclone_api-1.0.78.dist-info}/RECORD +12 -12
- {rclone_api-1.0.77.dist-info → rclone_api-1.0.78.dist-info}/LICENSE +0 -0
- {rclone_api-1.0.77.dist-info → rclone_api-1.0.78.dist-info}/WHEEL +0 -0
- {rclone_api-1.0.77.dist-info → rclone_api-1.0.78.dist-info}/entry_points.txt +0 -0
- {rclone_api-1.0.77.dist-info → rclone_api-1.0.78.dist-info}/top_level.txt +0 -0
rclone_api/__init__.py
CHANGED
@@ -9,7 +9,7 @@ from .process import Process
|
|
9
9
|
from .rclone import Rclone, rclone_verbose
|
10
10
|
from .remote import Remote
|
11
11
|
from .rpath import RPath
|
12
|
-
from .types import
|
12
|
+
from .types import ListingOption, Order, SizeResult
|
13
13
|
|
14
14
|
__all__ = [
|
15
15
|
"Rclone",
|
@@ -29,6 +29,5 @@ __all__ = [
|
|
29
29
|
"ListingOption",
|
30
30
|
"Order",
|
31
31
|
"ListingOption",
|
32
|
-
"GroupingOption",
|
33
32
|
"SizeResult",
|
34
33
|
]
|
rclone_api/dir_listing.py
CHANGED
@@ -29,6 +29,16 @@ class DirListing:
|
|
29
29
|
self.dirs: list[Dir] = [Dir(d) for d in dirs_and_files if d.is_dir]
|
30
30
|
self.files: list[File] = [File(f) for f in dirs_and_files if not f.is_dir]
|
31
31
|
|
32
|
+
def files_relative(self, prefix: str) -> list[str]:
|
33
|
+
"""Return a list of file paths relative to the root directory."""
|
34
|
+
from rclone_api.file import File
|
35
|
+
|
36
|
+
out: list[str] = []
|
37
|
+
f: File
|
38
|
+
for f in self.files:
|
39
|
+
out.append(f.relative_to(prefix))
|
40
|
+
return out
|
41
|
+
|
32
42
|
def __str__(self) -> str:
|
33
43
|
n_files = len(self.files)
|
34
44
|
n_dirs = len(self.dirs)
|
rclone_api/file.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import json
|
2
|
+
from pathlib import Path
|
2
3
|
|
3
4
|
from rclone_api.rpath import RPath
|
4
5
|
|
@@ -47,6 +48,12 @@ class File:
|
|
47
48
|
return f"{remote.name}:{rest}"
|
48
49
|
return rest
|
49
50
|
|
51
|
+
def relative_to(self, prefix: str) -> str:
|
52
|
+
"""Return the relative path to the other directory."""
|
53
|
+
self_path = Path(str(self))
|
54
|
+
rel_path = self_path.relative_to(prefix)
|
55
|
+
return str(rel_path.as_posix())
|
56
|
+
|
50
57
|
@property
|
51
58
|
def size(self) -> int:
|
52
59
|
"""Get the size of the file."""
|
rclone_api/group_files.py
CHANGED
@@ -182,6 +182,9 @@ def group_under_remote(
|
|
182
182
|
files: list[str], fully_qualified: bool = True
|
183
183
|
) -> dict[str, list[str]]:
|
184
184
|
"""split between filename and remote"""
|
185
|
+
|
186
|
+
#### DOE STHIS NEED TO BE REMOVEDD????? #####
|
187
|
+
|
185
188
|
assert fully_qualified is True, "Not implemented for fully_qualified=False"
|
186
189
|
out: dict[str, list[str]] = {}
|
187
190
|
for file in files:
|
rclone_api/rclone.py
CHANGED
@@ -24,14 +24,12 @@ from rclone_api.exec import RcloneExec
|
|
24
24
|
from rclone_api.file import File
|
25
25
|
from rclone_api.group_files import (
|
26
26
|
group_files,
|
27
|
-
group_under_remote,
|
28
27
|
group_under_remote_bucket,
|
29
28
|
)
|
30
29
|
from rclone_api.process import Process
|
31
30
|
from rclone_api.remote import Remote
|
32
31
|
from rclone_api.rpath import RPath
|
33
32
|
from rclone_api.types import (
|
34
|
-
GroupingOption,
|
35
33
|
ListingOption,
|
36
34
|
ModTimeStrategy,
|
37
35
|
Order,
|
@@ -840,21 +838,22 @@ class Rclone:
|
|
840
838
|
|
841
839
|
def size_files(
|
842
840
|
self,
|
841
|
+
src: str,
|
843
842
|
files: list[str],
|
844
843
|
fast_list: bool = True,
|
845
844
|
other_args: list[str] | None = None,
|
846
|
-
grouping: GroupingOption = GroupingOption.BUCKET,
|
847
845
|
check: bool | None = False,
|
848
846
|
verbose: bool | None = None,
|
849
847
|
) -> SizeResult:
|
850
848
|
"""Get the size of a list of files. Example of files items: "remote:bucket/to/file"."""
|
851
849
|
verbose = get_verbose(verbose)
|
852
850
|
check = get_check(check)
|
851
|
+
files = list(files)
|
852
|
+
prefix = src if src.endswith(":") else f"{src}/"
|
853
|
+
if src:
|
854
|
+
files = [f"{prefix}{f}" for f in files]
|
853
855
|
file_list: dict[str, list[str]]
|
854
|
-
|
855
|
-
file_list = group_under_remote_bucket(files)
|
856
|
-
elif grouping == GroupingOption.REMOTE:
|
857
|
-
file_list = group_under_remote(files)
|
856
|
+
file_list = group_under_remote_bucket(files)
|
858
857
|
all_files: list[File] = []
|
859
858
|
for src_path, files in file_list.items():
|
860
859
|
cmd = ["lsjson", src_path, "--files-only", "-R"]
|
@@ -900,5 +899,13 @@ class Rclone:
|
|
900
899
|
warnings.warn(f"File size is 0: {p}")
|
901
900
|
file_sizes[p] = f.size
|
902
901
|
total_size = sum(file_sizes.values())
|
903
|
-
|
902
|
+
file_sizes_path_corrected: dict[str, int] = {}
|
903
|
+
for path, size in file_sizes.items():
|
904
|
+
# remove the prefix
|
905
|
+
path_path = Path(path)
|
906
|
+
path_str = path_path.relative_to(prefix).as_posix()
|
907
|
+
file_sizes_path_corrected[path_str] = size
|
908
|
+
out: SizeResult = SizeResult(
|
909
|
+
prefix=prefix, total_size=total_size, file_sizes=file_sizes_path_corrected
|
910
|
+
)
|
904
911
|
return out
|
rclone_api/types.py
CHANGED
@@ -19,14 +19,15 @@ class Order(Enum):
|
|
19
19
|
RANDOM = "random"
|
20
20
|
|
21
21
|
|
22
|
-
class GroupingOption(Enum):
|
23
|
-
|
24
|
-
|
22
|
+
# class GroupingOption(Enum):
|
23
|
+
# BUCKET = "bucket"
|
24
|
+
# REMOTE = "remote"
|
25
25
|
|
26
26
|
|
27
27
|
@dataclass
|
28
28
|
class SizeResult:
|
29
29
|
"""Size result dataclass."""
|
30
30
|
|
31
|
+
prefix: str
|
31
32
|
total_size: int
|
32
33
|
file_sizes: dict[str, int]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
rclone_api/__init__.py,sha256=
|
1
|
+
rclone_api/__init__.py,sha256=UH1aIcovOSoiWwubbgBs_fvX3YcMhHnLTYJzLnCPKVs,722
|
2
2
|
rclone_api/cli.py,sha256=dibfAZIh0kXWsBbfp3onKLjyZXo54mTzDjUdzJlDlWo,231
|
3
3
|
rclone_api/completed_process.py,sha256=_IZ8IWK7DM1_tsbDEkH6wPZ-bbcrgf7A7smls854pmg,1775
|
4
4
|
rclone_api/config.py,sha256=tP6cU9DnCCEIRc_KP9HPur1jFLLg2QGFSxNwFm6_MVw,118
|
@@ -6,24 +6,24 @@ rclone_api/convert.py,sha256=Mx9Qo7zhkOedJd8LdhPvNGHp8znJzOk4f_2KWnoGc78,1012
|
|
6
6
|
rclone_api/deprecated.py,sha256=qWKpnZdYcBK7YQZKuVoWWXDwi-uqiAtbjgPcci_efow,590
|
7
7
|
rclone_api/diff.py,sha256=tMoJMAGmLSE6Q_7QhPf6PnCzb840djxMZtDmhc2GlGQ,5227
|
8
8
|
rclone_api/dir.py,sha256=i4h7LX5hB_WmVixxDRWL_l1nifvscrdWct_8Wx7wHZc,3540
|
9
|
-
rclone_api/dir_listing.py,sha256=
|
9
|
+
rclone_api/dir_listing.py,sha256=GoziW8Sne6FY90MLNcb2aO3aaa3jphB6H8ExYrV0Ryo,1882
|
10
10
|
rclone_api/exec.py,sha256=1ovvaMXDEfLiT7BrYZyE85u_yFhEUwUNW3jPOzqknR8,1023
|
11
|
-
rclone_api/file.py,sha256=
|
11
|
+
rclone_api/file.py,sha256=EP5yT2dZ0H2p7CY5n0y5k5pHhIliV25pm8KOwBklUTk,1863
|
12
12
|
rclone_api/filelist.py,sha256=xbiusvNgaB_b_kQOZoHMJJxn6TWGtPrWd2J042BI28o,767
|
13
|
-
rclone_api/group_files.py,sha256=
|
13
|
+
rclone_api/group_files.py,sha256=CiD2eRVyBn7_xumU0WvPW1268H3VTSy4m_7ZnOy-abg,6991
|
14
14
|
rclone_api/process.py,sha256=RrMfTe0bndmJ6gBK67ioqNvCstJ8aTC8RlGX1XBLlcw,4191
|
15
|
-
rclone_api/rclone.py,sha256=
|
15
|
+
rclone_api/rclone.py,sha256=e-SVNjxEGSvyyDXOv7AnLek7Wjt0NYDfBtvWSOA5F78,32858
|
16
16
|
rclone_api/remote.py,sha256=O9WDUFQy9f6oT1HdUbTixK2eg0xtBBm8k4Xl6aa6K00,431
|
17
17
|
rclone_api/rpath.py,sha256=8ZA_1wxWtskwcy0I8V2VbjKDmzPkiWd8Q2JQSvh-sYE,2586
|
18
18
|
rclone_api/scan_missing_folders.py,sha256=Kulca2Q6WZodt00ATFHkmqqInuoPvBkhTcS9703y6po,4740
|
19
|
-
rclone_api/types.py,sha256=
|
19
|
+
rclone_api/types.py,sha256=9-qY0Z1NFwiIrvV3e4Ty-dVfed1I_482jPohJ-2hs-o,567
|
20
20
|
rclone_api/util.py,sha256=XMrA2m_di4h8JTM-qyx2iyrFZn-l-or_SJOa5tEsDsI,4200
|
21
21
|
rclone_api/walk.py,sha256=-54NVE8EJcCstwDoaC_UtHm73R2HrZwVwQmsnv55xNU,3369
|
22
22
|
rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
|
23
23
|
rclone_api/cmd/list_files.py,sha256=x8FHODEilwKqwdiU1jdkeJbLwOqUkUQuDWPo2u_zpf0,741
|
24
|
-
rclone_api-1.0.
|
25
|
-
rclone_api-1.0.
|
26
|
-
rclone_api-1.0.
|
27
|
-
rclone_api-1.0.
|
28
|
-
rclone_api-1.0.
|
29
|
-
rclone_api-1.0.
|
24
|
+
rclone_api-1.0.78.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
25
|
+
rclone_api-1.0.78.dist-info/METADATA,sha256=DRNqEuwtsDKLk4yejLHUugWmD2oKBCSUGBxwZmSmYMw,4489
|
26
|
+
rclone_api-1.0.78.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
|
27
|
+
rclone_api-1.0.78.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
|
28
|
+
rclone_api-1.0.78.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
29
|
+
rclone_api-1.0.78.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|