mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-01-03 06:34:04 +01:00
Add sort_ships_splits and ships_CHARS.
This commit is contained in:
parent
3abb78a15e
commit
e2995a7614
4 changed files with 54 additions and 14 deletions
|
|
@ -344,12 +344,21 @@ anthology_title_pattern:${title} Anthology
|
|||
## any anthology tags.
|
||||
anthology_tags:Anthology
|
||||
|
||||
## Reorder ships so b/a and c/b/a become a/b and a/b/c. Only separates
|
||||
## on '/', so use replace_metadata to change separator first if
|
||||
## needed. Something like: ships=>[ ]*(/|&|&)[ ]*=>/ You can use
|
||||
## ships_LIST to change the / back to something else if you want.
|
||||
## Reorder ships so b/a and c/b/a become a/b and a/b/c. '/' is no
|
||||
## longer hard coded and can be changed and added to with
|
||||
## sort_ships_splits.
|
||||
sort_ships:false
|
||||
|
||||
## Each line indicates first a regex that should be used to split each
|
||||
## ships entry and then, after => the string to use to merge the parts
|
||||
## back together. \s == blank space.
|
||||
## Each part will have replace_metadata with key ships_CHARS applied.
|
||||
## By default, sort_ships_splits:/=>/
|
||||
## Here's possible an example for AO3:
|
||||
#sort_ships_splits:
|
||||
# [ ]*/[ ]*=>/
|
||||
# [ ]*&[ ]*=>\s&\s
|
||||
|
||||
## join_string_<entry> options -- FanFicFare list entries are comma
|
||||
## separated by default. You can use this to change that. For example,
|
||||
## if you want authors separated with ' & ' instead, use
|
||||
|
|
|
|||
|
|
@ -302,6 +302,7 @@ def get_valid_keywords():
|
|||
'replace_metadata',
|
||||
'slow_down_sleep_time',
|
||||
'sort_ships',
|
||||
'sort_ships_splits',
|
||||
'strip_chapter_numbers',
|
||||
'strip_chapter_numeral',
|
||||
'strip_text_links',
|
||||
|
|
|
|||
|
|
@ -343,12 +343,21 @@ chapter_title_new_pattern:(new) ${title}
|
|||
## (new) is just text and can be changed.
|
||||
chapter_title_addnew_pattern:${index}. (new) ${title}
|
||||
|
||||
## Reorder ships so b/a and c/b/a become a/b and a/b/c. Only separates
|
||||
## on '/', so use replace_metadata to change separator first if
|
||||
## needed. Something like: ships=>[ ]*(/|&|&)[ ]*=>/ You can use
|
||||
## ships_LIST to change the / back to something else if you want.
|
||||
## Reorder ships so b/a and c/b/a become a/b and a/b/c. '/' is no
|
||||
## longer hard coded and can be changed and added to with
|
||||
## sort_ships_splits.
|
||||
sort_ships:false
|
||||
|
||||
## Each line indicates first a regex that should be used to split each
|
||||
## ships entry and then, after => the string to use to merge the parts
|
||||
## back together. \s == blank space.
|
||||
## Each part will have replace_metadata with key ships_CHARS applied.
|
||||
## By default, sort_ships_splits:/=>/
|
||||
## Here's possible an example for AO3:
|
||||
#sort_ships_splits:
|
||||
# [ ]*/[ ]*=>/
|
||||
# [ ]*&[ ]*=>\s&\s
|
||||
|
||||
## join_string_<entry> options -- FanFicFare list entries are comma
|
||||
## separated by default. You can use this to change that. For example,
|
||||
## if you want authors separated with ' & ' instead, use
|
||||
|
|
|
|||
|
|
@ -793,6 +793,33 @@ class Story(Configurable):
|
|||
if retlist is None:
|
||||
retlist = []
|
||||
|
||||
# reorder ships so b/a and c/b/a become a/b and a/b/c. Only on '/',
|
||||
# use replace_metadata to change separator first if needed.
|
||||
# ships=>[ ]*(/|&|&)[ ]*=>/
|
||||
if listname == 'ships' and self.getConfig('sort_ships') and retlist:
|
||||
# retlist = [ '/'.join(sorted(x.split('/'))) for x in retlist ]
|
||||
## empty default of /=>/
|
||||
sort_ships_splits = self.getConfig('sort_ships_splits',"/=>/")
|
||||
|
||||
for line in sort_ships_splits.splitlines():
|
||||
if line:
|
||||
logger.debug("sort_ships_splits:%s"%line)
|
||||
logger.debug(retlist)
|
||||
(splitre,splitmerge) = line.split("=>")
|
||||
splitmerge = splitmerge.replace(SPACE_REPLACE,' ')
|
||||
newretlist = []
|
||||
for x in retlist:
|
||||
curlist = []
|
||||
for y in re.split(splitre,x):
|
||||
## for SPLIT_META(\,)
|
||||
if doreplacements:
|
||||
y = self.doReplacements(y,'ships_CHARS',return_list=True)
|
||||
curlist.extend(y)
|
||||
newretlist.append( splitmerge.join(sorted(curlist)) )
|
||||
|
||||
retlist = newretlist
|
||||
logger.debug(retlist)
|
||||
|
||||
if retlist:
|
||||
if doreplacements:
|
||||
newretlist = []
|
||||
|
|
@ -812,12 +839,6 @@ class Story(Configurable):
|
|||
)) > 1:
|
||||
retlist.append(self.getConfig('add_genre_when_multi_category'))
|
||||
|
||||
# reorder ships so b/a and c/b/a become a/b and a/b/c. Only on '/',
|
||||
# use replace_metadata to change separator first if needed.
|
||||
# ships=>[ ]*(/|&|&)[ ]*=>/
|
||||
if listname == 'ships' and self.getConfig('sort_ships') and retlist:
|
||||
retlist = [ '/'.join(sorted(x.split('/'))) for x in retlist ]
|
||||
|
||||
if retlist:
|
||||
if listname in ('author','authorUrl','authorId') or self.getConfig('keep_in_order_'+listname):
|
||||
# need to retain order for author & authorUrl so the
|
||||
|
|
|
|||
Loading…
Reference in a new issue