davemds pushed a commit to branch master.

http://git.enlightenment.org/editors/geany-configs.git/commit/?id=a1fab73a7e039c7a1a62b741a2ac60b3b53fbcb3

commit a1fab73a7e039c7a1a62b741a2ac60b3b53fbcb3
Author: Dave Andreoli <[email protected]>
Date:   Sun Feb 26 20:47:41 2017 +0100

    Add a simple multiline snippets parser
    
    Just a tiny utils that give you the ability to write geany snippets using a 
multiline syntax
---
 snippets.conf                            | 19 +++++++++++---
 snippets.conf => snippets.multiline.conf | 45 +++++++++++++++++++++++++++++---
 snippets_multiline_parser.py             | 42 +++++++++++++++++++++++++++++
 3 files changed, 98 insertions(+), 8 deletions(-)

diff --git a/snippets.conf b/snippets.conf
index 3e7132d..b0aea7f 100644
--- a/snippets.conf
+++ b/snippets.conf
@@ -10,18 +10,29 @@
 #
 # NOTE: default snippets file (with docs) at: /usr/share/geany/snippets.conf
 #
+# NOTE: the final snippets.conf file is generated from the
+#       snippets.multiline.conf one. Just run the snippets_multiline_parser.py
+#       script to regenerate.
+#
 
 [Python]
-# generic python
-prop=@property\ndef %cursor%(self):\n\treturn
-class=class %cursor%(object):\n\tdef __init__(self):\n\t\tpass
-
+### generic python
+prop=@property\ndef %cursor%(self):\n\treturn\n
+class=class %cursor%(object):\n\tdef __init__(self):\n\t\tpass\n
 
 # Python-EFL
 expand=size_hint_expand=EXPAND_BOTH
 fill=size_hint_fill=FILL_BOTH
 align=size_hint_align=(0.0,0.5)
 
+[Cython]
+# Sphyix
+since=.. versionadded:: 1.%cursor%
+
+# Python-EFL
+propbool=property %cursor%:\n\t""" TODOC\n\n\tTODOC\n\n\t:type: TODOC\n\n\t.. 
versionadded:: TODOC\n\n\t"""\n\tdef __get__(self):\n\t\treturn 
bool(XXXXXX_get(self.obj))\n\n\tdef __set__(self, bint 
value):\n\t\tXXXXXX_set(self.obj, value)\n\ndef XXXXXX_get(self):\n\treturn 
bool(XXXXXX_get(self.obj))\ndef XXXXXX_set(self, bint 
value):\n\tXXXXXX_set(self.obj, value)\n
+
+
 [Edje]
 # blocks
 collections=collections {\n\t%cursor% \n}
diff --git a/snippets.conf b/snippets.multiline.conf
similarity index 91%
copy from snippets.conf
copy to snippets.multiline.conf
index 3e7132d..3bc32c1 100644
--- a/snippets.conf
+++ b/snippets.multiline.conf
@@ -10,18 +10,55 @@
 #
 # NOTE: default snippets file (with docs) at: /usr/share/geany/snippets.conf
 #
+# NOTE: the final snippets.conf file is generated from the
+#       snippets.multiline.conf one. Just run the snippets_multiline_parser.py
+#       script to regenerate.
+#
 
 [Python]
-# generic python
-prop=@property\ndef %cursor%(self):\n\treturn
-class=class %cursor%(object):\n\tdef __init__(self):\n\t\tpass
-
+### generic python
+prop=MULTILINE
+# @property
+# def %cursor%(self):
+#     return
+class=MULTILINE
+# class %cursor%(object):
+#     def __init__(self):
+#         pass
 
 # Python-EFL
 expand=size_hint_expand=EXPAND_BOTH
 fill=size_hint_fill=FILL_BOTH
 align=size_hint_align=(0.0,0.5)
 
+[Cython]
+# Sphyix
+since=.. versionadded:: 1.%cursor%
+
+# Python-EFL
+propbool=MULTILINE
+# property %cursor%:
+#     """ TODOC
+# 
+#     TODOC
+# 
+#     :type: TODOC
+# 
+#     .. versionadded:: TODOC
+# 
+#     """
+#     def __get__(self):
+#         return bool(XXXXXX_get(self.obj))
+# 
+#     def __set__(self, bint value):
+#         XXXXXX_set(self.obj, value)
+# 
+# def XXXXXX_get(self):
+#     return bool(XXXXXX_get(self.obj))
+# def XXXXXX_set(self, bint value):
+#     XXXXXX_set(self.obj, value)
+
+
 [Edje]
 # blocks
 collections=collections {\n\t%cursor% \n}
diff --git a/snippets_multiline_parser.py b/snippets_multiline_parser.py
new file mode 100755
index 0000000..ce5e498
--- /dev/null
+++ b/snippets_multiline_parser.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#
+# Simple parser to generate snippets.conf file from the snippets.multiline.conf
+# template.
+# In the template you can write multiline snippets, that will be single-lined
+# by running this generator.
+#
+# Look at the existing template fiel to see the supported syntax.
+#
+
+TEMPLATE = 'snippets.multiline.conf'
+OUTPUT = 'snippets.conf'
+
+MODE_SEARCH = 0
+MODE_INSIDE = 1
+
+mode = MODE_SEARCH
+
+with open(TEMPLATE,'r') as infile, open(OUTPUT,'w') as outfile:
+    for line in infile:
+
+        if mode == MODE_INSIDE:
+            if line.startswith('# '):
+                # print("+", line)
+                escaped = line[2:]
+                escaped = escaped.replace('\n', '\\n')
+                escaped = escaped.replace('\t', '\\t')
+                escaped = escaped.replace('    ', '\\t')
+                outfile.write(escaped)
+            else:
+                # print("END", line)
+                outfile.write('\n')
+                mode = MODE_SEARCH
+
+        if mode == MODE_SEARCH:
+            if line.endswith('=MULTILINE\n'):
+                # print("START", line)
+                outfile.write(line.replace('MULTILINE\n', ''))
+                mode = MODE_INSIDE
+            else:
+                outfile.write(line)
+

-- 


Reply via email to