changeset 583:5726458585d7

parser.text_x_sort: sorts text lines e.g. items on a group definition page
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 16 Mar 2012 08:55:05 +0100
parents a6e3bc3c144e
children 7a22cd126aa4
files data/plugin/parser/text_x_sort.py
diffstat 1 files changed, 75 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/parser/text_x_sort.py	Fri Mar 16 08:55:05 2012 +0100
@@ -0,0 +1,75 @@
+#-*- coding: utf-8 -*-
+""" 
+sort to sort one level of input
+===================================
+
+This parser is used to sort text lines
+    
+
+Install
+-------
+
+remove the version number 
+Put it in your wiki/data/plugin/parser/
+
+
+Example
+-------
+
+{{{
+#!sort
+ * B
+ * A
+ * D
+ * C
+}}}
+ 
+
+Result::
+
+ * A
+ * B
+ * C
+ * D
+    
+
+Legal
+-----
+@copyright 2005-2012 MoinMoin:ReimarBauer
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+"""
+
+from MoinMoin.parser import text_moin_wiki as wiki
+
+Dependencies = []
+
+
+class Parser:
+
+    def __init__(self, raw, request, **kw):
+        self.raw = raw
+        self.request = request
+        self.form = request.form
+        self._ = request.getText
+
+
+    def format(self, formatter):
+        raw = self.raw.split('\n')
+        raw.sort()
+
+        wikiizer = wiki.Parser('\n'.join(raw), self.request)
+        wikiizer.format(formatter)
+