cloud-files 5.6.1__py3-none-any.whl → 5.8.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cloud-files
3
- Version: 5.6.1
3
+ Version: 5.8.0
4
4
  Summary: Fast access to cloud storage and local FS.
5
5
  Home-page: https://github.com/seung-lab/cloud-files/
6
6
  Author: William Silversmith
@@ -16,12 +16,12 @@ cloudfiles/threaded_queue.py,sha256=Nl4vfXhQ6nDLF8PZpSSBpww0M2zWtcd4DLs3W3BArBw,
16
16
  cloudfiles/typing.py,sha256=f3ZYkNfN9poxhGu5j-P0KCxjCCqSn9HAg5KiIPkjnCg,416
17
17
  cloudfiles_cli/LICENSE,sha256=Jna4xYE8CCQmaxjr5Fs-wmUBnIQJ1DGcNn9MMjbkprk,1538
18
18
  cloudfiles_cli/__init__.py,sha256=Wftt3R3F21QsHtWqx49ODuqT9zcSr0em7wk48kcH0WM,29
19
- cloudfiles_cli/cloudfiles_cli.py,sha256=IT6CHH7rI2B79ecV526uFa6ruAC8Yg25OO36Uwfxenc,37464
20
- cloud_files-5.6.1.dist-info/AUTHORS,sha256=BFVmobgAhaVFI5fqbuqAY5XmBQxe09ZZAsAOTy87hKQ,318
21
- cloud_files-5.6.1.dist-info/LICENSE,sha256=Jna4xYE8CCQmaxjr5Fs-wmUBnIQJ1DGcNn9MMjbkprk,1538
22
- cloud_files-5.6.1.dist-info/METADATA,sha256=AtO_CMUdfIoENAA2dteG4C0R0SBobuLaxjGslNLS1hI,30530
23
- cloud_files-5.6.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
24
- cloud_files-5.6.1.dist-info/entry_points.txt,sha256=xlirb1FVhn1mbcv4IoyMEGumDqKOA4VMVd3drsRQxIg,51
25
- cloud_files-5.6.1.dist-info/pbr.json,sha256=9w298syusRXCWa2l5yRkPwkdr43ov_GG0cxCaTBLnmg,46
26
- cloud_files-5.6.1.dist-info/top_level.txt,sha256=xPyrST3okJbsmdCF5IC2gYAVxg_aD5AYVTnNo8UuoZU,26
27
- cloud_files-5.6.1.dist-info/RECORD,,
19
+ cloudfiles_cli/cloudfiles_cli.py,sha256=JlP9ocqxZbMANAZhZCQSvvjwe6syovQ1asUzSeAlNYk,38459
20
+ cloud_files-5.8.0.dist-info/AUTHORS,sha256=BFVmobgAhaVFI5fqbuqAY5XmBQxe09ZZAsAOTy87hKQ,318
21
+ cloud_files-5.8.0.dist-info/LICENSE,sha256=Jna4xYE8CCQmaxjr5Fs-wmUBnIQJ1DGcNn9MMjbkprk,1538
22
+ cloud_files-5.8.0.dist-info/METADATA,sha256=uXp_MHaSxsZl91_w6JH5AK57J0NrpGg0i5Wj5GstvYQ,30530
23
+ cloud_files-5.8.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
24
+ cloud_files-5.8.0.dist-info/entry_points.txt,sha256=xlirb1FVhn1mbcv4IoyMEGumDqKOA4VMVd3drsRQxIg,51
25
+ cloud_files-5.8.0.dist-info/pbr.json,sha256=dhdn7QTnwpurvm9-sKoKO96OpKHfH64LwrYqVj-oPTs,46
26
+ cloud_files-5.8.0.dist-info/top_level.txt,sha256=xPyrST3okJbsmdCF5IC2gYAVxg_aD5AYVTnNo8UuoZU,26
27
+ cloud_files-5.8.0.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ {"git_version": "9e3fa7f", "is_release": true}
@@ -97,7 +97,7 @@ def ls(shortpath, flat, expr, cloudpath, no_auth):
97
97
  if no_auth and 's3://' not in cloudpath:
98
98
  cloudpath = cloudfiles.paths.to_https_protocol(cloudpath)
99
99
 
100
- _, flt, prefix = get_mfp(cloudpath, True)
100
+ _, flt, prefix, suffix = get_mfp(cloudpath, True)
101
101
  epath = extract(cloudpath)
102
102
  if len(epath.path) > 0:
103
103
  if prefix == "" and flt == False:
@@ -128,6 +128,10 @@ def ls(shortpath, flat, expr, cloudpath, no_auth):
128
128
  iterables = [ cf.list(prefix=prefix, flat=flat) ]
129
129
 
130
130
  iterables = itertools.chain(*iterables)
131
+
132
+ if suffix:
133
+ iterables = ( x for x in iterables if x.endswith(suffix) )
134
+
131
135
  for pathset in sip(iterables, 1000):
132
136
  if not shortpath:
133
137
  pathset = [ cloudpathjoin(cloudpath, pth) for pth in pathset ]
@@ -152,6 +156,7 @@ def exprgen(prefix, matches):
152
156
 
153
157
  return finished_prefixes
154
158
 
159
+ SUFFIX_REGEXP = re.compile(r'\*([\w\d\-\._]+)$')
155
160
 
156
161
  def get_mfp(path, recursive):
157
162
  """many,flat,prefix"""
@@ -159,6 +164,13 @@ def get_mfp(path, recursive):
159
164
  flat = not recursive
160
165
  many = recursive
