示例#1
0
    def run_prompt(self, interactive):
        """
        Runs the interactive modus

        """
        prompt = Interactive(self.gv)
        opts = ('Confirm', 'Unconfirm')
        sel = prompt.input_options(opts)
示例#2
0
    def run_prompt(self):
        self.run(False)
        self.debug.print_debug(self, u'Entering interactive mode')

        prompt = Interactive(self.gv)

        manipulate = NlmManipulate(self.gv)

        tree = manipulate.load_dom_tree()

        ref_items = tree.xpath('//back/ref-list/ref')

        # note that we don't want to exit even if there are no references to link because the user may want to delete
        # some

        delete_all = False

        for p in tree.xpath('//xref[@ref-type="bibr"]'):
            text = manipulate.get_stripped_text(p)
            prompt.print_(prompt.colorize('green', ("-" * 80)))

            if 'rid' in p.attrib and p.attrib['rid'] == 'TO_LINK':
                prompt.print_(
                    u"Found an unhandled reference marker: {0}".format(text))
            elif 'rid' in p.attrib:
                remote = next((x for x in ref_items if 'id' in x.attrib and (
                    x.attrib['id'] == p.attrib['rid'])), None)
                remote_text = manipulate.get_stripped_text(
                    remote) if remote else ''
                prompt.print_(
                    u"Found a handled reference marker: \"{0}\" which links to \"{1}\""
                    .format(text, remote_text))

            opts = ('Skip', 'Delete', 'deleTe all', 'Enter search', 'Ibid',
                    'enter Link id', 'skip Rest', 'show Context')

            sel = ''

            if delete_all:
                sel = 'd'
            else:
                sel = prompt.input_options(opts)

            result = self.handle_input(manipulate,
                                       opts,
                                       p,
                                       prompt,
                                       ref_items,
                                       sel,
                                       tree=tree)

            if result == 'abort':
                manipulate.save_tree(tree)
                return
            elif result == 'delall':
                delete_all = True

            manipulate.save_tree(tree)
示例#3
0
    def run_prompt(self):
        self.run(False)
        self.debug.print_debug(self, u"Entering interactive mode")

        prompt = Interactive(self.gv)

        manipulate = NlmManipulate(self.gv)

        tree = manipulate.load_dom_tree()

        ref_items = tree.xpath("//back/ref-list/ref")

        # note that we don't want to exit even if there are no references to link because the user may want to delete
        # some

        delete_all = False

        for p in tree.xpath('//xref[@ref-type="bibr"]'):
            text = manipulate.get_stripped_text(p)

            if "rid" in p.attrib and p.attrib["rid"] == "TO_LINK":
                prompt.print_(u"Found an unhandled reference marker: {0}".format(text))
            elif "rid" in p.attrib:
                remote = next((x for x in ref_items if "id" in x.attrib and (x.attrib["id"] == p.attrib["rid"])), None)
                remote_text = manipulate.get_stripped_text(remote)
                prompt.print_(u'Found a handled reference marker: "{0}" which links to "{1}"'.format(text, remote_text))

            opts = (
                "Skip",
                "Delete",
                "deleTe all",
                "Enter search",
                "Ibid",
                "enter Link id",
                "skip Rest",
                "show Context",
            )

            sel = ""

            if delete_all:
                sel = "d"
            else:
                sel = prompt.input_options(opts)

            result = self.handle_input(manipulate, opts, p, prompt, ref_items, sel, tree=tree)

            if result == "abort":
                manipulate.save_tree(tree)
                return
            elif result == "delall":
                delete_all = True

            manipulate.save_tree(tree)
示例#4
0
    def run_prompt(self, interactive):
        if not interactive:
            self.debug.fatal_error(
                self,
                'Cannot enter confirmation mode without interactive flag')

        prompt = Interactive(self.gv)

        opts = ('Confirm', 'Unconfirm', 'cOnfirm all', 'uNconfirm all',
                'Abort')

        manipulate = NlmManipulate(self.gv)

        tree = manipulate.load_dom_tree()

        ref_items = tree.xpath('//back/ref-list/ref')

        # note that we don't want to exit even if there are no references to link because the user may want to delete
        # some

        delete_all = False
        confirm_all = False

        for p in tree.xpath('//ref'):

            text = manipulate.get_stripped_text(p)

            sel = ''

            if delete_all:
                sel = 'u'
            elif confirm_all:
                sel = 'c'
            else:
                prompt.print_(
                    u"Please confirm whether the following is a bibliographic reference: {0}"
                    .format(text))
                sel = prompt.input_options(opts)

            result = self.handle_input(manipulate, opts, p, prompt, sel, tree,
                                       text)

            if result == 'abort':
                return
            elif result == 'delall':
                delete_all = True
            elif result == 'confirmall':
                confirm_all = True

        manipulate.save_tree(tree)
示例#5
0
    def run_prompt(self):
        self.run(False)
        self.debug.print_debug(self, u'Entering interactive mode')

        prompt = Interactive(self.gv)

        manipulate = NlmManipulate(self.gv)

        tree = manipulate.load_dom_tree()

        ref_items = tree.xpath('//back/ref-list/ref')

        # note that we don't want to exit even if there are no references to link because the user may want to delete
        # some

        delete_all = False

        for p in tree.xpath('//xref[@ref-type="bibr"]'):
            text = manipulate.get_stripped_text(p)
            prompt.print_(prompt.colorize('green',("-" * 80)))

            if 'rid' in p.attrib and p.attrib['rid'] == 'TO_LINK':
                prompt.print_(u"Found an unhandled reference marker: {0}".format(text))
            elif 'rid' in p.attrib:
                remote = next((x for x in ref_items if 'id' in x.attrib and (x.attrib['id'] == p.attrib['rid'])), None)
                remote_text = manipulate.get_stripped_text(remote)
                prompt.print_(u"Found a handled reference marker: \"{0}\" which links to \"{1}\"".format(text,
                                                                                                         remote_text))

            opts = ('Skip', 'Delete', 'deleTe all', 'Enter search', 'Ibid', 'enter Link id',
                    'skip Rest', 'show Context')

            sel = ''

            if delete_all:
                sel = 'd'
            else:
                sel = prompt.input_options(opts)

            result = self.handle_input(manipulate, opts, p, prompt, ref_items, sel, tree=tree)

            if result == 'abort':
                manipulate.save_tree(tree)
                return
            elif result == 'delall':
                delete_all = True

            manipulate.save_tree(tree)
    def run_prompt(self, interactive):
        if not interactive:
            self.debug.fatal_error(self, "Cannot enter confirmation mode without interactive flag")

        prompt = Interactive(self.gv)

        opts = ("Confirm", "Unconfirm", "cOnfirm all", "uNconfirm all", "Abort")

        manipulate = NlmManipulate(self.gv)

        tree = manipulate.load_dom_tree()

        ref_items = tree.xpath("//back/ref-list/ref")

        # note that we don't want to exit even if there are no references to link because the user may want to delete
        # some

        delete_all = False
        confirm_all = False

        for p in tree.xpath("//ref"):

            text = manipulate.get_stripped_text(p)

            sel = ""

            if delete_all:
                sel = "u"
            elif confirm_all:
                sel = "c"
            else:
                prompt.print_(u"Please confirm whether the following is a bibliographic reference: {0}".format(text))
                sel = prompt.input_options(opts)

            result = self.handle_input(manipulate, opts, p, prompt, sel, tree, text)

            if result == "abort":
                return
            elif result == "delall":
                delete_all = True
            elif result == "confirmall":
                confirm_all = True

        manipulate.save_tree(tree)