labpack/storage/dropbox.py
def list(self, prefix='', delimiter='', filter_function=None, max_results=1, previous_key=''):
        
        ''' 
            a method to list keys in the dropbox collection

        :param prefix: string with prefix value to filter results
        :param delimiter: string with value which results must not contain (after prefix)
        :param filter_function: (positional arguments) function used to filter results
        :param max_results: integer with maximum number of results to return
        :param previous_key: string with key in collection to begin search after
        :return: list of key strings

            NOTE:   each key string can be divided into one or more segments
                    based upon the / characters which occur in the key string as
                    well as its file extension type. if the key string represents
                    a file path, then each directory in the path, the file name
                    and the file extension are all separate indexed values.

                    eg. lab/unittests/1473719695.2165067.json is indexed:
                    [ 'lab', 'unittests', '1473719695.2165067', '.json' ]

                    it is possible to filter the records in the collection according
                    to one or more of these path segments using a filter_function.

            NOTE:   the filter_function must be able to accept an array of positional
                    arguments and return a value that can evaluate to true or false.
                    while searching the records, list produces an array of strings
                    which represent the directory structure in relative path of each
                    key string. if a filter_function is provided, this list of strings
                    is fed to the filter function. if the function evaluates this input
                    and returns a true value the file will be included in the list
                    results.
        '''
        
        title = '%s.list' % self.__class__.__name__
        
    # validate input
        input_fields = {
            'prefix': prefix,
            'delimiter': delimiter,
            'max_results': max_results,
            'previous_key': previous_key
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)

    # validate filter function
        if filter_function:
            try:
                path_segments = [ 'lab', 'unittests', '1473719695.2165067', '.json' ]
                filter_function(*path_segments)
            except:
                err_msg = '%s(filter_function=%s)' % (title, filter_function.__class__.__name__)
                raise TypeError('%s must accept positional arguments.' % err_msg)

    # construct empty results list
        results_list = []
        check_key = True
        if previous_key: 
            check_key = False
    
    # determine root path
        root_path = ''
        if prefix:
            from os import path
            root_path, file_name = path.split(prefix)

    # iterate over dropbox files
        for file_path in self._walk(root_path):
            path_segments = file_path.split(os.sep)
            record_key = os.path.join(*path_segments)
            record_key = record_key.replace('\\','/')
            if record_key == previous_key:
                check_key = True
    
    # find starting point
            if not check_key:
                continue
                
    # apply prefix filter
            partial_key = record_key
            if prefix:
                if record_key.find(prefix) == 0:
                    partial_key = record_key[len(prefix):]
                else:
                    continue
    
    # apply delimiter filter
            if delimiter:
                if partial_key.find(delimiter) > -1:
                    continue
    
    # apply filter function
            if filter_function:
                if filter_function(*path_segments):
                    results_list.append(record_key)
            else:
                results_list.append(record_key)

    # return results list
            if len(results_list) == max_results:
                return results_list

        return results_list
 
            a method to list keys in the dropbox collection

        :param prefix: string with prefix value to filter results
        :param delimiter: string with value which results must not contain (after prefix)
        :param filter_function: (positional arguments) function used to filter results
        :param max_results: integer with maximum number of results to return
        :param previous_key: string with key in collection to begin search after
        :return: list of key strings

            NOTE:   each key string can be divided into one or more segments
                    based upon the / characters which occur in the key string as
                    well as its file extension type. if the key string represents
                    a file path, then each directory in the path, the file name
                    and the file extension are all separate indexed values.

                    eg. lab/unittests/1473719695.2165067.json is indexed:
                    [ 'lab', 'unittests', '1473719695.2165067', '.json' ]

                    it is possible to filter the records in the collection according
                    to one or more of these path segments using a filter_function.

            NOTE:   the filter_function must be able to accept an array of positional
                    arguments and return a value that can evaluate to true or false.
                    while searching the records, list produces an array of strings
                    which represent the directory structure in relative path of each
                    key string. if a filter_function is provided, this list of strings
                    is fed to the filter function. if the function evaluates this input
                    and returns a true value the file will be included in the list
                    results.
        
a method to list keys in the dropbox collection
a method to list keys in the dropbox collection
def list(self, prefix='', delimiter='', filter_function=None, max_results=1, previous_key=''):
        title = '%s.list' % self.__class__.__name__
        input_fields = {
            'prefix': prefix,
            'delimiter': delimiter,
            'max_results': max_results,
            'previous_key': previous_key
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)
        if filter_function:
            try:
                path_segments = [ 'lab', 'unittests', '1473719695.2165067', '.json' ]
                filter_function(*path_segments)
            except:
                err_msg = '%s(filter_function=%s)' % (title, filter_function.__class__.__name__)
                raise TypeError('%s must accept positional arguments.' % err_msg)
        results_list = []
        check_key = True
        if previous_key: 
            check_key = False
        root_path = ''
        if prefix:
            from os import path
            root_path, file_name = path.split(prefix)
        for file_path in self._walk(root_path):
            path_segments = file_path.split(os.sep)
            record_key = os.path.join(*path_segments)
            record_key = record_key.replace('\\','/')
            if record_key == previous_key:
                check_key = True
            if not check_key:
                continue
            partial_key = record_key
            if prefix:
                if record_key.find(prefix) == 0:
                    partial_key = record_key[len(prefix):]
                else:
                    continue
            if delimiter:
                if partial_key.find(delimiter) > -1:
                    continue
            if filter_function:
                if filter_function(*path_segments):
                    results_list.append(record_key)
            else:
                results_list.append(record_key)
            if len(results_list) == max_results:
                return results_list
        return results_list
