[gnome-keysign: 1/18] added a primitive extract_desktop function to babelglade



commit 7f5bc8b0cd55254ac96bb6c4ab1d2dfc481b6279
Author: Tobias Mueller <muelli cryptobitch de>
Date:   Fri Oct 6 15:24:10 2017 +0200

    added a primitive extract_desktop function to babelglade

 babelglade/__init__.py | 15 +++++++++++++++
 setup.py               |  3 +++
 2 files changed, 18 insertions(+)
---
diff --git a/babelglade/__init__.py b/babelglade/__init__.py
index ec0e008..f629024 100644
--- a/babelglade/__init__.py
+++ b/babelglade/__init__.py
@@ -113,3 +113,18 @@ def extract_glade(fileobj, keywords, comment_tags, options):
             else:
                 yield (lineno, None, message, [])
     return get_messages()
+
+
+
+def extract_desktop(fileobj, keywords, comment_tags, options):
+    for lineno, line in enumerate(fileobj, 1):
+        comments = []
+        if line.strip().startswith('_'):
+            l = line.split('=', 1)
+            funcname, message = l[0:2]
+            funcname = funcname.lstrip('_')
+            comments.append(funcname)
+            funcname = '' # FIXME: Why can I not assign that name to funcname?
+            yield (lineno, funcname, message.strip(), comments)
+
+
diff --git a/setup.py b/setup.py
index 935bef6..13be66d 100644
--- a/setup.py
+++ b/setup.py
@@ -175,6 +175,9 @@ setup(
         'Topic :: Software Development :: Libraries :: Python Modules',
         ],
         message_extractors = {
+            '': [
+               ('**.desktop', 'babelglade:extract_desktop', None),
+            ],
             'keysign': [
                 ('**.py', 'python', None),
                 ('**.ui', 'babelglade:extract_glade', None),


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