コード例 #1
0
def run(cmd_format, stdin_str=None, verbose=False):
    """Run command"""
    if verbose:
        inkex.debug(cmd_format)
    out = err = None
    myproc = Popen(cmd_format,
                   shell=False,
                   stdin=PIPE,
                   stdout=PIPE,
                   stderr=PIPE)
    out, err = myproc.communicate(stdin_str)
    if myproc.returncode == 0:
        return out
    elif err is not None:
        inkex.errormsg(err)
コード例 #2
0
 def effect(self):
     """Main entry point to process current document."""
     if self.has_tagrefs():
         # unsafe to use with extensions ...
         inkex.errormsg("This document uses Inkscape selection sets. "
                        "Modifying the content with a PathOps extension "
                        "may cause Inkscape to crash on reload or close. "
                        "Please delete the selection sets, "
                        "save the document under a new name and "
                        "try again in a new Inkscape session.")
     else:
         # process selection
         top_path, other_paths = self.get_sorted_ids()
         if top_path is None or other_paths is None:
             return
         else:
             self.loop_pathops(top_path, other_paths)
コード例 #3
0
 def get_selected_ids(self):
     """Return a list of valid ids for inkscape path operations."""
     id_list = []
     if not len(self.selected):
         pass
     else:
         # level = 0: unlimited recursion into groups
         # level = 1: process top-level groups only
         level = 0 if self.options.recursive_sel else 1
         for node in self.selected.values():
             self.recurse_selection(node, id_list, level)
     if len(id_list) < 2:
         inkex.errormsg("This extension requires at least 2 elements "
                        "of type path, shape or text. "
                        "The elements can be part of selected groups, "
                        "or directly selected.")
         return None
     else:
         return id_list