[Blends-commit] [SCM] website branch, master, updated. 62b4b5d8b2d72459d39faf2a7c535e06ba4b8f6f

Ole Streicher olebole at debian.org
Mon Jan 11 13:31:11 UTC 2016


The following commit has been merged in the master branch:
commit c9145c4c444f6adec6a06192513e4c8b72f41cf9
Author: Ole Streicher <olebole at debian.org>
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 <Blend name>\n       The <Blend name> needs a matching config file webconf/<Blend name>.conf"\
-                        % argv[0], file=stderr)
+    stderr.write('Usage: {0} <Blend name>\n'.format(argv[0])
+                 + 'The <Blend name> needs a matching config file '
+                 + 'webconf/<Blend name>.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)))
         SetFilePermissions(outputfile)
 
     template = loader.load('packagelist.xhtml')
@@ -266,12 +270,14 @@ 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 long package list for lang %s.\n%s" \
-		  % (lang, errtxt), file=stderr)
-        except UndefinedError as errtxt:
-            print("UndefinedError while trying to render long package list for lang %s.\n%s" \
-		  % (lang, errtxt), file=stderr)
+        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)))
+        except UndefinedError as err:
+            stderr.write("UndefinedError while trying to render"
+                         + " long package list for lang {0}.\n{1}\n"
+		         .format(lang, str(err)))
     SetFilePermissions(outputfile)
 
 htafp.write("LanguagePriority ")

-- 
Static and dynamic websites for Debian Pure Blends



More information about the Blends-commit mailing list