[Blends-commit] [SCM] website branch, master, updated. 62b4b5d8b2d72459d39faf2a7c535e06ba4b8f6f
The following commit has been merged in the master branch: commit 2c2deb801ed584d0ebeaa449854eeb11c324fbe5 Author: Ole Streicher Date: Mon Jan 11 09:50:30 2016 +0100 Use os.path.join() instead of concatenating strings diff --git a/webtools_py3/tasks_udd.py b/webtools_py3/tasks_udd.py index 052a441..8362aad 100755 --- a/webtools_py3/tasks_udd.py +++ b/webtools_py3/tasks_udd.py @@ -74,7 +74,7 @@ if outputdir == None: exit(-1) t = datetime.now() -htaccess = outputdir + '/.htaccess' +htaccess = os.path.join(outputdir, 'htaccess') htafp = open(htaccess, 'w') htafp.write("DirectoryIndex index index.html\nOptions +MultiViews\n") @@ -172,9 +172,7 @@ for lang in languages: template = loader.load('tasks_idx.xhtml') -outputfile = outputdir + '/index' -if lang != 'xyz': # let 'en' be a language as any other and add suffix to file name -outputfile += '.' + language_dict[lang]['short'] + '.html' +outputfile = os.path.join(outputdir, 'index.{0}.html'.format(lang)) with open(outputfile, 'w') as f: try: f.write(template.generate(**data).render('xhtml')) @@ -184,9 +182,8 @@ for lang in languages: SetFilePermissions(outputfile) try: template = loader.load('%s_idx.xhtml' % tasks.blendname) -outputfile = tasks.data['outputdir'] + '/index' -if lang != 'xyz': # let 'en' be a language as any other and add suffix to file name -outputfile += '.' + language_dict[lang]['short'] + '.html' +outputfile = os.path.join(tasks.data['outputdir'], + 'index.{0}.html'.format(lang)) with open(outputfile, 'w') as f: try: f.write(template.generate(**data).render('xhtml')) @@ -237,9 +234,8 @@ for lang in languages: data['othertasks'] = ("Links to other tasks") data['indexlink'] = ("Index of all tasks") -outputfile = outputdir + '/' + task -if lang != 'xyz': # let 'en' be a language as any other and add suffix to file name -outputfile += '.' + language_dict[lang]['short'] + '.html' +outputfile = os.path.join(outputdir, + '{0}.{1}.html'.format(task, lang)) if data['projectname'] == 'Debian Astro': template = loader.load('packages.xhtml') @@ -267,9 +263,8 @@ for lang in languages: for task in data['taskskeys']: data['projectsintasks'] = tasks.tasks[task].dependencies -outputfile = outputdir + '/packagelist' -if lang != 'xyz': # let 'en' be a language as any other and add suffix to file name -outputfile += '.' + lang + '.html' +outputfile = os.path.join(outputdir, + 'packagelist.{0}.html'.format(lang)) with open(outputfile, 'w') as f: try: f.write(template.generate(**data).render('xhtml')) -- Static and dynamic websites for Debian Pure Blends ___ Blends-commit mailing list Blends-commit@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/blends-commit
[Blends-commit] [SCM] website branch, master, updated. 62b4b5d8b2d72459d39faf2a7c535e06ba4b8f6f
The following commit has been merged in the master branch: commit 62b4b5d8b2d72459d39faf2a7c535e06ba4b8f6f Author: Ole Streicher Date: Mon Jan 11 13:19:23 2016 +0100 Fix some formatting errors diff --git a/webtools_py3/tasks_udd.py b/webtools_py3/tasks_udd.py index 85f3f90..3b65707 100755 --- a/webtools_py3/tasks_udd.py +++ b/webtools_py3/tasks_udd.py @@ -176,9 +176,9 @@ for lang in languages: outputfile = os.path.join(outputdir, 'index.{0}.html'.format(lang)) with open(outputfile, 'w') as f: try: - f.write(template.generate(**data).render('xhtml')) +f.write(template.generate(**data).render('xhtml')) except UnicodeDecodeError as err: - stderr.write("Some critical encoding problem occured when trying" +stderr.write("Some critical encoding problem occured when trying" + " to render index for lang {0}.\n{1}\n" .format(lang, str(err))) SetFilePermissions(outputfile) @@ -235,12 +235,12 @@ for lang in languages: data['othertasks'] = ("Links to other tasks") data['indexlink'] = ("Index of all tasks") -outputfile = os.path.join(outputdir, '{0}.{1}.html'.format(task, lang)) - if data['projectname'] == 'Debian Astro': template = loader.load('packages.xhtml') else: template = loader.load('tasks.xhtml') + +outputfile = os.path.join(outputdir, '{0}.{1}.html'.format(task, lang)) with open(outputfile, "w") as f: try: # We had to mask ampersand ('&') from Genshi but even if the browser shows @@ -252,7 +252,7 @@ for lang in languages: except UnicodeDecodeError as err: stderr.write("Some critical encoding problem occured when trying" + " to render task {0} for lang {1}.\n{2}\n" -.format(task, lang, str(err)) +.format(task, lang, str(err))) except UndefinedError as err: stderr.write("UndefinedError while rendering" + " task {0} for lang {1}.\n{2}\n" @@ -265,15 +265,14 @@ for lang in languages: for task in data['taskskeys']: data['projectsintasks'] = tasks.tasks[task].dependencies -outputfile = os.path.join(outputdir, - 'packagelist.{0}.html'.format(lang)) +outputfile = os.path.join(outputdir, 'packagelist.{0}.html'.format(lang)) with open(outputfile, 'w') as f: try: f.write(template.generate(**data).render('xhtml')) except UnicodeDecodeError as err: stderr.write("Some critical encoding problem occured when trying" + " to render long package list for lang {0}.\n{1}\n" -.format((lang, str(err))) +.format((lang, str(err except UndefinedError as err: stderr.write("UndefinedError while trying to render" + " long package list for lang {0}.\n{1}\n" -- Static and dynamic websites for Debian Pure Blends ___ Blends-commit mailing list Blends-commit@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/blends-commit
[Blends-commit] [SCM] website branch, master, updated. 62b4b5d8b2d72459d39faf2a7c535e06ba4b8f6f
The following commit has been merged in the master branch: commit 24046d2dcb41f85f7e61a68c9f6aee830a4fafff Author: Ole Streicher Date: Mon Jan 11 10:07:41 2016 +0100 Remove unused local variable found_status diff --git a/webtools_py3/tasks_udd.py b/webtools_py3/tasks_udd.py index 8362aad..da188ba 100755 --- a/webtools_py3/tasks_udd.py +++ b/webtools_py3/tasks_udd.py @@ -213,22 +213,20 @@ for lang in languages: for task in data['taskskeys']: data['task'] = task -# Keep the Dependency lists per task to be able to loop over all tasks in plain package list +# Keep the Dependency lists per task to be able to loop over +# all tasks in plain package list data['dependencies'][task] = [] -found_status = {} for status in use_dependencystatus: if len(tasks.tasks[task].dependencies[status]) > 0: -if status == 'unknown': -# Just print an error message if there are packages with unknown status -if lang == 'en': -# ... but only once and not per language -for dep in tasks.tasks[task].dependencies[status]: -print("Warning: Dependency with unknown status:", dep.pkg, file=stderr) -else: +if status != 'unknown': data['dependencies'][task].append(status) -if status in data['dependencies'][task]: -if status not in found_status: -found_status[status] = 1 +elif lang == 'en': +# Just print an error message if there are packages with +# unknown status but only once and not per language +for dep in tasks.tasks[task].dependencies[status]: +print("Warning: Dependency with unknown status:", + dep.pkg, file=stderr) + # Keep the Project lists per task to be able to loop over all tasks in plain package list data['projects'][task] = tasks.tasks[task].dependencies data['othertasks'] = ("Links to other tasks") -- Static and dynamic websites for Debian Pure Blends ___ Blends-commit mailing list Blends-commit@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/blends-commit
[Blends-commit] [SCM] website branch, master, updated. 62b4b5d8b2d72459d39faf2a7c535e06ba4b8f6f
The following commit has been merged in the master branch: commit c9145c4c444f6adec6a06192513e4c8b72f41cf9 Author: Ole Streicher Date: Mon Jan 11 10:34:58 2016 +0100 print(...,file=stderr) --> stderr.write() diff --git a/webtools_py3/tasks_udd.py b/webtools_py3/tasks_udd.py index da188ba..85f3f90 100755 --- a/webtools_py3/tasks_udd.py +++ b/webtools_py3/tasks_udd.py @@ -22,8 +22,9 @@ from blendsunicode import to_unicode from blendslanguages import languages, language_dict if len(argv) <= 1: -print("Usage: %s \n The needs a matching config file webconf/.conf"\ -% argv[0], file=stderr) +stderr.write('Usage: {0} \n'.format(argv[0]) + + 'The needs a matching config file ' + + 'webconf/.conf') exit(-1) # LockBlendsTools() # logger handler not defined at this moment, needs rethinking ... FIXME @@ -83,7 +84,7 @@ detect_ampersand_code_re = re.compile("href=\"http://\w+\.debian\.org/.+\?\w+="; use_dependencystatus = GetDependencies2Use() for lang in languages: -htafp.write("AddLanguage %s .%s\n" % (language_dict[lang]['htaccess'], lang)) +htafp.write("AddLanguage {0} .{1}\n".format(language_dict[lang]['htaccess'], lang)) l10nstring[lang].install() # _ = l10nstring[lang].ugettext data['lang'] = lang @@ -176,9 +177,10 @@ for lang in languages: with open(outputfile, 'w') as f: try: f.write(template.generate(**data).render('xhtml')) -except UnicodeDecodeError as errtxt: - print("Some critical encoding problem occured when trying to render index for lang %s.\n%s" \ - % (lang, errtxt), file=stderr) +except UnicodeDecodeError as err: + stderr.write("Some critical encoding problem occured when trying" + + " to render index for lang {0}.\n{1}\n" + .format(lang, str(err))) SetFilePermissions(outputfile) try: template = loader.load('%s_idx.xhtml' % tasks.blendname) @@ -187,9 +189,10 @@ for lang in languages: with open(outputfile, 'w') as f: try: f.write(template.generate(**data).render('xhtml')) -except UnicodeDecodeError as errtxt: -print("Some critical encoding problem occured when trying to render index for lang %s.\n%s" - % (lang, errtxt), file = stderr) +except UnicodeDecodeError as err: +stderr.write("Some critical encoding problem occured when trying" + + " to render index for lang {0}.\n{1}\n" + .format(lang, str(err))) SetFilePermissions(outputfile) except: @@ -224,16 +227,15 @@ for lang in languages: # Just print an error message if there are packages with # unknown status but only once and not per language for dep in tasks.tasks[task].dependencies[status]: -print("Warning: Dependency with unknown status:", - dep.pkg, file=stderr) +stderr.write("Warning: Dependency with unknown status: " + + dep.pkg) # Keep the Project lists per task to be able to loop over all tasks in plain package list data['projects'][task] = tasks.tasks[task].dependencies data['othertasks'] = ("Links to other tasks") data['indexlink'] = ("Index of all tasks") -outputfile = os.path.join(outputdir, - '{0}.{1}.html'.format(task, lang)) +outputfile = os.path.join(outputdir, '{0}.{1}.html'.format(task, lang)) if data['projectname'] == 'Debian Astro': template = loader.load('packages.xhtml') @@ -247,12 +249,14 @@ for lang in languages: if detect_ampersand_code_re.search(line): line = re.sub('%26', '&', line) f.write(line + '\n') -except UnicodeDecodeError as errtxt: -print("Some critical encoding problem occured when trying to render task %s for lang %s.\n%s" \ - % (task, lang, errtxt), file=stderr) -except UndefinedError as errtxt: -print("UndefinedError while rendering task %s for lang %s.\n%s" \ - % (task, lang, errtxt), file=stderr) +except UnicodeDecodeError as err: +stderr.write("Some critical encoding problem occured when trying" + + " to render task {0} for lang {1}.\n{2}\n" +.format(task, lang, str(err)) +except UndefinedError as err: +stderr.write("UndefinedError while rendering" + + " task {0} for lang {1}.\n{2}\n" +.format(task, lang, str(err)))
[Blends-commit] [SCM] website branch, master, updated. 62b4b5d8b2d72459d39faf2a7c535e06ba4b8f6f
The following commit has been merged in the master branch: commit 3f361d50736068d83d091bd785bac5b74e75517b Author: Ole Streicher Date: Mon Jan 11 09:06:19 2016 +0100 Remove unlink() calls: existing files are automatically truncated when open('w')ed diff --git a/webtools_py3/tasks_udd.py b/webtools_py3/tasks_udd.py index a0305e2..772347d 100755 --- a/webtools_py3/tasks_udd.py +++ b/webtools_py3/tasks_udd.py @@ -75,10 +75,6 @@ if outputdir == None: t = datetime.now() htaccess = outputdir + '/.htaccess' -try: - os.unlink(htaccess) -except: # simply continue if file does not exist - pass htafp = open(htaccess, 'w') htafp.write("DirectoryIndex index index.html\nOptions +MultiViews\n") @@ -179,10 +175,6 @@ for lang in languages: outputfile = outputdir + '/index' if lang != 'xyz': # let 'en' be a language as any other and add suffix to file name outputfile += '.' + language_dict[lang]['short'] + '.html' -try: -os.unlink(outputfile) -except: # simply continue if file does not exist - pass with open(outputfile, 'w') as f: try: f.write(template.generate(**data).render('xhtml')) @@ -195,10 +187,6 @@ for lang in languages: outputfile = tasks.data['outputdir'] + '/index' if lang != 'xyz': # let 'en' be a language as any other and add suffix to file name outputfile += '.' + language_dict[lang]['short'] + '.html' -try: -os.unlink(outputfile) -except: # simply continue if file does not exist -pass with open(outputfile, 'w') as f: try: f.write(template.generate(**data).render('xhtml')) @@ -252,10 +240,6 @@ for lang in languages: outputfile = outputdir + '/' + task if lang != 'xyz': # let 'en' be a language as any other and add suffix to file name outputfile += '.' + language_dict[lang]['short'] + '.html' -try: -os.unlink(outputfile) -except: # simply continue if file does not exist -pass if data['projectname'] == 'Debian Astro': template = loader.load('packages.xhtml') @@ -293,10 +277,6 @@ for lang in languages: outputfile = outputdir + '/packagelist' if lang != 'xyz': # let 'en' be a language as any other and add suffix to file name outputfile += '.' + lang + '.html' -try: -os.unlink(outputfile) -except: # simply continue if file does not exist -pass with open(outputfile, 'w') as f: try: f.write(template.generate(**data).render('xhtml')) -- Static and dynamic websites for Debian Pure Blends ___ Blends-commit mailing list Blends-commit@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/blends-commit
[Blends-commit] [SCM] website branch, master, updated. 62b4b5d8b2d72459d39faf2a7c535e06ba4b8f6f
The following commit has been merged in the master branch: commit ee4f5e45ca5f13f4518ab5ad02e08bd387756b34 Author: Ole Streicher Date: Mon Jan 11 09:49:57 2016 +0100 use /usr/bin/env in bangpath to follow standard conventions diff --git a/webtools_py3/tasks_udd.py b/webtools_py3/tasks_udd.py index 8b36e09..052a441 100755 --- a/webtools_py3/tasks_udd.py +++ b/webtools_py3/tasks_udd.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 import apt import apt_pkg -- Static and dynamic websites for Debian Pure Blends ___ Blends-commit mailing list Blends-commit@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/blends-commit
[Blends-commit] [SCM] website branch, master, updated. 62b4b5d8b2d72459d39faf2a7c535e06ba4b8f6f
The following commit has been merged in the master branch: commit 22ce84b2dafa4fd1165dfc1daf3b2f36a0ec3d0f Author: Ole Streicher Date: Mon Jan 11 09:32:43 2016 +0100 Dont create temporary output file; do the %26->& replacement in-memory diff --git a/webtools_py3/tasks_udd.py b/webtools_py3/tasks_udd.py index 772347d..8b36e09 100755 --- a/webtools_py3/tasks_udd.py +++ b/webtools_py3/tasks_udd.py @@ -245,27 +245,20 @@ for lang in languages: template = loader.load('packages.xhtml') else: template = loader.load('tasks.xhtml') -with open(outputfile+'_tmp', "w") as f: +with open(outputfile, "w") as f: try: -f.write(template.generate(**data).render('xhtml')) +# We had to mask ampersand ('&') from Genshi but even if the browser shows +# the correct character packages.debian.org gets confused - so turn it back here +for line in template.generate(**data).render('xhtml').splitlines(): +if detect_ampersand_code_re.search(line): +line = re.sub('%26', '&', line) +f.write(line + '\n') except UnicodeDecodeError as errtxt: print("Some critical encoding problem occured when trying to render task %s for lang %s.\n%s" \ % (task, lang, errtxt), file=stderr) except UndefinedError as errtxt: print("UndefinedError while rendering task %s for lang %s.\n%s" \ % (task, lang, errtxt), file=stderr) -SetFilePermissions(outputfile+'_tmp') -# Really rude hack to get back '<' / '>' signs which actually shoul be -# in the output -with open(outputfile+'_tmp', "r") as tmp: -with open(outputfile, "w") as f: -for line in tmp.readlines(): -# We had to mask ampersand ('&') from Genshi but even if the browser shows -# the correct character packages.debian.org gets confused - so turn it back here -if detect_ampersand_code_re.search(line): -line = re.sub('%26', '&', line) -f.write(line) -os.unlink(outputfile+'_tmp') SetFilePermissions(outputfile) template = loader.load('packagelist.xhtml') -- Static and dynamic websites for Debian Pure Blends ___ Blends-commit mailing list Blends-commit@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/blends-commit
[Blends-commit] [SCM] website branch, master, updated. 62b4b5d8b2d72459d39faf2a7c535e06ba4b8f6f
The following commit has been merged in the master branch: commit 5fa8bf13933a7f57dc39757f52ae9a38ff78d075 Author: Ole Streicher Date: Mon Jan 11 09:04:38 2016 +0100 Replace print(.., file=f) with f.write() and most open/close sequences with 'with' diff --git a/webtools_py3/tasks_udd.py b/webtools_py3/tasks_udd.py index 8181029..a0305e2 100755 --- a/webtools_py3/tasks_udd.py +++ b/webtools_py3/tasks_udd.py @@ -80,14 +80,14 @@ try: except: # simply continue if file does not exist pass htafp = open(htaccess, 'w') -print("DirectoryIndex index index.html\nOptions +MultiViews", file=htafp) +htafp.write("DirectoryIndex index index.html\nOptions +MultiViews\n") detect_javascript_code_re = re.compile("onmouseover=\"Tip\(\\'") detect_ampersand_code_re = re.compile("href=\"http://\w+\.debian\.org/.+\?\w+=";) use_dependencystatus = GetDependencies2Use() for lang in languages: -print("AddLanguage %s .%s" % (language_dict[lang]['htaccess'], lang), file=htafp) +htafp.write("AddLanguage %s .%s\n" % (language_dict[lang]['htaccess'], lang)) l10nstring[lang].install() # _ = l10nstring[lang].ugettext data['lang'] = lang @@ -183,14 +183,12 @@ for lang in languages: os.unlink(outputfile) except: # simply continue if file does not exist pass -f = open(outputfile, 'w') -try: - print(template.generate(**data).render('xhtml'), file=f) -except UnicodeDecodeError as errtxt: +with open(outputfile, 'w') as f: +try: + f.write(template.generate(**data).render('xhtml')) +except UnicodeDecodeError as errtxt: print("Some critical encoding problem occured when trying to render index for lang %s.\n%s" \ - % (lang, errtxt), file=stderr) - -f.close() + % (lang, errtxt), file=stderr) SetFilePermissions(outputfile) try: template = loader.load('%s_idx.xhtml' % tasks.blendname) @@ -201,14 +199,13 @@ for lang in languages: os.unlink(outputfile) except: # simply continue if file does not exist pass -f = open(outputfile, 'w') -try: -print(template.generate(**data).render('xhtml'), file=f) -except UnicodeDecodeError as errtxt: -print("Some critical encoding problem occured when trying to render index for lang %s.\n%s" - % (lang, errtxt), file = stderr) +with open(outputfile, 'w') as f: +try: +f.write(template.generate(**data).render('xhtml')) +except UnicodeDecodeError as errtxt: +print("Some critical encoding problem occured when trying to render index for lang %s.\n%s" + % (lang, errtxt), file = stderr) -f.close() SetFilePermissions(outputfile) except: pass @@ -264,37 +261,35 @@ for lang in languages: template = loader.load('packages.xhtml') else: template = loader.load('tasks.xhtml') -f = open(outputfile+'_tmp', "w") -try: -print(template.generate(**data).render('xhtml'), file=f) -except UnicodeEncodeError as errtxt: -print("Some critical encoding problem occured when trying to render task %s for lang %s.\n%s" \ - % (task, lang, errtxt)) -except UnicodeDecodeError as errtxt: -print("Some critical encoding problem occured when trying to render task %s for lang %s.\n%s" \ -% (task, lang, errtxt), file=stderr) -except UndefinedError as errtxt: -print("UndefinedError while rendering task %s for lang %s.\n%s" \ -% (task, lang, errtxt), file=stderr) -f.close() +with open(outputfile+'_tmp', "w") as f: +try: +f.write(template.generate(**data).render('xhtml')) +except UnicodeDecodeError as errtxt: +print("Some critical encoding problem occured when trying to render task %s for lang %s.\n%s" \ + % (task, lang, errtxt), file=stderr) +except UndefinedError as errtxt: +print("UndefinedError while rendering task %s for lang %s.\n%s" \ + % (task, lang, errtxt), file=stderr) SetFilePermissions(outputfile+'_tmp') # Really rude hack to get back '<' / '>' signs which actually shoul be # in the output -tmp = open(outputfile+'_tmp', "r") -f = open(outputfile, "w") -for line in tmp.readlines(): -# We had to mask ampersand ('&') from Genshi but even if the browser shows -# the correct character packages.debian.org gets confused - so turn it back here -if detect_ampersand_code_re.search(line): -line = re.sub('%26', '&', line) -print(line, end=' ', file=f) -f.cl