Skip to content

Commit 21de933

Browse files
committed
Update docs
Update docs
1 parent f0759bf commit 21de933

File tree

4 files changed

+303
-1
lines changed

4 files changed

+303
-1
lines changed

docs/source/API/api_index.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ FileAutomation API Documentation
22
----
33

44
.. toctree::
5-
:maxdepth: 4
5+
:maxdepth:
6+
7+
local.rst
8+
remote.rst

docs/source/API/local.rst

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
Local file api
2+
----
3+
4+
.. code-block:: python
5+
6+
def copy_dir(dir_path: str, target_dir_path: str) -> bool:
7+
"""
8+
Copy dir to target path (path need as dir path)
9+
:param dir_path: which dir do we want to copy (str path)
10+
:param target_dir_path: copy dir to this path
11+
:return: True if success else False
12+
"""
13+
14+
.. code-block:: python
15+
16+
def remove_dir_tree(dir_path: str) -> bool:
17+
"""
18+
:param dir_path: which dir do we want to remove (str path)
19+
:return: True if success else False
20+
"""
21+
22+
.. code-block:: python
23+
24+
def rename_dir(origin_dir_path, target_dir: str) -> bool:
25+
"""
26+
:param origin_dir_path: which dir do we want to rename (str path)
27+
:param target_dir: target name as str full path
28+
:return: True if success else False
29+
"""
30+
31+
.. code-block:: python
32+
33+
def create_dir(dir_path: str) -> None:
34+
"""
35+
:param dir_path: create dir on dir_path
36+
:return: None
37+
"""
38+
39+
.. code-block:: python
40+
41+
42+
def copy_file(file_path: str, target_path: str) -> bool:
43+
"""
44+
:param file_path: which file do we want to copy (str path)
45+
:param target_path: put copy file on target path
46+
:return: True if success else False
47+
"""
48+
49+
.. code-block:: python
50+
51+
def copy_specify_extension_file(file_dir_path: str, target_extension: str, target_path: str) -> bool:
52+
"""
53+
:param file_dir_path: which dir do we want to search
54+
:param target_extension: what extension we will search
55+
:param target_path: copy file to target path
56+
:return: True if success else False
57+
"""
58+
59+
.. code-block:: python
60+
61+
def copy_all_file_to_dir(dir_path: str, target_dir_path: str) -> bool:
62+
"""
63+
:param dir_path: copy all file on dir
64+
:param target_dir_path: put file to target dir
65+
:return: True if success else False
66+
"""
67+
68+
.. code-block:: python
69+
70+
def rename_file(origin_file_path, target_name: str, file_extension=None) -> bool:
71+
"""
72+
:param origin_file_path: which dir do we want to search file
73+
:param target_name: rename file to target name
74+
:param file_extension: Which extension do we search
75+
:return: True if success else False
76+
"""
77+
78+
.. code-block:: python
79+
80+
def remove_file(file_path: str) -> None:
81+
"""
82+
:param file_path: which file do we want to remove
83+
:return: None
84+
"""
85+
86+
.. code-block:: python
87+
88+
def create_file(file_path: str, content: str) -> None:
89+
"""
90+
:param file_path: create file on path
91+
:param content: what content will write to file
92+
:return: None
93+
"""
94+
95+
.. code-block:: python
96+
97+
def zip_dir(dir_we_want_to_zip: str, zip_name: str) -> None:
98+
"""
99+
:param dir_we_want_to_zip: dir str path
100+
:param zip_name: zip file name
101+
:return: None
102+
"""
103+
104+
.. code-block:: python
105+
106+
def zip_file(zip_file_path: str, file: [str, List[str]]) -> None:
107+
"""
108+
:param zip_file_path: add file to zip file
109+
:param file: single file path or list of file path (str) to add into zip
110+
:return: None
111+
"""
112+
113+
.. code-block:: python
114+
115+
def read_zip_file(zip_file_path: str, file_name: str, password: [str, None] = None) -> bytes:
116+
"""
117+
:param zip_file_path: which zip do we want to read
118+
:param file_name: which file on zip do we want to read
119+
:param password: if zip have password use this password to unzip zip file
120+
:return:
121+
"""
122+
123+
.. code-block:: python
124+
125+
def unzip_file(
126+
zip_file_path: str, extract_member, extract_path: [str, None] = None, password: [str, None] = None) -> None:
127+
"""
128+
:param zip_file_path: which zip we want to unzip
129+
:param extract_member: which member we want to unzip
130+
:param extract_path: extract member to path
131+
:param password: if zip have password use this password to unzip zip file
132+
:return: None
133+
"""
134+
135+
.. code-block:: python
136+
137+
def unzip_all(
138+
zip_file_path: str, extract_member: [str, None] = None,
139+
extract_path: [str, None] = None, password: [str, None] = None) -> None:
140+
"""
141+
:param zip_file_path: which zip do we want to unzip
142+
:param extract_member: which member do we want to unzip
143+
:param extract_path: extract to path
144+
:param password: if zip have password use this password to unzip zip file
145+
:return: None
146+
"""
147+
148+
.. code-block:: python
149+
150+
def zip_info(zip_file_path: str) -> List[ZipInfo]:
151+
"""
152+
:param zip_file_path: read zip file info
153+
:return: List[ZipInfo]
154+
"""
155+
156+
.. code-block:: python
157+
158+
def zip_file_info(zip_file_path: str) -> List[str]:
159+
"""
160+
:param zip_file_path: read inside zip file info
161+
:return: List[str]
162+
"""
163+
164+
.. code-block:: python
165+
166+
def set_zip_password(zip_file_path: str, password: bytes) -> None:
167+
"""
168+
:param zip_file_path: which zip do we want to set password
169+
:param password: password will be set
170+
:return: None
171+
"""

