Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/source/API/api_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ FileAutomation API Documentation
----

.. toctree::
:maxdepth: 4
:maxdepth:

local.rst
remote.rst
171 changes: 171 additions & 0 deletions docs/source/API/local.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
Local file api
----

.. code-block:: python

def copy_dir(dir_path: str, target_dir_path: str) -> bool:
"""
Copy dir to target path (path need as dir path)
:param dir_path: which dir do we want to copy (str path)
:param target_dir_path: copy dir to this path
:return: True if success else False
"""

.. code-block:: python

def remove_dir_tree(dir_path: str) -> bool:
"""
:param dir_path: which dir do we want to remove (str path)
:return: True if success else False
"""

.. code-block:: python

def rename_dir(origin_dir_path, target_dir: str) -> bool:
"""
:param origin_dir_path: which dir do we want to rename (str path)
:param target_dir: target name as str full path
:return: True if success else False
"""

.. code-block:: python

def create_dir(dir_path: str) -> None:
"""
:param dir_path: create dir on dir_path
:return: None
"""

.. code-block:: python


def copy_file(file_path: str, target_path: str) -> bool:
"""
:param file_path: which file do we want to copy (str path)
:param target_path: put copy file on target path
:return: True if success else False
"""

.. code-block:: python

def copy_specify_extension_file(file_dir_path: str, target_extension: str, target_path: str) -> bool:
"""
:param file_dir_path: which dir do we want to search
:param target_extension: what extension we will search
:param target_path: copy file to target path
:return: True if success else False
"""

.. code-block:: python

def copy_all_file_to_dir(dir_path: str, target_dir_path: str) -> bool:
"""
:param dir_path: copy all file on dir
:param target_dir_path: put file to target dir
:return: True if success else False
"""

.. code-block:: python

def rename_file(origin_file_path, target_name: str, file_extension=None) -> bool:
"""
:param origin_file_path: which dir do we want to search file
:param target_name: rename file to target name
:param file_extension: Which extension do we search
:return: True if success else False
"""

.. code-block:: python

def remove_file(file_path: str) -> None:
"""
:param file_path: which file do we want to remove
:return: None
"""

.. code-block:: python

def create_file(file_path: str, content: str) -> None:
"""
:param file_path: create file on path
:param content: what content will write to file
:return: None
"""

.. code-block:: python

def zip_dir(dir_we_want_to_zip: str, zip_name: str) -> None:
"""
:param dir_we_want_to_zip: dir str path
:param zip_name: zip file name
:return: None
"""

.. code-block:: python

def zip_file(zip_file_path: str, file: [str, List[str]]) -> None:
"""
:param zip_file_path: add file to zip file
:param file: single file path or list of file path (str) to add into zip
:return: None
"""

.. code-block:: python

def read_zip_file(zip_file_path: str, file_name: str, password: [str, None] = None) -> bytes:
"""
:param zip_file_path: which zip do we want to read
:param file_name: which file on zip do we want to read
:param password: if zip have password use this password to unzip zip file
:return:
"""

.. code-block:: python

def unzip_file(
zip_file_path: str, extract_member, extract_path: [str, None] = None, password: [str, None] = None) -> None:
"""
:param zip_file_path: which zip we want to unzip
:param extract_member: which member we want to unzip
:param extract_path: extract member to path
:param password: if zip have password use this password to unzip zip file
:return: None
"""

.. code-block:: python

def unzip_all(
zip_file_path: str, extract_member: [str, None] = None,
extract_path: [str, None] = None, password: [str, None] = None) -> None:
"""
:param zip_file_path: which zip do we want to unzip
:param extract_member: which member do we want to unzip
:param extract_path: extract to path
:param password: if zip have password use this password to unzip zip file
:return: None
"""

.. code-block:: python

def zip_info(zip_file_path: str) -> List[ZipInfo]:
"""
:param zip_file_path: read zip file info
:return: List[ZipInfo]
"""

.. code-block:: python

def zip_file_info(zip_file_path: str) -> List[str]:
"""
:param zip_file_path: read inside zip file info
:return: List[str]
"""

.. code-block:: python

def set_zip_password(zip_file_path: str, password: bytes) -> None:
"""
:param zip_file_path: which zip do we want to set password
:param password: password will be set
:return: None
"""
126 changes: 126 additions & 0 deletions docs/source/API/remote.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
Remote file api
----

.. code-block:: python

def drive_delete_file(file_id: str) -> Union[Dict[str, str], None]:
"""
:param file_id: Google Drive file id
:return: Dict[str, str] or None
"""

.. code-block:: python

def drive_add_folder(folder_name: str) -> Union[dict, None]:
"""
:param folder_name: folder name will create on Google Drive
:return: dict or None
"""

.. code-block:: python

def drive_download_file(file_id: str, file_name: str) -> BytesIO:
"""
:param file_id: file have this id will download
:param file_name: file save on local name
:return: file
"""

.. code-block:: python

def drive_download_file_from_folder(folder_name: str) -> Union[dict, None]:
"""
:param folder_name: which folder do we want to download file
:return: dict or None
"""

.. code-block:: python

def drive_search_all_file() -> Union[dict, None]:
"""
Search all file on Google Drive
:return: dict or None
"""

.. code-block:: python

def drive_search_file_mimetype(mime_type: str) -> Union[dict, None]:
"""
:param mime_type: search all file with mime_type on Google Drive
:return: dict or None
"""

.. code-block:: python

def drive_search_field(field_pattern: str) -> Union[dict, None]:
"""
:param field_pattern: what pattern will we use to search
:return: dict or None
"""

.. code-block:: python

def drive_share_file_to_user(
file_id: str, user: str, user_role: str = "writer") -> Union[dict, None]:
"""
:param file_id: which file do we want to share
:param user: what user do we want to share
:param user_role: what role do we want to share
:return: dict or None
"""

.. code-block:: python

def drive_share_file_to_anyone(file_id: str, share_role: str = "reader") -> Union[dict, None]:
"""
:param file_id: which file do we want to share
:param share_role: what role do we want to share
:return: dict or None
"""

.. code-block:: python

def drive_share_file_to_domain(
file_id: str, domain: str, domain_role: str = "reader") -> Union[dict, None]:
"""
:param file_id: which file do we want to share
:param domain: what domain do we want to share
:param domain_role: what role do we want to share
:return: dict or None
"""

.. code-block:: python

def drive_upload_to_drive(file_path: str, file_name: str = None) -> Union[dict, None]:
"""
:param file_path: which file do we want to upload
:param file_name: file name on Google Drive
:return: dict or None
"""

.. code-block:: python

def drive_upload_to_folder(folder_id: str, file_path: str, file_name: str = None) -> Union[dict, None]:
"""
:param folder_id: which folder do we want to upload file into
:param file_path: which file do we want to upload
:param file_name: file name on Google Drive
:return: dict or None
"""

.. code-block:: python

def drive_upload_dir_to_drive(dir_path: str) -> List[Optional[set]]:
"""
:param dir_path: which dir do we want to upload to drive
:return: List[Optional[set]]
"""

.. code-block:: python

def drive_upload_dir_to_folder(folder_id: str, dir_path: str) -> List[Optional[set]]:
"""
:param folder_id: which folder do we want to put dir into
:param dir_path: which dir do we want to upload
:return: List[Optional[set]]
"""
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ FileAutomation
.. toctree::
:maxdepth: 4

API/api_index.rst


----

Expand Down