changeset 11:feb6bb4427fe

Applied a variation of Stephan Holl's zeiterfassung.non-utf8-chars-in-db.patch to force the encoding given by --encoding=.
author Sascha L. Teichmann <teichmann@intevation.de>
date Mon, 04 Aug 2008 12:32:46 +0200
parents 4f782a05b4dc
children 2ccae1e872e9
files ChangeLog contrib/zeiterfassung
diffstat 2 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Aug 03 16:11:21 2008 +0200
+++ b/ChangeLog	Mon Aug 04 12:32:46 2008 +0200
@@ -1,3 +1,9 @@
+2008-08-04	Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* contrib/zeiterfassung: Applied a variation of Stephan Holl's
+	  zeiterfassung.non-utf8-chars-in-db.patch to force the  encoding
+	  given by --encoding=.
+
 2008-08-03	Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* contrib/zeiterfassung: Added parameter -e | --encoding=.
--- a/contrib/zeiterfassung	Sun Aug 03 16:11:21 2008 +0200
+++ b/contrib/zeiterfassung	Mon Aug 04 12:32:46 2008 +0200
@@ -52,7 +52,7 @@
 SELECT 
     date(start_time), 
     sum(strftime('%s', stop_time) - strftime('%s', start_time)), 
-    'no description'
+    'no description' AS description
 FROM entries 
 WHERE 
     project_id = :project_id AND 
@@ -67,10 +67,9 @@
 '''
 
 def human_time(s):
-    s_h = s % 3600
     h = s / 3600
-    m = s_h / 60
-    if (s_h % 60) >= 30:
+    m = (s % 3600) / 60
+    if (s % 60) >= 30:
         m += 1
         if m == 60:
             m = 0
@@ -137,6 +136,8 @@
     try:
         try:
             con = db.connect(database)
+            if encoding:
+                con.text_factory = lambda s: s.decode(encoding)
             cur = con.cursor()
 
             if list_projects:
@@ -173,7 +174,7 @@
                             if m:
                                 workpackage = m.group(1)
                                 c = c[m.end():].strip()
-                        print u"%s %sh %s %3s [%s] %s" % (
+                        print "%s %sh %s %3s [%s] %s" % (
                             d.strftime("%d.%m.%Y"),
                             human_time(t),
                             TYPE_OF_ENTRY,
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)