暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.py 862B

1234567891011121314151617181920
  1. import os
  2. ## @brief Registers a lodelsite
  3. #
  4. # Each lodelsite is a Flask Blueprint.
  5. #
  6. # @param lodelapp Flask : application in which the lodelsite will be registered
  7. # @param sitepath str
  8. # @todo Use the main settings to get the lodelsites_main_module value
  9. def register_lodelsites(lodelapp):
  10. lodelsites_main_module = 'sites'
  11. lodelsites_main_module_path = os.path.abspath(lodelsites_main_module)
  12. sitenames = os.listdir(lodelsites_main_module_path)
  13. for sitename in sitenames:
  14. # We check if the found item is a python package
  15. if os.path.isfile('%s/%s/__init__.py' % (lodelsites_main_module_path, sitename)):
  16. module = __import__('%s.%s' % (lodelsites_main_module, sitename), globals(), locals(), [sitename], 0)
  17. bp = getattr(module, 'lodelsite_%s' % sitename)
  18. lodelapp.register_blueprint(bp)