def get_reports(self, domain=None): attr_name = self.map_name from corehq import reports if domain: project = Domain.get_by_name(domain) else: project = None def process(reports): if project and callable(reports): reports = reports(project) return tuple(reports) corehq_reports = process(getattr(reports, attr_name, ())) module_name = get_domain_module_map().get(domain) if module_name is None: custom_reports = () else: module = __import__(module_name, fromlist=['reports']) if hasattr(module, 'reports'): reports = getattr(module, 'reports') custom_reports = process(getattr(reports, attr_name, ())) else: custom_reports = () # soon to be removed if not custom_reports: domain_module = Domain.get_module_by_name(domain) custom_reports = process(getattr(domain_module, attr_name, ())) return corehq_reports + custom_reports
def get_module_by_name(cls, domain_name): """ import and return the python module corresponding to domain_name, or None if it doesn't exist. """ from corehq.apps.domain.utils import get_domain_module_map module_name = get_domain_module_map().get(domain_name, domain_name) try: return import_module(module_name) if module_name else None except ImportError: return None
def get_module_by_name(cls, domain_name): """ import and return the python module corresponding to domain_name, or None if it doesn't exist. """ module_name = get_domain_module_map().get(domain_name, domain_name) try: return import_module(module_name) if module_name else None except ImportError: return None
def get_module_by_name(cls, domain_name): """ import and return the python module corresponding to domain_name, or None if it doesn't exist. """ module_name = get_domain_module_map().get(domain_name, domain_name) try: return __import__(module_name) if module_name else None except ImportError: return None