Commits

Anonymous committed 285ec90

json to cfg conversor finished

Comments (0)

Files changed (7)

snippets_plugin/snippets/constants.py

 
 RESOURCES_PATH = os.path.join(PATH, "res")
 
-SNIPPETS_TEMPLATE_FILE_PATH = os.path.join(RESOURCES_PATH, "template.json")
+SNIPPETS_TEMPLATE_FILE_PATH = os.path.join(RESOURCES_PATH, "template.cfg")
 
-SNIPPETS_FILE_PATH = os.path.join(resources.HOME_NINJA_PATH, "snippets.json")
+SNIPPETS_FILE_PATH = os.path.join(resources.HOME_NINJA_PATH, "snippets.cfg")
 
 
 #===============================================================================

snippets_plugin/snippets/conversor.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+a = r"""
+{
+  "VARS": {},
+  "pot": {},
+  "tex": {},
+  "go": {},
+  "pxi": {},
+  "conf": {},
+  "cs": {},
+  "js": {},
+  "pxd": {},
+  "pas": {},
+  "java": {
+    "pr": "private",
+    "pb": "public",
+    "elif": "if(%cursor%){\n\n} else if(){\n\n} else{\n\n}",
+    "ab": "abstract",
+    "po": "protected",
+    "sy": "synchronized",
+    "st": "static",
+    "try": "try{\n\n} catch(%cursor% ex){\n\n} finally{\n\n}",
+    "switch": "switch(%cursor%){\n    case :\n        break;\n    default:\n        break;\n}",
+    "sout": "System.out.println(%cursor%);",
+    "main": "public static void main(String[] args){\n    %cursor%\n}",
+    "class": "public class %cursor%{\n\n}",
+    "if": "if(%cursor%){\n\n} else {\n\n}"
+  },
+  "*GENERAL*": {
+    "$hostname": "$hostname",
+    "$co": "$co",
+    "$email": "$email",
+    "$project": "$project",
+    "$time": "$time",
+    "$cc": "$cc",
+    "$user": "$user",
+    "$cm": "$cm",
+    "apl": "$co\nAPACHE LICENSE\n--------------\n\nCopyright $year $user\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n$cc",
+    "agpl": "$co\nAGPL LICENSE\n------------\n\nCopyright $year $user <$email>\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as\npublished by the Free Software Foundation, either version 3 of the\nLicense, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n$cc",
+    "gpl3": "$co\nGPL LICENSE\n-----------\n\nCopyright $year $user <$email>\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\nMA 02110-1301, USA.\n$cc",
+    "lgpl": "$co\nLGPL LICENSE\n------------\n\nCopyright $year $user <$email>\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as\npublished by the Free Software Foundation, either version 3 of the\nLicense, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n$cc",
+    "$license": "$license",
+    "bsdl": "$co\nBSD LICENSE\n-----------\n\nCopyright (c) $year, $user\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this list\nof conditions and the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright notice, this\nlist of conditions and the following disclaimer in the documentation and/or\nother materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n$cc",
+    "$year": "$year",
+    "$date": "$date",
+    "beerl": "$co\nTHE BEER-WARE LICENSE\n---------------------\n\n\"THE BEER-WARE LICENSE\" (Revision 42):\n<$email> wrote this file. As long as you retain this notice you\ncan do whatever you want with this stuff. If we meet some day, and you think\nthis stuff is worth it, you can buy me a beer in return $user\n$cc",
+    "mitl": "$co\nMIT LICENSE\n-----------\n\nCopyright (c) $year, $user\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n$cc",
+    "$absfile": "$absfile",
+    "wiskeyl": "$co\nTHE WISKEY-WARE LICENSE\n-----------------------\n\n\"THE WISKEY-WARE LICENSE\":\n<$email> wrote this file. As long as you retain this notice you\ncan do whatever you want with this stuff. If we meet some day, and you think\nthis stuff is worth it, you can buy me a wiskey in return $user\n$cc",
+    "$file": "$file",
+    "block": "$co \n==============================================================================\n %cursor%\n==============================================================================\n$cc"
+  },
+  "py": {
+    "head": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n%cursor%",
+    "doc": "'''%cursor%\n\n'''",
+    "meta": "__prj__ = '$project'\n__version__ = ''\n__license__ = '$license'\n__author__ = '$user'\n__email__ = '$email'\n__url__ = ''\n__date__ = '$date'",
+    "main": "if __name__ == '__main__':\n    print(__doc__)\n    %cursor%",
+    "class": "class %cursor%(object):\n    '''class doc\n\n    '''\n    \n    def __init__(self):\n        '''init doc\n\n        '''\n        pass",
+    "block": "$cm ==============================================================================\n$cm %cursor%\n$cm =============================================================================="
+  },
+  "lol": {},
+  "json": {},
+  "html": {},
+  "php4": {},
+  "php5": {},
+  "po": {},
+  "css": {},
+  "pyx": {},
+  "asp": {},
+  "pyw": {
+    "head": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n%cursor%",
+    "doc": "'''%cursor%\n\n'''",
+    "meta": "__prj__ = '$project'\n__version__ = ''\n__license__ = '$license'\n__author__ = '$user'\n__email__ = '$email'\n__url__ = \n__date__ = '$date'",
+    "main": "if __name__ == '__main__':\n    print(__doc__)\n    %cursor%",
+    "class": "class %cursor%(object):\n    '''class doc\n\n    '''\n    \n    def __init__(self):\n        '''init doc\n\n        '''\n        pass",
+    "block": "$cm ==============================================================================\n$cm %cursor%\n$cm =============================================================================="
+  },
+  "php": {},
+  "asm": {},
+  "c": {},
+  "mo": {},
+  "list": {},
+  "cpp": {}
+}
+""".strip()
+
+import json
+import ConfigParser
+
+
+data = json.loads(a)
+
+parser = ConfigParser.ConfigParser()
+
+parser.add_section("USER_VARIABLES")
+for n, v in data["VARS"].items():
+    parser.set("USER_VARIABLES", n, v)
+
+parser.add_section("GENERAL")
+for n, v in data["*GENERAL*"].items():
+    parser.set("GENERAL", n, v)
+
+for lang, snippets in data.items():
+    if lang in ("vars", "*GENERAL*"):
+        continue
+    parser.add_section(lang)
+    for n, v in snippets.items():
+        parser.set(lang, n, v)
+    
+
+with open("/home/juan/proyectos/ninja-ide_plugins_hg/snippets_plugin/snippets/res/template.cfg", "w") as fp:
+    parser.write(fp)

