예제 #1
0
 def read_stream_get(self):
     if self._vfile.content:
         ret = compat.BytesIO()
         ret.write(self._vfile.content.encode())
         ret.seek(0)
         return ret
     elif self._vfile.blocks:
         ret = compat.BytesIO()
         for block_id in self._vfile.blocks:
             ret.write(self._block_model.get(block_id).content)
         ret.seek(0)
         return ret
     else:
         return compat.BytesIO()
예제 #2
0
    def __init__(self,
                 session: Session,
                 content_api: ContentApi,
                 workspace: Workspace,
                 path: str,
                 file_name: str = '',
                 content: Content = None,
                 parent: Content = None):
        """

        :param content_api:
        :param workspace:
        :param path:
        :param file_name:
        :param content:
        :param parent:
        """
        self._file_stream = compat.BytesIO()
        self._session = session
        self._file_name = file_name if file_name != '' else self._content.file_name
        self._content = content
        self._api = content_api
        self._workspace = workspace
        self._parent = parent
        self._path = path
예제 #3
0
    def getContent(self):
        filestream = compat.BytesIO()

        filestream.write(bytes(self.content_designed, 'utf-8'))
        filestream.seek(0)

        return filestream
예제 #4
0
파일: resources.py 프로젝트: inkhey/tracim
    def getContent(self):
        # TODO - G.M - 2019-06-13 - find solution to handle properly big file here without having
        # big file in memory. see https://github.com/tracim/tracim/issues/1913
        filestream = compat.BytesIO()

        filestream.write(bytes(self.content_designed, "utf-8"))
        filestream.seek(0)
        return filestream
예제 #5
0
 def get_content(self):
     fileLinks = [
         "<a href='%s'>%s</a>\n" % (os.path.basename(f), f)
         for f in self.data["resPathList"]
     ]
     dict = self.data.copy()
     dict["fileLinks"] = ", ".join(fileLinks)
     if self.name == ".Info.html":
         html = ("""\
         <html><head>
         <title>%(title)s</title>
         </head><body>
         <h1>%(title)s</h1>
         <table>
         <tr>
             <td>Description</td>
             <td>%(description)s</td>
         </tr><tr>
             <td>Status</td>
             <td>%(status)s</td>
         </tr><tr>
             <td>Tags</td>
             <td>%(tags)s</td>
         </tr><tr>
             <td>Orga unit</td>
             <td>%(orga)s</td>
         </tr><tr>
             <td>Files</td>
             <td>%(fileLinks)s</td>
         </tr><tr>
             <td>Key</td>
             <td>%(key)s</td>
         </tr>
         </table>
         <p>This is a virtual WsgiDAV resource called '%(title)s'.</p>
         </body></html>""" % dict)
     elif self.name == ".Info.txt":
         lines = [
             self.data["title"],
             "=" * len(self.data["title"]),
             self.data["description"],
             "",
             "Status: %s" % self.data["status"],
             "Orga:   %8s" % self.data["orga"],
             "Tags:   '%s'" % "', '".join(self.data["tags"]),
             "Key:    %s" % self.data["key"],
         ]
         html = "\n".join(lines)
     elif self.name == ".Description.txt":
         html = self.data["description"]
     else:
         raise DAVError(HTTP_INTERNAL_ERROR,
                        "Invalid artifact '%s'" % self.name)
     return compat.BytesIO(compat.to_bytes(html))
예제 #6
0
    def getContent(self) -> typing.BinaryIO:
        filestream = compat.BytesIO()
        filestream.write(self.content.depot_file.file.read())
        filestream.seek(0)

        return filestream
예제 #7
0
    def getContent(self):
        filestream = compat.BytesIO()
        filestream.write(self.content_revision.depot_file.file.read())
        filestream.seek(0)

        return filestream
예제 #8
0
    def getContent(self):
        filestream = compat.BytesIO()
        filestream.write(self.content.file_content)
        filestream.seek(0)

        return filestream