def handle()

in api-reference-examples/python/te-tag-query/TETagQuery.py [0:0]


    def handle(self, args, options):

        options["includeIndicatorInOutput"] = True
        options["pageSize"] = 10

        while True:
            if len(args) == 0:
                break
            if args[0][0] != "-":
                break
            option = args[0]
            args = args[1:]

            if option == "-h":
                self.usage(0)
            elif option == "--help":
                self.usage(0)

            elif option == "--tagged-since":
                if len(args) < 1:
                    self.usage(1)
                options["taggedSince"] = args[0]
                args = args[1:]
            elif option == "--tagged-until":
                if len(args) < 1:
                    self.usage(1)
                options["taggedUntil"] = args[0]
                args = args[1:]

            elif option == "--page-size":
                if len(args) < 1:
                    self.usage(1)
                options["pageSize"] = args[0]
                args = args[1:]

            else:
                eprint(
                    "%s %s: unrecognized  option %s"
                    % (self.progName, self.verbName, option)
                )
                sys.exit(1)

        if len(args) != 1:
            self.usage(1)
        tagName = args[0]

        tag_id = TE.Net.getTagIDFromName(tagName, options["showURLs"])
        if tag_id is None:
            eprint('Tag "%s" not found.' % tagName)
            sys.exit(1)

        # Step 1: tag text to ID
        # Step 2: tag ID to descriptor IDs, paginated
        # Step 3: descriptor IDs to descriptor details, paginated
        idProcessor = lambda idBatch: self.IDProcessor(idBatch)

        TE.Net.processDescriptorIDsByTagID(
            tag_id,
            idProcessor,
            verbose=options["verbose"],
            showURLs=options["showURLs"],
            taggedSince=options.get("taggedSince", None),
            taggedUnti=options.get("taggedUntil", None),
            pageSize=options["pageSize"],
        )