snippets_plugin/snippets/res/SnippetConfigurationFrame.ui

   <property name="frameShadow">
    <enum>QFrame::Raised</enum>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_2">
-     <item>
-      <layout class="QVBoxLayout" name="verticalLayout_5">
-       <item>
-        <widget class="QLabel" name="label_2">
-         <property name="text">
-          <string>Languages File Extension</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignCenter</set>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QListWidget" name="languagesList">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="addLanguageButton">
-         <property name="text">
-          <string>Add &amp;Language File Extension</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="removeLanguageButton">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
-         <property name="text">
-          <string>&amp;Remove File Extension</string>
-         </property>
-        </widget>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <layout class="QVBoxLayout" name="verticalLayout_3">
-       <item>
-        <widget class="QLabel" name="label">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="text">
-          <string>Snippets</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignCenter</set>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QListWidget" name="snippetList">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="newSnippetButton">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
-         <property name="text">
-          <string>New &amp;Snippet</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="removeSnippetButton">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
-         <property name="text">
-          <string>R&amp;emove Snippet</string>
-         </property>
-        </widget>
-       </item>
-      </layout>
-     </item>
-    </layout>
-   </item>
+  <layout class="QVBoxLayout" name="verticalLayout">
    <item>
     <layout class="QVBoxLayout" name="editorLayout">
      <item>
       </spacer>
      </item>
      <item>
