当前位置: 首页>>代码示例>>Python>>正文


Python uc2._函数代码示例

本文整理汇总了Python中uc2._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _extract_content

	def _extract_content(self):
		pdxf_file = ZipFile(self.path, 'r')
		try:
			fl = pdxf_file.namelist()
		except:
			errtype, value, traceback = sys.exc_info()
			msg = _('It seems the PDXF file is corrupted') + '\n' + value
			events.emit(events.MESSAGES, msgconst.ERROR, msg)
			raise IOError(errtype, msg , traceback)
		if not 'mimetype' in fl or not pdxf_file.read('mimetype') == const.DOC_MIME:
			msg = _('The file is corrupted or not PDXF file')
			events.emit(events.MESSAGES, msgconst.ERROR, msg)
			raise IOError(2, msg)

		filelist = []
		for item in fl:
			if item == 'mimetype' or item[-1] == '/':
				continue
			filelist.append(item)

		for item in filelist:
			source = pdxf_file.read(item)
			dest = open(os.path.join(self.presenter.doc_dir, item), 'wb')
			dest.write(source)
			dest.close()
		msg = _('The file content is extracted successfully')
		events.emit(events.MESSAGES, msgconst.OK, msg)
开发者ID:Scrik,项目名称:sk1-wx,代码行数:27,代码来源:pdxf_filters.py

示例2: _build_model

	def _build_model(self):
		content_handler = XMLDocReader(self.presenter)
		error_handler = ErrorHandler()
		entity_resolver = EntityResolver()
		dtd_handler = DTDHandler()
		try:
			filename = os.path.join(self.presenter.doc_dir, 'content.xml')
			handler = open(filename, 'r')
			lines = float(sum(1 for l in handler))
			handler.close()
			self.file_handler = open(filename, "r")
			input_source = InputSource()
			input_source.setByteStream(self.file_handler)
			content_handler.lines = lines
			xml_reader = xml.sax.make_parser()
			xml_reader.setContentHandler(content_handler)
			xml_reader.setErrorHandler(error_handler)
			xml_reader.setEntityResolver(entity_resolver)
			xml_reader.setDTDHandler(dtd_handler)
			xml_reader.parse(input_source)
			self.file_handler.close()
			content_handler.file = None
		except:
			errtype, value, traceback = sys.exc_info()
			msg = _('It seems content.xml is corrupted') + '\n' + value
			events.emit(events.MESSAGES, msgconst.ERROR, msg)
			raise IOError(errtype, msg , traceback)
		self.model = content_handler.model

		msg = _('Content.xml is parsed successfully')
		events.emit(events.MESSAGES, msgconst.OK, msg)
开发者ID:Scrik,项目名称:sk1-wx,代码行数:31,代码来源:pdxf_filters.py

示例3: load

	def load(self, presenter, path):
		self.presenter = presenter
		self.path = path
		self.model = presenter.model
		self.jobs = []

		try:
			file = open(path, 'rb')
		except:
			errtype, value, traceback = sys.exc_info()
			msg = _('Cannot open %s file for writing') % (path)
			events.emit(events.MESSAGES, msgconst.ERROR, msg)
			raise IOError(errtype, msg + '\n' + value, traceback)

		res = file.read().split('IN;')
		file.close()

		if not len(res) == 2:
			msg = _('Wrong content in %s file: "IN;" instruction should be unique') % (path)
			events.emit(events.MESSAGES, msgconst.ERROR, msg)
			raise IOError(msg)

		if res[0]:
			self.model.string = res[0]
		cmds = res[1].split(';')
		jobs = []
		job = []
		stack = ''
		for cmd in cmds:
			if cmd[:2] == 'PU':
				stack = cmd
				if job:
					jobs.append(job)
					job = []
			elif cmd[:2] == 'PD':
				if not job:
					if not stack:
						stack = 'PU0,0'
					job.append(stack)
				job.append(cmd)

		for job in jobs:
			string = ''
			for cmd in job:
				string += cmd + ';'
			self.jobs.append(model.PltJob(string))

		self.model.childs[1].childs = self.jobs
		return self.model
开发者ID:sk1project,项目名称:uc2,代码行数:49,代码来源:plt_filters.py

示例4: close

	def close(self):
		filename = self.doc_file
		self.doc_file = ''
		if not self.model is None:
			self.model.destroy()
		self.model = None

		self.send_ok(_('Document model is destroyed for') + ' %s' % (filename))

		if self.doc_dir and os.path.lexists(self.doc_dir):
			try:
				fs.xremove_dir(self.doc_dir)
				self.send_ok(_('Cache is cleared for') + ' %s' % (filename))
			except IOError:
				self.send_srror(_('Cache clearing is unsuccessful'))
开发者ID:Scrik,项目名称:sk1-wx,代码行数:15,代码来源:generic.py

示例5: __init__

	def __init__(self, config, parent=None, name=_('GridLayer')):
		Layer.__init__(self, config, parent, name)
		self.cid = GRID_LAYER
		self.childs = []
		self.color = [] + self.config.grid_layer_color
		self.grid = [] + self.config.grid_layer_geometry
		self.properties = [] + self.config.grid_layer_propeties
开发者ID:sk1project,项目名称:sk1-wx,代码行数:7,代码来源:sk2_model.py

示例6: add_layer

 def add_layer(self, page, layer_name=""):
     if not layer_name:
         layer_name = _("Layer") + " %i" % (page.layer_counter + 1)
     layer = sk2_model.Layer(self.config, page, layer_name)
     page.childs.append(layer)
     page.layer_counter += 1
     return layer
开发者ID:sk1project,项目名称:sk1-wx,代码行数:7,代码来源:sk2_methods.py

