From 0e42f758ab285a3cac3bbf9c2bba483fd4c61b15 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 5 Nov 2015 20:26:08 -0600 Subject: [PATCH] Add sort_ships_splits and ships_CHARS. --- fanficfare/story.py | 51 +++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/fanficfare/story.py b/fanficfare/story.py index 761e782..d5e6c56 100644 --- a/fanficfare/story.py +++ b/fanficfare/story.py @@ -380,29 +380,34 @@ def set_in_ex_clude(setting): ## metakey[,metakey]=>pattern=>replacement[&&metakey=>regexp] def make_replacements(replace): retval=[] - for line in replace.splitlines(): - # print("replacement line:%s"%line) - (metakeys,regexp,replacement,condkey,condregexp)=(None,None,None,None,None) - if "&&" in line: - (line,conditional) = line.split("&&") - (condkey,condregexp) = conditional.split("=>") - if "=>" in line: - parts = line.split("=>") - if len(parts) > 2: - metakeys = map( lambda x: x.strip(), parts[0].split(",") ) - (regexp,replacement)=parts[1:] - else: - (regexp,replacement)=parts - - if regexp: - regexp = re_compile(regexp,line) - if condregexp: - condregexp = re_compile(condregexp,line) - # A way to explicitly include spaces in the - # replacement string. The .ini parser eats any - # trailing spaces. - replacement=replacement.replace(SPACE_REPLACE,' ') - retval.append([metakeys,regexp,replacement,condkey,condregexp]) + for fullline in replace.splitlines(): + line=fullline + try: + (metakeys,regexp,replacement,condkey,condregexp)=(None,None,None,None,None) + if "&&" in line: + (line,conditional) = line.split("&&") + (condkey,condregexp) = conditional.split("=>") + if "=>" in line: + parts = line.split("=>") + if len(parts) > 2: + metakeys = map( lambda x: x.strip(), parts[0].split(",") ) + (regexp,replacement)=parts[1:] + else: + (regexp,replacement)=parts + + if regexp: + regexp = re_compile(regexp,line) + if condregexp: + condregexp = re_compile(condregexp,line) + # A way to explicitly include spaces in the + # replacement string. The .ini parser eats any + # trailing spaces. + replacement=replacement.replace(SPACE_REPLACE,' ') + retval.append([metakeys,regexp,replacement,condkey,condregexp]) + except Exception as e: + logger.error("Problem with Replacement Line:%s"%fullline) + raise exceptions.PersonalIniFailed(e,'replace_metadata unpacking failed',fullline) +# raise return retval class Story(Configurable):