cloud-files 5.4.0__py3-none-any.whl → 5.4.1__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.4.0
3
+ Version: 5.4.1
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
@@ -1,26 +1,26 @@
1
1
  cloudfiles/__init__.py,sha256=pLB4CcV2l3Jgv_ni1520Np1pfzFj8Cpr87vNxFT3rNI,493
2
- cloudfiles/cloudfiles.py,sha256=diET6pfFQKKDKF0-MsbXKa9tvs_Ik4N_vHQ7nNL5eaM,51211
2
+ cloudfiles/cloudfiles.py,sha256=nUIW-SDyeldvmUu_SETJXS4x38Nv3Kj7TBwMwLQhjns,51196
3
3
  cloudfiles/compression.py,sha256=WXJHnoNLJ_NWyoY9ygZmFA2qMou35_9xS5dzF7-2H-M,6262
4
4
  cloudfiles/connectionpools.py,sha256=aL8RiSjRepECfgAFmJcz80aJFKbou7hsbuEgugDKwB8,4814
5
5
  cloudfiles/exceptions.py,sha256=N0oGQNG-St6RvnT8e5p_yC_E61q2kgAe2scwAL0F49c,843
6
6
  cloudfiles/gcs.py,sha256=unqu5KxGKaPq6N4QeHSpCDdtnK1BzPOAerTZ8FLt2_4,3820
7
- cloudfiles/interfaces.py,sha256=f_7doKCiI_8--ghsQJvh8f5HhAn5u3haSlPHlxi_jbw,43949
7
+ cloudfiles/interfaces.py,sha256=3_ybsCKf74DPpI5Vv-BwFLLzc1cLUMfZLBtIKWkfoHQ,44478
8
8
  cloudfiles/lib.py,sha256=HHjCvjmOjA0nZWSvHGoSeYpxqd6FAG8xk8LM212LAUA,5382
9
9
  cloudfiles/paths.py,sha256=HOvtdLSIYGwlwvnZt9d_Ez3TXOe7WWd18bZNDpExUDQ,12231
10
10
  cloudfiles/resumable_tools.py,sha256=NyuSoGh1SaP5akrHCpd9kgy2-JruEWrHW9lvJxV7jpE,6711
11
11
  cloudfiles/scheduler.py,sha256=DqDANmOpB3NdzFgJDNMMibRIkCrXQqIh2XGL8GWoc9c,3668
12
- cloudfiles/secrets.py,sha256=791b5a8nWSBYtlleGzKeoYIR5jl-FI1bw6INRM4Wy-0,5295
12
+ cloudfiles/secrets.py,sha256=IuYKHmmvFmQTyG2Zcmbx7e8U2LIv-woG5d8qyOlyCD8,5431
13
13
  cloudfiles/test.py,sha256=jktBhzKLU448QPs5H7QVnTvpYMo4lBBWG1aE7-uzVGQ,678
14
14
  cloudfiles/threaded_queue.py,sha256=Nl4vfXhQ6nDLF8PZpSSBpww0M2zWtcd4DLs3W3BArBw,7082
15
15
  cloudfiles/typing.py,sha256=f3ZYkNfN9poxhGu5j-P0KCxjCCqSn9HAg5KiIPkjnCg,416
16
16
  cloudfiles_cli/LICENSE,sha256=Jna4xYE8CCQmaxjr5Fs-wmUBnIQJ1DGcNn9MMjbkprk,1538
17
17
  cloudfiles_cli/__init__.py,sha256=Wftt3R3F21QsHtWqx49ODuqT9zcSr0em7wk48kcH0WM,29
18
- cloudfiles_cli/cloudfiles_cli.py,sha256=KIK917MxYGmwiI7mXVYpL4M8iiyMew8Pd1eyWoI57yE,34866
19
- cloud_files-5.4.0.dist-info/AUTHORS,sha256=BFVmobgAhaVFI5fqbuqAY5XmBQxe09ZZAsAOTy87hKQ,318
20
- cloud_files-5.4.0.dist-info/LICENSE,sha256=Jna4xYE8CCQmaxjr5Fs-wmUBnIQJ1DGcNn9MMjbkprk,1538
21
- cloud_files-5.4.0.dist-info/METADATA,sha256=5kfzAsz8p7atAOuxCL1vVGljLsbyJTKFczui7pT-mH4,26970
22
- cloud_files-5.4.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
23
- cloud_files-5.4.0.dist-info/entry_points.txt,sha256=xlirb1FVhn1mbcv4IoyMEGumDqKOA4VMVd3drsRQxIg,51
24
- cloud_files-5.4.0.dist-info/pbr.json,sha256=dzxLD7W5Cqa2-KE8tL8nKLWjTqsUGyu181SesfMhxXA,46
25
- cloud_files-5.4.0.dist-info/top_level.txt,sha256=xPyrST3okJbsmdCF5IC2gYAVxg_aD5AYVTnNo8UuoZU,26
26
- cloud_files-5.4.0.dist-info/RECORD,,
18
+ cloudfiles_cli/cloudfiles_cli.py,sha256=L9xr_z9GCf5PcpmA21Iandim7uMviaLxTZ4Pf1B9Ui0,34865
19
+ cloud_files-5.4.1.dist-info/AUTHORS,sha256=BFVmobgAhaVFI5fqbuqAY5XmBQxe09ZZAsAOTy87hKQ,318
20
+ cloud_files-5.4.1.dist-info/LICENSE,sha256=Jna4xYE8CCQmaxjr5Fs-wmUBnIQJ1DGcNn9MMjbkprk,1538
21
+ cloud_files-5.4.1.dist-info/METADATA,sha256=BZxaKaIJQbrjwqOv22B6hvKgcGytByxLvymqMCud8zA,26970
22
+ cloud_files-5.4.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
23
+ cloud_files-5.4.1.dist-info/entry_points.txt,sha256=xlirb1FVhn1mbcv4IoyMEGumDqKOA4VMVd3drsRQxIg,51
24
+ cloud_files-5.4.1.dist-info/pbr.json,sha256=vJBo8lXE6N74KksvUpcUNMoRKRKsC1vGUjDpi0woDm4,46
25
+ cloud_files-5.4.1.dist-info/top_level.txt,sha256=xPyrST3okJbsmdCF5IC2gYAVxg_aD5AYVTnNo8UuoZU,26
26
+ cloud_files-5.4.1.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ {"git_version": "e4d56b4", "is_release": true}
cloudfiles/cloudfiles.py CHANGED
@@ -751,8 +751,7 @@ class CloudFiles:
751
751
  res = first(self.list(prefix=prefix))
