Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use flag instead of getattr as it was not working as expected. Provid… #14

Merged
merged 2 commits into from
Apr 1, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions haralyzer/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,18 @@ def __init__(self, page_id, har_parser=None, har_data=None):

# Init properties that mimic the actual 'pages' object from the HAR file
raw_data = self.parser.har_data
valid = False
for page in raw_data['pages']:
if page['id'] == self.page_id:
valid = True
self.title = page['title']
self.startedDateTime = page['startedDateTime']
self.pageTimings = page['pageTimings']

if not getattr(self, 'title', None):
if not valid:
raise PageNotFoundError(
'No page found with id {0}\n\nValid pages are {1}'.format(
self.page_id, self.parser.pages)
'No page found with id {0}\n\nPages are {1}'.format(
self.page_id, raw_data['pages'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you think about just printing the page ID's here instead of the full pages dict? This output could probably get pretty confusing for a file with lots of HAR pages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that could work, I went with the closest thing to accessing the property .pages. I think the id's would be sufficient since most errors would have to do with the id in this instance

)

def __repr__(self):
Expand Down