-
Notifications
You must be signed in to change notification settings - Fork 243
adds other chrome profile directories to the collection list #154
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I think the important thing to fix would be to squeeze these 3 loops into 1.
osxcollector/osxcollector.py
Outdated
profile_paths = [] | ||
for subdir in os.listdir(chrome_path): | ||
if os.path.isdir(os.path.join(chrome_path, subdir)): | ||
if os.path.isfile("{0}/{1}/History".format(chrome_path, subdir)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if
statement could be merged with the one in the line before using and
.
osxcollector/osxcollector.py
Outdated
if not os.path.isdir(chrome_path): | ||
Logger.log_warning('Directory not found {0}'.format(chrome_path)) | ||
return | ||
|
||
profile_paths = [] | ||
for subdir in os.listdir(chrome_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a lengthy list comprehension, but you should be able to squeeze it into one if you'd like to :) In a Pythonic way ;)
E.g.:
profile_paths = [pathjoin(chrome_path, subdir) for subdir in os.listdir(chrome_path) if os.path.isdir(os.path.join(chrome_path, subdir)) and os.path.isfile("{0}/{1}/History".format(chrome_path, subdir))]
or sth like that ;)
osxcollector/osxcollector.py
Outdated
|
||
with Logger.Extra('osxcollector_subsection', 'preferences'): | ||
self._log_json_file(chrome_path, 'preferences') | ||
for profile_path in profile_paths: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you have introduced 3 new for loops, each looping over the same resource. Any way you can refactor this code to merge it into 1 loop?
I've updated as per review comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to cut this long line ;)
Maybe it was actually more readable when it was for/if? It's up to you to decide, I am just suggesting ;)
osxcollector/osxcollector.py
Outdated
if os.path.isdir(os.path.join(chrome_path, subdir)): | ||
if os.path.isfile("{0}/{1}/History".format(chrome_path, subdir)): | ||
profile_paths.append(pathjoin(chrome_path, subdir)) | ||
profile_paths = [pathjoin(chrome_path, subdir) for subdir in os.listdir(chrome_path) if os.path.isdir(os.path.join(chrome_path, subdir)) and os.path.isfile("{0}/{1}/History".format(chrome_path, subdir))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, okay, so now the tricky question is how do you split it into multiple lines so it is readable? ;)
@ytonui for some reason Travis is failing :( |
👍 shipit! |
No description provided.