Returns a list of files that match the given pattern(s).
(self, filename)
| 337 | client.put_object(Body=file_content, Bucket=bucket, Key=path) |
| 338 | |
| 339 | def glob(self, filename): |
| 340 | """Returns a list of files that match the given pattern(s).""" |
| 341 | # Only support prefix with * at the end and no ? in the string |
| 342 | star_i = filename.find("*") |
| 343 | quest_i = filename.find("?") |
| 344 | if quest_i >= 0: |
| 345 | raise NotImplementedError( |
| 346 | "{} not supported by compat glob".format(filename) |
| 347 | ) |
| 348 | if star_i != len(filename) - 1: |
| 349 | # Just return empty so we can use glob from directory watcher |
| 350 | # |
| 351 | # TODO: Remove and instead handle in GetLogdirSubdirectories. |
| 352 | # However, we would need to handle it for all non-local registered |
| 353 | # filesystems in some way. |
| 354 | return [] |
| 355 | filename = filename[:-1] |
| 356 | client = boto3.client("s3", endpoint_url=self._s3_endpoint) |
| 357 | bucket, path = self.bucket_and_path(filename) |
| 358 | p = client.get_paginator("list_objects") |
| 359 | keys = [] |
| 360 | for r in p.paginate(Bucket=bucket, Prefix=path): |
| 361 | for o in r.get("Contents", []): |
| 362 | key = o["Key"][len(path) :] |
| 363 | if key: # Skip the base dir, which would add an empty string |
| 364 | keys.append(filename + key) |
| 365 | return keys |
| 366 | |
| 367 | def isdir(self, dirname): |
| 368 | """Returns whether the path is a directory or not.""" |