Пример #1
0
def test_jsdump():
    from sphinx.util.jsdump import dumps

    assert dumps({'1a': 1}) == '{"1a":1}'
    assert dumps({'a1': 1}) == '{a1:1}'

    assert dumps({u'a\xe8': 1}) == '{"a\\u00e8":1}'
Пример #2
0
 def context_for_searchtool(self):
     return dict(
         search_language_stemming_code = self.lang.js_stemmer_code,
         search_language_stop_words =
             jsdump.dumps(sorted(self.lang.stopwords)),
         search_scorer_tool = self.js_scorer_code,
     )
Пример #3
0
 def context_for_searchtool(self):
     # type: () -> Dict[unicode, Any]
     return dict(
         search_language_stemming_code = self.lang.js_stemmer_code,
         search_language_stop_words = jsdump.dumps(sorted(self.lang.stopwords)),
         search_scorer_tool = self.js_scorer_code,
         search_word_splitter_code = self.js_splitter_code,
     )
Пример #4
0
 def context_for_searchtool(self):
     # type: () -> Dict[str, Any]
     return {
         'search_language_stemming_code': self.lang.js_stemmer_code,
         'search_language_stop_words': jsdump.dumps(sorted(self.lang.stopwords)),
         'search_scorer_tool': self.js_scorer_code,
         'search_word_splitter_code': self.js_splitter_code,
     }
Пример #5
0
def test_jsdump():
    data = {'1a': 1}
    assert dumps(data) == '{"1a":1}'
    assert data == loads(dumps(data))

    data = {'a1': 1}
    assert dumps(data) == '{a1:1}'
    assert data == loads(dumps(data))

    data = {u'a\xe8': 1}
    assert dumps(data) == '{"a\\u00e8":1}'
    assert data == loads(dumps(data))

    data = {'_foo': 1}
    assert dumps(data) == '{_foo:1}'
    assert data == loads(dumps(data))
Пример #6
0
 def dumps(self, data):
     # type: (Any) -> unicode
     return self.PREFIX + jsdump.dumps(data) + self.SUFFIX
Пример #7
0
 def dumps(self, data):
     return self.PREFIX + jsdump.dumps(data) + self.SUFFIX