Skip to content

Commit

Permalink
Fix error:
Browse files Browse the repository at this point in the history
TypeError: a bytes-like object is required, not 'generator'
  • Loading branch information
dpetzold committed Jan 28, 2025
1 parent 0c4430d commit d22a885
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aws_log_parser/aws/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def read_keys(self, bucket, prefix, endswith=None, regex_filter=None):
if endswith and not file["Key"].endswith(endswith):
continue

if reo and not reo.match(file):
if reo and not reo.match(file["Key"]):
continue

yield from self.read_key(bucket, file["Key"])
19 changes: 18 additions & 1 deletion test/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ def paginate(self, **_):
"ETag": '"37c13f9a66a79c2b474356adaf5da1d0"',
"Size": 2844,
"StorageClass": "STANDARD",
}
},
{
"Key": f"csv-file.csv{suffix}",
"LastModified": datetime.datetime(2021, 11, 28, 3, 31, 56, tzinfo=tzutc()),
"ETag": '"37c13f9a66a79c2b474356adaf555555"',
"Size": 2844,
"StorageClass": "STANDARD",
},
],
}

Expand Down Expand Up @@ -63,6 +70,16 @@ def cloudfront_parser():
)


def test_regex_filter(monkeypatch):
monkeypatch.setattr(S3Service, "client", MockS3Client())
aws_log_parser = AwsLogParser(
log_type=LogType.CloudFront,
regex_filter="cloudfront",
)
entries = aws_log_parser.read_url("s3://aws-logs-test-data/")
assert len(list(entries)) == 6


def test_parse_file(cloudfront_parser):
entries = cloudfront_parser.read_file("test/data/cloudfront-multiple.log")
assert len(list(entries)) == 6
Expand Down

0 comments on commit d22a885

Please sign in to comment.