[Saegewerk-commits] r5 - trunk
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Jun 26 10:59:30 CEST 2008
Author: khruskowski
Date: 2008-06-26 10:59:29 +0200 (Thu, 26 Jun 2008)
New Revision: 5
Modified:
trunk/Makefile
trunk/generate_site.py
trunk/report_parser.py
Log:
retabbet
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2008-06-24 12:52:04 UTC (rev 4)
+++ trunk/Makefile 2008-06-26 08:59:29 UTC (rev 5)
@@ -1,41 +1,25 @@
-# Makefile
HTDOCS_DIR=htdocs/
TEMPLATE_DIR=template/
REPORTS_DIR=reports/
ONLINE_REPOS=fnord at saegewerk.wald.intevation.de
-ONLINE_REPORTS=/saegewerk/htdocs/reports/
ONLINE_HTDOCS=/saegewerk/htdocs/
-all: get_reports build_website
+all: build_website
@echo "done."
-get_reports: clean_htdocs
-# get listing
-# from saegewerk server
- cd $(REPORTS_DIR); \
- rsync -rloDhzv --progress $(ONLINE_REPOS):$(ONLINE_REPORTS) .; \
- tar -xjvf *.tar.bz2 -C $(HTDOCS_DIR); \
- rm *.tar.bz2
- @echo "got reports."
-
build_website:
@echo "building website..."
- python generate_site.py $(PWD) $(TEMPLATE_DIR) $(REPORTS_DIR) $(HTDOCS_DIR)
+ python generate_site.py $(TEMPLATE_DIR) $(HTDOCS_DIR)
# remove .svn from htdocs/img/
rm -Rf $(HTDOCS_DIR)img/.svn
online:
-# upload website data
+# upload data
rsync -rloDhzv --del --progress $(HTDOCS_DIR) $(ONLINE_REPOS):$(ONLINE_HTDOCS) --exclude="reports/"
@echo "Site online."
-clean_htdocs:
+clean: clean_htdocs
cd $(HTDOCS_DIR); rm -Rf *
-
-clean_reports:
- cd $(REPORTS_DIR); rm -Rf *
-
-clean: clean_reports clean_htdocs
@echo "clean."
Modified: trunk/generate_site.py
===================================================================
--- trunk/generate_site.py 2008-06-24 12:52:04 UTC (rev 4)
+++ trunk/generate_site.py 2008-06-26 08:59:29 UTC (rev 5)
@@ -11,102 +11,98 @@
import os, re, sys, shutil, glob, fnmatch
from distutils import dir_util
-from Cheetah.Template import Template
+from Cheetah.Template import Template
from report_parser import ReportParser
-HOME_DIR = sys.argv[1]
-REPORT_DIR = sys.argv[3]
-TEMPLATE_DIR = sys.argv[2]
-HTDOCS_DIR = sys.argv[4]
+TEMPLATE_DIR = sys.argv[1]
+HTDOCS_DIR = sys.argv[2]
ADDITIONAL_FILES = ['*.css', 'img/']
-
-# Htmlparser for buildreportfiles
+
+# Htmlparser for buildreportfiles
def main():
- # Site Frame Template & bound template variables
- site_frame_template_namespace = { 'TITLE': '',
- 'STYLE_TAG': '',
- 'SITE_CONTENT': '',
+ # Site Frame Template & bound template variables
+ site_frame_template_namespace = { 'TITLE': '',
+ 'STYLE_TAG': '',
+ 'SITE_CONTENT': '',
'SOURCE_PATH': '' }
-
- site_frame_template = Template(open('%ssite_frame.ctpl.html' % TEMPLATE_DIR).read(), \
- searchList = [site_frame_template_namespace])
- #print 'Copying reports to %s' % HTDOCS_DIR
- #dir_util.copy_tree(REPORT_DIR, HTDOCS_DIR, verbose=1)
+ site_frame_template = Template(open('%ssite_frame.ctpl.html' % TEMPLATE_DIR).read(), \
+ searchList = [site_frame_template_namespace])
- # Collect full report-dir-tree
- build_reports = []
- for root, dirs, files in os.walk(HTDOCS_DIR):
- for filename in files:
- if fnmatch.fnmatch(filename, '*.html'):
- build_reports.append(os.path.join(root, filename))
+ # Collect full report-dir-tree
+ build_reports = []
+ for root, dirs, files in os.walk(HTDOCS_DIR):
+ for filename in files:
+ if fnmatch.fnmatch(filename, '*.html'):
+ build_reports.append(os.path.join(root, filename))
- projects = []
+ projects = []
- # Walk over reports, scan them and create static html files in htdocs
- for report in build_reports:
- print 'Report File: %s' % (report)
+ # Walk over reports, scan them and create static html files in htdocs
+ for report in build_reports:
+ print 'Report File: %s' % (report)
- #New & clean Parser
- report_parser = ReportParser()
+ #New & clean Parser
+ report_parser = ReportParser()
- report_parser.feed(open(report).read())
- report_parser.close()
-
- # Imprison css
- report_css = report_parser.get_style_content()
- report_css = re.sub(r"(\.*\w+\s*{)", '#css_prison \g<1>', report_css)
+ report_parser.feed(open(report).read())
+ report_parser.close()
- report_content_template = Template(open('%sreport.ctpl' % TEMPLATE_DIR).read(), \
+ # Imprison css
+ report_css = report_parser.get_style_content()
+ report_css = re.sub(r"(\.*\w+\s*{)", '#css_prison \g<1>', report_css)
+
+ report_content_template = Template(open('%sreport.ctpl' % TEMPLATE_DIR).read(), \
searchList = [{'CONTENT': \
report_parser.get_body_content()}])
- site_frame_template_namespace = { 'TITLE': report_parser.get_title(),
- 'STYLE_TAG': report_css,
- 'SITE_CONTENT': str(report_content_template),
- 'SOURCE_PATH': '../' }
+ site_frame_template_namespace = { 'TITLE': report_parser.get_title(),
+ 'STYLE_TAG': report_css,
+ 'SITE_CONTENT': str(report_content_template),
+ 'SOURCE_PATH': '../' }
- site_frame_template.searchList()[0] = site_frame_template_namespace
+ site_frame_template.searchList()[0] = site_frame_template_namespace
- buildlog_file_h = open(report, 'w')
- buildlog_file_h.write(str(site_frame_template))
- buildlog_file_h.close()
+ buildlog_file_h = open(report, 'w')
+ buildlog_file_h.write(str(site_frame_template))
+ buildlog_file_h.close()
- print report_parser.get_title()
- if report.find('index.html') > -1:
- projects.append({'title': report_parser.get_title(), 'src': report.replace(HTDOCS_DIR, '')})
+ print report_parser.get_title()
+ if report.find('index.html') > -1:
+ projects.append({'title': report_parser.get_title(),\
+ 'src': report.replace(HTDOCS_DIR, '')})
- print 'Projects: %s' % projects
+ print 'Projects: %s' % projects
- # Create saegewerks index site
- print 'Creating Saegewerk index.html'
- buildlog_block = Template(open('%sbuildlog_block.ctpl' % TEMPLATE_DIR).read(), \
- searchList = [{'BUILDLOGS': projects}])
+ # Create saegewerks index site
+ print 'Creating Saegewerk index.html'
+ buildlog_block = Template(open('%sbuildlog_block.ctpl' % TEMPLATE_DIR).read(), \
+ searchList = [{'BUILDLOGS': projects}])
- site_frame_template_namespace = { 'TITLE': 'Sägewerk - Free Software forestry',
+ site_frame_template_namespace = { 'TITLE': 'Sägewerk - Free Software forestry',
'SITE_CONTENT': str(buildlog_block),
- 'SOURCE_PATH': '' }
+ 'SOURCE_PATH': '' }
- site_frame_template.searchList()[0] = site_frame_template_namespace
-
- site_index_h = open('%sindex.html' % HTDOCS_DIR, 'w+')
- site_index_h.write(str(site_frame_template))
- site_index_h.close()
+ site_frame_template.searchList()[0] = site_frame_template_namespace
- # Copy additional files
- for additional_file in ADDITIONAL_FILES:
- for file in glob.glob('%s%s' % (TEMPLATE_DIR, additional_file)):
- print 'copy %s -> %s' % (file, HTDOCS_DIR)
+ site_index_h = open('%sindex.html' % HTDOCS_DIR, 'w+')
+ site_index_h.write(str(site_frame_template))
+ site_index_h.close()
- if file[-1] == '/' and file[0] != '.':
- # Copy a directory
- dest_dir = file.replace(TEMPLATE_DIR, '')
- dir_util.copy_tree(file, '%s%s' % (HTDOCS_DIR, dest_dir), verbose=1)
+ # Copy additional files
+ for additional_file in ADDITIONAL_FILES:
+ for file in glob.glob('%s%s' % (TEMPLATE_DIR, additional_file)):
+ print 'copy %s -> %s' % (file, HTDOCS_DIR)
- else:
- # Copy a single file
- shutil.copy(file, HTDOCS_DIR)
-
+ if file[-1] == '/' and file[0] != '.':
+ # Copy a directory
+ dest_dir = file.replace(TEMPLATE_DIR, '')
+ dir_util.copy_tree(file, '%s%s' % (HTDOCS_DIR, dest_dir), verbose=1)
+
+ else:
+ # Copy a single file
+ shutil.copy(file, HTDOCS_DIR)
+
if __name__ == '__main__':
- main()
+ main()
Modified: trunk/report_parser.py
===================================================================
--- trunk/report_parser.py 2008-06-24 12:52:04 UTC (rev 4)
+++ trunk/report_parser.py 2008-06-26 08:59:29 UTC (rev 5)
@@ -3,76 +3,75 @@
import HTMLParser
class ReportParser(HTMLParser.HTMLParser):
- def __init__(self):
- HTMLParser.HTMLParser.__init__(self)
+ def __init__(self):
+ HTMLParser.HTMLParser.__init__(self)
- self.body_start_end = [(0,0),(0,0)]
- self.style_start_end = [(0,0),(0,0)]
- self.title_start_end = [(0,0), (0,0)]
+ self.body_start_end = [(0,0),(0,0)]
+ self.style_start_end = [(0,0),(0,0)]
+ self.title_start_end = [(0,0), (0,0)]
- self.raw_data = ''
+ self.raw_data = ''
- def handle_starttag(self, tag, attr):
- # copy raw data
- if self.raw_data == '':
- self.raw_data = self.rawdata
-
- if tag == 'body':
- self.body_start_end[0] = self.getpos()
-
- if tag == 'style':
- self.style_start_end[0] = self.getpos()
+ def handle_starttag(self, tag, attr):
+ # copy raw data
+ if self.raw_data == '':
+ self.raw_data = self.rawdata
- if tag == 'title':
- self.title_start_end[0] = self.getpos()
+ if tag == 'body':
+ self.body_start_end[0] = self.getpos()
- def handle_endtag(self, tag):
- if tag == 'body':
- self.body_start_end[1] = self.getpos()
-
- if tag == 'style':
- self.style_start_end[1] = self.getpos()
+ if tag == 'style':
+ self.style_start_end[0] = self.getpos()
- if tag == 'title':
- self.title_start_end[1] = self.getpos()
-
- def x_seek(self, start, end):
- # Record raw content from - to line
- if(start[0] > end[0]):
- raise 'Invalid range %s to %s' % (start, end)
+ if tag == 'title':
+ self.title_start_end[0] = self.getpos()
- rawdata = self.raw_data
- rawdata = rawdata.splitlines(1)
- line_i = 0
- rec = 0
- content = ''
+ def handle_endtag(self, tag):
+ if tag == 'body':
+ self.body_start_end[1] = self.getpos()
- for line in rawdata:
- if line_i == start[0] and start[0] != end[0]:
- rec = 1
-
- if line_i == (end[0]-1) and start[0] != end[0]:
- content += line[:end[1]]
- break
+ if tag == 'style':
+ self.style_start_end[1] = self.getpos()
- if line_i == (start[0]-1) and start[0] == end[0]:
- content = line[start[1]:end[1]]
- break
+ if tag == 'title':
+ self.title_start_end[1] = self.getpos()
- if rec == 1:
- content += line
+ def x_seek(self, start, end):
+ # Record raw content from - to line
+ if(start[0] > end[0]):
+ raise 'Invalid range %s to %s' % (start, end)
-
- line_i += 1
+ rawdata = self.raw_data
+ rawdata = rawdata.splitlines(1)
+ line_i = 0
+ rec = 0
+ content = ''
- return content
+ for line in rawdata:
+ if line_i == start[0] and start[0] != end[0]:
+ rec = 1
- def get_body_content(self):
- return self.x_seek(self.body_start_end[0], self.body_start_end[1])
-
- def get_style_content(self):
- return self.x_seek(self.style_start_end[0], self.style_start_end[1])
+ if line_i == (end[0]-1) and start[0] != end[0]:
+ content += line[:end[1]]
+ break
- def get_title(self):
- return self.x_seek(self.title_start_end[0], self.title_start_end[1]).replace('<title>', '')
+ if line_i == (start[0]-1) and start[0] == end[0]:
+ content = line[start[1]:end[1]]
+ break
+ if rec == 1:
+ content += line
+
+ line_i += 1
+
+ return content
+
+ def get_body_content(self):
+ return self.x_seek(self.body_start_end[0], self.body_start_end[1])
+
+ def get_style_content(self):
+ return self.x_seek(self.style_start_end[0], self.style_start_end[1])
+
+ def get_title(self):
+ return self.x_seek(self.title_start_end[0], self.title_start_end[1]).replace('<title>', '')
+
More information about the Saegewerk-commits
mailing list