Пример #1
0
    def test_url(self):
        url_no_branch = "https://github.com/JarbasSkills/skill-ddg"
        url_branch = "https://github.com/JarbasSkills/skill-ddg/tree/v0.1.0"
        blob_url = "https://github.com/OpenVoiceOS/OVOS-skills-store/blob" \
                   "/f4ab4ea00e47955798c9906c8c03807391bc20f0/skill-icanhazdadjokes.json"

        self.assertEqual(get_branch_from_github_url(url_branch), "v0.1.0")
        self.assertEqual(get_branch_from_github_url(blob_url),
                         "f4ab4ea00e47955798c9906c8c03807391bc20f0")
        self.assertRaises(GithubInvalidBranch, get_branch_from_github_url,
                          url_no_branch)
Пример #2
0
 def test_get_branch_from_url_at(self):
     from ovos_skills_manager.github import get_branch_from_github_url
     self.assertEqual(
         get_branch_from_github_url(
             "https://github.com/OpenVoiceOS/[email protected]",
             True), "v0.2.1")
     self.assertEqual(
         get_branch_from_github_url(
             "https://github.com/OpenVoiceOS/[email protected]",
             True), "v0.2.1")
     self.assertEqual(
         get_branch_from_github_url(
             "https://github.com/OpenVoiceOS/tskill-osm_parsing@master",
             True), "master")
Пример #3
0
 def from_github_url(url, branch: str = None, parse_github: bool = True):
     if not branch:
         try:
             branch = get_branch_from_github_url(url)
         except GithubInvalidBranch:
             branch = None
     url = normalize_github_url(url)
     return SkillEntry.from_json({
         "url": url,
         "branch": branch
     },
                                 parse_github=parse_github)
Пример #4
0
 def search_skills_by_url(self, url, as_json=False):
     query = Query(self.db)
     try:
         # if branch implicit in url, be sure to use it!
         branch = get_branch_from_github_url(url)
     except GithubInvalidBranch:
         branch = None
     url = normalize_github_url(url)
     query.equal("url", url, ignore_case=True)
     results = query.result
     for idx in range(0, len(results)):
         if "appstore" not in results[idx]:
             results[idx]["appstore"] = self.appstore_id
         if branch:
             # TODO what if branch does not exist? should throw exception
             results[idx]["branch"] = branch
     if as_json:
         return query.result
     return [SkillEntry.from_json(s, parse_github=False) for s in results]
Пример #5
0
 def test_get_branch_from_url_invalid(self):
     from ovos_skills_manager.exceptions import GithubInvalidBranch
     from ovos_skills_manager.github import get_branch_from_github_url
     with self.assertRaises(GithubInvalidBranch):
         get_branch_from_github_url(
             "https://github.com/OpenVoiceOS/tskill-osm_parsing")
     with self.assertRaises(GithubInvalidBranch):
         get_branch_from_github_url(
             "https://github.com/OpenVoiceOS/tskill-osm_parsing/tree/INVALID_BRANCH",
             True)
     with self.assertRaises(GithubInvalidBranch):
         get_branch_from_github_url(
             "https://github.com/OpenVoiceOS/tskill-osm_parsing@INVALID_BRANCH",
             True)
Пример #6
0
 def skill_entry_from_url(url: str):
     """
     Builds a minimal SkillEntry object from the passed GitHub URL to use for skill installation
     :param url: URL of skill to install
     :return: SkillEntry object with url, branch, requirements, and authorname populated
     """
     from ovos_skills_manager.exceptions import GithubInvalidBranch, GithubFileNotFound
     from ovos_skills_manager.github import get_branch_from_github_url, normalize_github_url, get_requirements_json,\
         get_skill_json
     from ovos_skills_manager.skill_entry import SkillEntry
     try:
         branch = get_branch_from_github_url(url)
     except GithubInvalidBranch:
         branch = None
     url = normalize_github_url(url)
     requirements = get_requirements_json(url, branch)
     requirements["system"] = {
         k: v.split()
         for k, v in requirements.get("system", {}).items()
     }
     try:
         json = get_skill_json(url, branch)
         requirements = merge_dict(requirements,
                                   json.get("requirements", {}),
                                   merge_lists=True,
                                   skip_empty=True,
                                   no_dupes=True)
     except GithubFileNotFound:
         json = {"authorname": author_repo_from_github_url(url)[0]}
     return SkillEntry.from_json(
         {
             "url": url,
             "branch": branch,
             "requirements": requirements,
             "authorname": json.get("authorname")
         }, False)
Пример #7
0
 def test_get_branch_from_blob(self):
     from ovos_skills_manager.github import get_branch_from_github_url
     self.assertEqual(
         get_branch_from_github_url(
             "https://github.com/OpenVoiceOS/tskill-osm_parsing/blob/v0.2.1/skill.json",
             True), "v0.2.1")
Пример #8
0
 def test_get_branch_from_commit(self):
     from ovos_skills_manager.github import get_branch_from_github_url
     self.assertEqual(
         get_branch_from_github_url(
             "https://github.com/OpenVoiceOS/tskill-osm_parsing/commit/06fabb262077d80c32ffd12ed1092bb914658067",
             True), "06fabb262077d80c32ffd12ed1092bb914658067")