1. Juan BC
  2. ninja-ide_plugins

Commits

leliel12  committed 1194ffc

removed unused file

  • Participants
  • Parent commits ab3c3b5
  • Branches default

Comments (0)

Files changed (1)

File snippets_plugin/snippets/jsonparser.py

-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# "THE WISKEY-WARE LICENSE":
-# <jbc.develop@gmail.com> 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 Juan BC
-
-#===============================================================================
-# DOC
-#===============================================================================
-
-"""This is a parser for preserve orders in json
- dumps files of ninja-ide snippets plugin
-
-"""
-
-
-#===============================================================================
-# IMPORT
-#===============================================================================
-
-import json
-import collections
-import StringIO
-
-import constants
-
-
-#===============================================================================
-# ERROR CLASS
-#===============================================================================
-
-class JSONParserError(BaseException):
-    pass
-
-
-#===============================================================================
-# FUNCTIONS
-#===============================================================================
-
-def load(fp, *args, **kwargs):
-    """Load a json stream and fix all types to adjust to snippets"""
-    obj = json.load(fp, *args, **kwargs)
-    fixed = {}
-    if constants.USER_VARS_KEY not in obj:
-        fixed[constants.USER_VARS_KEY] = {}
-    if constants.GENERAL_KEY not in obj:
-        fixed[constants.GENERAL_KEY] = {}
-    for lang, spts in obj.items():
-        fixed[unicode(lang)] = {}
-        for sn, sv in spts.items():
-            fixed[unicode(lang)][unicode(sn)] = unicode(sv)
-    return fixed
-    
-    
-def loads(src, *args, **kwargs):
-    """Load a json string and fix all types to adjust to snippets"""
-    fp = StringIO.StringIO(src)
-    return load(fp, *args, **kwargs)
-    
-    
-def dump(obj, fp, indent=4, *args, **kwargs):
-    """Dump to stream a fixed type and order snippets
-    
-    """
-    fixed = loads(json.dumps(obj))
-    
-    odict = collections.OrderedDict()
-        
-    # dump vars
-    odict[constants.USER_VARS_KEY] = fixed.get(constants.USER_VARS_KEY, {})
-
-    # dump general
-    odict[constants.GENERAL_KEY] = fixed.get(constants.GENERAL_KEY, {})
-        
-    # dump the rest
-    for lang, values in sorted(fixed.items()):
-        if lang not in (constants.GENERAL_KEY, constants.USER_VARS_KEY):
-            odict[lang] = values
-                
-    json.dump(odict, fp, indent=indent, *args, **kwargs)
-
-
-def dumps(obj, indent=4, *args, **kwargs):
-    """Dump to string a fixed type and order snippets
-    
-    """
-    fp = StringIO.StringIO()
-    dump(obj, fp, indent=indent, *args, **kwargs)
-    return fp.getvalue()                 
-    
-
-#===============================================================================
-# MAIN
-#===============================================================================
-
-if __name__ == '__main__':
-    print(__doc__)
-
-