qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jr...@apache.org
Subject svn commit: r1509179 - in /qpid/site: Makefile TODO python/transom/site.py
Date Thu, 01 Aug 2013 11:47:47 GMT
Author: jross
Date: Thu Aug  1 11:47:47 2013
New Revision: 1509179

URL: http://svn.apache.org/r1509179
Log:
QPID-4990: Use mtimes to speed up rendering; discard the previous content comparison code

Modified:
    qpid/site/Makefile
    qpid/site/TODO
    qpid/site/python/transom/site.py

Modified: qpid/site/Makefile
URL: http://svn.apache.org/viewvc/qpid/site/Makefile?rev=1509179&r1=1509178&r2=1509179&view=diff
==============================================================================
--- qpid/site/Makefile (original)
+++ qpid/site/Makefile Thu Aug  1 11:47:47 2013
@@ -25,7 +25,6 @@ render: devel-render
 	@echo "See the output in your browser at ${SITE_URL}/index.html"
 
 devel-render:
-	mkdir -p ${OUTPUT_DIR}
 	scripts/render ${SITE_URL} input ${OUTPUT_DIR}
 
 devel-publish: TAG := "head"

Modified: qpid/site/TODO
URL: http://svn.apache.org/viewvc/qpid/site/TODO?rev=1509179&r1=1509178&r2=1509179&view=diff
==============================================================================
--- qpid/site/TODO (original)
+++ qpid/site/TODO Thu Aug  1 11:47:47 2013
@@ -4,7 +4,6 @@
 
 ## Medium
 
- - use stat to speed up render
  - set up git access for qpid-site
  - add checklist for periodic updates
  - hover nav for more resources

Modified: qpid/site/python/transom/site.py
URL: http://svn.apache.org/viewvc/qpid/site/python/transom/site.py?rev=1509179&r1=1509178&r2=1509179&view=diff
==============================================================================
--- qpid/site/python/transom/site.py (original)
+++ qpid/site/python/transom/site.py Thu Aug  1 11:47:47 2013
@@ -22,7 +22,6 @@ import os
 import shutil
 import sys
 import tempfile
-import zlib
 
 from ConfigParser import SafeConfigParser
 from collections import defaultdict
@@ -59,6 +58,8 @@ class Site(object):
         self.links = defaultdict(set)
         self.targets = set()
 
+        self.last_rendered = None
+
     def init(self):
         self.config.read(self.config_path)
 
@@ -72,20 +73,34 @@ class Site(object):
             file.init()
 
     def render(self):
-        for page in self.pages:
+        self.last_rendered = self.update_render_timestamp()
+
+        modified_pages = [x for x in self.pages if x.is_modified()]
+        modified_resources = [x for x in self.resources if x.is_modified()]
+
+        for page in modified_pages:
             page.read_input()
             page.convert()
 
-        for page in self.pages:
+        for page in modified_pages:
             page.process()
 
-        for page in self.pages:
+        for page in modified_pages:
             page.render()
             page.write_output()
 
-        for resource in self.resources:
+        for resource in modified_resources:
             resource.copy_to_output()
 
+    def update_render_timestamp(self):
+        last = None
+
+        if os.path.exists(self.output_dir):
+            last = os.stat(self.output_dir).st_mtime
+            os.utime(self.output_dir, None)
+
+        return last
+
     def check_output_files(self):
         expected_files = set()
         found_files = set()
@@ -229,6 +244,14 @@ class _File(object):
     def init(self):
         self.site.targets.add(self.url)
 
+    def is_modified(self):
+        if self.site.last_rendered is None:
+            return True
+
+        mtime = os.stat(self.input_path).st_mtime
+
+        return mtime > self.site.last_rendered
+
     def __repr__(self):
         return "{}({})".format(self.__class__.__name__, self.input_path)
 
@@ -239,16 +262,6 @@ class _Resource(_File):
         self.site.resources.append(self)
 
     def copy_to_output(self):
-        if os.path.exists(self.output_path):
-            with open(self.input_path, "r") as file:
-                input_checksum = zlib.adler32(file.read())
-
-            with open(self.output_path, "r") as file:
-                output_checksum = zlib.adler32(file.read())
-
-            if input_checksum == output_checksum:
-                return
-
         _make_dirs(os.path.dirname(self.output_path))
         shutil.copy(self.input_path, self.output_path)
 
@@ -283,15 +296,6 @@ class _Page(_File):
         if path is None:
             path = self.output_path
 
-        if os.path.exists(path):
-            content_checksum = zlib.adler32(self.content)
-
-            with open(path, "r") as file:
-                file_checksum = zlib.adler32(file.read())
-
-            if content_checksum == file_checksum:
-                return
-
         _make_dirs(os.path.dirname(path))
 
         with open(path, "w") as file:



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message