From 094ca85029467aff90a064a4dc15dfc956d6a54c Mon Sep 17 00:00:00 2001 From: tritoch Date: Mon, 19 Jun 2017 12:12:55 -0500 Subject: [PATCH 1/2] Allow comments in JSON files --- cards_corrections.json | 7 +++++++ cards_delete.json | 10 +++++++++- main.py | 15 ++++++--------- requirements.txt | 3 ++- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/cards_corrections.json b/cards_corrections.json index 7a73a41b..25ef57c2 100644 --- a/cards_corrections.json +++ b/cards_corrections.json @@ -1,2 +1,9 @@ +// Objects to be fixed +// "Card Name": { +// "Key": "New Value" +// } +// List of Keys: +// + { } \ No newline at end of file diff --git a/cards_delete.json b/cards_delete.json index fe51488c..509ff735 100644 --- a/cards_delete.json +++ b/cards_delete.json @@ -1 +1,9 @@ -[] +// List of card strings to be removed +// [ +// "Card Name 1", +// "Card Name 2" +// ] +// Case-sensitive + +[ +] \ No newline at end of file diff --git a/main.py b/main.py index ed4791b9..74190c44 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,8 @@ # -*- coding: utf-8 -*- import spoilers -import sys import os -import shutil -#import configparser +import commentjson import json -#import urllib presets = { "isfullspoil": False, #when full spoil comes around, we only want to use WOTC images @@ -17,17 +14,17 @@ presets = { } with open('set_info.json') as data_file: - setinfos = json.load(data_file) + setinfos = commentjson.load(data_file) with open('cards_manual.json') as data_file: - manual_sets = json.load(data_file) + manual_sets = commentjson.load(data_file) #manual_cards = manual_cards['cards'] with open('cards_corrections.json') as data_file: - card_corrections = json.load(data_file) + card_corrections = commentjson.load(data_file) with open('cards_delete.json') as data_file: - delete_cards = json.load(data_file) + delete_cards = commentjson.load(data_file) errorlog = [] @@ -115,4 +112,4 @@ if __name__ == '__main__': save_xml(spoilers.pretty_xml('out/spoiler.xml'), 'out/spoiler.xml') save_errorlog(errorlog) save_allsets(AllSets) - #save_setjson(mtgjson) + #save_setjson(mtgjson) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f053885b..09b173ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ feedparser lxml Pillow datetime -beautifulsoup4 \ No newline at end of file +beautifulsoup4 +commentjson \ No newline at end of file From fbdee30d65ddebf377dd3a2c63880908c665c22a Mon Sep 17 00:00:00 2001 From: tritoch Date: Mon, 19 Jun 2017 15:20:48 -0500 Subject: [PATCH 2/2] Improved Split Card Handling. Dump XML to log. --- cards_corrections.json => cards_corrections | 0 cards_delete.json => cards_delete | 0 cards_manual.json => cards_manual | 0 main.py | 8 ++++---- set_info.json => set_info | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename cards_corrections.json => cards_corrections (100%) rename cards_delete.json => cards_delete (100%) rename cards_manual.json => cards_manual (100%) rename set_info.json => set_info (100%) diff --git a/cards_corrections.json b/cards_corrections similarity index 100% rename from cards_corrections.json rename to cards_corrections diff --git a/cards_delete.json b/cards_delete similarity index 100% rename from cards_delete.json rename to cards_delete diff --git a/cards_manual.json b/cards_manual similarity index 100% rename from cards_manual.json rename to cards_manual diff --git a/main.py b/main.py index 74190c44..4f4d0295 100644 --- a/main.py +++ b/main.py @@ -13,17 +13,17 @@ presets = { } } -with open('set_info.json') as data_file: +with open('set_info') as data_file: setinfos = commentjson.load(data_file) -with open('cards_manual.json') as data_file: +with open('cards_manual') as data_file: manual_sets = commentjson.load(data_file) #manual_cards = manual_cards['cards'] -with open('cards_corrections.json') as data_file: +with open('cards_corrections') as data_file: card_corrections = commentjson.load(data_file) -with open('cards_delete.json') as data_file: +with open('cards_delete') as data_file: delete_cards = commentjson.load(data_file) errorlog = [] diff --git a/set_info.json b/set_info similarity index 100% rename from set_info.json rename to set_info