code: def import_app_factory(self):
          
          rel_py_file = self.py_file.relative_to(self.python_path)
          module_path = '.'.join(rel_py_file.with_suffix('').parts)
  
          sys.path.append(str(self.python_path))
          try:
              module = import_module(module_path)
          except ImportError as e:
              raise AdevConfigError('error importing "{}" '
                                    'from "{}": {}'.format(module_path, self.python_path, e)) from e
  
          logger.debug('successfully loaded "%s" from "%s"', module_path, self.python_path)
  
          if self.app_factory_name is None:
              try:
                  self.app_factory_name = next(an for an in APP_FACTORY_NAMES if hasattr(module, an))
              except StopIteration as e:
                  raise AdevConfigError('No name supplied and no default app factory '
                                        'found in {s.py_file.name}'.format(s=self)) from e
              else:
                  logger.debug('found default attribute "%s" in module "%s"',
                               self.app_factory_name, module)
  
          try:
              attr = getattr(module, self.app_factory_name)
          except AttributeError as e:
              raise AdevConfigError('Module "{s.py_file.name}" '
                                    'does not define a "{s.app_factory_name}" attribute/class'.format(s=self)) from e
  
          self.watch_path = self.watch_path or Path(module.__file__).parent
          return attr
docs: Import attribute/class from from a python module. Raise AdevConfigError if the import failed.
  
          :return: (attribute, Path object for directory of file)