-      <widget class="QPushButton" name="varsButton">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text">
-        <string>&amp;Variables</string>
-       </property>
-      </widget>
-     </item>
-     <item>
       <widget class="QPushButton" name="importButton">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">

snippets_plugin/snippets/res/VarsEditDialog.ui

-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Variables</class>
- <widget class="QDialog" name="Variables">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>376</width>
-    <height>300</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Variables</string>
-  </property>
-  <property name="modal">
-   <bool>true</bool>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
-    <widget class="QFrame" name="frame">
-     <property name="frameShape">
-      <enum>QFrame::NoFrame</enum>
-     </property>
-     <property name="frameShadow">
-      <enum>QFrame::Raised</enum>
-     </property>
-     <layout class="QHBoxLayout" name="horizontalLayout">
-      <item>
-       <widget class="QTableWidget" name="varsTableWidget">
-        <attribute name="horizontalHeaderVisible">
-         <bool>true</bool>
-        </attribute>
-        <attribute name="verticalHeaderVisible">
-         <bool>true</bool>
-        </attribute>
-        <attribute name="verticalHeaderShowSortIndicator" stdset="0">
-         <bool>false</bool>
-        </attribute>
-        <attribute name="verticalHeaderStretchLastSection">
-         <bool>false</bool>
-        </attribute>
-        <column>
-         <property name="text">
-          <string>Value</string>
-         </property>
-        </column>
-       </widget>
-      </item>
-      <item>
-       <widget class="QFrame" name="frame_2">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="frameShape">
-         <enum>QFrame::NoFrame</enum>
-        </property>
-        <property name="frameShadow">
-         <enum>QFrame::Raised</enum>
-        </property>
-        <layout class="QVBoxLayout" name="verticalLayout_2">
-         <item>
-          <widget class="QPushButton" name="newVarButton">
-           <property name="sizePolicy">
-            <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
-             <horstretch>0</horstretch>
-             <verstretch>0</verstretch>
-            </sizepolicy>
-           </property>
-           <property name="text">
-            <string>&amp;New</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QPushButton" name="removeVarButton">
-           <property name="enabled">
-            <bool>false</bool>
-           </property>
-           <property name="sizePolicy">
-            <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
-             <horstretch>0</horstretch>
-             <verstretch>0</verstretch>
-            </sizepolicy>
-           </property>
-           <property name="text">
-            <string>&amp;Remove</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <spacer name="verticalSpacer">
-           <property name="orientation">
-            <enum>Qt::Vertical</enum>
-           </property>
-           <property name="sizeHint" stdset="0">
-            <size>
-             <width>20</width>
-             <height>40</height>
-            </size>
-           </property>
-          </spacer>
-         </item>
-        </layout>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-     </property>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>accepted()</signal>
-   <receiver>Variables</receiver>
-   <slot>accept()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>248</x>
-     <y>254</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>157</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>rejected()</signal>
-   <receiver>Variables</receiver>
-   <slot>reject()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>316</x>
-     <y>260</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>286</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
-</ui>

snippets_plugin/snippets/res/template.cfg

