rclone-api 1.0.69__py2.py3-none-any.whl → 1.0.70__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/diff_walk.py CHANGED
@@ -1,5 +1,6 @@
1
+ import time
1
2
  from concurrent.futures import ThreadPoolExecutor
2
- from queue import Queue
3
+ from queue import Empty, Queue
3
4
  from threading import Thread
4
5
  from typing import Generator
5
6
 
@@ -13,96 +14,71 @@ _MAX_OUT_QUEUE_SIZE = 50
13
14
 
14
15
  # ONLY Works from src -> dst diffing.
15
16
  def _async_diff_dir_walk_task(
16
- src: Dir, dst: Dir, max_depth: int, out_queue: Queue[Dir | None], reverse=False
17
+ src: Dir, dst: Dir, max_depth: int, out_queue: Queue[Dir | None], reverse
17
18
  ) -> None:
18
-
19
- try:
20
- stack = [(src, dst)]
21
- while stack:
22
- curr_src, curr_dst = stack.pop()
23
- curr_src = curr_src
24
- curr_dst = curr_dst
25
-
26
- with ThreadPoolExecutor(max_workers=2) as executor:
27
- # src_dir_listing = src.ls(listing_option=ListingOption.DIRS_ONLY)
28
- # dst_dir_listing = dst.ls(listing_option=ListingOption.DIRS_ONLY)
29
- t1 = executor.submit(
30
- src.ls, listing_option=ListingOption.DIRS_ONLY, reverse=reverse
31
- )
32
- t2 = executor.submit(
33
- dst.ls, listing_option=ListingOption.DIRS_ONLY, reverse=reverse
34
- )
35
- src_dir_listing: DirListing = t1.result()
36
- dst_dir_listing: DirListing = t2.result()
37
-
38
- # dirlisting = current_dir.ls()
39
- # if reverse:
40
- # dirlisting.dirs.reverse()
41
- # if depth != 0:
42
- # for subdir in dirlisting.dirs: # Process deeper directories first
43
- # # stack.append((child, depth - 1 if depth > 0 else depth))
44
- # next_depth = depth - 1 if depth > 0 else depth
45
- # _walk_runner_depth_first(
46
- # subdir, next_depth, out_queue, reverse=reverse
47
- # )
48
- # out_queue.put(dirlisting)
49
-
50
- # for subdir in dst_dir_listing.dirs:
51
- # subdir.to_string(include_remote=False)
52
- # walk_runner_depth_first()
53
-
54
- # find elements missing on dst
55
- # missing_on_dst: set[Dir] = set(src_dir_listing.dirs) - set(
56
- # dst_dir_listing.dirs
57
- # )
58
- # exists_on_dst: set[Dir] = set(src_dir_listing.dirs) - missing_on_dst
59
-
60
- dst_files: list[str] = [d.name for d in dst_dir_listing.dirs]
61
- src_files: list[str] = [d.name for d in src_dir_listing.dirs]
62
-
63
- dst_files_set: set[str] = set(dst_files)
64
- # src_files_set: set[str] = set(src_files)
65
-
66
- # print(f"src_files: {src_files}")
67
- # print(f"dst_files: {dst_files}")
68
-
69
- matching_dirs: list[str] = []
70
-
71
- for file in src_files:
72
- if file not in dst_files_set:
73
- # print(f"missing dir on src: {file}")
74
- queue_dir_listing: Queue[DirListing | None] = Queue()
75
- walk_runner_depth_first(
76
- dir=curr_src,
77
- max_depth=max_depth,
78
- out_queue=queue_dir_listing,
79
- reverse=reverse,
80
- )
81
- while dirlisting := queue_dir_listing.get():
82
- if dirlisting is None:
83
- break
84
- # print(f"dirlisting: {dirlisting}")
85
- for d in dirlisting.dirs:
86
- out_queue.put(d)
87
- else:
88
- matching_dirs.append(file)
89
-
90
- for matching_dir in matching_dirs:
91
- # print(f"matching dir: {matching_dir}")
92
- _async_diff_dir_walk_task(
93
- src=curr_src / matching_dir,
94
- dst=curr_dst / matching_dir,
95
- max_depth=max_depth,
96
- out_queue=out_queue,
19
+ curr_src, curr_dst = src, dst
20
+ with ThreadPoolExecutor(max_workers=2) as executor:
21
+ # src_dir_listing = src.ls(listing_option=ListingOption.DIRS_ONLY)
22
+ # dst_dir_listing = dst.ls(listing_option=ListingOption.DIRS_ONLY)
23
+ t1 = executor.submit(
24
+ src.ls, listing_option=ListingOption.DIRS_ONLY, reverse=reverse
25
+ )
26
+ t2 = executor.submit(
27
+ dst.ls, listing_option=ListingOption.DIRS_ONLY, reverse=reverse
28
+ )
29
+ src_dir_listing: DirListing = t1.result()
30
+ dst_dir_listing: DirListing = t2.result()
31
+ next_depth = max_depth - 1 if max_depth > 0 else max_depth
32
+ dst_files: list[str] = [d.name for d in dst_dir_listing.dirs]
33
+ src_files: list[str] = [d.name for d in src_dir_listing.dirs]
34
+ dst_files_set: set[str] = set(dst_files)
35
+ matching_dirs: list[str] = []
36
+ for file in src_files:
37
+ if file not in dst_files_set:
38
+ # print(f"missing dir on src: {file}")
39
+ queue_dir_listing: Queue[DirListing | None] = Queue()
40
+ if next_depth > 0 or next_depth == -1:
41
+ walk_runner_depth_first(
42
+ dir=curr_src,
43
+ out_queue=queue_dir_listing,
97
44
  reverse=reverse,
45
+ max_depth=next_depth,
98
46
  )
99
-
100
- out_queue.put(None)
101
- except KeyboardInterrupt:
47
+ while dirlisting := queue_dir_listing.get():
48
+ if dirlisting is None:
49
+ break
50
+ # print(f"dirlisting: {dirlisting}")
51
+ for d in dirlisting.dirs:
52
+ out_queue.put(d)
53
+ else:
54
+ matching_dirs.append(file)
55
+
56
+ for matching_dir in matching_dirs:
57
+ # print(f"matching dir: {matching_dir}")
58
+ if next_depth > 0 or next_depth == -1:
59
+ src_next = curr_src / matching_dir
60
+ dst_next = curr_dst / matching_dir
61
+ _async_diff_dir_walk_task(
62
+ src=src_next,
63
+ dst=dst_next,
64
+ max_depth=next_depth,
65
+ out_queue=out_queue,
66
+ reverse=reverse,
67
+ )
68
+
69
+
70
+ def async_diff_dir_walk_task(
71
+ src: Dir, dst: Dir, max_depth: int, out_queue: Queue[Dir | None], reverse=False
72
+ ) -> None:
73
+ try:
74
+ _async_diff_dir_walk_task(src, dst, max_depth, out_queue, reverse)
75
+ except Exception:
102
76
  import _thread
103
77
 
104
- out_queue.put(None)
105
78
  _thread.interrupt_main()
79
+ raise
80
+ finally:
81
+ out_queue.put(None)
106
82
 
107
83
 
108
84
  def diff_walk(
@@ -125,7 +101,7 @@ def diff_walk(
125
101
  out_queue: Queue[Dir | None] = Queue(maxsize=_MAX_OUT_QUEUE_SIZE)
126
102
 
127
103
  def task() -> None:
128
- _async_diff_dir_walk_task(src, dst, max_depth, out_queue, reverse=reverse)
104
+ async_diff_dir_walk_task(src, dst, max_depth, out_queue, reverse=reverse)
129
105
 
130
106
  worker = Thread(
131
107
  target=task,
@@ -133,10 +109,14 @@ def diff_walk(
133
109
  )
134
110
  worker.start()
135
111
 
136
- while dirlisting := out_queue.get():
137
- if dirlisting is None:
138
- break
139
- yield dirlisting
112
+ while True:
113
+ try:
114
+ dirlisting = out_queue.get_nowait()
115
+ if dirlisting is None:
116
+ break
117
+ yield dirlisting
118
+ except Empty:
119
+ time.sleep(0.1)
140
120
 
141
121
  worker.join()
142
122
  except KeyboardInterrupt:
rclone_api/dir.py CHANGED
@@ -102,7 +102,7 @@ class Dir:
102
102
  path = Path(self.path.path) / other
103
103
  rpath = RPath(
104
104
  self.path.remote,
105
- str(path),
105
+ str(path.as_posix()),
106
106
  name=other,
107
107
  size=0,
108
108
  mime_type="inode/directory",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.0.69
3
+ Version: 1.0.70
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  Maintainer: Zachary Vorhies
@@ -5,8 +5,8 @@ rclone_api/config.py,sha256=tP6cU9DnCCEIRc_KP9HPur1jFLLg2QGFSxNwFm6_MVw,118
5
5
  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=ggdDLUZxa13jMcPzKBcwAElmPCNWMOSR89D4yhpO74M,5264
8
- rclone_api/diff_walk.py,sha256=V8U6qwCzG7_Z6-xFpB4zP6kCq_jN30OMYo7tT92OTd0,5061
9
- rclone_api/dir.py,sha256=8EwaGonkCeHhe-rsVl98PkEKvyf-3pFUJnXqkN6Fx24,3509
8
+ rclone_api/diff_walk.py,sha256=fnCjzenKBBocu6sEd9CDEcwNqCUYwz3rZsxUuKNaYEg,4049
9
+ rclone_api/dir.py,sha256=BuXPd-bAvZund8k7mXjvx_UylsPFwbWq2zaUdflTX04,3520
10
10
  rclone_api/dir_listing.py,sha256=9Qqf2SUswrOEkyqmaH23V51I18X6ePiXb9B1vUwRF5o,1571
11
11
  rclone_api/exec.py,sha256=1ovvaMXDEfLiT7BrYZyE85u_yFhEUwUNW3jPOzqknR8,1023
12
12
  rclone_api/file.py,sha256=YtR5Y6c0YfXTS-sReOy2UgiSnafcAeO6b2hnbojBQD4,1423
@@ -21,9 +21,9 @@ rclone_api/util.py,sha256=_cvmHcJPRl2yXw4zgZiop3z-riA_8Ek6S5NDPw8cqSY,4198
21
21
  rclone_api/walk.py,sha256=ndWV7WBVQLbpZu3HuJrAe1cXcmQVjT9_YPsbat158bQ,3231
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.69.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
25
- rclone_api-1.0.69.dist-info/METADATA,sha256=bl94_jCcD0a0buUsLVFIQ-MPQ5O2fy-hFrvK1EvU7Ls,4489
26
- rclone_api-1.0.69.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
27
- rclone_api-1.0.69.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
28
- rclone_api-1.0.69.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
29
- rclone_api-1.0.69.dist-info/RECORD,,
24
+ rclone_api-1.0.70.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
25
+ rclone_api-1.0.70.dist-info/METADATA,sha256=73129SIcLoTZ3R35zB0vuZZ65SC0RBttGk1LtPARAx8,4489
26
+ rclone_api-1.0.70.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
27
+ rclone_api-1.0.70.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
28
+ rclone_api-1.0.70.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
29
+ rclone_api-1.0.70.dist-info/RECORD,,