def test_show_versions_with_proj(capsys): show_versions() out, err = capsys.readouterr() assert "System" in out assert "python" in out assert "PROJ" in out assert "data dir" in out assert "Python deps" in out
def main(): """ Main entrypoint into the command line interface. """ args = parser.parse_args() if hasattr(args, "bbox"): _parse_sync_command(args) elif args.verbose: _show_versions.show_versions() else: parser.print_help()
""" This is the main entry point for pyproj e.g. python -m pyproj """ import argparse from pyproj import __proj_version__, __version__, _show_versions parser = argparse.ArgumentParser() parser.add_argument( "-v", "--verbose", help="Show verbose debugging version information.", action="store_true", ) args = parser.parse_args() if args.verbose: _show_versions.show_versions() else: print(f"pyproj version: {__version__} [PROJ version: {__proj_version__}]") parser.print_help()
def main(): args = parser.parse_args() if hasattr(args, "bbox") and any(( args.bbox, args.list_files, args.all, args.source_id, args.area_of_use, args.file, )): if args.all and (args.list_files or args.source_id or args.area_of_use or args.file or args.bbox): raise RuntimeError( "Cannot use '--all' with '--list-files', '--source-id'," "'--area-of-use', '--bbox', or '--file'.") bbox = None if args.bbox is not None: west, south, east, north = args.bbox.split(",") bbox = BBox( west=float(west), south=float(south), east=float(east), north=float(north), ) if args.target_directory and args.system_directory: raise RuntimeError( "Cannot set both --target-directory and --system-directory.") target_directory = args.target_directory if args.system_directory: target_directory = get_data_dir().split(os.path.sep)[0] elif not target_directory: target_directory = get_user_data_dir(True) grids = get_transform_grid_list( source_id=args.source_id, area_of_use=args.area_of_use, filename=args.file, bbox=bbox, spatial_test=args.spatial_test, include_world_coverage=not args.exclude_world_coverage, include_already_downloaded=args.include_already_downloaded, target_directory=target_directory, ) if args.list_files: print("filename | source_id | area_of_use") print("----------------------------------") else: endpoint = get_proj_endpoint() for grid in grids: if args.list_files: print( grid["properties"]["name"], grid["properties"]["source_id"], grid["properties"].get("area_of_use"), sep=" | ", ) else: filename = grid["properties"]["name"] _download_resource_file( file_url=f"{endpoint}/{filename}", short_name=filename, directory=target_directory, verbose=args.verbose, sha256=grid["properties"]["sha256sum"], ) elif not hasattr(args, "bbox") and args.verbose: _show_versions.show_versions() elif hasattr(args, "bbox"): sync_parser.print_help() else: parser.print_help()