예제 #1
0
파일: io.py 프로젝트: appscluster/holopy
def save(outf, obj):
    """
    Save a holopy object

    Will save objects as yaml text containing all information about the object
    unless outf is a filename with an image extension, in which case it will
    save an image, truncating metadata.

    Parameters
    ----------
    outf : basestring or file
        Location to save the object
    obj : :class:`holopy.core.holopy_object.HoloPyObject`
        The object to save

    Notes
    -----
    Marray objects are actually saved as a custom yaml file consisting of a yaml
    header and a numpy .npy binary array.  This is done because yaml's saving of
    binary array is very slow for large arrays.  HoloPy can read these 'yaml'
    files, but any other yaml implementation will get confused.
    """
    if isinstance(outf, basestring):
        filename, ext = os.path.splitext(outf)
        if ext in ['.tif', '.TIF', '.tiff', '.TIFF']:
            save_image(outf, obj)
            return
    serialize.save(outf, obj)
예제 #2
0
파일: io.py 프로젝트: yurivish/holopy
def save(outf, obj):
    """
    Save a holopy object

    Will save objects as yaml text containing all information about the object
    unless outf is a filename with an image extension, in which case it will
    save an image, truncating metadata.

    Parameters
    ----------
    outf : basestring or file
        Location to save the object
    obj : :class:`holopy.core.holopy_object.HoloPyObject`
        The object to save

    Notes
    -----
    Marray objects are actually saved as a custom yaml file consisting of a yaml
    header and a numpy .npy binary array.  This is done because yaml's saving of
    binary array is very slow for large arrays.  HoloPy can read these 'yaml'
    files, but any other yaml implementation will get confused.
    """
    if isinstance(outf, basestring):
        filename, ext = os.path.splitext(outf)
        if ext in ['.tif', '.TIF', '.tiff', '.TIFF']:
            save_image(outf, obj)
            return
    serialize.save(outf, obj)
예제 #3
0
 def test_json(self):
     """ test for serialization with json """
     output = srz.save(self.data, self.output, 'json')
     output = unicode(output)
     self.output = StringIO(output)
     extr_data = srz.load(self.output, 'json')
     self.assertEqual(self.data, extr_data)
예제 #4
0
파일: main.py 프로젝트: yatsek/mindmaps-qt
	def saveFile(self):
		a=QMessageBox()
		if not serialize.save(self.filename,self.view):
			a.setText("Document couldn't be saved")
			a.exec_()
		else:
			a.setText("Document succesfully saved")
			a.exec_()
예제 #5
0
파일: Main.py 프로젝트: archcompyym/lab_1
def start(config, file_name):
    """function for run project"""

    file_obj = open (config, "r")
    tp = pickle.load(file_obj);
    file_obj.close()
    
    file_obj = open (file_name, "r ");
    calendar = serialize.load(file_obj, tp)
    file_obj.close()
    calendar = Control.menu(calendar)

    new_tp = save_result()
    file_obj = open (file_name, "w");
    
    if new_tp == "":
        serialize.save(calendar, file_obj, tp)
    else:
        fl = open(config, "w")
        pickle.dump(new_tp, fl)
        fl.close()
        serialize.save(calendar, file_obj, new_tp)
    file_obj.close()
예제 #6
0
파일: main.py 프로젝트: yatsek/mindmaps-qt
	def save(self):
		"""Method which checks if filename is defined.
		   If not, asks where to save and saves"""
		a=QMessageBox()
		if self.filename == "":
			path = "."
			fname = QFileDialog.getSaveFileName(self,"Save mindmap",path,"Mind maps (*.mindqt)")
			if fname.isEmpty():
				return
			self.filename = fname
		if not serialize.save(self.filename,self.view):
			a.setText("Document couldn't be saved")
			a.exec_()
		else:
			a.setText("Document succesfully saved")
			a.exec_()
예제 #7
0
 def test_pickle(self):
     """ test for serialization with pickle """
     output = srz.save(self.data, self.output, 'pickle')
     self.output = BytesIO(output)
     extr_data = srz.load(self.output, "pickle")
     self.assertEqual(self.data, extr_data)
예제 #8
0
	def save(self):
		specifier = "wb" if self.config == "pickle" else "w"
		with open(self.filename, specifier) as target_file:
			serialize.save(self._db, target_file,self.config)	
			
		save_last_configs(self.config)