change vsCode settings for python
This commit is contained in:
parent
c408c55086
commit
fed6380af6
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
@ -9,5 +9,8 @@
|
||||||
},
|
},
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.formatOnPaste": true,
|
"editor.formatOnPaste": true,
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"[python]": {
|
||||||
|
"editor.defaultFormatter": "ms-python.python"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,8 @@ import requests
|
||||||
import json
|
import json
|
||||||
|
|
||||||
# add category name here
|
# add category name here
|
||||||
allCategories = ['counterspell', 'beast', 'burn', 'commander', 'artist'] #, 'terror', 'wrath', 'zombie', 'artifact']
|
# , 'terror', 'wrath', 'zombie', 'artifact']
|
||||||
|
allCategories = ['counterspell', 'beast', 'burn', 'commander', 'artist']
|
||||||
specialCategories = ['set', 'basic']
|
specialCategories = ['set', 'basic']
|
||||||
artists = dict()
|
artists = dict()
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ def generate_initial_query(category):
|
||||||
print(string_query)
|
print(string_query)
|
||||||
return string_query
|
return string_query
|
||||||
|
|
||||||
|
|
||||||
def generate_initial_special_query(category):
|
def generate_initial_special_query(category):
|
||||||
string_query = 'https://api.scryfall.com/cards/search?q='
|
string_query = 'https://api.scryfall.com/cards/search?q='
|
||||||
if category == 'set':
|
if category == 'set':
|
||||||
|
@ -84,18 +86,19 @@ def fetch_and_write_all_special(category, query):
|
||||||
json.dump(all_cards, f)
|
json.dump(all_cards, f)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def fetch(query, count):
|
def fetch(query, count):
|
||||||
query += str(count)
|
query += str(count)
|
||||||
response = requests.get(f"{query}").json()
|
response = requests.get(f"{query}").json()
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def fetch_special(query):
|
def fetch_special(query):
|
||||||
response = requests.get(f"{query}").json()
|
response = requests.get(f"{query}").json()
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def write_art(art_names, id, index, digital):
|
def write_art(art_names, id, index, digital):
|
||||||
if digital:
|
if digital:
|
||||||
art_names[id] = index
|
art_names[id] = index
|
||||||
|
@ -104,7 +107,8 @@ def write_art(art_names, id, index, digital):
|
||||||
|
|
||||||
|
|
||||||
def to_compact_write_form(smallJson, art_names, response, category):
|
def to_compact_write_form(smallJson, art_names, response, category):
|
||||||
fieldsInCard = ['name', 'image_uris', 'flavor_name', 'reprint', 'frame_effects', 'digital', 'set_type']
|
fieldsInCard = ['name', 'image_uris', 'flavor_name',
|
||||||
|
'reprint', 'frame_effects', 'digital', 'set_type']
|
||||||
data = []
|
data = []
|
||||||
# write all fields needed in card
|
# write all fields needed in card
|
||||||
for card in response['data']:
|
for card in response['data']:
|
||||||
|
@ -115,17 +119,26 @@ def to_compact_write_form(smallJson, art_names, response, category):
|
||||||
if category == 'artist' and len(card['artist_ids']) != 1:
|
if category == 'artist' and len(card['artist_ids']) != 1:
|
||||||
continue
|
continue
|
||||||
# do not repeat art
|
# do not repeat art
|
||||||
digital_holder = False
|
digital_holder = -1
|
||||||
if 'card_faces' in card:
|
if 'card_faces' in card:
|
||||||
card_face = card['card_faces'][0]
|
card_face = card['card_faces'][0]
|
||||||
if 'illustration_id' not in card_face or card_face['illustration_id'] in art_names and (art_names[card_face['illustration_id']] < 0 or card['digital']):
|
if 'illustration_id' not in card_face or card_face['illustration_id'] in art_names and (art_names[card_face['illustration_id']] < 0 or card['digital']):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
write_art(art_names, card_face['illustration_id'], len(data)+len(smallJson['data']), card['digital'])
|
ind = len(data)+len(smallJson['data'])
|
||||||
elif 'illustration_id' not in card or card['illustration_id'] in art_names:
|
if (card_face['illustration_id'] in art_names):
|
||||||
|
digital_holder = ind
|
||||||
|
ind = -1
|
||||||
|
write_art(
|
||||||
|
art_names, card_face['illustration_id'], ind, card['digital'])
|
||||||
|
elif 'illustration_id' not in card or card['illustration_id'] in art_names and (art_names[card['illustration_id']] < 0 or card['digital']):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
write_art(art_names, card['illustration_id'], len(data)+len(smallJson['data']), card['digital'])
|
ind = len(data)+len(smallJson['data'])
|
||||||
|
if (card['illustration_id'] in art_names):
|
||||||
|
digital_holder = ind
|
||||||
|
ind = -1
|
||||||
|
write_art(art_names, card['illustration_id'], ind, card['digital'])
|
||||||
write_card = dict()
|
write_card = dict()
|
||||||
for field in fieldsInCard:
|
for field in fieldsInCard:
|
||||||
# if field == 'name' and category == 'artifact':
|
# if field == 'name' and category == 'artifact':
|
||||||
|
@ -140,14 +153,20 @@ def to_compact_write_form(smallJson, art_names, response, category):
|
||||||
write_card['name'] = card['card_faces'][0]['name']
|
write_card['name'] = card['card_faces'][0]['name']
|
||||||
elif field == 'image_uris':
|
elif field == 'image_uris':
|
||||||
if 'card_faces' in card and 'image_uris' in card['card_faces'][0]:
|
if 'card_faces' in card and 'image_uris' in card['card_faces'][0]:
|
||||||
write_card['image_uris'] = write_image_uris(card['card_faces'][0]['image_uris'])
|
write_card['image_uris'] = write_image_uris(
|
||||||
|
card['card_faces'][0]['image_uris'])
|
||||||
else:
|
else:
|
||||||
write_card['image_uris'] = write_image_uris(card['image_uris'])
|
write_card['image_uris'] = write_image_uris(
|
||||||
|
card['image_uris'])
|
||||||
elif field in card:
|
elif field in card:
|
||||||
write_card[field] = card[field]
|
write_card[field] = card[field]
|
||||||
|
if digital_holder != -1:
|
||||||
|
data[digital_holder] = write_card
|
||||||
|
else:
|
||||||
data.append(write_card)
|
data.append(write_card)
|
||||||
smallJson['data'] += data
|
smallJson['data'] += data
|
||||||
|
|
||||||
|
|
||||||
def to_compact_write_form_special(smallJson, art_names, response, category):
|
def to_compact_write_form_special(smallJson, art_names, response, category):
|
||||||
fieldsInBasic = ['image_uris', 'set', 'set_type', 'digital']
|
fieldsInBasic = ['image_uris', 'set', 'set_type', 'digital']
|
||||||
data = []
|
data = []
|
||||||
|
@ -159,17 +178,27 @@ def to_compact_write_form_special(smallJson, art_names, response, category):
|
||||||
if category == 'basic':
|
if category == 'basic':
|
||||||
write_card = dict()
|
write_card = dict()
|
||||||
# do not repeat art
|
# do not repeat art
|
||||||
if 'illustration_id' not in card or card['illustration_id'] in art_names:
|
digital_holder = -1
|
||||||
|
if 'illustration_id' not in card or card['illustration_id'] in art_names and (art_names[card['illustration_id']] < 0 or card['digital']):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
write_art(art_names, card['illustration_id'], len(data)+len(smallJson['data']), card['digital'])
|
ind = len(data)+len(smallJson['data'])
|
||||||
|
if (card['illustration_id'] in art_names):
|
||||||
|
digital_holder = ind
|
||||||
|
ind = -1
|
||||||
|
write_art(
|
||||||
|
art_names, card['illustration_id'], ind, card['digital'])
|
||||||
for field in fieldsInBasic:
|
for field in fieldsInBasic:
|
||||||
if field == 'image_uris':
|
if field == 'image_uris':
|
||||||
write_card['image_uris'] = write_image_uris(card['image_uris'])
|
write_card['image_uris'] = write_image_uris(
|
||||||
|
card['image_uris'])
|
||||||
elif field == 'set':
|
elif field == 'set':
|
||||||
write_card['name'] = card['set']
|
write_card['name'] = card['set']
|
||||||
elif field in card:
|
elif field in card:
|
||||||
write_card[field] = card[field]
|
write_card[field] = card[field]
|
||||||
|
if digital_holder != -1:
|
||||||
|
data[digital_holder] = write_card
|
||||||
|
else:
|
||||||
data.append(write_card)
|
data.append(write_card)
|
||||||
else:
|
else:
|
||||||
if card['set_type'] != 'token':
|
if card['set_type'] != 'token':
|
||||||
|
@ -198,7 +227,8 @@ if __name__ == "__main__":
|
||||||
fetch_and_write_all(category, generate_initial_query(category))
|
fetch_and_write_all(category, generate_initial_query(category))
|
||||||
for category in specialCategories:
|
for category in specialCategories:
|
||||||
print(category)
|
print(category)
|
||||||
fetch_and_write_all_special(category, generate_initial_special_query(category))
|
fetch_and_write_all_special(
|
||||||
|
category, generate_initial_special_query(category))
|
||||||
print("artistList")
|
print("artistList")
|
||||||
with open('jsons/artistList.json', 'w') as f:
|
with open('jsons/artistList.json', 'w') as f:
|
||||||
json.dump(artists, f)
|
json.dump(artists, f)
|
Loading…
Reference in New Issue
Block a user