[Blends-commit] [SCM] website branch, master, updated. ff4cb06d2c11eb2efe7bb67ba4481c01d8926a31
Ole Streicher
olebole at debian.org
Sun Mar 6 08:31:01 UTC 2016
The following commit has been merged in the master branch:
commit ff4cb06d2c11eb2efe7bb67ba4481c01d8926a31
Author: Ole Streicher <olebole at debian.org>
Date: Sun Mar 6 09:30:36 2016 +0100
Remove blendsunicode.py and to_unicode() completely
diff --git a/webtools/blendsmarkdown.py b/webtools/blendsmarkdown.py
index a7de6f1..51692ca 100644
--- a/webtools/blendsmarkdown.py
+++ b/webtools/blendsmarkdown.py
@@ -12,8 +12,6 @@ from markdown import markdown # Markdown
from docutils.core import publish_parts # alternatively reST
from genshi import Markup
-from blendsunicode import to_unicode
-
detect_list_start_re = re.compile("^\s+[-*+]\s+")
detect_code_start_re = re.compile("^\s")
detect_code_end_re = re.compile("^[^\s]")
@@ -66,7 +64,7 @@ def PrepareMarkdownInput(lines):
return ret
def render_longdesc(lines):
- MarkDownInput = to_unicode(PrepareMarkdownInput(lines))
+ MarkDownInput = PrepareMarkdownInput(lines)
global rendering_lib
if rendering_lib == 'rest':
@@ -96,7 +94,7 @@ def MarkupString(string, pkg, elem, lang='en'):
if string == None:
return None
try:
- string = Markup(to_unicode(string))
+ string = Markup(string)
except UnicodeDecodeError, errtxt:
print >> stderr, "----> %s UnicodeDecodeError in %s (lang='%s'): '%s'; ErrTxt: %s" % \
(elem, pkg, lang, 'debug-string', errtxt)
diff --git a/webtools/blendsunicode.py b/webtools/blendsunicode.py
deleted file mode 100644
index daeaf05..0000000
--- a/webtools/blendsunicode.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/python
-# Copyright 2010: Andreas Tille <tille at debian.org>
-# License: GPL
-
-# Handle UTF-8 encoded strings as well as unicode to cope
-# with different versions of python-debian
-# python-debian <0.15 returns string; >=0.15 returns unicode
-
-from sys import stderr
-
-def to_unicode(value, encoding='utf-8'):
- if isinstance(value, str):
- try:
- return value.decode(encoding)
- except UnicodeDecodeError, err:
- print >>stderr, "type(value) =", type(value), \
- "; isinstance(value, str) =", isinstance(value, str), \
- ";", err
- print >>stderr, value
- return '???'
- else:
- return unicode(value)
-
diff --git a/webtools/bugs.py b/webtools/bugs.py
index a91d563..66afc67 100755
--- a/webtools/bugs.py
+++ b/webtools/bugs.py
@@ -27,7 +27,6 @@ from genshi.template import TemplateLoader
from genshi import Markup
from genshi.template.eval import UndefinedError
-from blendsunicode import to_unicode
from blendstasktools import ReadConfig, RowDictionaries, CheckOrCreateOutputDir, SetFilePermissions
from blendsmarkdown import MarkupString
@@ -165,7 +164,7 @@ def main():
bugs_data[task] = {}
bugs_data[task]['title'] = t['title']
bugs_data[task]['description'] = t['description']
- bugs_data[task]['long_description'] = to_unicode(t['long_description'])
+ bugs_data[task]['long_description'] = t['long_description']
bugs_data[task]['nopenbugs'] = 0
bugs_data[task]['ndonebugs'] = 0
bugs_data[task]['weighttask'] = 0
@@ -201,7 +200,7 @@ def main():
if k in ('source', 'status') :
continue
if k == 'title':
- b[k] = to_unicode(bug[k])
+ b[k] = bug[k]
elif k == 'tags':
komma = ''
b['tags'] = ''
@@ -233,8 +232,8 @@ def main():
sources['vcs_browser'] = pkg['vcs_browser']
(_name, _url) = email.Utils.parseaddr(pkg['maintainer'])
sources['maintainer_email'] = _url
- sources['maintainer_name'] = to_unicode(_name)
- sources['maintainer'] = MarkupString('<a href="mailto:%s">%s</a>' % (_url, to_unicode(_name)), pkg['source'], 'maintainer')
+ sources['maintainer_name'] = _name
+ sources['maintainer'] = MarkupString('<a href="mailto:%s">%s</a>' % (_url, _name), pkg['source'], 'maintainer')
if pkg['status'] == 'depends':
sources['bugs'] = bugs[pkg['source']]['open']
bugs_data[task][pkg['status']+'_l'].append(pkg['source'])
@@ -260,8 +259,8 @@ def main():
sources['vcs_browser'] = pkg['vcs_browser']
(_name, _url) = email.Utils.parseaddr(pkg['maintainer'])
sources['maintainer_email'] = _url
- sources['maintainer_name'] = to_unicode(_name)
- sources['maintainer'] = MarkupString('<a href="mailto:%s">%s</a>' % (_url, to_unicode(_name)), pkg['source'], 'maintainer')
+ sources['maintainer_name'] = _name
+ sources['maintainer'] = MarkupString('<a href="mailto:%s">%s</a>' % (_url, _name), pkg['source'], 'maintainer')
sources['bugs'] = bugs[pkg['source']]['done']
bugs_data[task]['done_l'].append(pkg['source'])
bugs_data[task]['done']['sources'].append(sources)
@@ -296,16 +295,16 @@ def main():
# be made explicitely in the python code
advertising = re.sub('_\(\W(.+)\W\)', '\\1', config['advertising'])
# gettext needs to escape '"' thus we need to remove the escape character '\'
- data['projectadvertising'] = Markup(to_unicode(re.sub('\\\\"', '"', advertising)))
+ data['projectadvertising'] = Markup(re.sub('\\\\"', '"', advertising))
else:
data['projectadvertising'] = None
- data['summary'] = to_unicode(_('Summary'))
- data['idxsummary'] = to_unicode(_("""A %sDebian Pure Blend%s is a Debian internal project which assembles
+ data['summary'] = _('Summary')
+ data['idxsummary'] = _("""A %sDebian Pure Blend%s is a Debian internal project which assembles
a set of packages that might help users to solve certain tasks of their work. The list on
the right shows the tasks of %s.""" ) \
- % ('<a href="http://blends.alioth.debian.org/blends/">', '</a>', data['projectname']))
- data['idxsummary'] = Markup(to_unicode(data['idxsummary']))
+ % ('<a href="http://blends.alioth.debian.org/blends/">', '</a>', data['projectname'])
+ data['idxsummary'] = Markup(data['idxsummary'])
t = datetime.now()
data['lang'] = 'en'
diff --git a/webtools/new_upstream.py b/webtools/new_upstream.py
index 0e502cf..ca2e111 100755
--- a/webtools/new_upstream.py
+++ b/webtools/new_upstream.py
@@ -6,7 +6,6 @@
from sys import argv, exit, stderr
from blendstasktools import Tasks
-from blendsunicode import to_unicode
if len(argv) <= 1:
print >>stderr, "Usage: %s <Blend name>\n The <Blend name> needs a matching config file webconf/<Blend name>.conf"\
diff --git a/webtools/tasks.py b/webtools/tasks.py
index 95ea358..f75cdb3 100755
--- a/webtools/tasks.py
+++ b/webtools/tasks.py
@@ -20,7 +20,6 @@ from genshi import Markup
from genshi.template.eval import UndefinedError
from blendstasktools import Tasks, GetDependencies2Use, pkgstatus, pkgstatus_sortedkeys, UnlockBlendsTools, CheckOrCreateOutputDir, SetFilePermissions
-from blendsunicode import to_unicode
from blendslanguages import languages, language_dict
if len(argv) <= 1:
@@ -99,37 +98,37 @@ for lang in languages:
l10nstring[lang].install()
_ = l10nstring[lang].ugettext
data['lang'] = lang
- data['license'] = to_unicode(_('License'))
- data['version'] = to_unicode(_('Version'))
- data['summary'] = to_unicode(_('Summary'))
- data['updatetimestamp'] = to_unicode(_('Last update:')) + ' ' + formatdate(time.mktime(t.timetuple()))
- data['nopkgavail'] = to_unicode(_('Debian package not available'))
+ data['license'] = _('License')
+ data['version'] = _('Version')
+ data['summary'] = _('Summary')
+ data['updatetimestamp'] = _('Last update:') + ' ' + formatdate(time.mktime(t.timetuple()))
+ data['nopkgavail'] = _('Debian package not available')
# Description of package in specific packges (same for Depends, Recommends, Suggests)
- data['legend'] = to_unicode(_("For a better overview of the project's availability as a Debian package, each head row has a color code according to this scheme:"))
- data['discovery'] = Markup(to_unicode(_("""If you discover a project which looks like a good candidate for %s
+ data['legend'] = _("For a better overview of the project's availability as a Debian package, each head row has a color code according to this scheme:")
+ data['discovery'] = Markup(_("""If you discover a project which looks like a good candidate for %s
to you, or if you have prepared an unofficial Debian package, please do not hesitate to
send a description of that project to the <a href="mailto:%s">%s mailing list</a>""") % \
- (data['projectname'], data['projectlist'], data['projectname'])))
- data['bugs'] = to_unicode(_('Bugs'))
- data['thermometer'] = to_unicode(_('Thermometer'))
- data['maintstats'] = to_unicode(_('Maintainer Stats'))
- data['contact'] = to_unicode(_('Contact'))
- data['contribute'] = to_unicode(_('Contribute'))
- data['description'] = to_unicode(_('Description'))
- data['metapackage'] = to_unicode(_('Metapackage'))
- data['packages'] = to_unicode(_('Packages'))
- data['gtstrTasksPage'] = to_unicode(_('Tasks page'))
- data['gtstrProject'] = to_unicode(_('Project'))
- data['gtstrThisIsAList'] = to_unicode(_('This is a list of the Tasks %s is made of:') % data['projectname'])
- data['langavail'] = to_unicode(_('This page is also available in the following languages:'))
- data['howtosetlang'] = to_unicode(_('How to set <a href="%s">the default document language</a>'))
- data['howtosetlang'] = Markup(to_unicode(data['howtosetlang'] % ('http://www.debian.org/intro/cn.%s.html' % lang)))
- data['nohomepage'] = to_unicode(_('Homepage not available'))
- data['translatedesc'] = to_unicode(_('Translate description'))
- data['fixtranslation'] = to_unicode(_('Fix translated description'))
- data['popconexplanation'] = to_unicode(_('Popularitycontest results: number of people who use this package regularly (number of people who upgraded this package recently) out of'))
- data['tableofcontents'] = to_unicode(_('Table of contents'))
- data['packagelist'] = to_unicode(_('complete packagelist'))
+ (data['projectname'], data['projectlist'], data['projectname']))
+ data['bugs'] = _('Bugs')
+ data['thermometer'] = _('Thermometer')
+ data['maintstats'] = _('Maintainer Stats')
+ data['contact'] = _('Contact')
+ data['contribute'] = _('Contribute')
+ data['description'] = _('Description')
+ data['metapackage'] = _('Metapackage')
+ data['packages'] = _('Packages')
+ data['gtstrTasksPage'] = _('Tasks page')
+ data['gtstrProject'] = _('Project')
+ data['gtstrThisIsAList'] = _('This is a list of the Tasks %s is made of:') % data['projectname']
+ data['langavail'] = _('This page is also available in the following languages:')
+ data['howtosetlang'] = _('How to set <a href="%s">the default document language</a>')
+ data['howtosetlang'] = Markup(data['howtosetlang'] % ('http://www.debian.org/intro/cn.%s.html' % lang))
+ data['nohomepage'] = _('Homepage not available')
+ data['translatedesc'] = _('Translate description')
+ data['fixtranslation'] = _('Fix translated description')
+ data['popconexplanation'] = _('Popularitycontest results: number of people who use this package regularly (number of people who upgraded this package recently) out of')
+ data['tableofcontents'] = _('Table of contents')
+ data['packagelist'] = _('complete packagelist')
if data['advertising'] != None:
# If data['advertising'] is enclosed in _() gettext tries to ask for translations of 'advertising'
# which makes no sense. That's why this is masked by an extra string variable
@@ -137,35 +136,35 @@ for lang in languages:
##data['projectadvertising'] = _(advertising) # Hopefully translation will work this way ...
# Genshi needs explicite information that it is dealing with an UTF-8 string which should not be changed
advertising = _(advertising)
- data['projectadvertising'] = Markup(to_unicode(advertising))
+ data['projectadvertising'] = Markup(advertising)
else:
data['projectadvertising'] = None
- data['packages'] = to_unicode(_('Packages'))
- data['idxsummary'] = to_unicode(_('''The {0} Pure Blend contains {1} packages which
+ data['packages'] = _('Packages')
+ data['idxsummary'] = _('''The {0} Pure Blend contains {1} packages which
are grouped by metapackages. Each metapackage will cause the
installation of packages for a specific topic. The following table lists
- the metapackages of {0}''').format(data['projectname'], len(data['PackageByName'])))
+ the metapackages of {0}''').format(data['projectname'], len(data['PackageByName']))
- pkgstatus['official_high']['headline'] = to_unicode(_('Official Debian packages with high relevance'))
+ pkgstatus['official_high']['headline'] = _('Official Debian packages with high relevance')
# before fiddling around with unicode() read
# http://www.red-mercury.com/blog/eclectic-tech/python-unicode-fixing-utf-8-encoded-as-latin-1-iso-8859-1/
- pkgstatus['official_high']['pdolinkname'] = to_unicode(_('Official Debian package'))
- pkgstatus['official_low'] ['headline'] = to_unicode(_('Official Debian packages with lower relevance'))
+ pkgstatus['official_high']['pdolinkname'] = _('Official Debian package')
+ pkgstatus['official_low'] ['headline'] = _('Official Debian packages with lower relevance')
pkgstatus['official_low'] ['pdolinkname'] = pkgstatus['official_high']['pdolinkname']
- pkgstatus['non-free'] ['headline'] = to_unicode(_('Debian packages in contrib or non-free'))
- pkgstatus['non-free'] ['pdolinkname'] = to_unicode(_('Debian package in contrib/non-free'))
- pkgstatus['experimental'] ['headline'] = to_unicode(_('Debian packages in experimental'))
- pkgstatus['experimental'] ['pdolinkname'] = to_unicode(_('Debian package in experimental'))
- pkgstatus['new'] ['headline'] = to_unicode(_('Debian packages in New queue (hopefully available soon)'))
- pkgstatus['new'] ['pdolinkname'] = to_unicode(_('New Debian package'))
- pkgstatus['pkgvcs'] ['headline'] = to_unicode(_('Packaging has started and developers might try the packaging code in VCS'))
- pkgstatus['pkgvcs'] ['pdolinkname'] = to_unicode(_('Unofficial Debian package'))
- pkgstatus['unofficial'] ['headline'] = to_unicode(_('Unofficial packages built by somebody else'))
+ pkgstatus['non-free'] ['headline'] = _('Debian packages in contrib or non-free')
+ pkgstatus['non-free'] ['pdolinkname'] = _('Debian package in contrib/non-free')
+ pkgstatus['experimental'] ['headline'] = _('Debian packages in experimental')
+ pkgstatus['experimental'] ['pdolinkname'] = _('Debian package in experimental')
+ pkgstatus['new'] ['headline'] = _('Debian packages in New queue (hopefully available soon)')
+ pkgstatus['new'] ['pdolinkname'] = _('New Debian package')
+ pkgstatus['pkgvcs'] ['headline'] = _('Packaging has started and developers might try the packaging code in VCS')
+ pkgstatus['pkgvcs'] ['pdolinkname'] = _('Unofficial Debian package')
+ pkgstatus['unofficial'] ['headline'] = _('Unofficial packages built by somebody else')
pkgstatus['unofficial'] ['pdolinkname'] = pkgstatus['pkgvcs']['pdolinkname']
- pkgstatus['prospective'] ['headline'] = to_unicode(_('No known packages available'))
- pkgstatus['prospective'] ['pdolinkname'] = to_unicode(_('Debian package not available'))
- pkgstatus['wnpp'] ['headline'] = to_unicode(_('No known packages available but some record of interest (WNPP bug)'))
+ pkgstatus['prospective'] ['headline'] = _('No known packages available')
+ pkgstatus['prospective'] ['pdolinkname'] = _('Debian package not available')
+ pkgstatus['wnpp'] ['headline'] = _('No known packages available but some record of interest (WNPP bug)')
pkgstatus['wnpp'] ['pdolinkname'] = pkgstatus['prospective']['pdolinkname']
# Ignore/Avoid is only relevant for blends-dev, not webtools
pkgstatus['ignore'] ['headline'] = 'Should not show up here'
@@ -234,12 +233,12 @@ for lang in languages:
# I18n for headlines, link description, maintainer
for status in use_dependencystatus:
- data['headline'][status] = Markup(to_unicode(pkgstatus[status]['headline']))
- data['pdolinkname'][status]= Markup(to_unicode(pkgstatus[status]['pdolinkname']))
+ data['headline'][status] = Markup(pkgstatus[status]['headline'])
+ data['pdolinkname'][status]= Markup(pkgstatus[status]['pdolinkname'])
if pkgstatus[status]['order'] <= pkgstatus['experimental']['order']:
- data['maintainer'][status] = to_unicode(_('Maintainer'))
+ data['maintainer'][status] = _('Maintainer')
else:
- data['maintainer'][status] = to_unicode(_('Responsible'))
+ data['maintainer'][status] = _('Responsible')
for task in data['taskskeys']:
data['task'] = task
diff --git a/webtools/thermometer.py b/webtools/thermometer.py
index e243cb6..6897ec1 100755
--- a/webtools/thermometer.py
+++ b/webtools/thermometer.py
@@ -22,7 +22,6 @@ from genshi.template import TemplateLoader
from genshi import Markup
from genshi.template.eval import UndefinedError
-from blendsunicode import to_unicode
from blendstasktools import ReadConfig, RowDictionaries, CheckOrCreateOutputDir, SetFilePermissions
###########################################################################################
@@ -367,7 +366,7 @@ def main():
# be made explicitely in the python code
advertising = re.sub('_\(\W(.+)\W\)', '\\1', config['advertising'])
# gettext needs to escape '"' thus we need to remove the escape character '\'
- data['projectadvertising'] = Markup(to_unicode(re.sub('\\\\"', '"', advertising)))
+ data['projectadvertising'] = Markup(re.sub('\\\\"', '"', advertising))
else:
data['projectadvertising'] = None
@@ -392,16 +391,16 @@ def main():
data['latestubuntu'] = latestubuntu
data['legend'] = legend
data['ulegend'] = ulegend
- data['summary'] = to_unicode(_('Summary'))
- data['idxsummary'] = to_unicode(_("""A %sDebian Pure Blend%s is a Debian internal project which assembles
+ data['summary'] = _('Summary')
+ data['idxsummary'] = _("""A %sDebian Pure Blend%s is a Debian internal project which assembles
a set of packages that might help users to solve certain tasks of their work. The list on
the right shows the tasks of %s.""" ) \
- % ('<a href="http://blends.alioth.debian.org/blends/">', '</a>', data['projectname']))
- data['idxsummary'] = Markup(to_unicode(data['idxsummary']))
+ % ('<a href="http://blends.alioth.debian.org/blends/">', '</a>', data['projectname'])
+ data['idxsummary'] = Markup(data['idxsummary'])
for key in ('homepage', 'projecturl', 'projectname', 'logourl', 'ubuntuhome', 'projectubuntu'):
data[key] = config[key]
- data['updatetimestamp'] = to_unicode(_('Last update:')) + ' ' + formatdate(time.mktime(t.timetuple()))
+ data['updatetimestamp'] = _('Last update:')) + ' ' + formatdate(time.mktime(t.timetuple())
data['thermometer'] = blendname + '_thermometer.html'
os.system("ln -sf %s %s/index.html" % (data['thermometer'], outputdir))
--
Static and dynamic websites for Debian Pure Blends
More information about the Blends-commit
mailing list