Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added custom exceptions file to allow for user-based exceptions, as w…

…ell as being able to maintain a base file in exceptions.csv
  • Loading branch information...
commit c9acfb465f5c0bc8d2e02f525838be3455b27ea8 1 parent 150dcd7
@evilhero authored
Showing with 61 additions and 28 deletions.
  1. +21 −0 custom_exceptions_sample.csv
  2. +8 −12 exceptions.csv
  3. +32 −16 mylar/__init__.py
View
21 custom_exceptions_sample.csv
@@ -0,0 +1,21 @@
+# Mylar Custom Exception listings
+# In an effort to map ComicVine to GCD correctly, use this.
+#
+#
+# Make changes/additions, and rename this file to 'custom_exceptions.csv'.
+#
+#
+# Required Format, : code, ComicVineID, GCDComicID, GCDComicIDs (for volume spanning series)
+# ----Format Breakdown
+# code = # of volumes in series to be checked minus 1 (if there are 4 volumes in a series, put 3)
+# = 99 is mismatched names. If a series won't match on GCD, this is what you would put.
+# ComicVineID = the ComicVineID (taken from the searchresults, or the ..Loading.. detail screen)
+# GCDComicID = the correct GCD Comic ID that Mylar is to match with.
+# GCDComicIDs = put the GCD Comic ID's here for the given multiple volume spanning series seperated by a '/'
+# use 'none' if you are not using an option (yes, it's necessary)
+#
+#-----Volume Spanning Series-----
+
+#-----Mismatched Names------
+#test
+99,1111,22222,none
View
20 exceptions.csv
@@ -1,16 +1,12 @@
-#Mylar Exception listings
-# In an effort to map ComicVine to GCD correctly, use this.
+# Mylar Exception listings
+# In an effort to map ComicVine to GCD correctly, this file will be imported into Mylar.
#----
-#Required Format : code, ComicVineID, GCDComicID, GCDComicIDs (for volume spanning series)
-#----Format Breakdown
-#code = # of volumes in series to be checked minus 1 (if there are 4 volumes in a series, put 3)
- = 99 is mismatched names. If a series won't match on GCD, this is what you would put.
-#ComicVineID = the ComicVineID (taken from the searchresults, or the ..Loading.. detail screen)
-#GCDComicID = the correct GCD Comic ID that Mylar is to match with.
-#GCDComicIDs = put the GCD Comic ID's here for the given multiple volume spanning series seperated by a '/'
-#use 'none' if you are not using an option (yes, it's necessary)
-#--------
-#--------
+#
+######### DO NOT USE THIS FILE TO ADD YOUR OWN EXCEPTIONS! ###########
+# USE custom_exceptions.csv FOR USER-ADDED EXCEPTIONS. #
+# NOT DOING THIS WILL RESULT IN LOSING YOUR USER-ADDED EXCEPTIONS. #
+######################################################################
+#
#-----Volume Spanning Series-----
#Fantastic Four
4,2045,none,1482/10251/6029/11218/62349
View
48 mylar/__init__.py
@@ -521,30 +521,46 @@ def dbcheck():
# c.execute('CREATE TABLE IF NOT EXISTS weekly (SHIPDATE, PUBLISHER text, ISSUE text, COMIC VARCHAR(150), EXTRA text, STATUS text)')
#new
- logger.info(u"Populating Exception listings into Mylar....")
c.execute('DROP TABLE IF EXISTS exceptions')
c.execute('CREATE TABLE IF NOT EXISTS exceptions (variloop TEXT, ComicID TEXT, NewComicID TEXT, GComicID TEXT)')
- EXCEPTIONS_FILE = os.path.join(DATA_DIR, 'exceptions.csv')
+ # for Mylar-based Exception Updates....
+ i = 0
+ EXCEPTIONS = []
+ EXCEPTIONS.append('exceptions.csv')
+ EXCEPTIONS.append('custom_exceptions.csv')
- if not os.path.exists(EXCEPTIONS_FILE):
- try:
+ while (i <= 1):
+ #EXCEPTIONS_FILE = os.path.join(DATA_DIR, 'exceptions.csv')
+ EXCEPTIONS_FILE = os.path.join(DATA_DIR, EXCEPTIONS[i])
+
+ if not os.path.exists(EXCEPTIONS_FILE):
+ try:
+ csvfile = open(str(EXCEPTIONS_FILE), "rb")
+ except (OSError,IOError):
+ if i == 1:
+ logger.error("No Custom Exceptions found. Using base exceptions only.")
+ else:
+ logger.error("Could not locate " + str(EXCEPTIONS[i]) + " file. Make sure it's in datadir: " + DATA_DIR)
+ break
+ else:
csvfile = open(str(EXCEPTIONS_FILE), "rb")
- except OSError:
- logger.error('Could not locate exceptions.csv file. Check in datadir: ' + DATA_DIR)
- else:
- csvfile = open(str(EXCEPTIONS_FILE), "rb")
+ if i == 0:
+ logger.info(u"Populating Base Exception listings into Mylar....")
+ elif i == 1:
+ logger.info(u"Populating Custom Exception listings into Mylar....")
- creader = csv.reader(csvfile, delimiter=',')
+ creader = csv.reader(csvfile, delimiter=',')
- for row in creader:
- try:
- c.execute("INSERT INTO exceptions VALUES (?,?,?,?);", row)
- except Exception, e:
- #print ("Error - invald arguments...-skipping")
- pass
- csvfile.close()
+ for row in creader:
+ try:
+ c.execute("INSERT INTO exceptions VALUES (?,?,?,?);", row)
+ except Exception, e:
+ #print ("Error - invald arguments...-skipping")
+ pass
+ csvfile.close()
+ i+=1
#c.executemany("INSERT INTO exceptions VALUES (?, ?);", to_db)
Please sign in to comment.
Something went wrong with that request. Please try again.