예제 #1
0
파일: cli.py 프로젝트: pumazi/pkgmeta
def main():
    """CLI main function"""
    parser = argparse.ArgumentParser(description="Tool for working with a "
                                                 "Python package repository")
    parser.add_argument('-c', '--configuration', metavar='CONFIG', nargs=1,
                        default=DEFAULT_CONFIG,
                        help="repository configuration file location")
    parser.add_argument('-r', '--repository-name', nargs=1,
                        # Default is handled by the
                        # Config.get_repository_config method.
                        help="a specific non-default repository name, "
                             "defaults to the default repository")
    subparsers = parser.add_subparsers(dest="command",
                                       help="sub-commands, use --help with "
                                            "action for more help")
    commands.init_subcommands(subparsers)

    args = parser.parse_args()

    # Process action
    cmd = commands[args.command]
    # Retrieve the repository configuration
    config_file = args.configuration[0]
    if config_file is not None:
        config_file = os.path.expanduser(config_file)
    config = PkgMetaConfig.from_file(config_file)
    repo_config = config.get_repository_config(args.repository_name)
    # Run the command
    return cmd(repo_config, args)
예제 #2
0
파일: make.py 프로젝트: pumazi/pkgmeta
def main():
    # Must create the repository location before we read in the configuration.
    repository_location = os.path.expanduser('~/example-repo')
    if not os.path.exists(repository_location):
        print("Creating the repository directory:  %s" % repository_location)
        os.mkdir(repository_location)

        print("Populating repository with example data...")
        populate_repo(ALL_DISTS, repository_location)

    cfg_file_in = os.path.join(HERE, 'example.cfg.in')
    cfg_file = os.path.expanduser('~/example.cfg')
    with open(cfg_file, 'w') as out_file:
        with open(cfg_file_in, 'r') as in_file:
            out_file.write(in_file.read() % repository_location)
    print("Writing configuration:  %s" % cfg_file)

    print("Reading configuration...")
    config = PkgMetaConfig.from_file(cfg_file)
    repo_config = config.get_repository_config()

    repo = Repository(repo_config)
    print("Loaded %s distributions into the repository" % len(repo))
    print("-" * 80)
    print("You can now use the example data by supplying the pkgmeta script "
          "with the configuration file flag:  -c ~/example.cfg")
예제 #3
0
 def make_one(self, file):
     from pkgmeta.config import PkgMetaConfig
     return PkgMetaConfig.from_file(file)