[library-web] Moved URL layout policy to App class
- From: Frederic Peters <fpeters src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [library-web] Moved URL layout policy to App class
- Date: Sat, 8 Aug 2009 13:50:37 +0000 (UTC)
commit 3217bde42d78f03c201ca27d4f51e5b07f4e3b7e
Author: Frédéric Péters <fpeters 0d be>
Date: Sat Aug 8 15:48:44 2009 +0200
Moved URL layout policy to App class
src/lgo.py | 16 +++++++++++++++-
src/modtypes/base.py | 15 ++-------------
src/modtypes/gnomedocbook.py | 5 ++---
src/modtypes/gtkdoc.py | 6 ++----
src/modtypes/htmlfiles.py | 3 +--
5 files changed, 22 insertions(+), 23 deletions(-)
---
diff --git a/src/lgo.py b/src/lgo.py
index 5ec080f..e9300c8 100755
--- a/src/lgo.py
+++ b/src/lgo.py
@@ -448,7 +448,7 @@ class Lgo(App):
doc.mtime_tarball = mtime
doc.extract()
doc.setup_channel()
- doc.setup_path()
+ doc.path = self.get_module_web_path(doc)
doc_modules.append(doc)
tar.close()
@@ -659,6 +659,20 @@ class Lgo(App):
if rc != 0:
logging.warn('%s failed with error %d' % (' '.join(cmd), rc))
+ def get_module_web_path(self, module, versioned=True):
+ licence_modules = ['fdl', 'gpl', 'lgpl']
+ if module.modulename in licence_modules or versioned is False:
+ # special casing the licences, they do not go in a
+ # versioned path
+ return '/' + os.path.join(module.channel, module.modulename) + '/'
+ else:
+ return '/' + os.path.join(module.channel, module.modulename,
+ module.one_dot_version) + '/'
+
+ def get_module_web_output_dir(self, module, versioned=True):
+ return os.path.join(self.config.output_dir,
+ self.get_module_web_path(module, versioned=versioned)[1:])
+
if __name__ == '__main__':
app = Lgo()
diff --git a/src/modtypes/base.py b/src/modtypes/base.py
index 3759821..1fe56f0 100644
--- a/src/modtypes/base.py
+++ b/src/modtypes/base.py
@@ -24,9 +24,6 @@ import tarfile
from utils import version_cmp, is_version_number
-licence_modules = ['fdl', 'gpl', 'lgpl']
-
-
class DocModule(object):
'''Base class for documentation shipped in tarballs'''
makefile_am = None
@@ -38,6 +35,7 @@ class DocModule(object):
related_xsl_files = None
mtime_xslt_files = 0
+ channel = None
nightly = False
def create_from_tar(cls, tar, tarinfo, makefile_am, nightly = False):
@@ -98,15 +96,6 @@ class DocModule(object):
open(dest, 'w').write(tar.extractfile(tarinfo).read())
tar.close()
- def setup_path(self):
- if self.modulename in licence_modules:
- # special casing the licences, they do not go in a
- # versioned path
- self.path = '/' + os.path.join(self.channel, self.modulename) + '/'
- else:
- self.path = '/' + os.path.join(self.channel, self.modulename,
- self.one_dot_version) + '/'
-
def get_libgo_document(self, doc_linguas):
try:
doc = [x for x in app.documents if \
@@ -168,7 +157,7 @@ class DocModule(object):
# had been depreciated
return
- web_output_dir = os.path.join(app.config.output_dir, self.channel, self.modulename)
+ web_output_dir = app.get_module_web_output_dir(self, versioned=False)
development_release = (int(self.one_dot_version.split('.')[1]) % 2 == 1) or (
int(self.one_dot_version.split('.')[0]) == 0)
diff --git a/src/modtypes/gnomedocbook.py b/src/modtypes/gnomedocbook.py
index 39d6df1..1625188 100644
--- a/src/modtypes/gnomedocbook.py
+++ b/src/modtypes/gnomedocbook.py
@@ -131,9 +131,8 @@ class GnomeDocbookModule(DocModule):
doc.category = self.category
doc.toc_id = app.toc_mapping.get(doc.category)
- web_output_dir = os.path.join(app.config.output_dir, self.channel,
- doc_module, self.one_dot_version)
-
+ web_output_dir = app.get_module_web_output_dir(self)
+
quirks = app.overlay.get_quirks(self)
if not 'flat-rendering' in quirks:
doc.single_page_alternative = True
diff --git a/src/modtypes/gtkdoc.py b/src/modtypes/gtkdoc.py
index 869652d..561502a 100644
--- a/src/modtypes/gtkdoc.py
+++ b/src/modtypes/gtkdoc.py
@@ -66,8 +66,7 @@ class GtkDocModule(DocModule):
html_images = []
html_images = [x.replace('$(srcdir)/', '') for x in html_images]
- web_output_dir = os.path.join(app.config.output_dir, self.channel,
- doc_module, self.one_dot_version)
+ web_output_dir = app.get_module_web_output_dir(self)
if not os.path.exists(web_output_dir):
os.makedirs(web_output_dir)
@@ -194,8 +193,7 @@ class GtkDocModule(DocModule):
self.install_version_symlinks(doc)
def create_tarball(self, doc):
- web_output_dir = os.path.join(app.config.output_dir, self.channel,
- self.modulename)
+ web_output_dir = app.get_module_web_output_dir(self, versioned=False)
tarball_name = '%s-html-%s.tar.gz' % (self.modulename, self.version)
tarball_filepath = os.path.join(web_output_dir, tarball_name)
if os.path.exists(tarball_filepath):
diff --git a/src/modtypes/htmlfiles.py b/src/modtypes/htmlfiles.py
index a81aca1..a356e5b 100644
--- a/src/modtypes/htmlfiles.py
+++ b/src/modtypes/htmlfiles.py
@@ -57,8 +57,7 @@ class HtmlFilesModule(DocModule):
doc_module = self.modulename
ext_dirname = os.path.join(app.config.private_dir, 'extracts')
- web_output_dir = os.path.join(app.config.output_dir, self.channel,
- doc_module, self.one_dot_version)
+ web_output_dir = app.get_module_web_output_dir(self)
if not os.path.exists(web_output_dir):
os.makedirs(web_output_dir)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]