def test_extract_gist_id(self): assert (extract_gist_id("https://gist.github.com/jacobtomlinson/" "c9852fa17d3463acc14dca1217d911f6") == "c9852fa17d3463acc14dca1217d911f6") assert (extract_gist_id("c9852fa17d3463acc14dca1217d911f6") == "c9852fa17d3463acc14dca1217d911f6")
def test_extract_gist_id(self): self.assertEqual( extract_gist_id("https://gist.github.com/jacobtomlinson/" "c9852fa17d3463acc14dca1217d911f6"), "c9852fa17d3463acc14dca1217d911f6") self.assertEqual(extract_gist_id("c9852fa17d3463acc14dca1217d911f6"), "c9852fa17d3463acc14dca1217d911f6")
def test_extract_gist_id(self): self.assertEqual( extract_gist_id( "https://gist.github.com/jacobtomlinson/" "c9852fa17d3463acc14dca1217d911f6"), "c9852fa17d3463acc14dca1217d911f6") self.assertEqual( extract_gist_id("c9852fa17d3463acc14dca1217d911f6"), "c9852fa17d3463acc14dca1217d911f6")
def _install_gist_module(self, config): gist_id = extract_gist_id(config['gist']) # Get the content of the gist req = urllib.request.Request( "https://api.github.com/gists/{}".format(gist_id)) cont = json.loads(urllib.request.urlopen(req).read().decode('utf-8')) python_files = [ cont["files"][file] for file in cont["files"] if '.ipynb' in cont["files"][file]["filename"] or '.py' in cont["files"][file]["filename"] ] # We only support one skill file in a gist for now. # # TODO: Add support for mutliple files. Could be particularly # useful for including a requirements.txt file. skill_content = python_files[0]["content"] extension = os.path.splitext(python_files[0]["filename"])[1] with tempfile.NamedTemporaryFile('w', delete=False, suffix=extension) as skill_file: skill_file.write(skill_content) skill_file.flush() # Set the path in the config config["path"] = skill_file.name # Run local install self._install_local_module(config)
def _install_gist_module(self, config): gist_id = extract_gist_id(config['gist']) # Get the content of the gist req = urllib.request.Request( "https://api.github.com/gists/{}".format(gist_id)) cont = json.loads(urllib.request.urlopen(req).read().decode('utf-8')) python_files = [cont["files"][file] for file in cont["files"] if '.ipynb' in cont["files"][file]["filename"] or '.py' in cont["files"][file]["filename"]] # We only support one skill file in a gist for now. # # TODO: Add support for mutliple files. Could be particularly # useful for including a requirements.txt file. skill_content = python_files[0]["content"] extension = os.path.splitext(python_files[0]["filename"])[1] with tempfile.NamedTemporaryFile('w', delete=False, suffix=extension) as skill_file: skill_file.write(skill_content) skill_file.flush() # Set the path in the config config["path"] = skill_file.name # Run local install self._install_local_module(config)