No Description
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 778B

12345678910111213141516171819202122232425262728293031
  1. import tempfile
  2. import shutil
  3. import sys
  4. import EditorialModel
  5. import leobject
  6. from EditorialModel.backend.json_backend import EmBackendJson
  7. from leobject.datasources.dummy import DummyDatasource
  8. from leobject.lefactory import LeFactory
  9. genepy_args = {
  10. 'backend_cls': EmBackendJson,
  11. 'backend_args': {'json_file': 'EditorialModel/test/me.json'},
  12. 'datasource_cls': DummyDatasource,
  13. 'datasource_args': {}
  14. }
  15. def tmp_load_factory_code(name='dyncode'):
  16. tmpdir = tempfile.mkdtemp('_lodel2_test_dyncode')
  17. fname = tmpdir+'/%s.py'%name
  18. with open(fname, 'w+') as dynfp:
  19. dynfp.write(LeFactory.generate_python(**genepy_args))
  20. sys.path.append(tmpdir)
  21. LeFactory.modname = name
  22. return tmpdir
  23. def cleanup(tmpdir):
  24. shutil.rmtree(tmpdir)