示例7: add_layer

	def add_layer(self, page, layer_name=''):
		if not layer_name:
			layer_name = _('Layer') + ' %i' % (page.layer_counter + 1)
		layer = model.Layer(self.config, page, layer_name)
		page.childs.append(layer)
		page.layer_counter += 1
		return layer
开发者ID:Scrik,项目名称:sk1-wx,代码行数:7,代码来源:methods.py

示例8: update

	def update(self, action=False):
		if not self.model is None:
			self.obj_num = self.model.count() + 1
			self.update_msg(0.0)
			try:
				self.model.config = self.config
				self.model.do_update(self, action)
			except:
				print sys.exc_info()[1], sys.exc_info()[2]
				msg = _('Exception while document model update')
				self.send_error(msg)
				raise IOError(msg)

			msg = _('Document model is updated successfully')
			self.send_progress_message(msg, 0.99)
			self.send_ok(msg)
开发者ID:Scrik,项目名称:sk1-wx,代码行数:16,代码来源:generic.py

示例9: startElement

	def startElement(self, name, attrs):
		if name == 'Content':
			pass
		else:
			position = float(self.locator.getLineNumber()) / self.lines
			if position - self.position > 0.05:
				msg = _('Parsing in process...')
				events.emit(events.FILTER_INFO, msg, position)
				self.position = position
			obj = None
			cid = model.TAGNAME_TO_CID[name]
			obj = model.CID_TO_CLASS[cid](self.presenter.config)
			obj.tag = name
			for item in attrs._attrs.keys():
				line = 'self.value=' + attrs._attrs[item]
				code = compile(line, '<string>', 'exec')
				exec code
				obj.__dict__[item] = self.value

			if self.parent_stack:
				parent = self.parent_stack[-1]
				methods.add_child(parent, obj)
			else:
				self.model = obj

			self.parent_stack.append(obj)
开发者ID:Scrik,项目名称:sk1-wx,代码行数:26,代码来源:pdxf_filters.py

示例10: create_jobs

	def create_jobs(self):
		if self.obj_stack:
			m11, m21, m12, m22, dx, dy = SK2_to_PLT_TRAFO

			if self.plt_doc.config.force_zero:
				bbox = []
				bbox += self.obj_stack[0].cache_bbox
				for obj in self.obj_stack:
					bbox = libgeom.sum_bbox(bbox, obj.cache_bbox)

				dx = -bbox[0] * m11
				dy = -bbox[1] * m22

			trafo = [m11, m21, m12, m22, dx, dy]

			obj_num = len(self.obj_stack)
			for obj in self.obj_stack:

				self.counter += 1
				position = float(self.counter) / obj_num
				if position - self.position > 0.05:
					msg = _('Saving in process...')
					events.emit(events.FILTER_INFO, msg, position)
					self.position = position

				paths = libgeom.get_flattened_path(obj, trafo,
									self.plt_doc.config.tolerance)
				if paths is None: continue

				for path in paths:
					if path and path[1]:
						self.jobs.append(plt_model.PltJob('', path))
开发者ID:Scrik,项目名称:sk1-wx,代码行数:32,代码来源:plt_translators.py

示例11: set_default_page_size

	def set_default_page_size(self, width, height):
		parent = self.model.childs[0]
		fmt = _('Custom size')
		size = (width, height)
		orient = uc2const.PORTRAIT
		if width > height:orient = uc2const.LANDSCAPE
		parent.page_format = [fmt, size, orient]
开发者ID:Scrik,项目名称:sk1-wx,代码行数:7,代码来源:methods.py

示例12: set_default_page_size

 def set_default_page_size(self, width, height):
     parent = self.get_pages_obj()
     fmt = _("Custom size")
     size = (width, height)
     orient = uc2const.PORTRAIT
     if width > height:
         orient = uc2const.LANDSCAPE
     parent.page_format = [fmt, size, orient]
开发者ID:sk1project,项目名称:sk1-wx,代码行数:8,代码来源:sk2_methods.py

示例13: get_loader_by_id

def get_loader_by_id(pid):
	loader = None
	if pid in data.LOADERS.keys():
		loader = data.LOADERS[pid]
	else:
		msg = _('Loader is not found for id %u') % (pid)
		events.emit(events.MESSAGES, msgconst.ERROR, msg)
	return loader
开发者ID:Scrik,项目名称:sk1-wx,代码行数:8,代码来源:__init__.py

示例14: get_saver_by_id

def get_saver_by_id(pid):
	saver = None
	if pid in data.SAVERS.keys():
		saver = data.SAVERS[pid]
	else:
		msg = _('Saver is not found for id %u') % (pid)
		events.emit(events.MESSAGES, msgconst.ERROR, msg)
	return saver
开发者ID:Scrik,项目名称:sk1-wx,代码行数:8,代码来源:__init__.py

示例15: check_sk2

def check_sk2(path):
	ret = False
	fileptr = get_fileptr(path)
	ln = fileptr.readline()
	if ln[:len(SK2DOC_ID)] == SK2DOC_ID:
		if int(ln[len(SK2DOC_ID):]) <= int(SK2VER): ret = True
		else:
			fileptr.close()
			raise RuntimeError(_('Newer version of SK2 format is found!'))
	else:
		ln2 = fileptr.readline()
		if ln2[:len(SK2XML_ID)] == SK2XML_ID:
			if int(ln2[len(SK2XML_ID):]) <= int(SK2VER): ret = True
			else:
				fileptr.close()
				raise RuntimeError(_('Newer version of SK2 format is found!'))
	fileptr.close()
	return ret
开发者ID:sk1project,项目名称:sk1-wx,代码行数:18,代码来源:__init__.py


注:本文中的uc2._函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。