diff --git a/ox/__init__.py b/ox/__init__.py index 7c1f959..ace9928 100644 --- a/ox/__init__.py +++ b/ox/__init__.py @@ -4,6 +4,8 @@ __version__ = '2.0.1' import cache +import js +import jsonc import net from file import * @@ -11,7 +13,6 @@ from form import * from format import * from html import * from image import * -from js import * from location import * from normalize import * from text import * diff --git a/ox/js.py b/ox/js.py index eac2d0f..88ec033 100644 --- a/ox/js.py +++ b/ox/js.py @@ -2,6 +2,8 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 +from ox.utils import json + def minify(source, comment=''): # see https://github.com/douglascrockford/JSMin/blob/master/README def get_next_non_whitespace_token(): @@ -41,6 +43,9 @@ def minify(source, comment=''): minified += token['value'] return minified +def parse_JSONC(source): + return json.loads(minify(source)) + def tokenize(source): # see https://github.com/mozilla/narcissus/blob/master/lib/jslex.js IDENTIFIER = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_' diff --git a/ox/jsonc.py b/ox/jsonc.py new file mode 100644 index 0000000..1b94eae --- /dev/null +++ b/ox/jsonc.py @@ -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)) + diff --git a/ox/text.py b/ox/text.py index 12e076b..cf4efc3 100644 --- a/ox/text.py +++ b/ox/text.py @@ -32,7 +32,7 @@ ASIAN_NAMES = [ 'yang', 'yeong', 'yeung' ] 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' ] MIDFIXES = ['und']