addok/shell.py
def do_GET(self, _id):
        """Get document from index with its id.
        GET 772210180J"""
        doc = doc_by_id(_id)
        if not doc:
            return self.error('id "{}" not found'.format(_id))
        for key, value in doc.items():
            if key == config.HOUSENUMBERS_FIELD:
                continue
            print('{} {}'.format(white(key), magenta(value)))
        if doc.get('housenumbers'):
            def sorter(v):
                try:
                    return int(re.match(r'^\d+', v['raw']).group())
                except AttributeError:
                    return -1
            housenumbers = sorted(doc['housenumbers'].values(), key=sorter)
            print(white('housenumbers'),
                  magenta(', '.join(v['raw'] for v in housenumbers)))
def do_GET(self, _id):
        doc = doc_by_id(_id)
        if not doc:
            return self.error('id "{}" not found'.format(_id))
        for key, value in doc.items():
            if key == config.HOUSENUMBERS_FIELD:
                continue
            print('{} {}'.format(white(key), magenta(value)))
        if doc.get('housenumbers'):
            def sorter(v):
                try:
                    return int(re.match(r'^\d+', v['raw']).group())
                except AttributeError:
                    return -1
            housenumbers = sorted(doc['housenumbers'].values(), key=sorter)
            print(white('housenumbers'),
                  magenta(', '.join(v['raw'] for v in housenumbers)))
def do_GET ( self , _id ) : doc = doc_by_id ( _id ) if not doc : return self . error ( 'id "{}" not found' . format ( _id ) ) for key , value in doc . items ( ) : if key == config . HOUSENUMBERS_FIELD : continue print ( '{} {}' . format ( white ( key ) , magenta ( value ) ) ) if doc . get ( 'housenumbers' ) : def sorter ( v ) : try : return int ( re . match ( r'^\d+' , v [ 'raw' ] ) . group ( ) ) except AttributeError : return - 1 housenumbers = sorted ( doc [ 'housenumbers' ] . values ( ) , key = sorter ) print ( white ( 'housenumbers' ) , magenta ( ', ' . join ( v [ 'raw' ] for v in housenumbers ) ) )
Get document from index with its id.
        GET 772210180J
Get document from index with its id . GET 772210180J