Ejemplo n.º 1
0
 def can_commit(self):
     """
     True if we can commit strings back to the repository this
     project is hosted in, False otherwise.
     """
     return utils.first(self.repositories.all(),
                        lambda r: r.can_commit) is not None
Ejemplo n.º 2
0
 def can_commit(self):
     """
     True if we can commit strings back to the repository this
     project is hosted in, False otherwise.
     """
     return utils.first(
         self.repositories.all(),
         lambda r: r.can_commit
     ) is not None
Ejemplo n.º 3
0
def directory_contains_resources(directory_path):
    """
    Return True if the given directory contains at least one
    supported resource file (checked via file extension), or False
    otherwise.
    """
    for root, dirnames, filenames in os.walk(directory_path):
        # first() avoids checking past the first matching resouce.
        if first(filenames, is_resource) is not None:
            return True
    return False
Ejemplo n.º 4
0
def directory_contains_resources(directory_path):
    """
    Return True if the given directory contains at least one
    supported resource file (checked via file extension), or False
    otherwise.
    """
    for root, dirnames, filenames in os.walk(directory_path):
        # first() avoids checking past the first matching resouce.
        if first(filenames, is_resource) is not None:
            return True
    return False
Ejemplo n.º 5
0
    def repository_for_path(self, path):
        """
        Return the repository instance whose checkout contains the given
        path. If no matching repo is found, raise a ValueError.
        """
        repo = utils.first(self.repositories.all(),
                           lambda r: path.startswith(r.checkout_path))

        if repo is None:
            raise ValueError(
                'Could not find repo matching path {path}.'.format(path=path))
        else:
            return repo
Ejemplo n.º 6
0
    def repository_for_path(self, path):
        """
        Return the repository instance whose checkout contains the given
        path. If no matching repo is found, raise a ValueError.
        """
        repo = utils.first(
            self.repositories.all(),
            lambda r: path.startswith(r.checkout_path)
        )

        if repo is None:
            raise ValueError('Could not find repo matching path {path}.'.format(path=path))
        else:
            return repo
Ejemplo n.º 7
0
def directory_contains_resources(directory_path, source_only=False):
    """
    Return True if the given directory contains at least one
    supported resource file (checked via file extension), or False
    otherwise.

    :param source_only:
        If True, only check for source-only formats.
    """
    resource_check = is_source_resource if source_only else is_resource
    for root, dirnames, filenames in scandir.walk(directory_path):
        # first() avoids checking past the first matching resource.
        if first(filenames, resource_check) is not None:
            return True
    return False
Ejemplo n.º 8
0
def directory_contains_resources(directory_path, source_only=False):
    """
    Return True if the given directory contains at least one
    supported resource file (checked via file extension), or False
    otherwise.

    :param source_only:
        If True, only check for source-only formats.
    """
    resource_check = is_source_resource if source_only else is_resource
    for root, dirnames, filenames in scandir.walk(directory_path):
        # first() avoids checking past the first matching resource.
        if first(filenames, resource_check) is not None:
            return True
    return False