752
752
  return res is not None
753
753
  except NotImplementedError as err:
754
- res = CloudFile(self.cloudpath).size()
755
- return res > 0
754
+ return not CloudFile(self.cloudpath).exists()
756
755
 
757
756
  def exists(
758
757
  self, paths:GetPathType,
cloudfiles/interfaces.py CHANGED
@@ -1497,8 +1497,25 @@ class CaveInterface(HttpInterface):
1497
1497
  is, don't worry about it.
1498
1498
  see: https://github.com/CAVEconnectome
1499
1499
  """
1500
- def default_headers(self):
1501
- cred = cave_credentials()
1500
+ def __init__(self, path, secrets=None, **kwargs):
1501
+ super().__init__(path, secrets=secrets, **kwargs)
1502
+
1503
+ secrets = kwargs.get('secrets', None)
1504
+ if secrets is None:
1505
+ secrets = {}
1506
+
1507
+ self._token = secrets.get('token', None)
1508
+ if self._token is None:
1509
+ server = self._path.host.replace("https://", "", 1)
1510
+ server = server.replace("http://", "", 1)
1511
+ self._token = cave_credentials(server)
1512
+ if self._token is not None:
1513
+ self._token = self._token.get('token', None)
1514
+
1515
+ def default_headers(self) -> dict:
1516
+ if self._token is None:
1517
+ return {}
1518
+
1502
1519
  return {
1503
- "Authorization": f"Bearer {cred['token']}",
1504
- }
1520
+ "Authorization": f"Bearer {self._token}",
1521
+ }
cloudfiles/secrets.py CHANGED
@@ -137,23 +137,27 @@ def aws_credentials(bucket = '', service = 'aws', skip_files=False):
137
137
  AWS_CREDENTIALS_CACHE[service][bucket] = aws_credentials
138
138
  return aws_credentials
139
139
 
140
- CAVE_CREDENTIALS = None
141
- def cave_credentials():
140
+ CAVE_CREDENTIALS:CredentialCacheType = {}
141
+ def cave_credentials(server = ''):
142
142
  global CAVE_CREDENTIALS
143
- default_file_path = 'cave-secret.json'
144
- path = secretpath(default_file_path)
145
143
 
146
- if CAVE_CREDENTIALS:
147
- return CAVE_CREDENTIALS
144
+ paths = [
145
+ secretpath('cave-secret.json')
146
+ ]
148
147
 
149
- if os.path.exists(path):
150
- with open(path, 'rt') as f:
151
- CAVE_CREDENTIALS = json.loads(f.read())
152
- else:
153
- CAVE_CREDENTIALS = None
148
+ if server:
149
+ paths = [ secretpath(f'{server}-cave-secret.json') ] + paths
150
+
151
+ if server in CAVE_CREDENTIALS:
152
+ return CAVE_CREDENTIALS.get(server, None)
154
153
 
155
- return CAVE_CREDENTIALS
154
+ for path in paths:
155
+ if os.path.exists(path):
156
+ with open(path, 'rt') as f:
157
+ CAVE_CREDENTIALS[server] = json.loads(f.read())
158
+ break
156
159
 
160
+ return CAVE_CREDENTIALS.get(server, None)
157
161
 
158
162
  HTTP_CREDENTIALS = None
159
163
  def http_credentials():
@@ -84,7 +84,7 @@ def license():
84
84
  @main.command()
85
85
  @click.option('--shortpath', is_flag=True, default=False, help='Don\'t print the common base path for each listed path.',show_default=True)
86
86
  @click.option('--flat', is_flag=True, default=False, help='Only produce a single level of directory hierarchy.',show_default=True)
87
- @click.option('-e','--expr',is_flag=True, default=False, help='Use a limited regexp language (e.g. [abc123]\{3\}) to generate prefixes.', show_default=True)
87
+ @click.option('-e','--expr',is_flag=True, default=False, help=r'Use a limited regexp language (e.g. [abc123]{3}) to generate prefixes.', show_default=True)
88
88
  @click.option('--no-auth',is_flag=True, default=False, help='Uses the http API for read-only operations.', show_default=True)
89
89
  @click.argument("cloudpath")
90
90
  def ls(shortpath, flat, expr, cloudpath, no_auth):
@@ -1 +0,0 @@
1
- {"git_version": "002c3fc", "is_release": true}