labpack/storage/dropbox.py
def export(self, storage_client, overwrite=True):
        
        '''
            a method to export all the records in collection to another platform
            
        :param storage_client: class object with storage client methods
        :return: string with exit message
        '''
        
        title = '%s.export' % self.__class__.__name__
        
    # validate storage client
        method_list = [ 'save', 'load', 'list', 'export', 'delete', 'remove', '_import', 'collection_name' ]
        for method in method_list:
            if not getattr(storage_client, method, None):
                from labpack.parsing.grammar import join_words
                raise ValueError('%s(storage_client=...) must be a client object with %s methods.' % (title, join_words(method_list)))
            
    # walk collection folder to find files
        import os
        count = 0
        skipped = 0
        for file_path in self._walk():
            path_segments = file_path.split(os.sep)
            record_key = os.path.join(*path_segments)
            record_key = record_key.replace('\\','/')
            file_path = '/%s' % file_path
            
    # retrieve data and metadata
            try:
                metadata, response = self.dropbox.files_download(file_path)
            except:
                raise DropboxConnectionError(title)
            record_data = response.content
            client_modified = metadata.client_modified
            
    # import record into storage client
            last_modified = 0.0
            if client_modified:
                from dateutil.tz import tzutc
                from labpack.records.time import labDT
                last_modified = labDT.fromPython(client_modified.replace(tzinfo=tzutc())).epoch()
            outcome = storage_client._import(record_key, record_data, overwrite=overwrite, last_modified=last_modified)
            if outcome:
                count += 1
            else:
                skipped += 1
            
    # report outcome
        plural = ''
        skip_insert = ''
        new_folder = storage_client.collection_name
        if count != 1:
            plural = 's'
        if skipped > 0:
            skip_plural = ''
            if skipped > 1:
                skip_plural = 's'
            skip_insert = ' %s record%s skipped to avoid overwrite.' % (str(skipped), skip_plural)
        exit_msg = '%s record%s exported to %s.%s' % (str(count), plural, new_folder, skip_insert)
        return exit_msg

            a method to export all the records in collection to another platform
            
        :param storage_client: class object with storage client methods
        :return: string with exit message
        
a method to export all the records in collection to another platform
a method to export all the records in collection to another platform
def export(self, storage_client, overwrite=True):
        title = '%s.export' % self.__class__.__name__
        method_list = [ 'save', 'load', 'list', 'export', 'delete', 'remove', '_import', 'collection_name' ]
        for method in method_list:
            if not getattr(storage_client, method, None):
                from labpack.parsing.grammar import join_words
                raise ValueError('%s(storage_client=...) must be a client object with %s methods.' % (title, join_words(method_list)))
        import os
        count = 0
        skipped = 0
        for file_path in self._walk():
            path_segments = file_path.split(os.sep)
            record_key = os.path.join(*path_segments)
            record_key = record_key.replace('\\','/')
            file_path = '/%s' % file_path
            try:
                metadata, response = self.dropbox.files_download(file_path)
            except:
                raise DropboxConnectionError(title)
            record_data = response.content
            client_modified = metadata.client_modified
            last_modified = 0.0
            if client_modified:
                from dateutil.tz import tzutc
                from labpack.records.time import labDT
                last_modified = labDT.fromPython(client_modified.replace(tzinfo=tzutc())).epoch()
            outcome = storage_client._import(record_key, record_data, overwrite=overwrite, last_modified=last_modified)
            if outcome:
                count += 1
            else:
                skipped += 1
        plural = ''
        skip_insert = ''
        new_folder = storage_client.collection_name
        if count != 1:
            plural = 's'
        if skipped > 0:
            skip_plural = ''
            if skipped > 1:
                skip_plural = 's'
            skip_insert = ' %s record%s skipped to avoid overwrite.' % (str(skipped), skip_plural)
        exit_msg = '%s record%s exported to %s.%s' % (str(count), plural, new_folder, skip_insert)
        return exit_msg
def export ( self , storage_client , overwrite = True ) : title = '%s.export' % self . __class__ . __name__ method_list = [ 'save' , 'load' , 'list' , 'export' , 'delete' , 'remove' , '_import' , 'collection_name' ] for method in method_list : if not getattr ( storage_client , method , None ) : from labpack . parsing . grammar import join_words raise ValueError ( '%s(storage_client=...) must be a client object with %s methods.' % ( title , join_words ( method_list ) ) ) import os count = 0 skipped = 0 for file_path in self . _walk ( ) : path_segments = file_path . split ( os . sep ) record_key = os . path . join ( * path_segments ) record_key = record_key . replace ( '\\' , '/' ) file_path = '/%s' % file_path try : metadata , response = self . dropbox . files_download ( file_path ) except : raise DropboxConnectionError ( title ) record_data = response . content client_modified = metadata . client_modified last_modified = 0.0 if client_modified : from dateutil . tz import tzutc from labpack . records . time import labDT last_modified = labDT . fromPython ( client_modified . replace ( tzinfo = tzutc ( ) ) ) . epoch ( ) outcome = storage_client . _import ( record_key , record_data , overwrite = overwrite , last_modified = last_modified ) if outcome : count += 1 else : skipped += 1 plural = '' skip_insert = '' new_folder = storage_client . collection_name if count != 1 : plural = 's' if skipped > 0 : skip_plural = '' if skipped > 1 : skip_plural = 's' skip_insert = ' %s record%s skipped to avoid overwrite.' % ( str ( skipped ) , skip_plural ) exit_msg = '%s record%s exported to %s.%s' % ( str ( count ) , plural , new_folder , skip_insert ) return exit_msg
a method to export all the records in collection to another platform
a method to export all the records in collection to another platform
'''
            a method to export all the records in collection to another platform
            
        :param storage_client: class object with storage client methods
        :return: string with exit message
        ''' # validate storage client
 # walk collection folder to find files
 # retrieve data and metadata
 # import record into storage client
 # report outcome

string with exit message
string with exit message
self
storage_client
class object with storage client methods
class object with storage client methods
overwrite