161
166
  prefix = ""
167
+ suffix = ""
168
+
169
+ matches = SUFFIX_REGEXP.search(path)
170
+ if matches is not None:
171
+ suffix = matches.groups()[0]
172
+ path = path.removesuffix(suffix)
173
+
162
174
  if path[-2:] == "**":
163
175
  many = True
164
176
  flat = False
@@ -168,7 +180,20 @@ def get_mfp(path, recursive):
168
180
  flat = True
169
181
  prefix = os.path.basename(path[:-1])
170
182
 
171
- return (many, flat, prefix)
183
+ return (many, flat, prefix, suffix)
184
+
185
+ @main.command("mkdir")
186
+ @click.argument("paths", nargs=-1)
187
+ def _mkdir(paths):
188
+ """
189
+ Create paths on the local file system.
190
+ """
191
+ for path in paths:
192
+ path = normalize_path(path)
193
+ protocol = get_protocol(path)
194
+
195
+ if protocol == "file":
196
+ mkdir(path.replace("file://", "", 1))
172
197
 
173
198
  @main.command()
174
199
  @click.argument("source", nargs=-1)
@@ -267,7 +292,7 @@ def _cp_single(
267
292
 
268
293
  # The else clause here is to handle single file transfers
269
294
  srcpath = nsrc if issrcdir else os.path.dirname(nsrc)
270
- many, flat, prefix = get_mfp(nsrc, recursive)
295
+ many, flat, prefix, suffix = get_mfp(nsrc, recursive)
271
296
 
272
297
  if issrcdir and not many:
273
298
  print(f"cloudfiles: {source} is a directory (not copied).")
@@ -302,6 +327,9 @@ def _cp_single(
302
327
  compression = False
303
328
 
304
329
  if not isinstance(xferpaths, str):
330
+ if suffix:
331
+ xferpaths = ( x for x in xferpaths if x.endswith(suffix) )
332
+
305
333
  if parallel == 1:
306
334
  _cp(
307
335
  srcpath, destpath, compression,
@@ -494,7 +522,7 @@ def _mv_single(
494
522
 
495
523
  # The else clause here is to handle single file transfers
496
524
  srcpath = nsrc if issrcdir else os.path.dirname(nsrc)
497
- many, flat, prefix = get_mfp(nsrc, recursive)
525
+ many, flat, prefix, suffix = get_mfp(nsrc, recursive)
498
526
 
499
527
  if issrcdir and not many:
500
528
  print(f"cloudfiles: {source} is a directory (not copied).")
@@ -524,6 +552,9 @@ def _mv_single(
524
552
  return
525
553
 
526
554
  if not isinstance(xferpaths, str):
555
+ if suffix:
556
+ xferpaths = ( x for x in xferpaths if x.endswith(suffix) )
557
+
527
558
  if parallel == 1:
528
559
  _mv(srcpath, destpath, progress, block_size, part_bytes, no_sign_request, xferpaths)
529
560
  return
@@ -570,6 +601,7 @@ def touch(
570
601
  ctx, sources,
571
602
  progress, no_sign_request,
572
603
  ):
604
+ """Create file if it doesn't exist."""
573
605
  sources = list(map(normalize_path, sources))
574
606
  sources = [ src.replace("precomputed://", "") for src in sources ]
575
607
  pbar = tqdm(total=len(sources), desc="Touch", disable=(not progress))
@@ -701,7 +733,7 @@ def rm(ctx, paths, recursive, progress, block_size):
701
733
  singles = []
702
734
  multiples = []
703
735
  for path in paths:
704
- many, flat, prefix = get_mfp(path, recursive)
736
+ many, flat, prefix, suffix = get_mfp(path, recursive)
705
737
  if ispathdir(path) and not many:
706
738
  print(f"cloudfiles: {path}: is a directory.")
707
739
  return
@@ -742,13 +774,15 @@ def _rm_many(path, recursive, progress, parallel, block_size):
742
774
  isdir = (ispathdir(path) or CloudFiles(npath).isdir())
743
775
  recursive = recursive and isdir
744
776
 
745
- many, flat, prefix = get_mfp(path, recursive)
777
+ many, flat, prefix, suffix = get_mfp(path, recursive)
746
778
 
747
779
  cfpath = npath if isdir else os.path.dirname(npath)
748
780
  xferpaths = os.path.basename(npath)
749
781
 
750
782
  if many:
751
783
  xferpaths = CloudFiles(cfpath).list(prefix=prefix, flat=flat)
784
+ if suffix:
785
+ xferpaths = ( x for x in xferpaths if x.endswith(suffix) )
752
786
 
753
787
  if parallel == 1 or not many:
754
788
  __rm(cfpath, progress, xferpaths)
@@ -825,10 +859,13 @@ def head(paths):
825
859
  for path in paths:
826
860
  npath = normalize_path(path)
827
861
  npath = re.sub(r'\*+$', '', path)
828
- many, flat, prefix = get_mfp(path, False)
862
+ many, flat, prefix, suffix = get_mfp(path, False)
829
863
  if many:
830
864
  cf = CloudFiles(npath)
831
- res = cf.head(cf.list(prefix=prefix, flat=flat))
865
+ lst = cf.list(prefix=prefix, flat=flat)
866
+ if suffix:
867
+ lst = ( x for x in lst if x.endswith(suffix) )
868
+ res = cf.head(lst)
832
869
  results.update(res)
833
870
  else:
834
871
  cf = CloudFiles(os.path.dirname(npath))
@@ -1 +0,0 @@
1
- {"git_version": "5554b92", "is_release": true}