automation-file-dev 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. automation_file_dev-0.0.3/LICENSE +21 -0
  2. automation_file_dev-0.0.3/PKG-INFO +61 -0
  3. automation_file_dev-0.0.3/README.md +44 -0
  4. automation_file_dev-0.0.3/automation_file_dev.egg-info/PKG-INFO +61 -0
  5. automation_file_dev-0.0.3/automation_file_dev.egg-info/SOURCES.txt +21 -0
  6. automation_file_dev-0.0.3/automation_file_dev.egg-info/dependency_links.txt +1 -0
  7. automation_file_dev-0.0.3/automation_file_dev.egg-info/top_level.txt +1 -0
  8. automation_file_dev-0.0.3/file_automation/__init__.py +6 -0
  9. automation_file_dev-0.0.3/file_automation/local/__init__.py +0 -0
  10. automation_file_dev-0.0.3/file_automation/local/dir/__init__.py +0 -0
  11. automation_file_dev-0.0.3/file_automation/local/dir/dir_process.py +43 -0
  12. automation_file_dev-0.0.3/file_automation/local/file/__init__.py +0 -0
  13. automation_file_dev-0.0.3/file_automation/local/file/file_process.py +61 -0
  14. automation_file_dev-0.0.3/file_automation/local/zip/__init__.py +0 -0
  15. automation_file_dev-0.0.3/file_automation/local/zip/zip_process.py +69 -0
  16. automation_file_dev-0.0.3/file_automation/remote/__init__.py +0 -0
  17. automation_file_dev-0.0.3/file_automation/remote/google_drive/__init__.py +0 -0
  18. automation_file_dev-0.0.3/file_automation/utils/__init__.py +0 -0
  19. automation_file_dev-0.0.3/file_automation/utils/exception/__init__.py +0 -0
  20. automation_file_dev-0.0.3/file_automation/utils/exception/exception_tags.py +0 -0
  21. automation_file_dev-0.0.3/file_automation/utils/exception/exceptions.py +10 -0
  22. automation_file_dev-0.0.3/pyproject.toml +31 -0
  23. automation_file_dev-0.0.3/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 JE-Chen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.1
