[library-web] Make it possible to limit processing to a single channel



commit 5d3e2d17687d0105ee97cbcddc57bafa3a50e923
Author: Frédéric Péters <fpeters 0d be>
Date:   Sat Mar 19 18:51:41 2011 +0100

    Make it possible to limit processing to a single channel

 src/config.py      |    3 ++-
 src/defaults.lgorc |    3 +++
 src/document.py    |    9 ++++++---
 src/lgo.py         |   11 +++++++++--
 src/overlay.py     |    6 ++++--
 5 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/src/config.py b/src/config.py
index 8d469bd..89715dd 100644
--- a/src/config.py
+++ b/src/config.py
@@ -35,7 +35,8 @@ _known_keys = ['ftp_gnome_org_local_copy', 'use_latest_version',
             'version_min', 'version_max', 'modules', 'languages',
             'blacklist', 'extra_tarballs', 'symbols_dbm_filepath',
             'httxt2dbm_path', 'fast_mode', 'create_tarballs',
-            'symbols_sqlite_filepath', 'nightly_tarballs_location']
+            'symbols_sqlite_filepath', 'nightly_tarballs_location',
+            'channels']
 
 class Config:
     def __init__(self, filename=_default_lgorc):
diff --git a/src/defaults.lgorc b/src/defaults.lgorc
index e289e36..742d6b5 100644
--- a/src/defaults.lgorc
+++ b/src/defaults.lgorc
@@ -61,3 +61,6 @@ create_tarballs = True
 
 # location of nightly tarballs
 nightly_tarballs_location = None
+
+# channels to process, None to process all of them
+channels = None
diff --git a/src/document.py b/src/document.py
index b3b709c..a56c222 100644
--- a/src/document.py
+++ b/src/document.py
@@ -204,11 +204,16 @@ class RemoteDocument(Document):
         if overlay.find('subsection') is not None:
             self.subsection = overlay.find('subsection').text
 
+    def retrieve_if_necessary(self, overlay):
         if overlay.find('local') is not None:
             self.remote_to_local(overlay.find('local').attrib)
 
     def remote_to_local(self, attribs):
-        web_output_dir = os.path.join(app.config.output_dir, self.channel, self.module)
+        self.path = app.config.doc_path_template % {
+                'channel': self.channel,
+                'module': self.module }
+        web_output_dir = os.path.join(app.config.output_dir, self.path.lstrip('/'))
+
         mtime_xsl = os.stat(self.html2html_xsl_file)[stat.ST_MTIME]
 
         for lang in self.href:
@@ -242,8 +247,6 @@ class RemoteDocument(Document):
             if xsltproc.returncode:
                 logging.warn('%s failed with error %d' % (' '.join(cmd), xsltproc.returncode))
 
-        self.path = '/' + os.path.join(self.channel, self.module) + '/'
-
     def download(self, href):
         # TODO: add some support (think <local update="daily"/>) so the file
         # can be "watched" for changes
diff --git a/src/lgo.py b/src/lgo.py
index 2fc7df3..5ab28c5 100755
--- a/src/lgo.py
+++ b/src/lgo.py
@@ -512,7 +512,10 @@ class Lgo(App):
                 doc.extract()
                 doc.setup_channel()
                 doc.path = self.get_module_web_path(doc)
-                doc_modules.append(doc)
+                if self.config.channels is None or doc.channel in self.config.channels:
+                    doc_modules.append(doc)
+                else:
+                    logging.debug('ignoring %s, not in an appropriate channel' % doc.modulename)
 
         if more_tarball_docs:
             for more_doc in more_tarball_docs:
@@ -573,7 +576,11 @@ class Lgo(App):
             home = ET.SubElement(indexes, 'home')
             home.set('lang', lang)
 
-        for channel in ('users', 'devel', 'admin', 'misc'):
+        channels = self.config.channels
+        if not channels:
+            channels = ('users', 'devel', 'admin', 'misc')
+
+        for channel in channels:
             docs = [x for x in self.documents if x.channel == channel]
 
             if not docs:
diff --git a/src/overlay.py b/src/overlay.py
index 9082a4e..55989e4 100644
--- a/src/overlay.py
+++ b/src/overlay.py
@@ -156,8 +156,10 @@ class Overlay:
         l = []
         for overlay in self.new_docs:
             doc = RemoteDocument(overlay)
-            self.apply(doc)
-            l.append(doc)
+            if app.config.channels is None or doc.channel in app.config.channels:
+                self.retrieve_if_necessary(overlay)
+                self.apply(doc)
+                l.append(doc)
         return l
 
     def get_section_weight(self, section_id):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]