labpack/storage/appdata.py
def _import(self, record_key, record_data, overwrite=True, last_modified=0.0, **kwargs):
        
        '''
            a helper method for other storage clients to import into appdata
            
        :param record_key: string with key for record
        :param record_data: byte data for body of record
        :param overwrite: [optional] boolean to overwrite existing records
        :param last_modified: [optional] float to record last modified date
        :param kwargs: [optional] keyword arguments from other import methods 
        :return: boolean indicating whether record was imported
        '''
        
    # construct and validate file path
        file_path = os.path.join(self.collection_folder, record_key)

    # check overwrite exception
        from os import path, makedirs
        if not overwrite:
            if path.exists(file_path):
                return False

    # create directories in path to file
        file_root, file_name = path.split(file_path)
        if file_root:
            if not path.exists(file_root):
                makedirs(file_root)
                
    # save file
        with open(file_path, 'wb') as f:
            f.write(record_data)
            f.close()
    
    # erase file date from drep files
        import re
        if re.search('\\.drep$', file_name):
            from os import utime
            file_time = 1
            utime(file_path, times=(file_time, file_time))
        elif last_modified:
            from os import utime
            utime(file_path, times=(last_modified, last_modified))
        
        return True

            a helper method for other storage clients to import into appdata
            
        :param record_key: string with key for record
        :param record_data: byte data for body of record
        :param overwrite: [optional] boolean to overwrite existing records
        :param last_modified: [optional] float to record last modified date
        :param kwargs: [optional] keyword arguments from other import methods 
        :return: boolean indicating whether record was imported
        
a helper method for other storage clients to import into appdata
a helper method for other storage clients to import into appdata
def _import(self, record_key, record_data, overwrite=True, last_modified=0.0, **kwargs):
        file_path = os.path.join(self.collection_folder, record_key)
        from os import path, makedirs
        if not overwrite:
            if path.exists(file_path):
                return False
        file_root, file_name = path.split(file_path)
        if file_root:
            if not path.exists(file_root):
                makedirs(file_root)
        with open(file_path, 'wb') as f:
            f.write(record_data)
            f.close()
        import re
        if re.search('\\.drep$', file_name):
            from os import utime
            file_time = 1
            utime(file_path, times=(file_time, file_time))
        elif last_modified:
            from os import utime
            utime(file_path, times=(last_modified, last_modified))
        return True
def _import ( self , record_key , record_data , overwrite = True , last_modified = 0.0 , ** kwargs ) : file_path = os . path . join ( self . collection_folder , record_key ) from os import path , makedirs if not overwrite : if path . exists ( file_path ) : return False file_root , file_name = path . split ( file_path ) if file_root : if not path . exists ( file_root ) : makedirs ( file_root ) with open ( file_path , 'wb' ) as f : f . write ( record_data ) f . close ( ) import re if re . search ( '\\.drep$' , file_name ) : from os import utime file_time = 1 utime ( file_path , times = ( file_time , file_time ) ) elif last_modified : from os import utime utime ( file_path , times = ( last_modified , last_modified ) ) return True
a helper method for other storage clients to import into appdata
a helper method for other storage clients to import into appdata
'''
            a helper method for other storage clients to import into appdata
            
        :param record_key: string with key for record
        :param record_data: byte data for body of record
        :param overwrite: [optional] boolean to overwrite existing records
        :param last_modified: [optional] float to record last modified date
        :param kwargs: [optional] keyword arguments from other import methods 
        :return: boolean indicating whether record was imported
        ''' # construct and validate file path
 # check overwrite exception
 # create directories in path to file
 # save file
 # erase file date from drep files

boolean indicating whether record was imported
boolean indicating whether record was imported
self
record_key
string with key for record
string with key for record
record_data
byte data for body of record
byte data for body of record
overwrite
[optional] boolean to overwrite existing records
[ optional ] boolean to overwrite existing records
last_modified
[optional] float to record last modified date
[ optional ] float to record last modified date
kwargs
[optional] keyword arguments from other import methods
[ optional ] keyword arguments from other import methods