add JSONC module
This commit is contained in:
parent
d8c371e7fb
commit
525d71bf89
4 changed files with 25 additions and 2 deletions
|
@ -4,6 +4,8 @@
|
||||||
__version__ = '2.0.1'
|
__version__ = '2.0.1'
|
||||||
|
|
||||||
import cache
|
import cache
|
||||||
|
import js
|
||||||
|
import jsonc
|
||||||
import net
|
import net
|
||||||
|
|
||||||
from file import *
|
from file import *
|
||||||
|
@ -11,7 +13,6 @@ from form import *
|
||||||
from format import *
|
from format import *
|
||||||
from html import *
|
from html import *
|
||||||
from image import *
|
from image import *
|
||||||
from js import *
|
|
||||||
from location import *
|
from location import *
|
||||||
from normalize import *
|
from normalize import *
|
||||||
from text import *
|
from text import *
|
||||||
|
|
5
ox/js.py
5
ox/js.py
|
@ -2,6 +2,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
|
|
||||||
|
from ox.utils import json
|
||||||
|
|
||||||
def minify(source, comment=''):
|
def minify(source, comment=''):
|
||||||
# see https://github.com/douglascrockford/JSMin/blob/master/README
|
# see https://github.com/douglascrockford/JSMin/blob/master/README
|
||||||
def get_next_non_whitespace_token():
|
def get_next_non_whitespace_token():
|
||||||
|
@ -41,6 +43,9 @@ def minify(source, comment=''):
|
||||||
minified += token['value']
|
minified += token['value']
|
||||||
return minified
|
return minified
|
||||||
|
|
||||||
|
def parse_JSONC(source):
|
||||||
|
return json.loads(minify(source))
|
||||||
|
|
||||||
def tokenize(source):
|
def tokenize(source):
|
||||||
# see https://github.com/mozilla/narcissus/blob/master/lib/jslex.js
|
# see https://github.com/mozilla/narcissus/blob/master/lib/jslex.js
|
||||||
IDENTIFIER = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
|
IDENTIFIER = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
|
||||||
|
|
17
ox/jsonc.py
Normal file
17
ox/jsonc.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
|
from __future__ import with_statement
|
||||||
|
|
||||||
|
from js import minify
|
||||||
|
from utils import json
|
||||||
|
|
||||||
|
|
||||||
|
def load(filename):
|
||||||
|
with open(filename) as f:
|
||||||
|
data = loads(f.read())
|
||||||
|
return data
|
||||||
|
|
||||||
|
def loads(source):
|
||||||
|
return json.loads(minify(source))
|
||||||
|
|
|
@ -32,7 +32,7 @@ ASIAN_NAMES = [
|
||||||
'yang', 'yeong', 'yeung'
|
'yang', 'yeong', 'yeung'
|
||||||
]
|
]
|
||||||
PREFIXES = [
|
PREFIXES = [
|
||||||
'al', 'da', 'de', 'del', 'dem', 'den', 'der', 'di', 'dos', 'du',
|
'al', 'bin', 'da', 'de', 'del', 'dem', 'den', 'der', 'di', 'dos', 'du',
|
||||||
'e', 'el', 'la', 'san', 'the', 'van', 'vom', 'von', 'y', 'zu'
|
'e', 'el', 'la', 'san', 'the', 'van', 'vom', 'von', 'y', 'zu'
|
||||||
]
|
]
|
||||||
MIDFIXES = ['und']
|
MIDFIXES = ['und']
|
||||||
|
|
Loading…
Reference in a new issue