From 6227a8da1770de3eb09e220d3330c21c00dd97ba Mon Sep 17 00:00:00 2001
From: Constantin Wenger <constantin.wenger@googlemail.com>
Date: Tue, 13 Aug 2019 20:41:25 +0000
Subject: [PATCH] work a round for "con" being a forbidden filename on windows
---
fetch_data.py | 10 ++++++++--
opencv_dnn.py | 12 ++++++++++--
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/fetch_data.py b/fetch_data.py
index 500dc55..e765ef3 100644
--- a/fetch_data.py
+++ b/fetch_data.py
@@ -100,7 +100,10 @@
:return:
"""
if out_dir is None:
- out_dir = '%s/card_img/%s/%s' % (Config.data_dir, size, row['set'])
+ s = row['set']
+ if s == 'con':
+ s = 'con__'
+ out_dir = '%s/card_img/%s/%s' % (Config.data_dir, size, s)
if not os.path.exists(out_dir):
os.makedirs(out_dir)
@@ -133,7 +136,10 @@
def main():
# Query card data by each set, then merge them together
for set_name in Config.all_set_list:
- csv_name = '%s/csv/%s.csv' % (Config.data_dir, set_name)
+ set_name_m = set_name
+ if set_name_m == 'con':
+ set_name_m = 'con__'
+ csv_name = '%s/csv/%s.csv' % (Config.data_dir, set_name_m)
print(csv_name)
if not os.path.isfile(csv_name):
df = fetch_all_cards_text(url='https://api.scryfall.com/cards/search?q=set:%s+lang:en' % set_name,
diff --git a/opencv_dnn.py b/opencv_dnn.py
index a2c9d3b..bf6142e 100644
--- a/opencv_dnn.py
+++ b/opencv_dnn.py
@@ -49,15 +49,21 @@
for card_name in card_names:
# Fetch the image - name can be found based on the card's information
card_info['name'] = card_name
+ cname = card_name
+ if cname == 'con':
+ cname == 'con__'
img_name = '%s/card_img/png/%s/%s_%s.png' % (Config.data_dir, card_info['set'],
card_info['collector_number'],
- fetch_data.get_valid_filename(card_info['name']))
+ fetch_data.get_valid_filename(cname))
card_img = cv2.imread(img_name)
# If the image doesn't exist, download it from the URL
if card_img is None:
+ set_name = card_info['set']
+ if set_name == 'con':
+ set_name = 'con__'
fetch_data.fetch_card_image(card_info,
- out_dir='%s/card_img/png/%s' % (Config.data_dir, card_info['set']))
+ out_dir='%s/card_img/png/%s' % (Config.data_dir, set_name))
card_img = cv2.imread(img_name)
if card_img is None:
print('WARNING: card %s is not found!' % img_name)
@@ -624,6 +630,8 @@
# Merge database for all cards, then calculate pHash values of each, store them
df_list = []
for set_name in Config.all_set_list:
+ if set_name == 'con':
+ set_name = 'con__'
csv_name = '%s/csv/%s.csv' % (Config.data_dir, set_name)
df = fetch_data.load_all_cards_text(csv_name)
df_list.append(df)
--
Gitblit v1.10.0