def __del__(self): pdebug('__del__', '__del__', self) if type(self.object) == ListType: for obj in self.object: obj.Destroy() else: self.object.Destroy()
def read_metric(ps_name): for afm in ps_to_filename[ps_name]: afm = afm + '.afm' filename = find_in_path(config.font_path, afm) if filename: if __debug__: import time start = time.clock() metric = read_afm_file(filename) if __debug__: pdebug('timing', 'time to read afm %s: %g', afm, time.clock() - start) return metric else: if not _warned_about_afm.get(afm): warn(USER, _("I cannot find the metrics for the font %(ps_name)s.\n" "The file %(afm)s is not in the font_path.\n" "I'll use the metrics for %(fallback)s instead."), ps_name = ps_name, afm = afm, fallback = config.preferences.fallback_font) _warned_about_afm[afm] = 1 if ps_name != config.preferences.fallback_font: return read_metric(config.preferences.fallback_font) else: raise SketchError("Can't load metrics for fallback font %s", config.preferences.fallback_font)
def ObjectRemoved(self, object): if object in self.stack: idx = self.stack.index(object) undo = (self.set_stack, self.stack[:]) self.stack[idx] = self.stack[idx].AsUndynamicStyle() pdebug('properties', 'made style undynamic') return undo return NullUndo
def read_outlines(ps_name): filename = font_file_name(ps_name) if filename: if __debug__: pdebug('font', 'read_outlines: %s', filename) import app.Lib.type1 return app.Lib.type1.read_outlines(filename) else: raise SketchInternalError('Cannot find file for font %s' % ps_name)
def DeleteNodes(self): new_paths = [] for path in self.paths: if path.selection_count() > 0: newpath = delete_segments(path) else: newpath = path if newpath.len > 1: new_paths.append(newpath) else: # all nodes of path have been deleted if __debug__: pdebug('bezier', 'path removed') if new_paths: return self.set_paths(new_paths) else: if __debug__: pdebug('bezier', 'PolyBezier removed') self.document.DeselectObject(self.object) return self.parent.Remove(self.object)
def load_plugin_configuration(): #path): if __debug__: import time start = time.clock() path = [import_dir, export_dir, parsing_dir]#, preview_dir] for dir in path: # XXX unix specific if len(dir) >= 2 and dir[-1] == '/': if dir[-2] == '/': recurse = -1 else: recurse = 1 else: recurse = 0 _search_dir(dir, recurse) if __debug__: pdebug('timing', 'time to scan cfg files: %g', time.clock()-start) # rearrange import plugins to ensure that native format is first for loader in import_plugins: if loader.format_name == NativeFormat: import_plugins.remove(loader) import_plugins.insert(0, loader)
def ComputeTrafo(self, oldStart, oldEnd, start, end): oldDelta = oldEnd - oldStart delta = end - start if self.selection == -1: # a translation. return _("Move Objects"), start - oldStart else: try: m11 = delta.x / oldDelta.x except ZeroDivisionError: m11 = 0 if __debug__: pdebug(None, "ComputeTrafo: ZeroDivisionError") try: m22 = delta.y / oldDelta.y except ZeroDivisionError: m22 = 0 if __debug__: pdebug(None, "ComputeTrafo: ZeroDivisionError") offx = start.x - m11 * oldStart.x offy = start.y - m22 * oldStart.y return _("Resize Objects"), Trafo(m11, 0, 0, m22, offx, offy)
def ComputeTrafo(self, oldStart, oldEnd, start, end): oldDelta = oldEnd - oldStart delta = end - start if self.selection == -1: # a translation. return _("Move Objects"), start - oldStart else: try: m11 = delta.x / oldDelta.x except ZeroDivisionError: m11 = 0 if __debug__: pdebug(None, 'ComputeTrafo: ZeroDivisionError') try: m22 = delta.y / oldDelta.y except ZeroDivisionError: m22 = 0 if __debug__: pdebug(None, 'ComputeTrafo: ZeroDivisionError') offx = start.x - m11 * oldStart.x offy = start.y - m22 * oldStart.y return _("Resize Objects"), Trafo(m11, 0, 0, m22, offx, offy)
def load_plugin_configuration(): #path): if __debug__: import time start = time.clock() path = [import_dir, export_dir, parsing_dir] #, preview_dir] for dir in path: # XXX unix specific if len(dir) >= 2 and dir[-1] == '/': if dir[-2] == '/': recurse = -1 else: recurse = 1 else: recurse = 0 _search_dir(dir, recurse) if __debug__: pdebug('timing', 'time to scan cfg files: %g', time.clock() - start) # rearrange import plugins to ensure that native format is first for loader in import_plugins: if loader.format_name == NativeFormat: import_plugins.remove(loader) import_plugins.insert(0, loader)
def __cmp__(self, other): if __debug__: pdebug(None, 'Arrow.__cmp__, %s', other) if isinstance(other, self.__class__): return cmp(self.path, other.path) return cmp(id(self), id(other))
raise SketchLoadError( _("error %s:%s in line %d:\n%s") % (sys.exc_info()[:2] + (num, ` line `))) self.end_all() if self.page_layout: self.object.load_SetLayout(self.page_layout) for style in self.style_dict.values(): self.object.load_AddStyle(style) self.object.load_Completed() app.updateInfo(inf2='Pasing is finished', inf3=100) self.object.meta.native_format = 1 if __debug__: pdebug('timing', 'time:', time.clock() - start_time) return self.object def call_function(function, args, kwargs): if hasattr(function, 'im_func'): args = (function.im_self, ) + args function = function.im_func code = function.func_code if code.co_flags & 0x000C: # uses *args or **kwargs return 0 args = args[:code.co_argcount] argnames = code.co_varnames[:code.co_argcount] for key in kwargs.keys(): if key not in argnames:
fontlist.append(tuple(info[:-1])) _add_ps_filename(psname, info[-1]) fontmap[psname] = tuple(info[1:-1]) elif len(info) == 2: psname, basename = info _add_ps_filename(psname, basename) else: warn(INTERNAL,'%s:%d: line must have exactly 6 fields', filename, line_nr) file.close() except IOError, value: warn(USER, _("Cannot load sfd file %(filename)s:%(message)s;" "ignoring it"), filename = filename, message = value.strerror) if __debug__: pdebug('timing', 'time to read font dirs: %g', time.clock() - start) def make_family_to_fonts(): families = {} for item in fontlist: family = item[1] fontname = item[0] if families.has_key(family): families[family] = families[family] + (fontname,) else: families[family] = (fontname,) return families xlfd_template = "%s--%s-*-*-*-*-*-%s"
raise else: raise SketchLoadError(_("error %s:%s in line %d:\n%s") % (sys.exc_info()[:2] + (num, ` line `))) self.end_all() if self.page_layout: self.object.load_SetLayout(self.page_layout) for style in self.style_dict.values(): self.object.load_AddStyle(style) self.object.load_Completed() app.updateInfo(inf2="Pasing is finished", inf3=100) self.object.meta.native_format = 1 if __debug__: pdebug("timing", "time:", time.clock() - start_time) return self.object def call_function(function, args, kwargs): if hasattr(function, "im_func"): args = (function.im_self,) + args function = function.im_func code = function.func_code if code.co_flags & 0x000C: # uses *args or **kwargs return 0 args = args[: code.co_argcount] argnames = code.co_varnames[: code.co_argcount] for key in kwargs.keys(): if key not in argnames:
else: raise SketchLoadError(_("error %s:%s in line %d:\n%s") % (sys.exc_info()[:2] +(num, `line`))) self.end_all() if self.page_layout: self.object.load_SetLayout(self.page_layout) for style in self.style_dict.values(): self.object.load_AddStyle(style) self.object.load_Completed() app.updateInfo(inf2='Pasing is finished',inf3=100) self.object.meta.native_format = 1 if __debug__: pdebug('timing', 'time:', time.clock() - start_time) return self.object def call_function(function, args, kwargs): if hasattr(function, 'im_func'): args = (function.im_self,) + args function = function.im_func code = function.func_code if code.co_flags & 0x000C: # uses *args or **kwargs return 0 args = args[:code.co_argcount] argnames = code.co_varnames[:code.co_argcount] for key in kwargs.keys(): if key not in argnames:
def add_message(self, message): pdebug(('load', 'echo_messages'), message) self.messages[message] = self.messages.get(message, 0) + 1
def __del__(self): if __debug__: pdebug('__del__', '__del__', self)
def __del__(self): pdebug('__del__', '__del__', self)