+[USER_VARIABLES]
+
+[GENERAL]
+$co = $co
+$project = $project
+$hostname = $hostname
+$time = $time
+$cc = $cc
+$user = $user
+$cm = $cm
+apl = $co
+	APACHE LICENSE
+	--------------
+	
+	Copyright $year $user
+	
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	   http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+	$cc
+agpl = $co
+	AGPL LICENSE
+	------------
+	
+	Copyright $year $user <$email>
+	
+	This program is free software: you can redistribute it and/or modify
+	it under the terms of the GNU Affero General Public License as
+	published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
+	
+	You should have received a copy of the GNU Affero General Public License
+	along with this program.  If not, see <http://www.gnu.org/licenses/>.
+	$cc
+gpl3 = $co
+	GPL LICENSE
+	-----------
+	
+	Copyright $year $user <$email>
+	
+	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 3 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., 51 Franklin Street, Fifth Floor, Boston,
+	MA 02110-1301, USA.
+	$cc
+lgpl = $co
+	LGPL LICENSE
+	------------
+	
+	Copyright $year $user <$email>
+	
+	This program is free software: you can redistribute it and/or modify
+	it under the terms of the GNU Lesser General Public License as
+	published by the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
+	
+	You should have received a copy of the GNU Lesser General Public License
+	along with this program.  If not, see <http://www.gnu.org/licenses/>.
+	$cc
+$license = $license
+bsdl = $co
+	BSD LICENSE
+	-----------
+	
+	Copyright (c) $year, $user
+	All rights reserved.
+	
+	Redistribution and use in source and binary forms, with or without modification,
+	are permitted provided that the following conditions are met:
+	
+	Redistributions of source code must retain the above copyright notice, this list
+	of conditions and the following disclaimer.
+	
+	Redistributions in binary form must reproduce the above copyright notice, this
+	list of conditions and the following disclaimer in the documentation and/or
+	other materials provided with the distribution.
+	
+	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+	ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+	WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+	DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+	ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+	(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+	ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+	$cc
+$year = $year
+$date = $date
+$email = $email
+beerl = $co
+	THE BEER-WARE LICENSE
+	---------------------
+	
+	"THE BEER-WARE LICENSE" (Revision 42):
+	<$email> wrote this file. As long as you retain this notice you
+	can do whatever you want with this stuff. If we meet some day, and you think
+	this stuff is worth it, you can buy me a beer in return $user
+	$cc
+mitl = $co
+	MIT LICENSE
+	-----------
+	
+	Copyright (c) $year, $user
+	
+	Permission is hereby granted, free of charge, to any person obtaining a copy of
+	this software and associated documentation files (the "Software"), to deal in
+	the Software without restriction, including without limitation the rights to
+	use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+	of the Software, and to permit persons to whom the Software is furnished to do
+	so, subject to the following conditions:
+	
+	The above copyright notice and this permission notice shall be included in all
+	copies or substantial portions of the Software.
+	
+	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+	FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+	COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+	IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+	CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+	$cc
+$absfile = $absfile
+wiskeyl = $co
+	THE WISKEY-WARE LICENSE
+	-----------------------
+	
+	"THE WISKEY-WARE LICENSE":
+	<$email> wrote this file. As long as you retain this notice you
+	can do whatever you want with this stuff. If we meet some day, and you think
+	this stuff is worth it, you can buy me a wiskey in return $user
+	$cc
+$file = $file
+block = $co 
+	==============================================================================
+	 %cursor%
+	==============================================================================
+	$cc
+
+[VARS]
+
+[pot]
+
+[tex]
+
+[go]
+
+[pxi]
+
+[conf]
+
+[cs]
+
+[php]
+
+[pxd]
+
+[pas]
+
+[java]
+pr = private
+try = try{
+	
+	} catch(%cursor% ex){
+	
+	} finally{
+	
+	}
+elif = if(%cursor%){
+	
+	} else if(){
+	
+	} else{
+	
+	}
+ab = abstract
+class = public class %cursor%{
+	
+	}
+sy = synchronized
+st = static
+pb = public
+switch = switch(%cursor%){
+	    case :
+	        break;
+	    default:
+	        break;
+	}
+sout = System.out.println(%cursor%);
+main = public static void main(String[] args){
+	    %cursor%
+	}
+po = protected
+if = if(%cursor%){
+	
+	} else {
+	
+	}
+
+[py]
+head = #!/usr/bin/env python
+	# -*- coding: utf-8 -*-
+	%cursor%
+doc = '''%cursor%
+	
+	'''
+meta = __prj__ = '$project'
+	__version__ = ''
+	__license__ = '$license'
+	__author__ = '$user'
+	__email__ = '$email'
+	__url__ = ''
+	__date__ = '$date'
+main = if __name__ == '__main__':
+	    print(__doc__)
+	    %cursor%
+class = class %cursor%(object):
+	    '''class doc
+	
+	    '''
+	    
+	    def __init__(self):
+	        '''init doc
+	
+	        '''
+	        pass
+block = $cm ==============================================================================
+	$cm %cursor%
+	$cm ==============================================================================
+
+[lol]
+
+[json]
+
+[html]
+
+[php4]
+
+[php5]
+
+[po]
+
+[css]
+
+[pyx]
+
+[asp]
+
+[js]
+
+[pyw]
+head = #!/usr/bin/env python
+	# -*- coding: utf-8 -*-
+	%cursor%
+doc = '''%cursor%
+	
+	'''
+meta = __prj__ = '$project'
+	__version__ = ''
+	__license__ = '$license'
+	__author__ = '$user'
+	__email__ = '$email'
+	__url__ = 
+	__date__ = '$date'
+main = if __name__ == '__main__':
+	    print(__doc__)
+	    %cursor%
+class = class %cursor%(object):
+	    '''class doc
+	
+	    '''
+	    
+	    def __init__(self):
+	        '''init doc
+	
+	        '''
+	        pass
+block = $cm ==============================================================================
+	$cm %cursor%
+	$cm ==============================================================================
+
+[asm]
+
+[c]
+
+[mo]
+
+[list]
+
+[cpp]
+

snippets_plugin/snippets/res/template.json

-{
-  "_*VARS*_": {},
-  "pot": {},
-  "tex": {},
-  "go": {},
-  "pxi": {},
-  "conf": {},
-  "cs": {},
-  "js": {},
-  "pxd": {},
-  "pas": {},
-  "java": {
-    "pr": "private",
-    "pb": "public",
-    "elif": "if(%cursor%){\n\n} else if(){\n\n} else{\n\n}",
-    "ab": "abstract",
-    "po": "protected",
-    "sy": "synchronized",
-    "st": "static",
-    "try": "try{\n\n} catch(%cursor% ex){\n\n} finally{\n\n}",
-    "switch": "switch(%cursor%){\n    case :\n        break;\n    default:\n        break;\n}",
-    "sout": "System.out.println(%cursor%);",
-    "main": "public static void main(String[] args){\n    %cursor%\n}",
-    "class": "public class %cursor%{\n\n}",
-    "if": "if(%cursor%){\n\n} else {\n\n}"
-  },
-  "*GENERAL*": {
-    "$hostname": "$hostname",
-    "$co": "$co",
-    "$email": "$email",
-    "$project": "$project",
-    "$time": "$time",
-    "$cc": "$cc",
-    "$user": "$user",
-    "$cm": "$cm",
-    "apl": "$co\nAPACHE LICENSE\n--------------\n\nCopyright $year $user\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n$cc",
-    "agpl": "$co\nAGPL LICENSE\n------------\n\nCopyright $year $user <$email>\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as\npublished by the Free Software Foundation, either version 3 of the\nLicense, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n$cc",
-    "gpl3": "$co\nGPL LICENSE\n-----------\n\nCopyright $year $user <$email>\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\nMA 02110-1301, USA.\n$cc",
-    "lgpl": "$co\nLGPL LICENSE\n------------\n\nCopyright $year $user <$email>\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as\npublished by the Free Software Foundation, either version 3 of the\nLicense, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with this program.  If not, see <http://www.gnu.org/licenses/>.\n$cc",
-    "$license": "$license",
-    "bsdl": "$co\nBSD LICENSE\n-----------\n\nCopyright (c) $year, $user\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this list\nof conditions and the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright notice, this\nlist of conditions and the following disclaimer in the documentation and/or\nother materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n$cc",
-    "$year": "$year",
-    "$date": "$date",
-    "beerl": "$co\nTHE BEER-WARE LICENSE\n---------------------\n\n\"THE BEER-WARE LICENSE\" (Revision 42):\n<$email> wrote this file. As long as you retain this notice you\ncan do whatever you want with this stuff. If we meet some day, and you think\nthis stuff is worth it, you can buy me a beer in return $user\n$cc",
-    "mitl": "$co\nMIT LICENSE\n-----------\n\nCopyright (c) $year, $user\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n$cc",
-    "$absfile": "$absfile",
-    "wiskeyl": "$co\nTHE WISKEY-WARE LICENSE\n-----------------------\n\n\"THE WISKEY-WARE LICENSE\":\n<$email> wrote this file. As long as you retain this notice you\ncan do whatever you want with this stuff. If we meet some day, and you think\nthis stuff is worth it, you can buy me a wiskey in return $user\n$cc",
-    "$file": "$file",
-    "block": "$co \n==============================================================================\n %cursor%\n==============================================================================\n$cc"
-  },
-  "py": {
-    "head": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n%cursor%",
-    "doc": "'''%cursor%\n\n'''",
-    "meta": "__prj__ = '$project'\n__version__ = ''\n__license__ = '$license'\n__author__ = '$user'\n__email__ = '$email'\n__url__ = ''\n__date__ = '$date'",
-    "main": "if __name__ == '__main__':\n    print(__doc__)\n    %cursor%",
-    "class": "class %cursor%(object):\n    '''class doc\n\n    '''\n    \n    def __init__(self):\n        '''init doc\n\n        '''\n        pass",
-    "block": "$cm ==============================================================================\n$cm %cursor%\n$cm =============================================================================="
-  },
-  "lol": {},
-  "json": {},
-  "html": {},
-  "php4": {},
-  "php5": {},
-  "po": {},
-  "css": {},
-  "pyx": {},
-  "asp": {},
-  "pyw": {
-    "head": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n%cursor%",
-    "doc": "'''%cursor%\n\n'''",
-    "meta": "__prj__ = '$project'\n__version__ = ''\n__license__ = '$license'\n__author__ = '$user'\n__email__ = '$email'\n__url__ = \n__date__ = '$date'",
-    "main": "if __name__ == '__main__':\n    print(__doc__)\n    %cursor%",
-    "class": "class %cursor%(object):\n    '''class doc\n\n    '''\n    \n    def __init__(self):\n        '''init doc\n\n        '''\n        pass",
-    "block": "$cm ==============================================================================\n$cm %cursor%\n$cm =============================================================================="
-  },
-  "php": {},
-  "asm": {},
-  "c": {},
-  "mo": {},
-  "list": {},
-  "cpp": {}
-}

snippets_plugin/snippets/snippets.py

 
 
 #===============================================================================
-# VARIABLE EDITION DIALOG
-#===============================================================================
-
-class VarsEditDialog(constants.UI("VarsEditDialog.ui")):
-    """This dialog is used for edit the user variables
-    
-    """
-    
-    def __init__(self, variables, *args):
-        super(self.__class__, self).__init__(*args)
-        self.v_names = variables.keys()
-        self.varsTableWidget.setRowCount(len(variables))
-        for idx, data in enumerate(variables.items()):
-            var_name, var_value = data
-            var_name_item = QTableWidgetItem(var_name)
-            var_value_item = QTableWidgetItem(var_value)
-            self.varsTableWidget.setVerticalHeaderItem(idx, var_name_item)
-            self.varsTableWidget.setItem(idx, 0, var_value_item)
-        self.varsTableWidget.resizeColumnsToContents()
-        
-    def on_newVarButton_pressed(self, *args):
-        """Create a new variable using a pop up for prevet duplicated names
-        
-        """
-        title = self.tr("New Variable")
-        msg = self.tr("Variable Name")
-        vname, ok = QInputDialog.getText(self, title, msg)
-        if ok:
-            if str(vname) in self.v_names:
-                title = self.tr("Variable Name Exists")
-                msg = self.tr("Variable name '%1' already exists")
-                QMessageBox.information(self, title, msg.arg(vname))
-            else:
-                idx = self.varsTableWidget.rowCount()
-                var_name_item = QTableWidgetItem(vname)
-                var_value_item = QTableWidgetItem(self.tr("<new value>"))
-                self.varsTableWidget.setRowCount(idx + 1)
-                self.varsTableWidget.setVerticalHeaderItem(idx, var_name_item)
-                self.varsTableWidget.setItem(idx, 0, var_value_item)
-                self.varsTableWidget.setCurrentItem(var_value_item)
-                self.varsTableWidget.editItem(var_value_item)
-                self.removeVarButton.setEnabled(True)
-                self.v_names.append(vname)
-        
-    def on_removeVarButton_pressed(self, *args):
-        """Remove a variable
-        
-        """
-        ridx = self.varsTableWidget.currentRow()
-        vname = str(self.varsTableWidget.verticalHeaderItem(ridx).text())
-        self.v_names.remove(vname)
-        self.varsTableWidget.removeRow(ridx)
-        self.removeVarButton.setEnabled(False)
-        
-    def on_varsTableWidget_currentCellChanged (self, *args):
-        """Activate de remove var Button
-        
-        """
-        self.removeVarButton.setEnabled(True)
-        
-    @property
-    def variables(self):
-        """Recolect all variables from table and return it as dict}
-        
-        """
-        vs = {}
-        for ridx in range(self.varsTableWidget.rowCount()):
-            vname = str(self.varsTableWidget.verticalHeaderItem(ridx).text())
-            vvalue = str(self.varsTableWidget.item(ridx, 0).text())
-            vs[vname] = vvalue
-        return vs
-
-
-#===============================================================================
 # FRAME FOR CONFIGURE YOUR SNIPPET
 #===============================================================================
 
         self.snippets = snippets
         self.reset()
 
-    def on_languagesList_currentItemChanged(self, enter_item, exit_item):
-        """This slot is call when an item changes on languagesList. Creates
-        the new snippetList based ons snippets dictionary.
 
-        """
-        if enter_item:
-            self.removeLanguageButton.setEnabled(True)
-            self.newSnippetButton.setEnabled(True)
-            self.snippetList.clear()
-            lang_snippets = self.snippets[str(enter_item.text())]
-            for snippet_name in sorted(lang_snippets.keys()):
-                sitem = QListWidgetItem()
-                sitem.setData(Qt.AccessibleDescriptionRole, enter_item.text())
-                sitem.setText(snippet_name)
-                self.snippetList.addItem(sitem)
-
-    def on_snippetList_currentItemChanged(self, enter_item, exit_item):
-        """This slot is called when anithing changes in snippetsList
-        (on_languagesList_currentItemChanged call this function autmagically)
-
-        1. Store the snippet open.
-        2. Set up the editor based on new item
-
-        """
-        if exit_item:
-            lang = str(exit_item.data(Qt.AccessibleDescriptionRole).toString())
-            sname = str(exit_item.text())
-            svalue = str(self.editor.get_text())
-            if lang in self.snippets and sname in self.snippets[lang]:
-                self.snippets[lang][sname] = svalue
-        lang = str(enter_item.data(Qt.AccessibleDescriptionRole).toString()) \
-               if enter_item else ""
-        sname = str(enter_item.text()) if enter_item else ""
-        svalue = self.snippets[lang][sname] if enter_item else ""
-        read_only = False if enter_item else True
-
-        self.snippetPathLabel.setText("{0} - {1}".format(lang, sname))
-        self.editor.setPlainText(svalue)
-        self.editor.setReadOnly(read_only)
-        self.removeSnippetButton.setEnabled(enter_item != None)
-
-    def on_addLanguageButton_pressed(self, *args):
-        """This slot is called when a  addLanguageButton is pressed
-
-        1 - Retrieve the new language name with a poup.
-        2 - Verify if the name is not exists.
-        3 - Create a new language.
-        4 - Change the current item to the new language.
-
-
-        """
-        title = self.tr("New Language")
-        msg = self.tr("File Extension")
-        lang, ok = QInputDialog.getText(self, title, msg)
-        if ok:
-            lang = str(lang).lower()
-            if lang in self.snippets:
-                title = self.tr("Language Extension Exists")
-                msg = self.tr("Language extension '%1' already exists")
-                QMessageBox.information(self, title, msg.arg(lang))
-            else:
-                lang_item = QListWidgetItem()
-                lang_item.setText(lang)
-                self.snippets[lang] = {}
-                self.languagesList.addItem(lang_item)
-                self.languagesList.setCurrentItem(lang_item)
-
-    def on_newSnippetButton_pressed(self, *args):
-        """This slot is called when a  newLanguageButton is pressed
-
-        1 - Retrieve the new snippet name with a poup.
-        2 - Verify if the name is not exists.
-        3 - Create a new snippet on selected language.
-        4 - Change the current snippet to the new snippet.
-
-
-        """
-        title = self.tr("New Snippet")
-        msg = self.tr("Snippet Name")
-        sname, ok = QInputDialog.getText(self, title, msg)
-        if ok:
-            lang_item = self.languagesList.currentItem()
-            lang = lang_item.text()
-            if str(sname) in self.snippets[str(lang)]:
-                title = self.tr("Snippet Exists")
-                msg = self.tr("Snippet name '%1' already exists in '%2'")
-                QMessageBox.information(self, title, msg.arg(sname, lang))
-            else:
-                snippet_item = QListWidgetItem()
-                snippet_item.setText(sname)
-                snippet_item.setData(Qt.AccessibleDescriptionRole, lang)
-                self.snippets[str(lang)][str(sname)] = ""
-                self.snippetList.addItem(snippet_item)
-                self.snippetList.setCurrentItem(snippet_item)
-
-    def on_removeLanguageButton_pressed(self, *args):
-        """This slot is called when a  removeLanguageButton is pressed
-
-        1 - Retrieve the selected language snippet.
-        2 - Ask with a popup if the user really want to delete the language.
-        3 - Removes the language.
-        4 - If not exists more languages in languagesLists, reset the editor
-            and deactivate remove button.
-
-
-        """
-        lang_item = self.languagesList.currentItem()
-        lang = str(lang_item.text())
-
-        title = self.tr("Remove Language File Extension")
-        msg = self.tr("Remove language file extension '%1'?")
-        status = QMessageBox.question(self, title, msg.arg(lang),
-                                      QMessageBox.Ok, QMessageBox.Cancel)
-
-        if status == QMessageBox.Ok:
-            row = self.languagesList.row(lang_item)
-            self.snippets.pop(lang)
-            self.languagesList.takeItem(row)
-            if not self.languagesList.count():
-                self.removeLanguageButton.setEnabled(False)
-                self.newSnippetButton.setEnabled(False)
-                self.removeSnippetButton.setEnabled(False)
-
-    def on_removeSnippetButton_pressed(self, *args):
-        """This slot is called when a  removeSnippetButton is pressed
-
-        1 - Retrieve the new language selected.
-        2 - Ask with a popup if the user really want to delete the snippet.
-        3 - Removes the snippet.
-        4 - If not exists more snippets in snippestLists Reset the editor and
-            deactivate remove button.
-
-
-        """
-        snippet_item = self.snippetList.currentItem()
-        sname = str(snippet_item.text())
-        lang = str(snippet_item.data(Qt.AccessibleDescriptionRole).toString())
-
-        title = self.tr("Remove Snippet")
-        msg = self.tr("Remove snippet '%1'?")
-        status = QMessageBox.question(self, title, msg.arg(sname),
-                                      QMessageBox.Ok, QMessageBox.Cancel)
-        if status == QMessageBox.Ok:
-            row = self.snippetList.row(snippet_item)
-            self.snippets[lang].pop(sname)
-            self.snippetList.takeItem(row)
-            if not self.snippetList.count():
-                self.removeSnippetButton.setEnabled(False)
-
-    def on_varsButton_pressed(self, *args):
-        """Open dialog for edit the user variables
-        
-        """
-        dialog = VarsEditDialog(self.vars)
-        dialog.exec_()
-        if dialog.result():
-            self.vars = dialog.variables
-        
+    
     def on_importButton_pressed(self, *args):
         """Open a file dialog for merge the snippets with json file
 
         return render
 
     def _resolve_cursor(self, render_tabed, from_pos):
-        """Betermine the cursor final position based on "%cursor%" word
+        """Determine the cursor final position based on "%cursor%" word
         and relative position of the render_tabed.
 
         """