Skip to content
This repository
Browse code

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
21 custom_exceptions_sample.csv
... ... @@ -0,0 +1,21 @@
  1 +# Mylar Custom Exception listings
  2 +# In an effort to map ComicVine to GCD correctly, use this.
  3 +#
  4 +#
  5 +# Make changes/additions, and rename this file to 'custom_exceptions.csv'.
  6 +#
  7 +#
  8 +# Required Format, : code, ComicVineID, GCDComicID, GCDComicIDs (for volume spanning series)
  9 +# ----Format Breakdown
  10 +# code = # of volumes in series to be checked minus 1 (if there are 4 volumes in a series, put 3)
  11 +# = 99 is mismatched names. If a series won't match on GCD, this is what you would put.
  12 +# ComicVineID = the ComicVineID (taken from the searchresults, or the ..Loading.. detail screen)
  13 +# GCDComicID = the correct GCD Comic ID that Mylar is to match with.
  14 +# GCDComicIDs = put the GCD Comic ID's here for the given multiple volume spanning series seperated by a '/'
  15 +# use 'none' if you are not using an option (yes, it's necessary)
  16 +#
  17 +#-----Volume Spanning Series-----
  18 +
  19 +#-----Mismatched Names------
  20 +#test
  21 +99,1111,22222,none
20 exceptions.csv
... ... @@ -1,16 +1,12 @@
1   -#Mylar Exception listings
2   -# In an effort to map ComicVine to GCD correctly, use this.
  1 +# Mylar Exception listings
  2 +# In an effort to map ComicVine to GCD correctly, this file will be imported into Mylar.
3 3 #----
4   -#Required Format : code, ComicVineID, GCDComicID, GCDComicIDs (for volume spanning series)
5   -#----Format Breakdown
6   -#code = # of volumes in series to be checked minus 1 (if there are 4 volumes in a series, put 3)
7   - = 99 is mismatched names. If a series won't match on GCD, this is what you would put.
8   -#ComicVineID = the ComicVineID (taken from the searchresults, or the ..Loading.. detail screen)
9   -#GCDComicID = the correct GCD Comic ID that Mylar is to match with.
10   -#GCDComicIDs = put the GCD Comic ID's here for the given multiple volume spanning series seperated by a '/'
11   -#use 'none' if you are not using an option (yes, it's necessary)
12   -#--------
13   -#--------
  4 +#
  5 +######### DO NOT USE THIS FILE TO ADD YOUR OWN EXCEPTIONS! ###########
  6 +# USE custom_exceptions.csv FOR USER-ADDED EXCEPTIONS. #
  7 +# NOT DOING THIS WILL RESULT IN LOSING YOUR USER-ADDED EXCEPTIONS. #
  8 +######################################################################
  9 +#
14 10 #-----Volume Spanning Series-----
15 11 #Fantastic Four
16 12 4,2045,none,1482/10251/6029/11218/62349
48 mylar/__init__.py
@@ -521,30 +521,46 @@ def dbcheck():
521 521 # c.execute('CREATE TABLE IF NOT EXISTS weekly (SHIPDATE, PUBLISHER text, ISSUE text, COMIC VARCHAR(150), EXTRA text, STATUS text)')
522 522
523 523 #new
524   - logger.info(u"Populating Exception listings into Mylar....")
525 524 c.execute('DROP TABLE IF EXISTS exceptions')
526 525
527 526 c.execute('CREATE TABLE IF NOT EXISTS exceptions (variloop TEXT, ComicID TEXT, NewComicID TEXT, GComicID TEXT)')
528 527
529   - EXCEPTIONS_FILE = os.path.join(DATA_DIR, 'exceptions.csv')
  528 + # for Mylar-based Exception Updates....
  529 + i = 0
  530 + EXCEPTIONS = []
  531 + EXCEPTIONS.append('exceptions.csv')
  532 + EXCEPTIONS.append('custom_exceptions.csv')
530 533
531   - if not os.path.exists(EXCEPTIONS_FILE):
532   - try:
  534 + while (i <= 1):
  535 + #EXCEPTIONS_FILE = os.path.join(DATA_DIR, 'exceptions.csv')
  536 + EXCEPTIONS_FILE = os.path.join(DATA_DIR, EXCEPTIONS[i])
  537 +
  538 + if not os.path.exists(EXCEPTIONS_FILE):
  539 + try:
  540 + csvfile = open(str(EXCEPTIONS_FILE), "rb")
  541 + except (OSError,IOError):
  542 + if i == 1:
  543 + logger.error("No Custom Exceptions found. Using base exceptions only.")
  544 + else:
  545 + logger.error("Could not locate " + str(EXCEPTIONS[i]) + " file. Make sure it's in datadir: " + DATA_DIR)
  546 + break
  547 + else:
533 548 csvfile = open(str(EXCEPTIONS_FILE), "rb")
534   - except OSError:
535   - logger.error('Could not locate exceptions.csv file. Check in datadir: ' + DATA_DIR)
536   - else:
537   - csvfile = open(str(EXCEPTIONS_FILE), "rb")
  549 + if i == 0:
  550 + logger.info(u"Populating Base Exception listings into Mylar....")
  551 + elif i == 1:
  552 + logger.info(u"Populating Custom Exception listings into Mylar....")
538 553
539   - creader = csv.reader(csvfile, delimiter=',')
  554 + creader = csv.reader(csvfile, delimiter=',')
540 555
541   - for row in creader:
542   - try:
543   - c.execute("INSERT INTO exceptions VALUES (?,?,?,?);", row)
544   - except Exception, e:
545   - #print ("Error - invald arguments...-skipping")
546   - pass
547   - csvfile.close()
  556 + for row in creader:
  557 + try:
  558 + c.execute("INSERT INTO exceptions VALUES (?,?,?,?);", row)
  559 + except Exception, e:
  560 + #print ("Error - invald arguments...-skipping")
  561 + pass
  562 + csvfile.close()
  563 + i+=1
548 564
549 565 #c.executemany("INSERT INTO exceptions VALUES (?, ?);", to_db)
550 566

0 comments on commit c9acfb4

Please sign in to comment.
Something went wrong with that request. Please try again.