def makeFile(self,contents,mode): files = [] files.append(StringIO(contents[0:5])) files.append(StringIO(contents[5:8])) files.append(StringIO(contents[8:])) f = join(files) def getvalue(): return "".join([s.getvalue() for s in files]) f.getvalue = getvalue return f
def makeFile(self, contents, mode): files = [] files.append(StringIO(contents[0:5])) files.append(StringIO(contents[5:8])) files.append(StringIO(contents[8:])) f = join(files) def getvalue(): return "".join([s.getvalue() for s in files]) f.getvalue = getvalue return f
def prep_content_datastream( self, item_dct ): """ Returns file-like object containing the item_dct. Called by create_metadata_only_object() """ jsn = json.dumps( item_dct ) file_obj = filelike.join( [SIO(jsn)] ) # this file_obj works with requests; vanilla StringIO didn't param_string = json.dumps( [{ 'dsID': 'bell_metadata', 'file_name': 'bell_item.json', 'mimetype': 'application/javascript' }] ) return_tuple = ( file_obj, param_string ) return return_tuple