2
+ Name: automation_file_dev
3
+ Version: 0.0.3
4
+ Author-email: JE-Chen <zenmailman@gmail.com>
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/JE-Chen/Integration-testing-environment
7
+ Classifier: Programming Language :: Python :: 3.7
8
+ Classifier: Development Status :: 2 - Pre-Alpha
9
+ Classifier: Environment :: Win32 (MS Windows)
10
+ Classifier: Environment :: MacOS X
11
+ Classifier: Environment :: X11 Applications
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+
18
+ ### FileAutomation
19
+
20
+ ### Documentation
21
+
22
+ * TODO
23
+
24
+ ---
25
+ > Project Kanban \
26
+ > https://github.com/orgs/Intergration-Automation-Testing/projects/2 \
27
+ > FileAutomation is used to manager files and dirs.
28
+
29
+
30
+ ---
31
+ ### Features
32
+ * Process multi file.
33
+ * copy file.
34
+ * copy specify extension file.
35
+ * copy all file to dir.
36
+ * rename file.
37
+ * remove file.
38
+ * Process multi dir.
39
+ * copy dir.
40
+ * remove dir.
41
+ * rename dir.
42
+ * create dir.
43
+ * Process zip files.
44
+ * zip a dir.
45
+ * zip a file.
46
+ * read zip file.
47
+ * unzip file on zip.
48
+ * un zip all file on zip.
49
+ * show zip info.
50
+ * show file on zip info.
51
+
52
+ ## install
53
+ > pip install automation_file
54
+
55
+ ## Requires
56
+ > python 3.8 or later
57
+
58
+ ### Architecture Diagram
59
+
60
+
61
+ * TODO
@@ -0,0 +1,44 @@
1
+ ### FileAutomation
2
+
3
+ ### Documentation
4
+
5
+ * TODO
6
+
7
+ ---
8
+ > Project Kanban \
9
+ > https://github.com/orgs/Intergration-Automation-Testing/projects/2 \
10
+ > FileAutomation is used to manager files and dirs.
11
+
12
+
13
+ ---
14
+ ### Features
15
+ * Process multi file.
16
+ * copy file.
17
+ * copy specify extension file.
18
+ * copy all file to dir.
19
+ * rename file.
20
+ * remove file.
21
+ * Process multi dir.
22
+ * copy dir.
23
+ * remove dir.
24
+ * rename dir.
25
+ * create dir.
26
+ * Process zip files.
27
+ * zip a dir.
28
+ * zip a file.
29
+ * read zip file.
30
+ * unzip file on zip.
31
+ * un zip all file on zip.
32
+ * show zip info.
33
+ * show file on zip info.
34
+
35
+ ## install
36
+ > pip install automation_file
37
+
38
+ ## Requires
39
+ > python 3.8 or later
40
+
41
+ ### Architecture Diagram
42
+
43
+
44
+ * TODO
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.1
2
+ Name: automation-file-dev
3
+ Version: 0.0.3
4
+ Author-email: JE-Chen <zenmailman@gmail.com>
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/JE-Chen/Integration-testing-environment
7
+ Classifier: Programming Language :: Python :: 3.7
8
+ Classifier: Development Status :: 2 - Pre-Alpha
9
+ Classifier: Environment :: Win32 (MS Windows)
10
+ Classifier: Environment :: MacOS X
11
+ Classifier: Environment :: X11 Applications
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+
18
+ ### FileAutomation
19
+
20
+ ### Documentation
21
+
22
+ * TODO
23
+
24
+ ---
25
+ > Project Kanban \
26
+ > https://github.com/orgs/Intergration-Automation-Testing/projects/2 \
27
+ > FileAutomation is used to manager files and dirs.
28
+
29
+
30
+ ---
31
+ ### Features
32
+ * Process multi file.
33
+ * copy file.
34
+ * copy specify extension file.
35
+ * copy all file to dir.
36
+ * rename file.
37
+ * remove file.
38
+ * Process multi dir.
39
+ * copy dir.
40
+ * remove dir.
41
+ * rename dir.
42
+ * create dir.
43
+ * Process zip files.
44
+ * zip a dir.
45
+ * zip a file.
46
+ * read zip file.
47
+ * unzip file on zip.
48
+ * un zip all file on zip.
49
+ * show zip info.
50
+ * show file on zip info.
51
+
52
+ ## install
53
+ > pip install automation_file
54
+
55
+ ## Requires
56
+ > python 3.8 or later
57
+
58
+ ### Architecture Diagram
59
+
60
+
61
+ * TODO
@@ -0,0 +1,21 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ automation_file_dev.egg-info/PKG-INFO
5
+ automation_file_dev.egg-info/SOURCES.txt
6
+ automation_file_dev.egg-info/dependency_links.txt
7
+ automation_file_dev.egg-info/top_level.txt
8
+ file_automation/__init__.py
9
+ file_automation/local/__init__.py
10
+ file_automation/local/dir/__init__.py
11
+ file_automation/local/dir/dir_process.py
12
+ file_automation/local/file/__init__.py
13
+ file_automation/local/file/file_process.py
14
+ file_automation/local/zip/__init__.py
15
+ file_automation/local/zip/zip_process.py
16
+ file_automation/remote/__init__.py
17
+ file_automation/remote/google_drive/__init__.py
18
+ file_automation/utils/__init__.py
19
+ file_automation/utils/exception/__init__.py
20
+ file_automation/utils/exception/exception_tags.py
21
+ file_automation/utils/exception/exceptions.py
@@ -0,0 +1,6 @@
1
+ __all__ = [
2
+ "copy_file", "rename_file", "remove_file", "copy_all_file_to_dir", "copy_specify_extension_file",
3
+ "copy_dir", "create_dir", "copy_specify_extension_file", "remove_dir_tree",
4
+ "zip_dir", "zip_file", "zip_info", "zip_file_info", "set_zip_password", "unzip_file", "read_zip_file",
5
+ "unzip_all"
6
+ ]
@@ -0,0 +1,43 @@
1
+ import os
2
+ import shutil
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ from file_automation.utils.exception.exceptions import DirNotExistsException
7
+
8
+
9
+ def copy_dir(dir_path: str, target_dir_path: str):
10
+ dir_path = Path(dir_path)
11
+ target_dir_path = Path(target_dir_path)
12
+ if dir_path.is_dir():
13
+ try:
14
+ shutil.copytree(dir_path, target_dir_path, dirs_exist_ok=True)
15
+ except shutil.Error as error:
16
+ print(repr(error))
17
+ else:
18
+ print(repr(DirNotExistsException), file=sys.stderr)
19
+
20
+
21
+ def remove_dir_tree(dir_path: str):
22
+ dir_path = Path(dir_path)
23
+ if dir_path.is_dir():
24
+ try:
25
+ shutil.rmtree(dir_path)
26
+ except shutil.Error as error:
27
+ print(repr(error))
28
+
29
+
30
+ def rename_dir(origin_dir_path, target_dir: str):
31
+ origin_dir_path = Path(origin_dir_path)
32
+ if origin_dir_path.exists() and origin_dir_path.is_dir():
33
+ try:
34
+ Path.rename(origin_dir_path, target_dir)
35
+ except Exception as error:
36
+ print(repr(error))
37
+ else:
38
+ print(repr(DirNotExistsException), file=sys.stderr)
39
+
40
+
41
+ def create_dir(dir_path: str):
42
+ dir_path = Path(dir_path)
43
+ dir_path.mkdir(exist_ok=True)
@@ -0,0 +1,61 @@
1
+ import shutil
2
+ import sys
3
+ from pathlib import Path
4
+
5
+ from file_automation.utils.exception.exceptions import FileNotExistsException, DirNotExistsException
6
+
7
+
8
+ def copy_file(file_path: str, target_path: str):
9
+ file_path = Path(file_path)
10
+ if file_path.is_file() and file_path.exists():
11
+ try:
12
+ shutil.copy2(file_path, target_path)
13
+ except shutil.Error as error:
14
+ print(repr(error))
15
+ else:
16
+ print(repr(FileNotExistsException), file=sys.stderr)
17
+
18
+
19
+ def copy_specify_extension_file(file_dir_path: str, target_extension: str, target_path: str):
20
+ file_dir_path = Path(file_dir_path)
21
+ if file_dir_path.exists() and file_dir_path.is_dir():
22
+ for file in file_dir_path.glob(f"**/*.{target_extension}"):
23
+ copy_file(str(file), target_path)
24
+ else:
25
+ print(repr(DirNotExistsException), file=sys.stderr)
26
+
27
+
28
+ def copy_all_file_to_dir(dir_path: str, target_dir_path: str):
29
+ dir_path = Path(dir_path)
30
+ target_dir_path = Path(target_dir_path)
31
+ if dir_path.is_dir() and target_dir_path.is_dir():
32
+ try:
33
+ shutil.move(str(dir_path), str(target_dir_path))
34
+ except shutil.Error as error:
35
+ print(repr(error), file=sys.stderr)
36
+ else:
37
+ print(repr(DirNotExistsException), file=sys.stderr)
38
+
39
+
40
+ def rename_file(origin_file_path, target_name: str, file_extension=None):
41
+ origin_file_path = Path(origin_file_path)
42
+ if origin_file_path.exists() and origin_file_path.is_dir():
43
+ if file_extension is None:
44
+ file_list = list(origin_file_path.glob("**/*"))
45
+ else:
46
+ file_list = list(origin_file_path.glob(f"**/*.{file_extension}"))
47
+ try:
48
+ file_index = 0
49
+ for file in file_list:
50
+ file.rename(Path(origin_file_path, target_name))
51
+ file_index = file_index + 1
52
+ except Exception as error:
53
+ print(repr(error))
54
+ else:
55
+ print(repr(DirNotExistsException), file=sys.stderr)
56
+
57
+
58
+ def remove_file(file_path: str):
59
+ file_path = Path(file_path)
60
+ if file_path.exists() and file_path.is_file():
61
+ file_path.unlink(missing_ok=True)
@@ -0,0 +1,69 @@
1
+ import sys
2
+ import zipfile
3
+ from pathlib import Path
4
+ from shutil import make_archive
5
+ from typing import List
6
+
7
+ from file_automation.utils.exception.exceptions import ZIPGetWrongFileException
8
+
9
+
10
+ def zip_dir(dir_we_want_to_zip: str, zip_name: str):
11
+ make_archive(root_dir=dir_we_want_to_zip, base_name=zip_name, format="zip")
12
+
13
+
14
+ def zip_file(zip_file_path: str, file: [str, List[str]]):
15
+ current_zip = zipfile.ZipFile(zip_file_path, mode="w")
16
+ if isinstance(file, str):
17
+ file_name = Path(file)
18
+ current_zip.write(file, file_name.name)
19
+ else:
20
+ if isinstance(file, list):
21
+ for writeable in file:
22
+ file_name = Path(writeable)
23
+ current_zip.write(writeable, file_name.name)
24
+ else:
25
+ print(repr(ZIPGetWrongFileException), file=sys.stderr)
26
+ current_zip.close()
27
+
28
+
29
+ def read_zip_file(zip_file_path: str, file_name: str, password: [str, None] = None):
30
+ current_zip = zipfile.ZipFile(zip_file_path, mode="r")
31
+ data = None
32
+ with current_zip.open(name=file_name, mode="r", pwd=password, force_zip64=True) as read_file:
33
+ data = read_file.read()
34
+ current_zip.close()
35
+ return data
36
+
37
+
38
+ def unzip_file(zip_file_path: str, extract_member, extract_path: [str, None] = None, password: [str, None] = None):
39
+ current_zip = zipfile.ZipFile(zip_file_path, mode="r")
40
+ current_zip.extract(member=extract_member, path=extract_path, pwd=password)
41
+ current_zip.close()
42
+
43
+
44
+ def unzip_all(
45
+ zip_file_path: str, extract_member: [str, None] = None,
46
+ extract_path: [str, None] = None, password: [str, None] = None):
47
+ current_zip = zipfile.ZipFile(zip_file_path, mode="r")
48
+ current_zip.extractall(members=extract_member, path=extract_path, pwd=password)
49
+ current_zip.close()
50
+
51
+
52
+ def zip_info(zip_file_path: str):
53
+ current_zip = zipfile.ZipFile(zip_file_path, mode="r")
54
+ info_list = current_zip.infolist()
55
+ current_zip.close()
56
+ return info_list
57
+
58
+
59
+ def zip_file_info(zip_file_path: str):
60
+ current_zip = zipfile.ZipFile(zip_file_path, mode="r")
61
+ name_list = current_zip.namelist()
62
+ current_zip.close()
63
+ return name_list
64
+
65
+
66
+ def set_zip_password(zip_file_path: str, password: bytes):
67
+ current_zip = zipfile.ZipFile(zip_file_path)
68
+ current_zip.setpassword(pwd=password)
69
+ current_zip.close()
@@ -0,0 +1,10 @@
1
+ class FileNotExistsException(Exception):
2
+ pass
3
+
4
+
5
+ class DirNotExistsException(Exception):
6
+ pass
7
+
8
+
9
+ class ZIPGetWrongFileException(Exception):
10
+ pass
@@ -0,0 +1,31 @@
1
+ # Rename to dev version
2
+ # This is dev version
3
+ [build-system]
4
+ requires = ["setuptools>=61.0"]
5
+ build-backend = "setuptools.build_meta"
6
+
7
+ [project]
8
+ name = "automation_file_dev"
9
+ version = "0.0.3"
10
+ authors = [
11
+ { name = "JE-Chen", email = "zenmailman@gmail.com" },
12
+ ]
13
+ description = ""
14
+ readme = { file = "README.md", content-type = "text/markdown" }
15
+ requires-python = ">=3.8"
16
+ license = { text = "MIT" }
17
+ classifiers = [
18
+ "Programming Language :: Python :: 3.7",
19
+ "Development Status :: 2 - Pre-Alpha",
20
+ "Environment :: Win32 (MS Windows)",
21
+ "Environment :: MacOS X",
22
+ "Environment :: X11 Applications",
23
+ "License :: OSI Approved :: MIT License",
24
+ "Operating System :: OS Independent"
25
+ ]
26
+
27
+ [project.urls]
28
+ "Homepage" = "https://github.com/JE-Chen/Integration-testing-environment"
29
+
30
+ [tool.setuptools.packages]
31
+ find = { namespaces = false }
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+