Ejemplo n.º 1
0
 def __init__(self, appdata, cnf={}, filepath=None):
     self.config = PDXF_Config()
     config_file = os.path.join(appdata.app_config_dir, 'pdxf_config.xml')
     self.config.load(config_file)
     self.config.update(cnf)
     self.appdata = appdata
     self.doc_id = generate_id()
     self.loader = PDXF_Loader()
     self.saver = PDXF_Saver()
     self.methods = PDXF_Methods(self)
     self.rm = ResourceManager(self)
     self.create_cache_structure()
     if filepath is None:
         self.new()
     else:
         self.load(filepath)
Ejemplo n.º 2
0
	def __init__(self, appdata, cnf={}, filepath=None):
		self.config = PDXF_Config()
		config_file = os.path.join(appdata.app_config_dir, 'pdxf_config.xml')
		self.config.load(config_file)
		self.config.update(cnf)
		self.appdata = appdata
		self.doc_id = generate_id()
		self.loader = PDXF_Loader()
		self.saver = PDXF_Saver()
		self.methods = PDXF_Methods(self)
		self.rm = ResourceManager(self)
		self.create_cache_structure()
		if filepath is None:
			self.new()
		else:
			self.load(filepath)
Ejemplo n.º 3
0
 def add_palette(self, palette):
     palette.model.name = str(palette.model.name)
     pname = palette.model.name
     i = 1
     while palette.model.name in self.palettes.keys():
         palette.model.name = pname + '(%u)' % i
         i += 1
     name = palette.model.name
     self.palettes[name] = palette
     pf = generate_id() + "." + uc2const.FORMAT_EXTENSION[uc2const.SKP][0]
     filepath = os.path.join(self.app.appdata.app_palette_dir, pf)
     palette.save(filepath)
     if config.palette_files:
         config.palette_files[name] = pf
     else:
         files = {name: pf}
         config.palette_files = files
Ejemplo n.º 4
0
	def add_palette(self, palette):
		palette.model.name = str(palette.model.name)
		pname = '' + palette.model.name
		i = 1
		while palette.model.name in self.palettes.keys():
			palette.model.name = pname + '(%u)' % i
			i += 1
		name = palette.model.name
		self.palettes[name] = palette
		pf = generate_id() + "." + uc2const.FORMAT_EXTENSION[uc2const.SKP][0]
		filepath = os.path.join(self.app.appdata.app_palette_dir, pf)
		palette.save(filepath)
		if config.palette_files:
			config.palette_files[name] = pf
		else:
			files = {}
			files[name] = pf
			config.palette_files = files
Ejemplo n.º 5
0
	def registry_file(self, filepath, place, id=None):
		"""
		Copies and registers file into specified place
		(one of document structure directories).
		If id is not provided, generates new unique id.
		"""
		ret = None
		if os.path.isfile(filepath):
			if id is None:
				id = generate_id()
			filename = os.path.basename(filepath)
			ext = os.path.splitext(filename)[1]
			dst_filename = id + ext
			dst_dir = os.path.join(self.doc_dir, place)
			dst = os.path.join(dst_dir, dst_filename)
			try:
				shutil.copyfile(filepath, dst)
				res_dict = self.presenter.model.resources
				res_dict[id] = place + '/' + dst_filename
				ret = id
			except: pass
		return ret
Ejemplo n.º 6
0
 def registry_file(self, filepath, place, id=None):
     """
     Copies and registers file into specified place
     (one of document structure directories).
     If id is not provided, generates new unique id.
     """
     ret = None
     if os.path.isfile(filepath):
         if id is None:
             id = generate_id()
         filename = os.path.basename(filepath)
         ext = os.path.splitext(filename)[1]
         dst_filename = id + ext
         dst_dir = os.path.join(self.doc_dir, place)
         dst = os.path.join(dst_dir, dst_filename)
         try:
             shutil.copyfile(filepath, dst)
             res_dict = self.presenter.model.resources
             res_dict[id] = place + '/' + dst_filename
             ret = id
         except:
             pass
     return ret