diff --git a/generators/generator.py b/generators/generator.py index 574efa3..2a70bf7 100644 --- a/generators/generator.py +++ b/generators/generator.py @@ -14,7 +14,6 @@ class StrictUTF8Writer(codecs.StreamWriter): def __init__(self): self.value = u'' - pass def write(self, object): object = object.replace('<', '<') @@ -41,9 +40,10 @@ class DynastieGenerator: report = '' somethingWrote = False - def __init__(self): + def __init__(self, hash_posts=None): self.report = '' self.somethingWrote = False + self.hash_posts = hash_posts def addReport(self, string, color=''): if color != '': diff --git a/generators/index.py b/generators/index.py index 4b4e2e3..362eb16 100644 --- a/generators/index.py +++ b/generators/index.py @@ -98,9 +98,13 @@ class Index(DynastieGenerator): self.addError('File does not exists ' + filename) return - f = open(filename, 'rb') - post_content = f.read() - f.close() + if self.hash_posts is None or not filename in self.hash_posts: + f = open(filename, 'rb') + post_content = f.read() + f.close() + self.hash_posts[filename] = post_content + else: + post_content = self.hash_posts[filename] while True: start = post_content.find('