tools/android/dependency_analysis/print_package_dependencies.py
def main():
    """Prints package-level dependencies for an input package."""
    arg_parser = argparse.ArgumentParser(
        description='Given a JSON dependency graph, output the package-level '
        'dependencies for a given package and the '
        'class dependencies comprising those dependencies')
    required_arg_group = arg_parser.add_argument_group('required arguments')
    required_arg_group.add_argument(
        '-f',
        '--file',
        required=True,
        help='Path to the JSON file containing the dependency graph. '
        'See the README on how to generate this file.')
    required_arg_group.add_argument(
        '-p',
        '--package',
        required=True,
        help='Case-insensitive name of the package to print dependencies for. '
        'Matches names of the form ...input, for example '
        '`browser` matches `org.chromium.browser`.')
    optional_arg_group = arg_parser.add_argument_group('optional arguments')
    optional_arg_group.add_argument(
        '-s',
        '--ignore-subpackages',
        action='store_true',
        help='If present, this tool will ignore dependencies between the '
        'given package and subpackages. For example, if given '
        'browser.customtabs, it won\'t print a dependency between '
        'browser.customtabs and browser.customtabs.content.')
    arguments = arg_parser.parse_args()

    _, package_graph, _ = serialization.load_class_and_package_graphs_from_file(
        arguments.file)
    package_graph_keys = [node.name for node in package_graph.nodes]
    valid_keys = print_dependencies_helper.get_valid_package_keys_matching(
        package_graph_keys, arguments.package)

    if len(valid_keys) == 0:
        print(f'No package found by the name {arguments.package}.')
    elif len(valid_keys) > 1:
        print(f'Multiple valid keys found for the name {arguments.package}, '
              'please disambiguate between one of the following options:')
        for valid_key in valid_keys:
            print(f'\t{valid_key}')
    else:
        print(f'Printing package dependencies for {valid_keys[0]}:')
        print_package_dependencies_for_key(package_graph, valid_keys[0],
                                           arguments.ignore_subpackages)
Prints package-level dependencies for an input package.
Prints package-level dependencies for an input package.
Prints package - level dependencies for an input package .
def main():
    arg_parser = argparse.ArgumentParser(
        description='Given a JSON dependency graph, output the package-level '
        'dependencies for a given package and the '
        'class dependencies comprising those dependencies')
    required_arg_group = arg_parser.add_argument_group('required arguments')
    required_arg_group.add_argument(
        '-f',
        '--file',
        required=True,
        help='Path to the JSON file containing the dependency graph. '
        'See the README on how to generate this file.')
    required_arg_group.add_argument(
        '-p',
        '--package',
        required=True,
        help='Case-insensitive name of the package to print dependencies for. '
        'Matches names of the form ...input, for example '
        '`browser` matches `org.chromium.browser`.')
    optional_arg_group = arg_parser.add_argument_group('optional arguments')
    optional_arg_group.add_argument(
        '-s',
        '--ignore-subpackages',
        action='store_true',
        help='If present, this tool will ignore dependencies between the '
        'given package and subpackages. For example, if given '
        'browser.customtabs, it won\'t print a dependency between '
        'browser.customtabs and browser.customtabs.content.')
    arguments = arg_parser.parse_args()
    _, package_graph, _ = serialization.load_class_and_package_graphs_from_file(
        arguments.file)
    package_graph_keys = [node.name for node in package_graph.nodes]
    valid_keys = print_dependencies_helper.get_valid_package_keys_matching(
        package_graph_keys, arguments.package)
    if len(valid_keys) == 0:
        print(f'No package found by the name {arguments.package}.')
    elif len(valid_keys) > 1:
        print(f'Multiple valid keys found for the name {arguments.package}, '
              'please disambiguate between one of the following options:')
        for valid_key in valid_keys:
            print(f'\t{valid_key}')
    else:
        print(f'Printing package dependencies for {valid_keys[0]}:')
        print_package_dependencies_for_key(package_graph, valid_keys[0],
                                           arguments.ignore_subpackages)
def main ( ) : arg_parser = argparse . ArgumentParser ( description = 'Given a JSON dependency graph, output the package-level ' 'dependencies for a given package and the ' 'class dependencies comprising those dependencies' ) required_arg_group = arg_parser . add_argument_group ( 'required arguments' ) required_arg_group . add_argument ( '-f' , '--file' , required = True , help = 'Path to the JSON file containing the dependency graph. ' 'See the README on how to generate this file.' ) required_arg_group . add_argument ( '-p' , '--package' , required = True , help = 'Case-insensitive name of the package to print dependencies for. ' 'Matches names of the form ...input, for example ' '`browser` matches `org.chromium.browser`.' ) optional_arg_group = arg_parser . add_argument_group ( 'optional arguments' ) optional_arg_group . add_argument ( '-s' , '--ignore-subpackages' , action = 'store_true' , help = 'If present, this tool will ignore dependencies between the ' 'given package and subpackages. For example, if given ' 'browser.customtabs, it won\'t print a dependency between ' 'browser.customtabs and browser.customtabs.content.' ) arguments = arg_parser . parse_args ( ) _ , package_graph , _ = serialization . load_class_and_package_graphs_from_file ( arguments . file ) package_graph_keys = [ node . name for node in package_graph . nodes ] valid_keys = print_dependencies_helper . get_valid_package_keys_matching ( package_graph_keys , arguments . package ) if len ( valid_keys ) == 0 : print ( f'No package found by the name {arguments.package}.' ) elif len ( valid_keys ) > 1 : print ( f'Multiple valid keys found for the name {arguments.package}, ' 'please disambiguate between one of the following options:' ) for valid_key in valid_keys : print ( f'\t{valid_key}' ) else : print ( f'Printing package dependencies for {valid_keys[0]}:' ) print_package_dependencies_for_key ( package_graph , valid_keys [ 0 ] , arguments . ignore_subpackages )
Prints package-level dependencies for an input package.
Prints package - level dependencies for an input package .
"""Prints package-level dependencies for an input package."""