MCPcopy Create free account
hub / github.com/pyathena-dev/PyAthena / info

Method info

pyathena/filesystem/s3.py:508–577  ·  view source on GitHub ↗
(self, path: str, **kwargs)

Source from the content-addressed store, hash-verified

506 break
507
508 def info(self, path: str, **kwargs) -> S3Object:
509 refresh = kwargs.pop("refresh", False)
510 path = self._strip_protocol(path)
511 bucket, key, path_version_id = self.parse_path(path)
512 version_id = path_version_id if path_version_id else kwargs.pop("version_id", None)
513 if path in ["/", ""]:
514 return S3Object(
515 init={
516 "ContentLength": 0,
517 "ContentType": None,
518 "StorageClass": S3StorageClass.S3_STORAGE_CLASS_BUCKET,
519 "ETag": None,
520 "LastModified": None,
521 },
522 type=S3ObjectType.S3_OBJECT_TYPE_DIRECTORY,
523 bucket=bucket,
524 key=None,
525 version_id=None,
526 )
527 if not refresh:
528 caches: list[S3Object] | S3Object | None = self._ls_from_cache(path)
529 if caches is not None:
530 if isinstance(caches, list):
531 cache = next((c for c in caches if c.name == path), None)
532 elif caches.name == path:
533 cache = caches
534 else:
535 cache = None
536
537 if cache:
538 if (
539 self.version_aware
540 and not version_id
541 and cache.get("type") == S3ObjectType.S3_OBJECT_TYPE_FILE
542 and not cache.get("version_id")
543 ):
544 # A version-aware lookup needs the version to pin;
545 # treat a version-less cached entry (e.g., populated
546 # by a listing) as stale and head the object again.
547 refresh = True
548 else:
549 return cache
550 else:
551 return self._directory_object(
552 bucket, key.rstrip("/") if key else None, version_id
553 )
554 if key:
555 object_info = self._head_object(path, refresh=refresh, version_id=version_id)
556 if object_info:
557 return object_info
558 else:
559 bucket_info = self._head_bucket(path, refresh=refresh)
560 if bucket_info:
561 return bucket_info
562 raise FileNotFoundError(path)
563
564 response = self._call(
565 self._client.list_objects_v2,

Callers 15

_findMethod · 0.95
existsMethod · 0.95
cp_fileMethod · 0.95
cat_fileMethod · 0.95
checksumMethod · 0.95
modifiedMethod · 0.95
__init__Method · 0.80
_initiate_uploadMethod · 0.80
_read_csvMethod · 0.80
to_sqlFunction · 0.80
test_struct_typesMethod · 0.80

Calls 8

parse_pathMethod · 0.95
_ls_from_cacheMethod · 0.95
_directory_objectMethod · 0.95
_head_objectMethod · 0.95
_head_bucketMethod · 0.95
_callMethod · 0.95
S3ObjectClass · 0.90
getMethod · 0.45

Tested by 14

test_struct_typesMethod · 0.64
test_array_typesMethod · 0.64
test_map_typesMethod · 0.64
test_array_operationsMethod · 0.64
test_info_bucketMethod · 0.64
test_info_dirMethod · 0.64