Mercurial > hg > config
view python/find_duplicate_files.py @ 799:dbd2562cb03e
remove old way of doing things; note TODO on replacing
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 28 Oct 2016 16:06:11 -0700 |
parents | ab831c7621e9 |
children | bea4dd61ae45 |
line wrap: on
line source
#!/usr/bin/env python # -*- coding: utf-8 -*- """ find duplicate files in a directory """ # imports import argparse import os import subprocess import sys class DuplicateFilesParser(argparse.ArgumentParser): """CLI option parser""" def __init__(self, **kwargs): kwargs.setdefault('description', __doc__) argparse.ArgumentParser.__init__(self, **kwargs) self.add_argument('directory') self.options = None def parse_args(self, *args, **kw): options = argparse.ArgumentParser.parse_args(self, *args, **kw) self.validate(options) self.options = options return options def validate(self, options): """validate options""" if not os.path.isdir(options.directory): self.error("Not a directory: {}".format(options.directory)) def main(args=sys.argv[1:]): """CLI""" # parse command line options parser = DuplicateFilesParser() options = parser.parse_args(args) # get all files raise NotImplementedError('TODO') # -> record TODO items if __name__ == '__main__': main()