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

Method cat_file

pyathena/filesystem/s3.py:1243–1273  ·  view source on GitHub ↗
(
        self, path: str, start: int | None = None, end: int | None = None, **kwargs
    )

Source from the content-addressed store, hash-verified

1241 raise
1242
1243 def cat_file(
1244 self, path: str, start: int | None = None, end: int | None = None, **kwargs
1245 ) -> bytes:
1246 bucket, key, version_id = self.parse_path(path)
1247 if start is not None or end is not None:
1248 size = self.info(path).get("size", 0)
1249 if start is None:
1250 range_start = 0
1251 elif start < 0:
1252 range_start = size + start
1253 else:
1254 range_start = start
1255
1256 if end is None:
1257 range_end = size
1258 elif end < 0:
1259 range_end = size + end
1260 else:
1261 range_end = end
1262
1263 ranges = (range_start, range_end)
1264 else:
1265 ranges = None
1266
1267 return self._get_object(
1268 bucket=bucket,
1269 key=cast(str, key),
1270 ranges=ranges,
1271 version_id=version_id,
1272 **kwargs,
1273 )[1]
1274
1275 def put_file(self, lpath: str, rpath: str, callback=_DEFAULT_CALLBACK, **kwargs):
1276 """Upload a local file to S3.

Callers 1

test_cat_rangesMethod · 0.80

Calls 4

parse_pathMethod · 0.95
infoMethod · 0.95
_get_objectMethod · 0.95
getMethod · 0.45

Tested by 1

test_cat_rangesMethod · 0.64