File tree Expand file tree Collapse file tree 5 files changed +29
-12
lines changed
Expand file tree Collapse file tree 5 files changed +29
-12
lines changed Original file line number Diff line number Diff line change 22from base64 import b64decode
33from pathlib import Path
44
5- JSON_FILE_NAME = "An ec-1667994848"
6- IMAGE_DIR = Path .cwd () / "images" / JSON_FILE_NAME
5+ JSON_FILE = Path ( "An ec-1668602437.json" )
6+ IMAGE_DIR = Path .cwd () / "images" / JSON_FILE . stem
77DATA_DIR = Path .cwd () / "responses"
88
99IMAGE_DIR .mkdir (parents = True , exist_ok = True )
1010
11- with open (DATA_DIR / f" { JSON_FILE_NAME } .json" , "r" ) as f :
12- response = json .load (f )
11+ with open (DATA_DIR / JSON_FILE , "r" ) as file :
12+ response = json .load (file )
1313
1414for index , image_dict in enumerate (response ["data" ]):
1515 image_data = b64decode (image_dict ["b64_json" ])
16- with open (IMAGE_DIR / f"{ JSON_FILE_NAME } -{ index } .png" , "wb" ) as f :
17- f .write (image_data )
16+ with open (IMAGE_DIR / f"{ JSON_FILE . stem } -{ index } .png" , "wb" ) as png_file :
17+ png_file .write (image_data )
Original file line number Diff line number Diff line change 2020
2121file_name = DATA_DIR / f"{ PROMPT [:5 ]} -{ response ['created' ]} .json"
2222
23- with open (file_name , mode = "w" ) as file_path :
24- json .dump (response , file_path )
23+ with open (file_name , mode = "w" , encoding = "utf-8" ) as file :
24+ json .dump (response , file )
Original file line number Diff line number Diff line change 2525with open (
2626 DESTINATION_PATH / f"edit-{ PROMPT [:5 ]} -{ response ['created' ]} .json" ,
2727 mode = "w" ,
28- ) as fp :
29- json .dump (response , fp )
28+ encoding = "utf-8" ,
29+ ) as file :
30+ json .dump (response , file )
Original file line number Diff line number Diff line change 1+ certifi == 2022.9.24
2+ charset-normalizer == 2.1.1
3+ et-xmlfile == 1.1.0
4+ idna == 3.4
5+ numpy == 1.23.4
6+ openai == 0.25.0
7+ openpyxl == 3.0.10
8+ pandas == 1.5.1
9+ pandas-stubs == 1.2.0.62
10+ python-dateutil == 2.8.2
11+ pytz == 2022.6
12+ requests == 2.28.1
13+ six == 1.16.0
14+ tqdm == 4.64.1
15+ typing_extensions == 4.4.0
16+ urllib3 == 1.26.12
Original file line number Diff line number Diff line change 2323
2424new_file_name = f"vary-{ SOURCE_FILE [:4 ]} -{ response ['created' ]} .json"
2525
26- with open (DATA_DIR / new_file_name , mode = "w" ) as new_json_file :
27- json .dump (response , new_json_file )
26+ with open (DATA_DIR / new_file_name , mode = "w" , encoding = "utf-8" ) as file :
27+ json .dump (response , file )
You can’t perform that action at this time.
0 commit comments