table-stream 0.1.0__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.
- table_stream-0.1.0/PKG-INFO +104 -0
- table_stream-0.1.0/README.md +93 -0
- table_stream-0.1.0/pyproject.toml +41 -0
- table_stream-0.1.0/setup.cfg +4 -0
- table_stream-0.1.0/table_stream/__init__.py +8 -0
- table_stream-0.1.0/table_stream/base/__init__.py +2 -0
- table_stream-0.1.0/table_stream/base/hash_map.py +160 -0
- table_stream-0.1.0/table_stream/base/mapping.py +153 -0
- table_stream-0.1.0/table_stream/erros/__init__.py +90 -0
- table_stream-0.1.0/table_stream/sheet/__init__.py +10 -0
- table_stream-0.1.0/table_stream/sheet/csv/__init__.py +97 -0
- table_stream-0.1.0/table_stream/sheet/excel/__init__.py +45 -0
- table_stream-0.1.0/table_stream/sheet/excel/_col_index.py +25 -0
- table_stream-0.1.0/table_stream/sheet/interface/__init__.py +63 -0
- table_stream-0.1.0/table_stream/sheet/load_adapter/__init__.py +64 -0
- table_stream-0.1.0/table_stream/sheet/ods/__init__.py +48 -0
- table_stream-0.1.0/table_stream/sheet/parse/__init__.py +183 -0
- table_stream-0.1.0/table_stream/thread/__init__.py +132 -0
- table_stream-0.1.0/table_stream/types/__init__.py +5 -0
- table_stream-0.1.0/table_stream/types/pattner/__init__.py +9 -0
- table_stream-0.1.0/table_stream/types/pattner/adapter/__init__.py +82 -0
- table_stream-0.1.0/table_stream/types/pattner/mediator/__init__.py +74 -0
- table_stream-0.1.0/table_stream/types/pattner/observer/__init__.py +166 -0
- table_stream-0.1.0/table_stream/types/workbook/__init__.py +20 -0
- table_stream-0.1.0/table_stream.egg-info/PKG-INFO +104 -0
- table_stream-0.1.0/table_stream.egg-info/SOURCES.txt +27 -0
- table_stream-0.1.0/table_stream.egg-info/dependency_links.txt +1 -0
- table_stream-0.1.0/table_stream.egg-info/requires.txt +4 -0
- table_stream-0.1.0/table_stream.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: table_stream
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tipos de dados e implementações para o uso em tabelas.
|
|
5
|
+
Requires-Python: >=3.14
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: odfpy>=1.4.1
|
|
8
|
+
Requires-Dist: openpyxl>=3.1.5
|
|
9
|
+
Requires-Dist: pandas>=3.0.0
|
|
10
|
+
Requires-Dist: soup-files>=1.4.2
|
|
11
|
+
|
|
12
|
+
# table
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Getting started
|
|
17
|
+
|
|
18
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
19
|
+
|
|
20
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
21
|
+
|
|
22
|
+
## Add your files
|
|
23
|
+
|
|
24
|
+
* [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
|
|
25
|
+
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
cd existing_repo
|
|
29
|
+
git remote add origin https://gitlab.com/bschaves/table.git
|
|
30
|
+
git branch -M main
|
|
31
|
+
git push -uf origin main
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Integrate with your tools
|
|
35
|
+
|
|
36
|
+
* [Set up project integrations](https://gitlab.com/bschaves/table/-/settings/integrations)
|
|
37
|
+
|
|
38
|
+
## Collaborate with your team
|
|
39
|
+
|
|
40
|
+
* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
|
|
41
|
+
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
|
|
42
|
+
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
|
|
43
|
+
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
|
|
44
|
+
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
45
|
+
|
|
46
|
+
## Test and Deploy
|
|
47
|
+
|
|
48
|
+
Use the built-in continuous integration in GitLab.
|
|
49
|
+
|
|
50
|
+
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
|
|
51
|
+
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
|
|
52
|
+
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
|
|
53
|
+
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
|
|
54
|
+
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
|
|
55
|
+
|
|
56
|
+
***
|
|
57
|
+
|
|
58
|
+
# Editing this README
|
|
59
|
+
|
|
60
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
61
|
+
|
|
62
|
+
## Suggestions for a good README
|
|
63
|
+
|
|
64
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
65
|
+
|
|
66
|
+
## Name
|
|
67
|
+
Choose a self-explaining name for your project.
|
|
68
|
+
|
|
69
|
+
## Description
|
|
70
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
71
|
+
|
|
72
|
+
## Badges
|
|
73
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
74
|
+
|
|
75
|
+
## Visuals
|
|
76
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
77
|
+
|
|
78
|
+
## Installation
|
|
79
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
83
|
+
|
|
84
|
+
## Support
|
|
85
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
86
|
+
|
|
87
|
+
## Roadmap
|
|
88
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
89
|
+
|
|
90
|
+
## Contributing
|
|
91
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
92
|
+
|
|
93
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
94
|
+
|
|
95
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
96
|
+
|
|
97
|
+
## Authors and acknowledgment
|
|
98
|
+
Show your appreciation to those who have contributed to the project.
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
For open source projects, say how it is licensed.
|
|
102
|
+
|
|
103
|
+
## Project status
|
|
104
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# table
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
* [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
|
|
14
|
+
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin https://gitlab.com/bschaves/table.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
* [Set up project integrations](https://gitlab.com/bschaves/table/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
|
|
30
|
+
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
|
|
31
|
+
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
|
|
32
|
+
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
|
|
33
|
+
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
|
|
40
|
+
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
|
|
41
|
+
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
|
|
42
|
+
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
|
|
43
|
+
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
|
|
53
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
|
+
|
|
55
|
+
## Name
|
|
56
|
+
Choose a self-explaining name for your project.
|
|
57
|
+
|
|
58
|
+
## Description
|
|
59
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
|
+
|
|
61
|
+
## Badges
|
|
62
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
|
+
|
|
64
|
+
## Visuals
|
|
65
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
|
+
|
|
73
|
+
## Support
|
|
74
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
|
+
|
|
76
|
+
## Roadmap
|
|
77
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
+
|
|
82
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
|
+
|
|
84
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
|
+
|
|
86
|
+
## Authors and acknowledgment
|
|
87
|
+
Show your appreciation to those who have contributed to the project.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
For open source projects, say how it is licensed.
|
|
91
|
+
|
|
92
|
+
## Project status
|
|
93
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "table_stream"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Tipos de dados e implementações para o uso em tabelas."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.14"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"odfpy>=1.4.1",
|
|
9
|
+
"openpyxl>=3.1.5",
|
|
10
|
+
"pandas>=3.0.0",
|
|
11
|
+
"soup-files>=1.4.2",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[dependency-groups]
|
|
15
|
+
dev = [
|
|
16
|
+
"build>=1.4.0",
|
|
17
|
+
"twine>=6.2.0",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[tool.setuptools]
|
|
21
|
+
packages = [
|
|
22
|
+
"table_stream",
|
|
23
|
+
"table_stream.base",
|
|
24
|
+
"table_stream.erros",
|
|
25
|
+
"table_stream.thread",
|
|
26
|
+
"table_stream.sheet",
|
|
27
|
+
"table_stream.sheet.csv",
|
|
28
|
+
"table_stream.sheet.excel",
|
|
29
|
+
"table_stream.sheet.ods",
|
|
30
|
+
"table_stream.sheet.parse",
|
|
31
|
+
"table_stream.sheet.interface",
|
|
32
|
+
"table_stream.sheet.load_adapter",
|
|
33
|
+
"table_stream.types",
|
|
34
|
+
"table_stream.types.workbook",
|
|
35
|
+
"table_stream.types.pattner",
|
|
36
|
+
"table_stream.types.pattner.adapter",
|
|
37
|
+
"table_stream.types.pattner.mediator",
|
|
38
|
+
"table_stream.types.pattner.observer",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from .base import HashMap, hashMapName, HashMapDataFrame, HashMapDict, ArrayList, K, T
|
|
2
|
+
from .types import (
|
|
3
|
+
WorkbookData, MessageNotification, Provider, Listener, EVENT_TYPE, VALUE,
|
|
4
|
+
Mediator, ComponentMediator
|
|
5
|
+
)
|
|
6
|
+
from .thread import ControlledThread, ThreadConsumer
|
|
7
|
+
from .sheet import SheetLoader, InterfaceSheetLoad, ParserData
|
|
8
|
+
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
from typing import Any, Literal
|
|
2
|
+
from pandas.core.api import DataFrame
|
|
3
|
+
from table_stream.base.mapping import ArrayList, HashMap, T
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class HashMapDict[K, T](HashMap):
|
|
8
|
+
|
|
9
|
+
def __init__(self, _mapping: dict[K, T] | None = None) -> None:
|
|
10
|
+
super().__init__()
|
|
11
|
+
if _mapping is None:
|
|
12
|
+
_mapping = dict()
|
|
13
|
+
self._mapping: dict[K, T] = _mapping
|
|
14
|
+
|
|
15
|
+
def size_values(self) -> int:
|
|
16
|
+
return len(self._mapping.values())
|
|
17
|
+
|
|
18
|
+
def size_header(self) -> int:
|
|
19
|
+
return self.header().size()
|
|
20
|
+
|
|
21
|
+
def __getitem__(self, key: K) -> T:
|
|
22
|
+
return self._mapping[key]
|
|
23
|
+
|
|
24
|
+
def __setitem__(self, key: K, value: T) -> None:
|
|
25
|
+
self._mapping[key] = value
|
|
26
|
+
|
|
27
|
+
def get_hash_map_name(self) -> Literal['DICT']:
|
|
28
|
+
return "DICT"
|
|
29
|
+
|
|
30
|
+
def get_real_hash_map(self) -> dict[K, T]:
|
|
31
|
+
return self._mapping
|
|
32
|
+
|
|
33
|
+
def set_real_hash_map(self, hash_map: dict[K, T]) -> None:
|
|
34
|
+
self._mapping = hash_map
|
|
35
|
+
|
|
36
|
+
def clear(self) -> None:
|
|
37
|
+
self._mapping.clear()
|
|
38
|
+
|
|
39
|
+
def get_first(self) -> T:
|
|
40
|
+
return self._mapping[self.header().get_first()]
|
|
41
|
+
|
|
42
|
+
def set_first(self, value: T) -> None:
|
|
43
|
+
self._mapping[self.header().get_first()] = value
|
|
44
|
+
|
|
45
|
+
def get_last(self) -> T:
|
|
46
|
+
return self._mapping[self.header().get_last()]
|
|
47
|
+
|
|
48
|
+
def set_last(self, value: T) -> None:
|
|
49
|
+
self._mapping[self.header().get_last()] = value
|
|
50
|
+
|
|
51
|
+
def set_value(self, key: K, value: T) -> None:
|
|
52
|
+
self._mapping[key] = value
|
|
53
|
+
|
|
54
|
+
def get_value(self, key: K) -> T:
|
|
55
|
+
return self._mapping[key]
|
|
56
|
+
|
|
57
|
+
def header(self) -> ArrayList[K]:
|
|
58
|
+
return ArrayList(list(self._mapping.keys()))
|
|
59
|
+
|
|
60
|
+
def values(self) -> ArrayList[T]:
|
|
61
|
+
return ArrayList(list(self._mapping.values()))
|
|
62
|
+
|
|
63
|
+
def delete_items(self, keys: list[K]) -> None:
|
|
64
|
+
for k in keys:
|
|
65
|
+
self._mapping.pop(k)
|
|
66
|
+
|
|
67
|
+
def to_json(self) -> str:
|
|
68
|
+
"""
|
|
69
|
+
Converte o mapa real para uma string JSON.
|
|
70
|
+
Nota: As chaves e valores devem ser serializáveis pelo módulo json.
|
|
71
|
+
"""
|
|
72
|
+
return json.dumps(self.to_map_str(), ensure_ascii=False, indent=4)
|
|
73
|
+
|
|
74
|
+
def to_map_str(self) -> dict[str, Any]:
|
|
75
|
+
final = dict()
|
|
76
|
+
for i in self.header():
|
|
77
|
+
final[str(i)] = str(self.get_value(i))
|
|
78
|
+
return final
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class HashMapDataFrame[K, Series](HashMap):
|
|
82
|
+
|
|
83
|
+
def __init__(self, data: DataFrame | None) -> None:
|
|
84
|
+
super().__init__()
|
|
85
|
+
if data is None:
|
|
86
|
+
data = DataFrame()
|
|
87
|
+
self._data: DataFrame = data
|
|
88
|
+
|
|
89
|
+
def size_values(self) -> int:
|
|
90
|
+
return len(self.values())
|
|
91
|
+
|
|
92
|
+
def size_header(self) -> int:
|
|
93
|
+
return len(self.header())
|
|
94
|
+
|
|
95
|
+
def __getitem__(self, key: K) -> Series:
|
|
96
|
+
return self._data[key]
|
|
97
|
+
|
|
98
|
+
def __setitem__(self, key: K, value: Series) -> None:
|
|
99
|
+
self._data[key] = value
|
|
100
|
+
|
|
101
|
+
def get_hash_map_name(self) -> Literal['DATAFRAME']:
|
|
102
|
+
return "DATAFRAME"
|
|
103
|
+
|
|
104
|
+
def get_real_hash_map(self) -> DataFrame:
|
|
105
|
+
return self._data
|
|
106
|
+
|
|
107
|
+
def set_real_hash_map(self, hash_map: DataFrame) -> None:
|
|
108
|
+
self._data = hash_map
|
|
109
|
+
|
|
110
|
+
def clear(self) -> None:
|
|
111
|
+
self._data = DataFrame()
|
|
112
|
+
|
|
113
|
+
def get_first(self) -> Series:
|
|
114
|
+
return self._data[self.header().get_first()]
|
|
115
|
+
|
|
116
|
+
def set_first(self, value: Series) -> None:
|
|
117
|
+
self._data[self.header().get_first()] = value
|
|
118
|
+
|
|
119
|
+
def get_last(self) -> Series:
|
|
120
|
+
return self._data[self.header().get_last()]
|
|
121
|
+
|
|
122
|
+
def set_last(self, value: T) -> None:
|
|
123
|
+
raise NotImplementedError
|
|
124
|
+
|
|
125
|
+
def set_value(self, key: K, value: Series) -> None:
|
|
126
|
+
self._data[key] = value
|
|
127
|
+
|
|
128
|
+
def get_value(self, key: K) -> Series:
|
|
129
|
+
return self._data[key]
|
|
130
|
+
|
|
131
|
+
def header(self) -> ArrayList[K]:
|
|
132
|
+
return ArrayList(self._data.columns.tolist())
|
|
133
|
+
|
|
134
|
+
def values(self) -> ArrayList[Any]:
|
|
135
|
+
return ArrayList(self._data.values.tolist())
|
|
136
|
+
|
|
137
|
+
def delete_items(self, keys: list[K]) -> None:
|
|
138
|
+
"""
|
|
139
|
+
Remove as colunas informadas.
|
|
140
|
+
"""
|
|
141
|
+
# axis=1 indica que queremos remover colunas (as chaves do seu mapa)
|
|
142
|
+
# errors='ignore' evita que o código quebre caso uma chave não exista
|
|
143
|
+
#self._data.drop(columns=keys, axis=1, inplace=True, errors='ignore'
|
|
144
|
+
self._data.drop(columns=keys, inplace=True, errors="ignore",)
|
|
145
|
+
|
|
146
|
+
def to_json(self) -> str:
|
|
147
|
+
"""
|
|
148
|
+
Serializa o DataFrame para JSON.
|
|
149
|
+
Mantém estrutura por colunas.
|
|
150
|
+
"""
|
|
151
|
+
return self._data.astype(str).to_json(orient="columns", force_ascii=False, indent=4)
|
|
152
|
+
|
|
153
|
+
def to_map_str(self) -> dict[str, Any]:
|
|
154
|
+
return self._data.astype('str').to_dict()
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
from abc import abstractmethod, ABC, ABCMeta
|
|
4
|
+
from collections.abc import Iterator
|
|
5
|
+
from typing import Any, Callable, TypeVar, Generic, Union, Literal
|
|
6
|
+
#import pandas as pd
|
|
7
|
+
#from pandas import Series
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
T = TypeVar('T')
|
|
11
|
+
K = TypeVar('K')
|
|
12
|
+
hashMapName = Literal['DATAFRAME', 'DICT']
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ArrayList[T](list):
|
|
16
|
+
|
|
17
|
+
def __init__(self, items: list[T] | None = None):
|
|
18
|
+
if items is None:
|
|
19
|
+
items = list()
|
|
20
|
+
super().__init__(items)
|
|
21
|
+
|
|
22
|
+
def set_items(self, items: list[T]):
|
|
23
|
+
self.clear()
|
|
24
|
+
super().__init__(items)
|
|
25
|
+
|
|
26
|
+
def for_each(self, func: Callable[[T], Any | None]) -> None:
|
|
27
|
+
for x in self: func(x)
|
|
28
|
+
|
|
29
|
+
def apply_command(self, func: Callable[[T], Any]) -> ArrayList[Any]:
|
|
30
|
+
return ArrayList([func(x) for x in self])
|
|
31
|
+
|
|
32
|
+
def size(self) -> int:
|
|
33
|
+
return len(self)
|
|
34
|
+
|
|
35
|
+
def empty(self) -> bool:
|
|
36
|
+
return self.size() == 0
|
|
37
|
+
|
|
38
|
+
def get_first(self) -> T:
|
|
39
|
+
return self[0]
|
|
40
|
+
|
|
41
|
+
def get_last(self) -> T:
|
|
42
|
+
return self[-1]
|
|
43
|
+
|
|
44
|
+
def hash(self) -> int:
|
|
45
|
+
return hash(tuple(self))
|
|
46
|
+
|
|
47
|
+
def contains(self, _o: T) -> bool:
|
|
48
|
+
for i in self:
|
|
49
|
+
if i == _o:
|
|
50
|
+
return True
|
|
51
|
+
return False
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class HashMap[K, T](metaclass=ABCMeta):
|
|
55
|
+
|
|
56
|
+
def __repr__(self) -> str:
|
|
57
|
+
return f"<HashMap()> {self.header()}"
|
|
58
|
+
|
|
59
|
+
@abstractmethod
|
|
60
|
+
def size_values(self) -> int:
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
@abstractmethod
|
|
64
|
+
def size_header(self) -> int:
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
@abstractmethod
|
|
68
|
+
def __getitem__(self, key: K) -> T:
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
@abstractmethod
|
|
72
|
+
def __setitem__(self, key: K, value: T) -> None:
|
|
73
|
+
pass
|
|
74
|
+
|
|
75
|
+
@abstractmethod
|
|
76
|
+
def get_hash_map_name(self) -> hashMapName:
|
|
77
|
+
pass
|
|
78
|
+
|
|
79
|
+
@abstractmethod
|
|
80
|
+
def get_real_hash_map(self) -> Union[dict[K, T], pd.DataFrame]:
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
@abstractmethod
|
|
84
|
+
def set_real_hash_map(self, hash_map: dict[K, T] | pd.DataFrame) -> None:
|
|
85
|
+
pass
|
|
86
|
+
|
|
87
|
+
@abstractmethod
|
|
88
|
+
def clear(self) -> None:
|
|
89
|
+
pass
|
|
90
|
+
|
|
91
|
+
@abstractmethod
|
|
92
|
+
def get_first(self) -> T:
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
@abstractmethod
|
|
96
|
+
def set_first(self, value: T) -> None:
|
|
97
|
+
pass
|
|
98
|
+
|
|
99
|
+
@abstractmethod
|
|
100
|
+
def get_last(self) -> T:
|
|
101
|
+
pass
|
|
102
|
+
|
|
103
|
+
@abstractmethod
|
|
104
|
+
def set_last(self, value: T) -> None:
|
|
105
|
+
pass
|
|
106
|
+
|
|
107
|
+
@abstractmethod
|
|
108
|
+
def set_value(self, key: K, value: T) -> None:
|
|
109
|
+
pass
|
|
110
|
+
|
|
111
|
+
@abstractmethod
|
|
112
|
+
def get_value(self, key: K) -> T:
|
|
113
|
+
pass
|
|
114
|
+
|
|
115
|
+
@abstractmethod
|
|
116
|
+
def header(self) -> ArrayList[K]:
|
|
117
|
+
"""
|
|
118
|
+
Retornar as chaves de um dicionário ou columns de um DataFrame()
|
|
119
|
+
"""
|
|
120
|
+
pass
|
|
121
|
+
|
|
122
|
+
@abstractmethod
|
|
123
|
+
def values(self) -> ArrayList[T]:
|
|
124
|
+
pass
|
|
125
|
+
|
|
126
|
+
@abstractmethod
|
|
127
|
+
def delete_items(self, keys: list[K]) -> None:
|
|
128
|
+
"""
|
|
129
|
+
Apaga chaves e valores, semelhante ao método pop().
|
|
130
|
+
"""
|
|
131
|
+
pass
|
|
132
|
+
|
|
133
|
+
@abstractmethod
|
|
134
|
+
def to_json(self) -> str:
|
|
135
|
+
"""
|
|
136
|
+
Converte o HashMap() para uma representação no formato json.
|
|
137
|
+
"""
|
|
138
|
+
pass
|
|
139
|
+
|
|
140
|
+
@abstractmethod
|
|
141
|
+
def to_map_str(self) -> dict[str, Any]:
|
|
142
|
+
"""
|
|
143
|
+
Converte o HashMap() para uma representação no formato dict() python.
|
|
144
|
+
"""
|
|
145
|
+
pass
|
|
146
|
+
|
|
147
|
+
@classmethod
|
|
148
|
+
def from_json(cls, data: str) -> HashMap:
|
|
149
|
+
pass
|
|
150
|
+
|
|
151
|
+
@classmethod
|
|
152
|
+
def from_map(cls, data: Any) -> HashMap:
|
|
153
|
+
pass
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
class CoreException(Exception):
|
|
2
|
+
|
|
3
|
+
def __init__(self, message: str = f'Erro') -> None:
|
|
4
|
+
super().__init__(message)
|
|
5
|
+
self._message = message
|
|
6
|
+
|
|
7
|
+
def get_message(self) -> str:
|
|
8
|
+
return self._message
|
|
9
|
+
|
|
10
|
+
def set_message(self, message: str) -> None:
|
|
11
|
+
self._message = message
|
|
12
|
+
super().__init__(f"{__class__.__name__}: {message}")
|
|
13
|
+
|
|
14
|
+
def launch_exception_handler(self) -> None:
|
|
15
|
+
raise self
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#============================================================#
|
|
19
|
+
# Erros relacionados a HashMap
|
|
20
|
+
#============================================================#
|
|
21
|
+
class InvalidHashMapTableError(CoreException):
|
|
22
|
+
|
|
23
|
+
def __init__(self, message: str = 'HashMap inválido') -> None:
|
|
24
|
+
super().__init__(message)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class InvalidBodyTableError(InvalidHashMapTableError):
|
|
28
|
+
|
|
29
|
+
def __init__(self, message: str = 'Erro corpo de tabela inválido') -> None:
|
|
30
|
+
super().__init__(message)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class SizeTableError(InvalidHashMapTableError):
|
|
34
|
+
|
|
35
|
+
def __init__(self, message: str = 'Tamanho de tabela inválido') -> None:
|
|
36
|
+
super().__init__(message)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
#============================================================#
|
|
40
|
+
# Erros relacionados a planilhas
|
|
41
|
+
#============================================================#
|
|
42
|
+
class UndefinedSheetIndex(CoreException):
|
|
43
|
+
|
|
44
|
+
def __init__(self, message: str = 'SheetIndexNames não foi definido') -> None:
|
|
45
|
+
super().__init__(message)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class LoadWorkbookError(CoreException):
|
|
49
|
+
|
|
50
|
+
def __init__(self, message: str = 'Erro ao tentar ler Workbook') -> None:
|
|
51
|
+
super().__init__(message)
|
|
52
|
+
|
|
53
|
+
#============================================================#
|
|
54
|
+
# Erros relacionados a arquivos/bytes de imagem (.png, .jpg, ...)
|
|
55
|
+
#============================================================#
|
|
56
|
+
class InvalidSourceImageError(CoreException):
|
|
57
|
+
|
|
58
|
+
def __init__(self, message: str = 'Erro, use bytes de imagem') -> None:
|
|
59
|
+
super().__init__(message)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
#============================================================#
|
|
63
|
+
# Erros relacionados a módulos
|
|
64
|
+
#============================================================#
|
|
65
|
+
class NotImplementedModuleError(CoreException):
|
|
66
|
+
|
|
67
|
+
def __init__(self, message: str = 'Erro, módulo não implementado') -> None:
|
|
68
|
+
super().__init__(message)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class NotImplementedModuleImageError(NotImplementedModuleError):
|
|
72
|
+
|
|
73
|
+
def __init__(self, message: str = 'Erro, módulo IMAGEM não implementado') -> None:
|
|
74
|
+
super().__init__(message)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class NotImplementedModulePdfError(NotImplementedModuleError):
|
|
78
|
+
|
|
79
|
+
def __init__(self, message: str = 'Erro, módulo PDF não implementado') -> None:
|
|
80
|
+
super().__init__(message)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class NotImplementedInvertColor(NotImplementedError):
|
|
84
|
+
|
|
85
|
+
def __init__(self, message: str = 'Adaptador InvertColor não implementado...') -> None:
|
|
86
|
+
super().__init__(message)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from .excel import ExcelLoadPandasInterface
|
|
2
|
+
from .ods import ODSLoadPandasInterface
|
|
3
|
+
from .csv import (
|
|
4
|
+
CsvLoadPandasInterface, csvEncoding, CsvMapping, csvSeparator, create_csv_mapping,
|
|
5
|
+
CsvSeparatorList, CsvEncodingList,
|
|
6
|
+
)
|
|
7
|
+
from .parse import FilterData, ParserData
|
|
8
|
+
from .interface import InterfaceSheetLoad
|
|
9
|
+
from .load_adapter import SheetLoader
|
|
10
|
+
|