/usr/lib/python3/dist-packages/tldextract/cli.py is in python3-tldextract 2.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | '''tldextract CLI'''
import logging
try:
import pkg_resources
__version__ = pkg_resources.get_distribution('tldextract').version # pylint: disable=no-member
except ImportError:
__version__ = '(local)'
except pkg_resources.DistributionNotFound:
__version__ = '(local)'
from .tldextract import TLDExtract
try:
unicode
except NameError:
unicode = str # pylint: disable=invalid-name,redefined-builtin
def main():
'''tldextract CLI main command.'''
import argparse
logging.basicConfig()
parser = argparse.ArgumentParser(
prog='tldextract',
description='Parse hostname from a url or fqdn')
parser.add_argument('--version', action='version', version='%(prog)s ' + __version__) # pylint: disable=no-member
parser.add_argument('input', metavar='fqdn|url',
type=unicode, nargs='*', help='fqdn or url')
parser.add_argument('-u', '--update', default=False, action='store_true',
help='force fetch the latest TLD definitions')
parser.add_argument('-c', '--cache_file',
help='use an alternate TLD definition file')
parser.add_argument('-p', '--private_domains', default=False, action='store_true',
help='Include private domains')
args = parser.parse_args()
tld_extract = TLDExtract(include_psl_private_domains=args.private_domains)
if args.cache_file:
tld_extract.cache_file = args.cache_file
if args.update:
tld_extract.update(True)
elif len(args.input) is 0:
parser.print_usage()
exit(1)
for i in args.input:
print(' '.join(tld_extract(i))) # pylint: disable=superfluous-parens
|