Skip to content

Commit 6de2640

Browse files
committed
improve path logic, fix data output to match destination file, update style/syntax per isort, black, and flake8
1 parent 1648361 commit 6de2640

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

flickr/photos.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
# Standard library
22
import json
3+
import os.path
34
import sys
45
import traceback
56

67
# Third-party
78
import flickrapi
89
import query_secrets
910

11+
CWD = os.path.dirname(os.path.abspath(__file__))
12+
1013

1114
def main():
1215
flickr = flickrapi.FlickrAPI(
1316
query_secrets.api_key, query_secrets.api_secret, format="json"
1417
)
15-
licenseJson = flickr.photos.licenses.getInfo()
16-
licenseInfo = json.loads(licenseJson.decode("utf-8"))
1718

18-
# use search method to pull general photo info under each cc license
19-
# data saved in photos.json
19+
# use search method to pull general photo info under each cc license data
20+
# saved in photos.json
2021
dic = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 9: 0, 10: 0}
2122
for i in dic.keys():
2223
photosJson = flickr.photos.search(license=i, per_page=500)
23-
photos = json.loads(photosJson.decode("utf-8"))
24-
with open("photos.json") as json_file:
24+
dic[i] = [json.loads(photosJson.decode("utf-8"))]
25+
with open(os.path.join(CWD, "photos.json"), "w") as json_file:
2526
json.dump(dic, json_file)
2627

2728

0 commit comments

Comments
 (0)