Ejemplo n.º 1
0
            def wrap(value):
                yield proto.PutFileRequest(
                    file=proto.File(commit=commit_from(commit), path=path),
                    value=value[:BUFFER_SIZE],
                    delimiter=delimiter,
                    target_file_datums=target_file_datums,
                    target_file_bytes=target_file_bytes,
                    overwrite_index=overwrite_index_proto)

                for i in range(BUFFER_SIZE, len(value), BUFFER_SIZE):
                    yield proto.PutFileRequest(
                        value=value[i:i + BUFFER_SIZE],
                        overwrite_index=overwrite_index_proto)
Ejemplo n.º 2
0
 def wrap(value):
     for i, chunk in enumerate(value):
         if i == 0:
             yield proto.PutFileRequest(
                 file=proto.File(commit=commit_from(commit),
                                 path=path),
                 value=chunk,
                 delimiter=delimiter,
                 target_file_datums=target_file_datums,
                 target_file_bytes=target_file_bytes,
                 overwrite_index=overwrite_index_proto)
         else:
             yield proto.PutFileRequest(value=chunk)
Ejemplo n.º 3
0
            def wrap(value):
                for i in itertools.count():
                    chunk = value.read(BUFFER_SIZE)

                    if len(chunk) == 0:
                        return

                    if i == 0:
                        yield proto.PutFileRequest(
                            file=proto.File(commit=commit_from(commit),
                                            path=path),
                            value=chunk,
                            delimiter=delimiter,
                            target_file_datums=target_file_datums,
                            target_file_bytes=target_file_bytes,
                            overwrite_index=overwrite_index_proto)
                    else:
                        yield proto.PutFileRequest(value=chunk)
Ejemplo n.º 4
0
    def put_file_url(self, commit, path, url, recursive=False):
        """
        Puts a file using the content found at a URL. The URL is sent to the
        server which performs the request.

        Params:
        * commit: A tuple, string, or Commit object representing the commit.
        * path: The path to the file.
        * url: The url of the file to put.
        * recursive: allow for recursive scraping of some types URLs for
        example on s3:// urls.
        """
        req = iter([
            proto.PutFileRequest(file=proto.File(commit=commit_from(commit),
                                                 path=path),
                                 url=url,
                                 recursive=recursive)
        ])
        self.stub.PutFile(req, metadata=self.metadata)
Ejemplo n.º 5
0
 def put_file_url(self, commit, path, url, recursive=None):
     """
     Puts a file using the content found at a URL. The URL is sent to the
     server which performs the request. Note that this is not a standard
     PFS function.
     Params:
     * commit: A tuple, string, or `Commit` object representing the commit.
     * path: A string specifying the path to the file.
     * url: A string specifying the url of the file to put.
     * recursive: allow for recursive scraping of some types URLs, for
     example on s3:// URLs.
     """
     req = iter([
         proto.PutFileRequest(file=proto.File(commit=commit_from(commit),
                                              path=path),
                              url=url,
                              recursive=recursive)
     ])
     self.stub.PutFile(req, metadata=self.metadata)