本文整理汇总了Python中uc2.events.emit函数的典型用法代码示例。如果您正苦于以下问题:Python emit函数的具体用法?Python emit怎么用?Python emit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了emit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: end_page
def end_page(self):
self.canvas.showPage()
self.page_count += 1
position = 1.0
if self.num_pages:
position = float(self.page_count) / float(self.num_pages)
events.emit(events.FILTER_INFO, self.prgs_msg, position)
示例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)
示例3: 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)
示例4: load
def load(self, presenter, path):
self.presenter = presenter
self.path = path
if not zipfile.is_zipfile(self.path):
msg = _('It seems the file is not CDRZ file')
events.emit(events.MESSAGES, msgconst.ERROR, msg)
raise IOError(2, msg)
self._extract_content()
self.model = None
path = os.path.join(self.presenter.doc_dir, 'content', 'riffData.cdr')
# try:
# file = open(path, 'rb')
# except:
# errtype, value, trace = sys.exc_info()
# msg = _('Cannot open %s file for reading') % (path)
# events.emit(events.MESSAGES, msgconst.ERROR, msg)
# raise IOError(errtype, msg + '\n' + value, trace)
#
# self.model = self.parse_file(file)
#
# file.close()
return self.model
示例5: start_page
def start_page(self, w, h, left_margin=0.0, top_margin=0.0):
self.canvas.translate(w / 2.0 - left_margin, h / 2.0 - top_margin)
self.canvas.setPageSize((w, h))
position = 0.0
if self.num_pages:
position = float(self.page_count) / float(self.num_pages)
events.emit(events.FILTER_INFO, self.prgs_msg, position)
示例6: 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))
示例7: render
def render(self, objs, toplevel=False):
obj_count = 0
for obj in objs:
if obj.is_pixmap():
self.draw_pixmap(obj)
elif obj.is_primitive():
curve_obj = obj.to_curve()
if curve_obj.is_primitive():
self.draw_curve(curve_obj)
else:
self.render(curve_obj.childs)
elif obj.is_container():
self.draw_container(obj)
else:
self.render(obj.childs)
#---Progress
obj_count += 1
shift = 0.0
page_size = 1.0
if self.num_pages:
shift = float(self.page_count) / float(self.num_pages)
page_size = 1.0 / float(self.num_pages)
position = shift + obj_count / len(objs) * page_size
events.emit(events.FILTER_INFO, self.prgs_msg, position)
示例8: 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
示例9: 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
示例10: _pack_content
def _pack_content(self):
pdxf_file = ZipFile(self.presenter.doc_file, 'w')
for item in self.content:
path, filename = item
filename = filename.encode('ascii')
pdxf_file.write(path, filename, zipfile.ZIP_DEFLATED)
pdxf_file.close()
msg = _('PDXF file is created successfully')
events.emit(events.MESSAGES, msgconst.OK, msg)
示例11: save
def save(self, presenter, path):
try:
file = open(path, 'wb')
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)
file.write(presenter.model.get_chunk())
file.close()
示例12: load
def load(self, presenter, path):
self.presenter = presenter
self.path = path
if not zipfile.is_zipfile(self.path):
msg = _('It seems the file is not PDXF file')
events.emit(events.MESSAGES, msgconst.ERROR, msg)
raise IOError(2, msg)
self._extract_content()
self._build_model()
return self.model
示例13: check_wmf
def check_wmf(path):
try:
file = open(path, 'rb')
except:
errtype, value, traceback = sys.exc_info()
msg = _('Cannot open %s file for reading') % (path)
events.emit(events.MESSAGES, msgconst.ERROR, msg)
raise IOError(errtype, msg + '\n' + value, traceback)
string = file.read(4)
file.close()
if string == WMF_SIGNATURE: return True
return False
示例14: 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
示例15: _write_tree
def _write_tree(self, item):
self.counter += 1
position = float(self.counter) / self.obj_num
if position - self.position > 0.05:
msg = _('Saving in process...')
events.emit(events.FILTER_INFO, msg, position)
self.position = position
tag = model.CID_TO_TAGNAME[item.cid]
params = self._get_params(item)
self._open_tag(tag, params, item.childs)
if item.childs:
self.ident += 1
for child in item.childs:
self._write_tree(child)
self.ident -= 1
self._close_tag(tag)