def list ( self , prefix = '' , delimiter = '' , filter_function = None , max_results = 1 , previous_key = '' ) : title = '%s.list' % self . __class__ . __name__ input_fields = { 'prefix' : prefix , 'delimiter' : delimiter , 'max_results' : max_results , 'previous_key' : previous_key } for key , value in input_fields . items ( ) : if value : object_title = '%s(%s=%s)' % ( title , key , str ( value ) ) self . fields . validate ( value , '.%s' % key , object_title ) if filter_function : try : path_segments = [ 'lab' , 'unittests' , '1473719695.2165067' , '.json' ] filter_function ( * path_segments ) except : err_msg = '%s(filter_function=%s)' % ( title , filter_function . __class__ . __name__ ) raise TypeError ( '%s must accept positional arguments.' % err_msg ) results_list = [ ] check_key = True if previous_key : check_key = False root_path = '' if prefix : from os import path root_path , file_name = path . split ( prefix ) for file_path in self . _walk ( root_path ) : path_segments = file_path . split ( os . sep ) record_key = os . path . join ( * path_segments ) record_key = record_key . replace ( '\\' , '/' ) if record_key == previous_key : check_key = True if not check_key : continue partial_key = record_key if prefix : if record_key . find ( prefix ) == 0 : partial_key = record_key [ len ( prefix ) : ] else : continue if delimiter : if partial_key . find ( delimiter ) > - 1 : continue if filter_function : if filter_function ( * path_segments ) : results_list . append ( record_key ) else : results_list . append ( record_key ) if len ( results_list ) == max_results : return results_list return results_list
a method to list keys in the dropbox collection
a method to list keys in the dropbox collection
''' 
            a method to list keys in the dropbox collection

        :param prefix: string with prefix value to filter results
        :param delimiter: string with value which results must not contain (after prefix)
        :param filter_function: (positional arguments) function used to filter results
        :param max_results: integer with maximum number of results to return
        :param previous_key: string with key in collection to begin search after
        :return: list of key strings

            NOTE:   each key string can be divided into one or more segments
                    based upon the / characters which occur in the key string as
                    well as its file extension type. if the key string represents
                    a file path, then each directory in the path, the file name
                    and the file extension are all separate indexed values.

                    eg. lab/unittests/1473719695.2165067.json is indexed:
                    [ 'lab', 'unittests', '1473719695.2165067', '.json' ]

                    it is possible to filter the records in the collection according
                    to one or more of these path segments using a filter_function.

            NOTE:   the filter_function must be able to accept an array of positional
                    arguments and return a value that can evaluate to true or false.
                    while searching the records, list produces an array of strings
                    which represent the directory structure in relative path of each
                    key string. if a filter_function is provided, this list of strings
                    is fed to the filter function. if the function evaluates this input
                    and returns a true value the file will be included in the list
                    results.
        ''' # validate input
 # validate filter function
 # construct empty results list
 # determine root path
 # iterate over dropbox files
 # find starting point
 # apply prefix filter
 # apply delimiter filter
 # apply filter function
 # return results list

list of key strings
NOTE:   each key string can be divided into one or more segments
based upon the / characters which occur in the key string as
well as its file extension type. if the key string represents
a file path, then each directory in the path, the file name
and the file extension are all separate indexed values.

eg.

it is possible to filter the records in the collection according
to one or more of these path segments using a filter_function.

the filter_function must be able to accept an array of positional
arguments and return a value that can evaluate to true or false.
while searching the records, list produces an array of strings
which represent the directory structure in relative path of each
key string. if a filter_function is provided, this list of strings
is fed to the filter function. if the function evaluates this input
and returns a true value the file will be included in the list
results.
list of key strings NOTE : each key string can be divided into one or more segments based upon the / characters which occur in the key string as well as its file extension type . if the key string represents a file path then each directory in the path the file name and the file extension are all separate indexed values . eg . it is possible to filter the records in the collection according to one or more of these path segments using a filter_function . the filter_function must be able to accept an array of positional arguments and return a value that can evaluate to true or false . while searching the records list produces an array of strings which represent the directory structure in relative path of each key string . if a filter_function is provided this list of strings is fed to the filter function . if the function evaluates this input and returns a true value the file will be included in the list results .
self
prefix
string with prefix value to filter results
string with prefix value to filter results
delimiter
string with value which results must not contain (after prefix)
string with value which results must not contain ( after prefix )
filter_function
(positional arguments) function used to filter results
( positional arguments ) function used to filter results
max_results
integer with maximum number of results to return
integer with maximum number of results to return
previous_key
string with key in collection to begin search after
string with key in collection to begin search after