From e43e939ce0db4a26602a882f9d575afd1793c805 Mon Sep 17 00:00:00 2001 From: Shuning Bian Date: Sat, 15 Dec 2018 13:09:11 +0000 Subject: [PATCH] Adds info subcommand --- shputil.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shputil.py b/shputil.py index c407cfe..11e0c23 100755 --- a/shputil.py +++ b/shputil.py @@ -100,6 +100,15 @@ def list_fields(shp_file): ftype_desc_tab[ftype], flen)) +@shp_util.command() +@click.argument('shp_file', type=click.Path(dir_okay=False)) +def info(shp_file): + """ + Prints metadata about the shp_file. + """ + with shapefile.Reader(shp_file) as sf: + print('Shape type:', sf.shapeTypeName) + print('Number of records:', len(sf)) if __name__ == '__main__': import sys