示例#1
0
文件: cli.py 项目: pombredanne/kvlite
 def do_scheme(self, line):
     '''   scheme\t\tshow structure of collection'''
     if not self.__current_coll_name in self.__kvlite_colls:
         print 'Error! Unknown collection: %s' % self.__current_coll_name
         return
     print 'Building ...'
     doc_struct = kvlite.docs_struct(self.__current_coll.get())
     if doc_struct:
         pprint.pprint(doc_struct)
     print 'Done'
示例#2
0
文件: cli.py 项目: ownport/kvlite
 def do_scheme(self, line):
     """   scheme\t\tshow structure of collection"""
     if not self.__current_coll_name in self.__kvlite_colls:
         print "Error! Unknown collection: %s" % self.__current_coll_name
         return
     print "Building ..."
     doc_struct = kvlite.docs_struct(self.__current_coll.get())
     if doc_struct:
         pprint.pprint(doc_struct)
     print "Done"
示例#3
0
文件: cli.py 项目: pombredanne/kvlite
 def do_scheme(self, line):
     '''   scheme\t\tshow structure of collection'''
     if not self.__current_coll_name in self.__kvlite_colls:
         print 'Error! Unknown collection: %s' % self.__current_coll_name
         return
     print 'Building ...'
     doc_struct = kvlite.docs_struct(self.__current_coll.get())
     if doc_struct:
         pprint.pprint(doc_struct)
     print 'Done'
示例#4
0
 def test_docs_struct(self):
     
     import json
     documents = [
         ('id1', {
             'title': 'title1', 'pages': 1, 'description': u'Description1',
             'keywords': ['a1', 'b1', 'c1', u'd1', 1] 
         }),
         ('id2', {
             'title': 'title2', 'pages': 2, 'description': u'Description2',
             'keywords': ['a2', 'b2', 'c2', u'd2', 2 ] 
         }),
         ('id3', {
             'title': 'title1', 'pages': 3, 'description': u'Description3',
             'keywords': ['a3', 'b3', 3] 
         }),            
         ('id4', {
             'title': u'title4', 'pages': '4', 'description': u'Description4',
             'keywords': ['a4', 'b4', 'c4',  u'd4'] 
         }),            
     ] 
     result = [
         {
             'name': 'keywords',
             'types': {'list_type': { 'string_type': 11, 'unicode_type': 3, 'integer_type':3 }}
         },
         {
             'name': 'title', 
             'types': { 'string_type': 3, 'unicode_type': 1},
         },
         {
             'name': 'description',
             'types': { 'unicode_type': 4},
         },
         { 
             'name': 'pages',
             'types': { 'integer_type': 3, 'string_type': 1},
         },
     ]
     
     for s in kvlite.docs_struct(documents)['structure']:
         if json.dumps(s) not in [json.dumps(r) for r in result]:
             raise RuntimeError('Incorrect document structure')
示例#5
0
    def test_docs_struct(self):

        import json
        documents = [
            ('id1', {
                'title': 'title1',
                'pages': 1,
                'description': u'Description1',
                'keywords': ['a1', 'b1', 'c1', u'd1', 1]
            }),
            ('id2', {
                'title': 'title2',
                'pages': 2,
                'description': u'Description2',
                'keywords': ['a2', 'b2', 'c2', u'd2', 2]
            }),
            ('id3', {
                'title': 'title1',
                'pages': 3,
                'description': u'Description3',
                'keywords': ['a3', 'b3', 3]
            }),
            ('id4', {
                'title': u'title4',
                'pages': '4',
                'description': u'Description4',
                'keywords': ['a4', 'b4', 'c4', u'd4']
            }),
        ]
        result = [
            {
                'name': 'keywords',
                'types': {
                    'list_type': {
                        'string_type': 11,
                        'unicode_type': 3,
                        'integer_type': 3
                    }
                }
            },
            {
                'name': 'title',
                'types': {
                    'string_type': 3,
                    'unicode_type': 1
                },
            },
            {
                'name': 'description',
                'types': {
                    'unicode_type': 4
                },
            },
            {
                'name': 'pages',
                'types': {
                    'integer_type': 3,
                    'string_type': 1
                },
            },
        ]

        for s in kvlite.docs_struct(documents)['structure']:
            if json.dumps(s) not in [json.dumps(r) for r in result]:
                raise RuntimeError('Incorrect document structure')