api.py 782 B

1234567891011121314151617181920212223242526272829303132333435
  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():
  10. path = Demeter.path + Demeter.web + '/page/'
  11. files = os.listdir(path)
  12. result = []
  13. for key in files:
  14. if '.DS_Store' not in key and '__' not in key and 'pyc' not in key:
  15. key = key.replace('.py', '')
  16. result.append(key)
  17. return result
  18. def loadUrl(module, key, url):
  19. str = dir(module)
  20. for i in str:
  21. act = ''
  22. if '_path' in i:
  23. act = i.replace('_path', '')
  24. if '_html' in i:
  25. act = i.replace('_html', '.html')
  26. if act:
  27. attr = getattr(module, i)
  28. if key == 'main' and act == 'index':
  29. url.append((r'/', attr))
  30. elif key == act:
  31. url.append((r'/'+act, attr))
  32. url.append((r'/'+key+'/'+act, attr))
  33. return url