docs/source/API/remote.rst

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
Remote file api
2+
----
3+
4+
.. code-block:: python
5+
6+
def drive_delete_file(file_id: str) -> Union[Dict[str, str], None]:
7+
"""
8+
:param file_id: Google Drive file id
9+
:return: Dict[str, str] or None
10+
"""
11+
12+
.. code-block:: python
13+
14+
def drive_add_folder(folder_name: str) -> Union[dict, None]:
15+
"""
16+
:param folder_name: folder name will create on Google Drive
17+
:return: dict or None
18+
"""
19+
20+
.. code-block:: python
21+
22+
def drive_download_file(file_id: str, file_name: str) -> BytesIO:
23+
"""
24+
:param file_id: file have this id will download
25+
:param file_name: file save on local name
26+
:return: file
27+
"""
28+
29+
.. code-block:: python
30+
31+
def drive_download_file_from_folder(folder_name: str) -> Union[dict, None]:
32+
"""
33+
:param folder_name: which folder do we want to download file
34+
:return: dict or None
35+
"""
36+
37+
.. code-block:: python
38+
39+
def drive_search_all_file() -> Union[dict, None]:
40+
"""
41+
Search all file on Google Drive
42+
:return: dict or None
43+
"""
44+
45+
.. code-block:: python
46+
47+
def drive_search_file_mimetype(mime_type: str) -> Union[dict, None]:
48+
"""
49+
:param mime_type: search all file with mime_type on Google Drive
50+
:return: dict or None
51+
"""
52+
53+
.. code-block:: python
54+
55+
def drive_search_field(field_pattern: str) -> Union[dict, None]:
56+
"""
57+
:param field_pattern: what pattern will we use to search
58+
:return: dict or None
59+
"""
60+
61+
.. code-block:: python
62+
63+
def drive_share_file_to_user(
64+
file_id: str, user: str, user_role: str = "writer") -> Union[dict, None]:
65+
"""
66+
:param file_id: which file do we want to share
67+
:param user: what user do we want to share
68+
:param user_role: what role do we want to share
69+
:return: dict or None
70+
"""
71+
72+
.. code-block:: python
73+
74+
def drive_share_file_to_anyone(file_id: str, share_role: str = "reader") -> Union[dict, None]:
75+
"""
76+
:param file_id: which file do we want to share
77+
:param share_role: what role do we want to share
78+
:return: dict or None
79+
"""
80+
81+
.. code-block:: python
82+
83+
def drive_share_file_to_domain(
84+
file_id: str, domain: str, domain_role: str = "reader") -> Union[dict, None]:
85+
"""
86+
:param file_id: which file do we want to share
87+
:param domain: what domain do we want to share
88+
:param domain_role: what role do we want to share
89+
:return: dict or None
90+
"""
91+
92+
.. code-block:: python
93+
94+
def drive_upload_to_drive(file_path: str, file_name: str = None) -> Union[dict, None]:
95+
"""
96+
:param file_path: which file do we want to upload
97+
:param file_name: file name on Google Drive
98+
:return: dict or None
99+
"""
100+
101+
.. code-block:: python
102+
103+
def drive_upload_to_folder(folder_id: str, file_path: str, file_name: str = None) -> Union[dict, None]:
104+
"""
105+
:param folder_id: which folder do we want to upload file into
106+
:param file_path: which file do we want to upload
107+
:param file_name: file name on Google Drive
108+
:return: dict or None
109+
"""
110+
111+
.. code-block:: python
112+
113+
def drive_upload_dir_to_drive(dir_path: str) -> List[Optional[set]]:
114+
"""
115+
:param dir_path: which dir do we want to upload to drive
116+
:return: List[Optional[set]]
117+
"""
118+
119+
.. code-block:: python
120+
121+
def drive_upload_dir_to_folder(folder_id: str, dir_path: str) -> List[Optional[set]]:
122+
"""
123+
:param folder_id: which folder do we want to put dir into
124+
:param dir_path: which dir do we want to upload
125+
:return: List[Optional[set]]
126+
"""

docs/source/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ FileAutomation
44
.. toctree::
55
:maxdepth: 4
66

7+
API/api_index.rst
8+
79

810
----
911

0 commit comments

Comments
 (0)