Skip to content

Commit

Permalink
Data i/o docstring format (#309)
Browse files Browse the repository at this point in the history
unify Data I/O function doc string format
  • Loading branch information
Wendong-Fan authored Oct 14, 2023
1 parent 3ba1754 commit 3c2f6be
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions camel/functions/data_io_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


class File(ABC):
"""Represents an uploaded file comprised of Documents"""
r"""Represents an uploaded file comprised of Documents"""

def __init__(
self,
Expand All @@ -34,7 +34,8 @@ def __init__(
metadata: Optional[Dict[str, Any]] = None,
docs: Optional[List[Dict[str, Any]]] = None,
):
"""
r"""
Args:
name (str): The name of the file.
id (str): The unique identifier of the file.
Expand All @@ -51,8 +52,7 @@ def __init__(
@classmethod
@abstractmethod
def from_bytes(cls, file: BytesIO) -> "File":
"""
Creates a File object from a BytesIO object.
r"""Creates a File object from a BytesIO object.
Args:
file (BytesIO):
Expand All @@ -71,7 +71,8 @@ def __str__(self) -> str:
f"File(name={self.name}, id={self.id}, metadata={self.metadata})")

def copy(self) -> "File":
"""Create a deep copy of this File"""
r"""Create a deep copy of this File"""

return self.__class__(
name=self.name,
id=self.id,
Expand All @@ -81,8 +82,7 @@ def copy(self) -> "File":


def strip_consecutive_newlines(text: str) -> str:
"""
Strips consecutive newlines from a string.
r"""Strips consecutive newlines from a string.
Args:
text (str): The string to strip.
Expand All @@ -97,8 +97,7 @@ class DocxFile(File):

@classmethod
def from_bytes(cls, file: BytesIO) -> "DocxFile":
"""
Creates a DocxFile object from a BytesIO object.
r"""Creates a DocxFile object from a BytesIO object.
Args:
file (BytesIO):
Expand All @@ -123,8 +122,7 @@ class PdfFile(File):

@classmethod
def from_bytes(cls, file: BytesIO) -> "PdfFile":
"""
Creates a PdfFile object from a BytesIO object.
r"""Creates a PdfFile object from a BytesIO object.
Args:
file (BytesIO):
Expand Down Expand Up @@ -153,8 +151,7 @@ class TxtFile(File):

@classmethod
def from_bytes(cls, file: BytesIO) -> "TxtFile":
"""
Creates a TxtFile object from a BytesIO object.
r"""Creates a TxtFile object from a BytesIO object.
Args:
file (BytesIO):
Expand All @@ -179,8 +176,7 @@ class JsonFile(File):

@classmethod
def from_bytes(cls, file: BytesIO) -> "JsonFile":
"""
Creates a JsonFile object from a BytesIO object.
r"""Creates a JsonFile object from a BytesIO object.
Args:
file (BytesIO):
Expand All @@ -204,8 +200,7 @@ class HtmlFile(File):

@classmethod
def from_bytes(cls, file: BytesIO) -> "HtmlFile":
"""
Creates a HtmlFile object from a BytesIO object.
r"""Creates a HtmlFile object from a BytesIO object.
Args:
file (BytesIO):
Expand All @@ -228,8 +223,7 @@ def from_bytes(cls, file: BytesIO) -> "HtmlFile":


def read_file(file: BytesIO) -> File:
"""
Reads an uploaded file and returns a File object.
r"""Reads an uploaded file and returns a File object.
Args:
file (BytesIO): A BytesIO object representing the contents of the file.
Expand Down

0 comments on commit 3c2f6be

Please sign in to comment.