Ejemplo n.º 1
0
 def _load_local_course(course_path, slug, canonical_if_local=False):
     link_path = course_path / 'link.yml'
     if link_path.is_file():
         with link_path.open() as f:
             link_info = yaml.safe_load(f)
         checked_url = '{repo}#{branch}'.format(**link_info)
         if any(
                 fnmatch(checked_url, l)
                 for l in self.trusted_repo_patterns):
             course = Course.load_remote(
                 slug,
                 parent=self,
                 link_info=link_info,
             )
             self.add_course(course)
         else:
             logger.debug(f'Untrusted repo: {checked_url}')
     if (course_path / 'info.yml').is_file():
         course = Course.load_local(
             slug,
             parent=self,
             repo_info=self.repo_info,
             path=path,
             canonical=canonical_if_local,
         )
         self.add_course(course)
Ejemplo n.º 2
0
def get_repo_info(repo_url, branch):
    """Return repository information for a particular repo URL and branch"""

    for regex, func in _kinds:
        match = re.fullmatch(regex, repo_url)
        if match:
            return func(match, branch)
    logger.debug(f'get_edit_info: repo not matched: {repo_url}')