diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index a0832d9..ebaa3f7 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -392,8 +392,8 @@ add_to_replace_metadata: tagsfromtitle=>^.*?([\(\[]([^\]\)]+)[\)\]]).*?$=>\1 # remove () [] tagsfromtitle=>[\(\)\[\]]=> -# change (spaces)slash(spaces) to comma - tagsfromtitle=> */ *=>, +# change (spaces)slash(or semicolon)(spaces) to comma + tagsfromtitle=> *[/;] *=>, tagsfromtitle=> x =>, # remove [] or () blocks and leading/trailing spaces/dashes/colons diff --git a/fanficfare/cli.py b/fanficfare/cli.py index 2291d12..74f5750 100644 --- a/fanficfare/cli.py +++ b/fanficfare/cli.py @@ -16,7 +16,7 @@ # from optparse import OptionParser -from os.path import expanduser, isfile, join, dirname +from os.path import expanduser, join, dirname from os import access, R_OK from subprocess import call import ConfigParser @@ -214,25 +214,18 @@ def do_download(arg, if passed_defaultsini: configuration.readfp(passed_defaultsini) - if isfile(join(dirname(__file__), 'defaults.ini')): - conflist.append(join(dirname(__file__), 'defaults.ini')) - - if isfile(join(homepath, 'defaults.ini')): - conflist.append(join(homepath, 'defaults.ini')) - if isfile(join(homepath2, 'defaults.ini')): - conflist.append(join(homepath2, 'defaults.ini')) - if isfile('defaults.ini'): - conflist.append('defaults.ini') + # don't need to check existance for our selves. + conflist.append(join(dirname(__file__), 'defaults.ini')) + conflist.append(join(homepath, 'defaults.ini')) + conflist.append(join(homepath2, 'defaults.ini')) + conflist.append('defaults.ini') if passed_personalini: configuration.readfp(passed_personalini) - if isfile(join(homepath, 'personal.ini')): - conflist.append(join(homepath, 'personal.ini')) - if isfile(join(homepath2, 'personal.ini')): - conflist.append(join(homepath2, 'personal.ini')) - if isfile('personal.ini'): - conflist.append('personal.ini') + conflist.append(join(homepath, 'personal.ini')) + conflist.append(join(homepath2, 'personal.ini')) + conflist.append('personal.ini') if options.configfile: conflist.extend(options.configfile) diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py index 61b306d..d7168aa 100644 --- a/fanficfare/configurable.py +++ b/fanficfare/configurable.py @@ -17,6 +17,7 @@ import ConfigParser, re import exceptions +import codecs from ConfigParser import DEFAULTSECT, MissingSectionHeaderError, ParsingError # All of the writers(epub,html,txt) and adapters(ffnet,twlt,etc) @@ -459,6 +460,30 @@ class Configuration(ConfigParser.SafeConfigParser): else: return self.linenos.get(section,None) + ## Copied from Python 2.7 library so as to make read utf8. + def read(self, filenames): + """Read and parse a filename or a list of filenames. + Files that cannot be opened are silently ignored; this is + designed so that you can specify a list of potential + configuration file locations (e.g. current directory, user's + home directory, systemwide directory), and all existing + configuration files in the list will be read. A single + filename may also be given. + Return list of successfully read files. + """ + if isinstance(filenames, basestring): + filenames = [filenames] + read_ok = [] + for filename in filenames: + try: + fp = codecs.open(filename,encoding='utf-8') + except IOError: + continue + self._read(fp, filename) + fp.close() + read_ok.append(filename) + return read_ok + ## Copied from Python 2.7 library so as to make it save linenos too. # # Regular expressions for parsing section headers and options. diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 856bfa3..b0a4754 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -389,8 +389,8 @@ add_to_replace_metadata: tagsfromtitle=>^.*?([\(\[]([^\]\)]+)[\)\]]).*?$=>\1 # remove () [] tagsfromtitle=>[\(\)\[\]]=> -# change (spaces)slash(spaces) to comma - tagsfromtitle=> */ *=>, +# change (spaces)slash(or semicolon)(spaces) to comma + tagsfromtitle=> *[/;] *=>, tagsfromtitle=> x =>, # remove [] or () blocks and leading/trailing spaces/dashes/colons