From 84bc9b3a3ee88952273864e3fc81b12d3045c5ef Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Fri, 12 Jul 2013 15:36:36 -0500 Subject: [PATCH] Add join_string_, keep_in_order_ and replace_metadata _LIST options. --- fanficdownloader/adapters/adapter_test1.py | 58 ++++++++++++++++++++-- fanficdownloader/story.py | 11 ++-- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/fanficdownloader/adapters/adapter_test1.py b/fanficdownloader/adapters/adapter_test1.py index 019e984c..73ae3e96 100644 --- a/fanficdownloader/adapters/adapter_test1.py +++ b/fanficdownloader/adapters/adapter_test1.py @@ -141,14 +141,66 @@ Some more longer description. "I suck at summaries!" "Better than it sounds!" self.story.setMetadata('rating','Tweenie') if idstr == '673': - self.story.addToList('author','Author From List') + self.story.addToList('author','Author From List 1') self.story.addToList('author','Author From List 2') + self.story.addToList('author','Author From List 3') + self.story.addToList('author','Author From List 4') + self.story.addToList('author','Author From List 5') + self.story.addToList('author','Author From List 6') + self.story.addToList('author','Author From List 7') + self.story.addToList('author','Author From List 8') + self.story.addToList('author','Author From List 9') + self.story.addToList('author','Author From List 0') + self.story.addToList('author','Author From List q') + self.story.addToList('author','Author From List w') + self.story.addToList('author','Author From List e') + self.story.addToList('author','Author From List r') + self.story.addToList('author','Author From List t') + self.story.addToList('author','Author From List y') + self.story.addToList('author','Author From List u') + self.story.addToList('author','Author From List i') + self.story.addToList('author','Author From List o') - self.story.addToList('authorId','98765') + self.story.addToList('authorId','98765-1') self.story.addToList('authorId','98765-2') + self.story.addToList('authorId','98765-3') + self.story.addToList('authorId','98765-4') + self.story.addToList('authorId','98765-5') + self.story.addToList('authorId','98765-6') + self.story.addToList('authorId','98765-7') + self.story.addToList('authorId','98765-8') + self.story.addToList('authorId','98765-9') + self.story.addToList('authorId','98765-0') + self.story.addToList('authorId','98765-q') + self.story.addToList('authorId','98765-w') + self.story.addToList('authorId','98765-e') + self.story.addToList('authorId','98765-r') + self.story.addToList('authorId','98765-t') + self.story.addToList('authorId','98765-y') + self.story.addToList('authorId','98765-u') + self.story.addToList('authorId','98765-i') + self.story.addToList('authorId','98765-o') - self.story.addToList('authorUrl','http://author/url') + self.story.addToList('authorUrl','http://author/url-1') self.story.addToList('authorUrl','http://author/url-2') + self.story.addToList('authorUrl','http://author/url-3') + self.story.addToList('authorUrl','http://author/url-4') + self.story.addToList('authorUrl','http://author/url-5') + self.story.addToList('authorUrl','http://author/url-6') + self.story.addToList('authorUrl','http://author/url-7') + self.story.addToList('authorUrl','http://author/url-8') + self.story.addToList('authorUrl','http://author/url-9') + self.story.addToList('authorUrl','http://author/url-0') + self.story.addToList('authorUrl','http://author/url-q') + self.story.addToList('authorUrl','http://author/url-w') + self.story.addToList('authorUrl','http://author/url-e') + self.story.addToList('authorUrl','http://author/url-r') + self.story.addToList('authorUrl','http://author/url-t') + self.story.addToList('authorUrl','http://author/url-y') + self.story.addToList('authorUrl','http://author/url-u') + self.story.addToList('authorUrl','http://author/url-i') + self.story.addToList('authorUrl','http://author/url-o') + self.story.addToList('category','Power Rangers') self.story.addToList('category','SG-1') self.story.addToList('genre','Porn') diff --git a/fanficdownloader/story.py b/fanficdownloader/story.py index 87ef85f0..d470f2c2 100644 --- a/fanficdownloader/story.py +++ b/fanficdownloader/story.py @@ -326,7 +326,11 @@ class Story(Configurable): return value if self.isList(key): - return u', '.join(self.getList(key, removeallentities, doreplacements=True)) + join_string = self.getConfig("join_string_"+key,u", ").replace('\s',' ') + value = join_string.join(self.getList(key, removeallentities, doreplacements=True)) + if doreplacements: + value = self.doReplacements(value,key+"_LIST") + return value elif self.metadata.has_key(key): value = self.metadata[key] if value: @@ -371,7 +375,8 @@ class Story(Configurable): auth=removeAllEntities(auth) htmllist.append(linkhtml%('author',aurl,auth)) - self.setMetadata('authorHTML',', '.join(htmllist)) + join_string = self.getConfig("join_string_authorHTML",u", ").replace('\s',' ') + self.setMetadata('authorHTML',join_string.join(htmllist)) else: self.setMetadata('authorHTML',linkhtml%('author',self.getMetadata('authorUrl', removeallentities, doreplacements), self.getMetadata('author', removeallentities, doreplacements))) @@ -444,7 +449,7 @@ class Story(Configurable): map(removeAllEntities,retlist) ) if retlist: - if listname in ('author','authorUrl'): + if listname in ('author','authorUrl') or self.getConfig('keep_in_order_'+listname): # need to retain order for author & authorUrl so the # two match up. return retlist