Mercurial > hg > config
view python/find_duplicate_files.py @ 820:737b9eda7f77
[git submodules] logging stub
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 31 Jan 2017 14:31:03 -0800 |
parents | bea4dd61ae45 |
children | aa9a3850ed56 |
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()