예제 #1
0
def main(input_args):
    """Parse input and run the program"""

    short_opts = "hiIpoF:"  # -i was option for default action
    # --installed is no longer needed, kept for compatibility (djanderson '09)
    long_opts = (
        "help",
        "installed",
        "exclude-installed",
        "portage-tree",
        "overlay-tree",
        "format=",
    )

    try:
        module_opts, queries = gnu_getopt(input_args, short_opts, long_opts)
    except GetoptError as err:
        sys.stderr.write(pp.error("Module %s" % err))
        print()
        print_help(with_description=False)
        sys.exit(2)

    parse_module_options(module_opts)

    if not queries:
        print_help()
        sys.exit(2)

    matches = Query("*").smart_find(**QUERY_OPTS)
    matches.sort()

    #
    # Output
    #

    first_run = True
    got_match = False
    for query in queries:
        if not first_run:
            print()

        if CONFIG["verbose"]:
            pp.uprint(" * Searching for USE flag %s ... " % pp.emph(query))

        for pkg in matches:
            if display_useflags(query, pkg):
                got_match = True

        first_run = False

    if not got_match:
        sys.exit(1)
예제 #2
0
def main(input_args):
	"""Parse input and run the program"""

	# -e, --exact-name is legacy option. djanderson '09
	short_opts = "hemstf:"
	long_opts = ('help', 'exact-name', 'md5sum', 'timestamp', 'type', 'tree',
		'filter=')

	try:
		module_opts, queries = gnu_getopt(input_args, short_opts, long_opts)
	except GetoptError as err:
		sys.stderr.write(pp.error("Module %s" % err))
		print()
		print_help(with_description=False)
		sys.exit(2)

	parse_module_options(module_opts)

	if not queries:
		print_help()
		sys.exit(2)

	# Turn off filtering for tree output
	if QUERY_OPTS["output_tree"]:
		QUERY_OPTS["type_filter"] = None

	#
	# Output files
	#

	first_run = True
	for query in queries:
		if not first_run:
			print()

		matches = Query(query).smart_find(**QUERY_OPTS)

		if not matches:
			sys.stderr.write(
				pp.error("No matching packages found for %s" % query)
			)

		matches.sort()

		for pkg in matches:
			if CONFIG['verbose']:
				pp.uprint(" * Contents of %s:" % pp.cpv(str(pkg.cpv)))

			contents = pkg.parsed_contents()
			display_files(filter_contents(contents))

		first_run = False
예제 #3
0
파일: files.py 프로젝트: pamxy/gentoolkit
def main(input_args):
    """Parse input and run the program"""

    # -e, --exact-name is legacy option. djanderson '09
    short_opts = "hemstf:"
    long_opts = ('help', 'exact-name', 'md5sum', 'timestamp', 'type', 'tree',
                 'filter=')

    try:
        module_opts, queries = gnu_getopt(input_args, short_opts, long_opts)
    except GetoptError as err:
        sys.stderr.write(pp.error("Module %s" % err))
        print()
        print_help(with_description=False)
        sys.exit(2)

    parse_module_options(module_opts)

    if not queries:
        print_help()
        sys.exit(2)

    # Turn off filtering for tree output
    if QUERY_OPTS["output_tree"]:
        QUERY_OPTS["type_filter"] = None

    #
    # Output files
    #

    first_run = True
    for query in queries:
        if not first_run:
            print()

        matches = Query(query).smart_find(**QUERY_OPTS)

        if not matches:
            sys.stderr.write(
                pp.error("No matching packages found for %s" % query))

        matches.sort()

        for pkg in matches:
            if CONFIG['verbose']:
                pp.uprint(" * Contents of %s:" % pp.cpv(str(pkg.cpv)))

            contents = pkg.parsed_contents()
            display_files(filter_contents(contents))

        first_run = False
