コード例 #1
0
ファイル: presenter.py プロジェクト: wenlibin02/sk1-wx
 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)
コード例 #2
0
ファイル: presenter.py プロジェクト: sk1project/uc2
	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)
コード例 #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
コード例 #4
0
ファイル: app_palettes.py プロジェクト: Scrik/sk1-wx
	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
コード例 #5
0
ファイル: resmngr.py プロジェクト: Scrik/sk1-wx
	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
コード例 #6
0
ファイル: resmngr.py プロジェクト: sahwar/sk1-wx
 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