Skip to content

Commit

Permalink
Make the linter happy after refactoring a lot #38
Browse files Browse the repository at this point in the history
  • Loading branch information
flosell committed Apr 22, 2018
1 parent 42c1b21 commit f03ad5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion trailscraper/cloudtrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class Record(object):
"""Represents a CloudTrail record"""

# pylint: disable=too-many-arguments
def __init__(self, event_source, event_name, resource_arns=None, assumed_role_arn=None, event_time=None, raw_source=None):
def __init__(self, event_source, event_name,
resource_arns=None, assumed_role_arn=None, event_time=None, raw_source=None):
self.event_source = event_source
self.event_name = event_name
self.raw_source = raw_source
Expand Down Expand Up @@ -236,6 +237,7 @@ def _parse_record(json_record):


def parse_records(json_records):
"""Convert JSON Records into Record objects"""
parsed_records = [_parse_record(record) for record in json_records]
return [r for r in parsed_records if r is not None]

Expand Down Expand Up @@ -312,6 +314,7 @@ def filter_records(records,
arns_to_filter_for=None,
from_date=datetime.datetime(1970, 1, 1, tzinfo=pytz.utc),
to_date=datetime.datetime.now(tz=pytz.utc)):
"""Filter records so they match the given condition"""
return pipe(records,
filterz(_by_timeframe(from_date, to_date)),
filterz(_by_role_arns(arns_to_filter_for)))
2 changes: 1 addition & 1 deletion trailscraper/policy_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def generate_policy_from_records(records,

filtered_records = list(filter_records(records, arns_to_filter_for, from_date, to_date))

if len(filtered_records) == 0 and records:
if filtered_records and records:
logging.warning(ALL_RECORDS_FILTERED)

return generate_policy(filtered_records)
Expand Down

0 comments on commit f03ad5a

Please sign in to comment.