|
| 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 | + """ |
0 commit comments