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:]
elif option == "--no-print-indicator":
if len(args) < 1:
self.usage(1)
options["includeIndicatorInOutput"] = False
else:
eprint(
"%s %s: unrecognized option %s"
% (self.progName, self.verbName, option)
)
sys.exit(1)
ids = []
if len(args) > 0:
ids = args
else:
while True:
# Python line-reader returns the trailing newlines so
# we need to right-strip the lines
line = sys.stdin.readline()
if line == "":
break
ids.append(line.rstrip())
for id in ids:
idBatch = [id]
descriptors = TE.Net.getInfoForIDs(
idBatch,
verbose=options["verbose"],
showURLs=options["showURLs"],
includeIndicatorInOutput=options["includeIndicatorInOutput"],
)
for descriptor in descriptors:
print(json.dumps(descriptor))