sandbox_registry.py 746 B

123456789101112131415161718192021
  1. import os
  2. import ymake
  3. def onregister_sandbox_import(unit, *args):
  4. args = iter(args)
  5. for path in args:
  6. path = os.path.normpath(path)
  7. source = unit.resolve_arc_path(path)
  8. abs_source = unit.resolve(source)
  9. if not os.path.exists(abs_source):
  10. ymake.report_configure_error('REGISTER_SANDBOX_IMPORT: File or directory {} does not exists'.format(path))
  11. splited_path = path.split(os.sep)
  12. l, r = 0, len(splited_path)
  13. if splited_path[-1] == "__init__.py":
  14. r -= 1
  15. if not splited_path[0]:
  16. l += 1
  17. path = ".".join(splited_path[l:r])
  18. unit.onresource(["-", "{}.{}={}".format("SANDBOX_TASK_REGISTRY", path, path)])