[Cdd-commits] r819 - in cdd/trunk/webtools: . templates
CDD Subversion Commit
noreply at alioth.debian.org
Tue Jun 17 08:08:58 UTC 2008
Author: tille
Date: Tue Jun 17 08:08:57 2008
New Revision: 819
Modified:
cdd/trunk/webtools/cddtasktools.py
cdd/trunk/webtools/tasks.py
cdd/trunk/webtools/templates/tasks.xhtml
Log:
Better handling of UNICODE problems
Modified: cdd/trunk/webtools/cddtasktools.py
==============================================================================
--- cdd/trunk/webtools/cddtasktools.py (original)
+++ cdd/trunk/webtools/cddtasktools.py Tue Jun 17 08:08:57 2008
@@ -99,6 +99,18 @@
LongDesc += "</pre>\n"
return (ShortDesc, LongDesc)
+def MarkupString(string, pkg, elem):
+ # Genshi does not touch strings that are marked with "Markup()"
+ # This function does the actual Markup call for any string with error checking
+
+ try:
+ string = Markup(string)
+ except UnicodeDecodeError, errtxt:
+ print >> stderr, "%s UnicodeDecodeError in %s: '%s'; ErrTxt: %s" % \
+ (elem, pkg, string, errtxt)
+ string = "DEBUG: Element %s of %s has Unicode problems" % (elem, pkg)
+ return string
+
class DependantPackage:
# Hold information about a program that is in dependency list
# The
@@ -305,6 +317,13 @@
trans[lang][pkg] = SplitDescription(stanza['description-'+lang])
return trans
+ def MarkupPreformatedStringsCDD(self):
+ # Genshi does not touch strings that are marked with "Markup()" - so just
+ # mark the strings that are ready formatted for the whole CDD
+ for task in self.tasknames:
+ tdeps = self.tasks[task]
+ tdeps.MarkupPreformatedStrings()
+
class TaskDependencies:
# List of depencencies defined in one Metapackage
@@ -381,9 +400,7 @@
if key == 'Responsible':
responsible = stanza['responsible'].strip()
if responsible != '':
- responsible = re.sub('\s*(.+)\s+<(.+ at .+)>\s*', '<a href="mailto:\\2">\\1</a>', responsible)
- # Markup to make sure the string is inserted verbatim in Template
- dep.responsible = Markup(responsible)
+ dep.responsible = re.sub('\s*(.+)\s+<(.+ at .+)>\s*', '<a href="mailto:\\2">\\1</a>', responsible)
continue
if key in dep_strength_keys:
@@ -431,18 +448,8 @@
dep.license = 'non-free'
else:
dep.license = 'unknown'
- try:
- dep.pkgShortDesc = Markup(self.available.packages[component][dep.pkg].pkgShortDesc)
- except UnicodeDecodeError:
- print >> stderr, "Can not Markup %s because of unicode error" % self.available.packages[component][dep.pkg].pkgShortDesc
- dep.pkgShortDesc = "DEBUG: Short description of %s has Unicode problems" % \
- dep.pkg # self.available.packages[component][dep.pkg].pkgShortDesc
- try:
- dep.pkgLongDesc = unicode(self.available.packages[component][dep.pkg].pkgLongDesc)
- except UnicodeDecodeError:
- print >> stderr, "Problem rendering %s because of unicode error" % self.available.packages[component][dep.pkg].pkgLongDesc
- dep.pkgLongDesc = "DEBUG: Long description of %s has Unicode problems" % \
- dep.pkg # self.available.packages[component][dep.pkg].pkgLongDesc
+ dep.pkgShortDesc = self.available.packages[component][dep.pkg].pkgShortDesc
+ dep.pkgLongDesc = self.available.packages[component][dep.pkg].pkgLongDesc
dep.homepage = self.available.packages[component][dep.pkg].homepage
dep.version = self.available.packages[component][dep.pkg].version
dep.responsible = self.available.packages[component][dep.pkg].responsible
@@ -522,6 +529,16 @@
return 'prospective'
return 'unknown'
+ def MarkupPreformatedStrings(self):
+ # Genshi does not touch strings that are marked with "Markup()" - so just
+ # mark the strings that are ready formatted
+
+ for dependency in self.dependencies.keys():
+ for dep in self.dependencies[dependency]:
+ dep.responsible = MarkupString(dep.responsible, dep.pkg, 'responsible')
+ dep.pkgShortDesc = MarkupString(dep.pkgShortDesc, dep.pkg, 'pkgShortDesc')
+ dep.pkgLongDesc = MarkupString(dep.pkgLongDesc, dep.pkg, 'pkgLongDesc')
+
class Available:
# Information about available packages
@@ -606,13 +623,8 @@
deppkg.homepage = '.' # Something else in case unexpected things happen
deppkg.version = stanza['version'].split('-')[0]
deppkg.section = stanza['section']
- responsible = re.sub('\s*(.+)\s+<(.+ at .+)>\s*', '<a href="mailto:\\2">\\1</a>', stanza['maintainer'])
- # Markup to make sure the string is inserted verbatim in Template
- try:
- deppkg.responsible = Markup(responsible)
- except UnicodeDecodeError:
- print >> stderr, "Can not Markup %s because of unicode error" % responsible
- deppkg.responsible = "DEBUG: Responsible of %s has Unicode problems" % deppkg.pkg
+ deppkg.responsible = re.sub('\s*(.+)\s+<(.+ at .+)>\s*', '<a href="mailto:\\2">\\1</a>', \
+ stanza['maintainer'])
deppkg.filename = BASEURL+stanza['filename']
self.packages[component][stanza['package']] = deppkg
g.close()
Modified: cdd/trunk/webtools/tasks.py
==============================================================================
--- cdd/trunk/webtools/tasks.py (original)
+++ cdd/trunk/webtools/tasks.py Tue Jun 17 08:08:57 2008
@@ -24,6 +24,7 @@
tasks = cdeps.tasknames
packages = cdeps.GetNamesOnlyDict()
task_details = cdeps.GetTaskDescDict()
+cdeps.MarkupPreformatedStringsCDD()
# Define directories used
current_dir = os.path.dirname(__file__)
Modified: cdd/trunk/webtools/templates/tasks.xhtml
==============================================================================
--- cdd/trunk/webtools/templates/tasks.xhtml (original)
+++ cdd/trunk/webtools/templates/tasks.xhtml Tue Jun 17 08:08:57 2008
@@ -57,7 +57,7 @@
<a name="${project.pkg}" id="${project.pkg}"/>
<strong>${project.pkg}</strong>
<a py:if="project.wnpp != None" href="http://bugs.debian.org/#${project.wnpp}">wnpp</a>
- <em>project.pkgShortDesc - Unicode Problems by Markup in cddtasktools.py</em><br/>
+ <em>${project.pkgShortDesc}</em><br/>
<a href="$project.homepage}">${project.homepage}</a>
<div py:if="project.responsible != None"><span py:choose="type"><span py:when="'official'">${maintainer}</span><span py:otherwise="">${responsible}</span></span>: ${project.responsible}</div>
</td>
@@ -74,7 +74,7 @@
</td>
</tr>
<tr>
- <td colspan="2" class="project-description">project.pkgLongDesc
+ <td colspan="2" class="project-description">${project.pkgLongDesc}
</td>
</tr>
</tbody>
More information about the Cdd-commits
mailing list