mkdir_2.py 715 B

12345678910111213141516171819202122232425
  1. def main():
  2. usage = '%prog path [path2] [path3] [pathN]\n\n' + __doc__.strip()
  3. parser = OptionParser(usage=usage, option_list=(
  4. make_option('-v', '--verbose', default=False, action='store_true'),
  5. ))
  6. options, args = parser.parse_args()
  7. if len(args) == 0:
  8. parser.error('No paths given.')
  9. output = sys.stdout if options.verbose else None
  10. for index, path in enumerate(args):
  11. path = path.replace('.', os.path.sep)
  12. if output and index > 0:
  13. output.write('\n')
  14. try:
  15. pydir(path, output=output)
  16. except BaseException as exc:
  17. print ('Couldn\'t create %s: %s' % (path, exc,))