예제 #4
0
def main(input_args):
	"""Parse input and run the program"""

	short_opts = "hiIpoF:" # -i was option for default action
	# --installed is no longer needed, kept for compatibility (djanderson '09)
	long_opts = ('help', 'installed', 'exclude-installed', 'portage-tree',
		'overlay-tree', 'format=')

	try:
		module_opts, queries = gnu_getopt(input_args, short_opts, long_opts)
	except GetoptError as err:
		sys.stderr.write(pp.error("Module %s" % err))
		print()
		print_help(with_description=False)
		sys.exit(2)

	parse_module_options(module_opts)

	if not queries:
		print_help()
		sys.exit(2)

	matches = Query("*").smart_find(**QUERY_OPTS)
	matches.sort()

	#
	# Output
	#

	first_run = True
	got_match = False
	for query in queries:
		if not first_run:
			print()

		if CONFIG['verbose']:
			pp.uprint(" * Searching for USE flag %s ... " % pp.emph(query))

		for pkg in matches:
			if display_useflags(query, pkg):
				got_match = True

		first_run = False

	if not got_match:
		sys.exit(1)
예제 #5
0
파일: has.py 프로젝트: zmedico/gentoolkit
def main(input_args):
	"""Parse input and run the program"""

	short_opts = "hiIpoF:" # -i was option for default action
	# --installed is no longer needed, kept for compatibility (djanderson '09)
	long_opts = ('help', 'installed', 'exclude-installed', 'portage-tree',
		'overlay-tree', 'format=', 'package=')

	try:
		module_opts, queries = gnu_getopt(input_args, short_opts, long_opts)
	except GetoptError as err:
		sys.stderr.write(pp.error("Module %s" % err))
		print()
		print_help(with_description=False)
		sys.exit(2)

	parse_module_options(module_opts)

	if not queries:
		print_help()
		sys.exit(2)

	query_scope = QUERY_OPTS['package_filter'] or '*'
	matches = Query(query_scope).smart_find(**QUERY_OPTS)
	matches.sort()

	# split out the first query since it is suppose to be the env_var
	QUERY_OPTS['env_var'] = queries.pop(0)
	env_var = QUERY_OPTS['env_var']

	#
	# Output
	#

	if not queries:
		if not QUERY_OPTS['package_filter']:
			err = "Used ENV_VAR without match_expression or --package"
			raise errors.GentoolkitFatalError(err, is_serious=False)
		else:
			if len(matches) > 1:
				raise errors.AmbiguousPackageName(matches)
			for match in matches:
				env = QUERY_OPTS['env_var']
				print(match.environment(env))

	first_run = True
	got_match = False
	for query in queries:
		if not first_run:
			print()

		if CONFIG['verbose']:
			status = " * Searching for {0} {1} ... "
			pp.uprint(status.format(env_var, pp.emph(query)))

		for pkg in matches:
			if query_in_env(query, env_var, pkg):
				display_pkg(query, env_var, pkg)
				got_match = True
		first_run = False

	if not got_match:
		sys.exit(1)
예제 #6
0
def main(input_args):
    """Parse input and run the program"""

    short_opts = "hiIpoF:"  # -i was option for default action
    # --installed is no longer needed, kept for compatibility (djanderson '09)
    long_opts = ('help', 'installed', 'exclude-installed', 'portage-tree',
                 'overlay-tree', 'format=', 'package=')

    try:
        module_opts, queries = gnu_getopt(input_args, short_opts, long_opts)
    except GetoptError as err:
        sys.stderr.write(pp.error("Module %s" % err))
        print()
        print_help(with_description=False)
        sys.exit(2)

    parse_module_options(module_opts)

    if not queries:
        print_help()
        sys.exit(2)

    query_scope = QUERY_OPTS['package_filter'] or '*'
    matches = Query(query_scope).smart_find(**QUERY_OPTS)
    matches.sort()

    # split out the first query since it is suppose to be the env_var
    QUERY_OPTS['env_var'] = queries.pop(0)
    env_var = QUERY_OPTS['env_var']

    #
    # Output
    #

    if not queries:
        if not QUERY_OPTS['package_filter']:
            err = "Used ENV_VAR without match_expression or --package"
            raise errors.GentoolkitFatalError(err, is_serious=False)
        else:
            if len(matches) > 1:
                raise errors.AmbiguousPackageName(matches)
            for match in matches:
                env = QUERY_OPTS['env_var']
                print(match.environment(env))

    first_run = True
    got_match = False
    for query in queries:
        if not first_run:
            print()

        if CONFIG['verbose']:
            status = " * Searching for {0} {1} ... "
            pp.uprint(status.format(env_var, pp.emph(query)))

        for pkg in matches:
            if query_in_env(query, env_var, pkg):
                display_pkg(query, env_var, pkg)
                got_match = True
        first_run = False

    if not got_match:
        sys.exit(1)