def _install_local_module(config): """Install a module from a local path.""" installed = False config["path"] = os.path.expanduser(config["path"]) installdir, _ = os.path.split(config["install_path"]) if not os.path.isdir(installdir): os.makedirs(installdir, exist_ok=True) if os.path.isdir(config["path"]): shutil.copytree(config["path"], config["install_path"]) installed = True if os.path.isfile(config["path"]): os.makedirs(config["install_path"], exist_ok=True) init_path = os.path.join(config["install_path"], "__init__.py") if file_is_ipython_notebook(config["path"]): convert_ipynb_to_script(config["path"], init_path) else: shutil.copyfile(config["path"], init_path) installed = True if not installed: _LOGGER.error("Failed to install from %s", str(config["path"]))
def _install_local_module(self, config): """Install a module from a local path. Args: config: dict of module config fields """ installed = False config["path"] = os.path.expanduser(config["path"]) installdir, _ = os.path.split(config["install_path"]) if not os.path.isdir(installdir): os.makedirs(installdir, exist_ok=True) if os.path.isdir(config["path"]): shutil.copytree(config["path"], config["install_path"]) installed = True if os.path.isfile(config["path"]): os.makedirs(config["install_path"], exist_ok=True) init_path = os.path.join(config["install_path"], "__init__.py") if file_is_ipython_notebook(config["path"]): convert_ipynb_to_script(config["path"], init_path) else: shutil.copyfile(config["path"], init_path) installed = True if not installed: _LOGGER.error("Failed to install from %s.", str(config["path"])) else: self.opsdroid.reload_paths.append(config["path"])
def test_file_is_ipython_notebook(self): assert file_is_ipython_notebook("test.ipynb") is True assert file_is_ipython_notebook("test.py") is False
def test_file_is_ipython_notebook(self): self.assertTrue(file_is_ipython_notebook('test.ipynb')) self.assertFalse(file_is_ipython_notebook('test.py'))
def test_file_is_ipython_notebook(self): self.assertTrue(file_is_ipython_notebook('test.ipynb')) self.assertFalse(file_is_ipython_notebook('test.py'))