Esempio n. 1
0
    def effect(self):
        """ Like cut but requires no selection and does no validation for
        text nodes.
        """
        #: If running from source
        if DEBUG:
            python = '~/inkcut/venv/bin/python'
            inkcut = '~/inkcut/main.py'
            cmd = [python, inkcut]
        else:
            cmd = ['inkcut']

        document = convert_objects_to_paths(
            self.options.input_file if VERSION == "1.X" else self.args[-1],
            self.document)

        cmd += ['open', '-']
        p = subprocess.Popen(cmd,
                             stdin=subprocess.PIPE,
                             stdout=DEVNULL,
                             stderr=subprocess.STDOUT,
                             close_fds=sys.platform != "win32")
        p.stdin.write(
            etree.tostring(document) if VERSION ==
            "1.X" else inkex.etree.tostring(document))
        p.stdin.close()
        # Set the returncode to avoid this warning when popen is garbage collected:
        # "ResourceWarning: subprocess XXX is still running".
        # See https://bugs.python.org/issue38890 and
        # https://bugs.python.org/issue26741.
        p.returncode = 0
Esempio n. 2
0
    def effect(self):
        """ Like cut but requires no selection and does no validation for
        text nodes.
        """
        nodes = self.selected
        if not len(nodes):
            inkex.errormsg("There were no paths were selected.")
            return

        document = self.document
        if contains_text(self.selected.values()):
            document = convert_objects_to_paths(self.args[-1], self.document)

        #: If running from source
        if DEBUG:
            python = '~/inkcut/venv/bin/python'
            inkcut = '~/inkcut/main.py'
            cmd = [python, inkcut]
        else:
            cmd = ['inkcut']

        cmd += ['open', '-', '--nodes'] + [str(k) for k in nodes.keys()]
        p = subprocess.Popen(cmd,
                             stdin=subprocess.PIPE,
                             stdout=DEVNULL,
                             stderr=subprocess.STDOUT,
                             close_fds=sys.platform != "win32")
        p.stdin.write(inkex.etree.tostring(document))
        p.stdin.close()
Esempio n. 3
0
    def effect(self):
        """ Like cut but requires no selection and does no validation for
        text nodes.
        """
        #: If running from source
        if DEBUG:
            python = '~/inkcut/venv/bin/python'
            inkcut = '~/inkcut/main.py'
            cmd = [python, inkcut]
        else:
            cmd = ['inkcut']

        document = convert_objects_to_paths(
            self.options.input_file if VERSION == "1.X" else self.args[-1],
            self.document)

        cmd += ['open', '-']
        p = subprocess.Popen(cmd,
                             stdin=subprocess.PIPE,
                             stdout=DEVNULL,
                             stderr=subprocess.STDOUT,
                             close_fds=sys.platform != "win32")
        p.stdin.write(
            etree.tostring(document) if VERSION ==
            "1.X" else inkex.etree.tostring(document))
        p.stdin.close()
Esempio n. 4
0
    def effect(self):
        """ Like cut but requires no selection and does no validation for
        text nodes.
        """
        nodes = self.selected
        if not len(nodes):
            inkex.errormsg("There were no paths were selected.")
            return

        document = self.document
        if contains_text(self.selected.values()):
            document = convert_objects_to_paths(self.args[-1], self.document)

        #: If running from source
        if DEBUG:
            python = '~/inkcut/venv/bin/python'
            inkcut = '~/inkcut/main.py'
            cmd = [python, inkcut]
        else:
            cmd = ['inkcut']

        cmd += ['open', '-',
               '--nodes']+[str(k) for k in nodes.keys()]
        p = subprocess.Popen(cmd,
                             stdin=subprocess.PIPE,
                             stdout=DEVNULL,
                             stderr=subprocess.STDOUT,
                             close_fds=sys.platform != "win32")
        p.stdin.write(inkex.etree.tostring(document))
        p.stdin.close()
Esempio n. 5
0
    def effect(self):
        """ Like cut but requires no selection and does no validation for
        text nodes.
        """

        nodes = self.svg.selected if (VERSION == "1.X") else self.selected
        if not len(nodes):
            inkex.errormsg("There were no paths were selected.")
            return

        document = self.document
        if contains_text(self.svg.selected.values() if VERSION ==
                         "1.X" else self.selected.values()):
            document = convert_objects_to_paths(self.args[-1], self.document)

        #: If running from source
        if DEBUG:
            python = '~/inkcut/venv/bin/python'
            inkcut = '~/inkcut/main.py'
            cmd = [python, inkcut]
        else:
            cmd = ['inkcut']

        cmd += ['open', '-', '--nodes'] + [str(k) for k in nodes.keys()]
        p = subprocess.Popen(cmd,
                             stdin=subprocess.PIPE,
                             stdout=DEVNULL,
                             stderr=subprocess.STDOUT,
                             close_fds=sys.platform != "win32")
        p.stdin.write(
            etree.tostring(document) if VERSION ==
            "1.X" else inkex.etree.tostring(document))
        p.stdin.close()

        # Set the returncode to avoid this warning when popen is garbage collected:
        # "ResourceWarning: subprocess XXX is still running".
        # See https://bugs.python.org/issue38890 and
        # https://bugs.python.org/issue26741.
        p.returncode = 0