Commit a81386e0 authored by Denis Salem's avatar Denis Salem
Browse files

add tiny optimisation in content/preview processing

parent fd67a9d5
......@@ -41,8 +41,16 @@ class EntryWrapper:
".:GetEntryPreview:." : "---VENC-GET-ENTRY-PREVIEW---",
".:PreviewIfInThreadElseContent:." : "---VENC-PREVIEW-IF-IN-THREAD-ELSE-CONTENT---"
}
self.content_type_flag = 0
wrapper_len = len(wrapper)
for content_pattern in pattern_replacement.keys():
self.process_get_entry_content = 1 if ".:GetEntryContent:." in wrapper else 0
self.process_get_entry_preview = 1 if ".:GetEntryPreview:." in wrapper else 0
if ".:PreviewIfInThreadElseContent:." in wrapper:
self.process_get_entry_content = 1
self.process_get_entry_preview = 1
for content_pattern in pattern_replacement.keys():
wrapper = wrapper.replace(content_pattern, pattern_replacement[content_pattern])
if len(wrapper) == wrapper_len:
......
......@@ -370,58 +370,44 @@ class Thread:
def do_iteration(self, entry):
global current_source
wrapper = getattr(entry, self.content_type+"_wrapper").processed_string
self.processor.process(wrapper, safe_process = True)
self.processor.process(entry.content, safe_process = True)
self.processor.process(entry.preview, safe_process = True)
output=wrapper.string.replace(
"---VENC-GET-ENTRY-CONTENT---",
entry.content.string
).replace(
"---VENC-GET-ENTRY-PREVIEW---",
entry.preview.string
).replace(
entry_wrapper = getattr(entry, self.content_type+"_wrapper")
preprocessed_wrapper = getattr(entry, self.content_type+"_wrapper").processed_string
self.processor.process(preprocessed_wrapper, safe_process = True)
output=preprocessed_wrapper.string
if entry_wrapper.process_get_entry_content:
self.processor.process(entry.content, safe_process = True)
output=output.replace(
"---VENC-GET-ENTRY-CONTENT---",
entry.content.string
)
if entry_wrapper.process_get_entry_preview:
self.processor.process(entry.preview, safe_process = True)
output=output.replace(
"---VENC-GET-ENTRY-PREVIEW---",
entry.preview.string
)
output=output.replace(
"---VENC-PREVIEW-IF-IN-THREAD-ELSE-CONTENT---",
entry.preview.string if self.in_thread else entry.content.string
)
self.columns[self.columns_counter] += output
wrapper.restore()
entry.content.restore()
entry.preview.restore()
preprocessed_wrapper.restore()
if entry_wrapper.process_get_entry_content:
entry.content.restore()
if entry_wrapper.process_get_entry_preview:
entry.preview.restore()
self.columns_counter +=1
if self.columns_counter >= self.columns_number:
self.columns_counter = 0
def old_do_iteration(self, entry):
global current_source
current_source = getattr(entry, self.content_type+"_wrapper").above
self.processor.process(current_source, safe_process = True)
self.columns[self.columns_counter] += current_source.string
current_source.restore()
if (entry.html_wrapper.required_content_pattern == ".:GetEntryPreview:.") or (entry.html_wrapper.required_content_pattern == ".:PreviewIfInThreadElseContent:." and self.in_thread):
current_source = entry.preview
else:
current_source = entry.content
self.processor.process(current_source, safe_process = True)
self.columns[self.columns_counter] += current_source.string
current_source.restore()
current_source = getattr(entry, self.content_type+"_wrapper").below
self.processor.process(current_source, safe_process = True)
self.columns[self.columns_counter] += current_source.string
current_source.restore()
self.columns_counter +=1
if self.columns_counter >= self.columns_number:
self.columns_counter = 0
def iterate_through_pages(self):
for page in self.pages:
self.pre_iteration()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment