Skip to content

Commit 7bcabfc

Browse files
committed
Merge pull request #1 from danasmera-clone/master
Made script PEP8 compliant
2 parents 2b17bfd + fc72d3c commit 7bcabfc

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

show_firefox_bookmarks.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22
'''extract a list of URLs from Firefox exported bookmars JSON file '''
3-
43
__author__ = "Daniel T."
54
__license__ = "GPL"
65
__version__ = "0.1.0"
@@ -12,6 +11,7 @@
1211
import json
1312
import io
1413

14+
1515
def Usage():
1616
print "{0} Path-to-bookmarks-file".format(sys.argv[0])
1717
sys.exit(1)
@@ -26,33 +26,32 @@ def Usage():
2626
print "{0} not found.".format(bookmark_file)
2727
sys.exit(1)
2828

29-
# Load JSON file
29+
# Load JSON file
3030
fp_data = io.open(bookmark_file, encoding='utf-8')
3131
try:
3232
jdata = json.load(fp_data)
3333
except ValueError:
3434
print "{0} not valid JSON file".format(bookmark_file)
3535
sys.exit(1)
3636
fp_data.close()
37-
38-
3937
#Recursive function to get the title and URL keys from JSON file
40-
38+
39+
4140
def grab_keys(bookmarks_data, bookmarks_list=[]):
42-
if 'children' in bookmarks_data:
43-
for item in bookmarks_data['children']:
44-
bookmarks_list.append({'title': item.get('title', 'No title'),
45-
'uri': item.get('uri', 'None')})
46-
grab_keys(item, bookmarks_list)
47-
return bookmarks_list
48-
49-
41+
if 'children' in bookmarks_data:
42+
for item in bookmarks_data['children']:
43+
bookmarks_list.append({'title': item.get('title', 'No title'),
44+
'uri': item.get('uri', 'None')})
45+
grab_keys(item, bookmarks_list)
46+
return bookmarks_list
47+
48+
5049
def main():
51-
mydata=grab_keys(jdata)
52-
for item in mydata:
53-
myurl = item['uri']
54-
if myurl.startswith('http') or myurl.startswith('ftp'):
55-
print item['uri'], " ", item['title']
56-
57-
if __name__=="__main__":
58-
main()
50+
mydata = grab_keys(jdata)
51+
for item in mydata:
52+
myurl = item['uri']
53+
if myurl.startswith('http') or myurl.startswith('ftp'):
54+
print item['uri'], " ", item['title']
55+
56+
if __name__ == "__main__":
57+
main()

0 commit comments

Comments
 (0)