Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

__init__.py 1.4 KiB

před 14 roky
před 13 roky
před 13 roky
před 11 roky
před 11 roky
před 11 roky
před 13 roky
před 13 roky
před 11 roky
před 11 roky
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
  2. # MIT License. See license.txt
  3. from __future__ import unicode_literals
  4. """
  5. Utilities for using modules
  6. """
  7. import webnotes, os
  8. from webnotes import conf
  9. import webnotes.utils
  10. lower_case_files_for = ['DocType', 'Page', 'Report',
  11. "Workflow", 'Module Def', 'Desktop Item', 'Workflow State', 'Workflow Action']
  12. def scrub(txt):
  13. return webnotes.scrub(txt)
  14. def scrub_dt_dn(dt, dn):
  15. """Returns in lowercase and code friendly names of doctype and name for certain types"""
  16. ndt, ndn = dt, dn
  17. if dt in lower_case_files_for:
  18. ndt, ndn = scrub(dt), scrub(dn)
  19. return ndt, ndn
  20. def get_module_path(module):
  21. """Returns path of the given module"""
  22. return webnotes.get_module_path(module)
  23. def get_doc_path(module, doctype, name):
  24. dt, dn = scrub_dt_dn(doctype, name)
  25. return os.path.join(get_module_path(module), dt, dn)
  26. def reload_doc(module, dt=None, dn=None, force=True):
  27. from webnotes.modules.import_file import import_files
  28. return import_files(module, dt, dn, force=force)
  29. def export_doc(doctype, name, module=None):
  30. """write out a doc"""
  31. from webnotes.modules.export_file import write_document_file
  32. import webnotes.model.doc
  33. if not module: module = webnotes.conn.get_value(doctype, name, 'module')
  34. write_document_file(webnotes.model.doc.get(doctype, name), module)
  35. def get_doctype_module(doctype):
  36. return webnotes.conn.get_value('DocType', doctype, 'module') or "core"