Exemple #1
0
    def get_file(self,
                 commit,
                 path,
                 offset_bytes=0,
                 size_bytes=0,
                 extract_value=True):
        """
        Returns an iterator of the contents contents of a file at a specific Commit.

        Params:
        * commit: A tuple, string, or Commit object representing the commit.
        * path: The path of the file.
        * offset_bytes: Optional. specifies a number of bytes that should be
        skipped in the beginning of the file.
        * size_bytes: Optional. limits the total amount of data returned, note
        you will get fewer bytes than size if you pass a value larger than the
        size of the file. If size is set to 0 then all of the data will be
        returned.
        * extract_value: If True, then an ExtractValueIterator will be return,
        which will iterate over the bytes of the file. If False, then the
        protobuf response iterator will return.
        """
        req = proto.GetFileRequest(file=proto.File(commit=commit_from(commit),
                                                   path=path),
                                   offset_bytes=offset_bytes,
                                   size_bytes=size_bytes)
        res = self.stub.GetFile(req, metadata=self.metadata)
        if extract_value:
            return ExtractValueIterator(res)
        return res
Exemple #2
0
 def get_file(self, commit, path, offset_bytes=None, size_bytes=None):
     """
     Returns an iterator of the contents of a file at a specific commit.
     Params:
     * commit: A tuple, string, or `Commit` object representing the commit.
     * path: A string specifying the path of the file.
     * offset_bytes: An optional int. Specifies a number of bytes that
     should be skipped in the beginning of the file.
     * size_bytes: An optional int. limits the total amount of data
     returned, note you will get fewer bytes than size if you pass a value
     larger than the size of the file. If size is set to 0 then all of the
     data will be returned.
     """
     req = proto.GetFileRequest(file=proto.File(commit=commit_from(commit),
                                                path=path),
                                offset_bytes=offset_bytes,
                                size_bytes=size_bytes)
     res = self.stub.GetFile(req, metadata=self.metadata)
     for item in res:
         yield item.value