[gnome-keysign: 3/18] babelglade: decode line to a string in extract_desktop



commit a11757a888334f3379858582d372faed4d592ad7
Author: Tobias Mueller <muelli cryptobitch de>
Date:   Sun Oct 8 17:09:35 2017 +0200

    babelglade: decode line to a string in extract_desktop
    
    For Python 3 compatibility.

 babelglade/__init__.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/babelglade/__init__.py b/babelglade/__init__.py
index 8825f15..69aac12 100644
--- a/babelglade/__init__.py
+++ b/babelglade/__init__.py
@@ -12,6 +12,7 @@
 #
 # Please view LICENSE for additional licensing information.
 # =============================================================================
+from __future__ import unicode_literals
 
 from xml.parsers import expat
 
@@ -128,12 +129,16 @@ TRANSLATABLE = (
 
 def extract_desktop(fileobj, keywords, comment_tags, options):
     for lineno, line in enumerate(fileobj, 1):
+        if line.startswith(b'[Desktop Entry]'):
+            continue
+
         for t in TRANSLATABLE:
-            if not line.startswith(t):
+            if not line.startswith(t.encode('utf-8')):
                 continue
             else:
+                l = line.decode('utf-8')
                 comments = []
-                key_value = line.split('=', 1)
+                key_value = l.split('=', 1)
                 key, value = key_value[0:2]
 
                 funcname = key # FIXME: Why can I not assign that name to funcname?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]