From a70ca606ef616fbddec15da35820cd8c8694f1f6 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 4 Apr 2014 13:09:58 +0200 Subject: Add support for running the script on local files, for this workflow: * make local change, commit * run script * open generated HTML in browser, to check what it looks like * git push * scp generated subdir to website --- web-export/update.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'web-export') diff --git a/web-export/update.py b/web-export/update.py index 8b9b6f0..6c392a0 100755 --- a/web-export/update.py +++ b/web-export/update.py @@ -27,7 +27,12 @@ import urllib import urllib2 import urlparse -DEVELOPMENT = False +# True = Allow this file to differ from the committed version +DEVELOPMENT = True + +# When running this on the website itself, set USELOCALFILES to False +# But since xmlto isn't installed there, we currently have to run it locally so this is now True (i.e. it uses the local files) +USELOCALFILES = True GITWEB = 'http://cgit.freedesktop.org' HASH = 'md5' @@ -106,10 +111,16 @@ class VcsObject: if self.data: return - url = self.get_url() - fd = urllib2.urlopen(url, None) - self.data = fd.read() - fd.close() + if USELOCALFILES: + localpath = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + '/' + self.file + fd = open(localpath) + self.data = fd.read() + fd.close() + else: + url = self.get_url() + fd = urllib2.urlopen(url, None) + self.data = fd.read() + fd.close() def get_hash(self): self.fetch() @@ -158,6 +169,8 @@ class SpecObject(): if self.ext == '.html': return + print "Converting", self.filename, "to HTML" + path = os.path.join(self.spec_dir, self.filename) (path_no_ext, ext) = os.path.splitext(path) @@ -256,7 +269,10 @@ for line in lines: (data, revision, version, path) = line.split() splitted_line = data.split(":") if data.startswith("git:"): - vcs = VcsObject('git', splitted_line[1], splitted_line[2], revision) + repo = splitted_line[1] + if USELOCALFILES and (revision != "master" or repo != "xdg/xdg-specs" or path in [ "idle-inhibit-spec", "secret-service-spec" ]): + continue + vcs = VcsObject('git', repo, splitted_line[2], revision) else: vcs = VcsObject(splitted_line[0], None, data, revision) -- cgit v1.2.3-70-g09d2