api.py 740 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter init
  5. author:rabin
  6. """
  7. import os
  8. from demeter.core import *
  9. def loadFile(path):
  10. files = os.listdir(path)
  11. result = []
  12. for key in files:
  13. if '.DS_Store' not in key and '__' not in key and 'pyc' not in key:
  14. key = key.replace('.py', '')
  15. result.append(key)
  16. return result
  17. def loadUrl(module, key, url):
  18. str = dir(module)
  19. for i in str:
  20. act = ''
  21. if '_path' in i:
  22. act = i.replace('_path', '')
  23. if '_html' in i:
  24. act = i.replace('_html', '.html')
  25. if act:
  26. attr = getattr(module, i)
  27. if key == 'main' and act == 'index':
  28. url.append((r'/', attr))
  29. elif key == act:
  30. url.append((r'/'+act, attr))
  31. url.append((r'/'+key+'/'+act, attr))
  32. return url