A bin folder, holding helpfull scripts and commands
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/home/dirk/bin/venv/bin/python
  2. # -*- coding: UTF-8 -*-
  3. import optparse
  4. import os
  5. repolist = []
  6. def findrepos(p, **kwargs):
  7. depth = kwargs.get('depth', 0)
  8. max_depth = kwargs.get('max_depth')
  9. ld = os.listdir(p)
  10. if '.git' in ld:
  11. if os.path.isdir(os.path.join(p, '.git')):
  12. repolist.append(p)
  13. return
  14. else:
  15. for entry in ld:
  16. np = os.path.join(p, entry)
  17. if os.path.isdir(np):
  18. findrepos(np, depth=depth+1, max_depth=max_depth)
  19. if __name__ == "__main__":
  20. parser = optparse.OptionParser("usage: %%prog target_path [opions]")
  21. parser.add_option("-d", "--depth", dest="depth", default=None, type="int", help="Folder depth to search for a repo")
  22. parser.add_option("-p", "--human-readable", dest="human_readable", action="store_true", default=False, help="Print a human readable list")
  23. (options, args) = parser.parse_args()
  24. if len(args) != 1:
  25. parser.print_help()
  26. else:
  27. findrepos(args[0])
  28. repolist.sort()
  29. if options.human_readable:
  30. print('- ' + '\n- '.join(repolist), '\n')
  31. else:
  32. print(' '.join(repolist))