solax-py-library 1.0.0.5__tar.gz → 1.0.0.7__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.
- solax_py_library-1.0.0.7/PKG-INFO +69 -0
- solax_py_library-1.0.0.7/README.md +50 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/pyproject.toml +1 -1
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/core/upload_service/base.py +1 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/core/upload_service/ftp.py +4 -4
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/test/test_ftp.py +4 -4
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/types/client.py +5 -5
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/types/ftp.py +7 -6
- solax_py_library-1.0.0.5/PKG-INFO +0 -20
- solax_py_library-1.0.0.5/README.md +0 -1
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/__init__.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/__init__.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/api/__init__.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/api/service.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/core/__init__.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/core/data_adapter/__init__.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/core/data_adapter/base.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/core/data_adapter/csv.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/core/upload_service/__init__.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/errors/__init__.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/errors/base.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/errors/upload_error.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/test/__init__.py +0 -0
- {solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/types/__init__.py +0 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: solax-py-library
|
3
|
+
Version: 1.0.0.7
|
4
|
+
Summary: some common tool
|
5
|
+
Author: shenlvyu
|
6
|
+
Author-email: 13296718439@163.com
|
7
|
+
Requires-Python: >=3.8,<4.0
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: Programming Language :: Python :: 3.8
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
15
|
+
Requires-Dist: pydantic (>=1.10.0,<2.0.0)
|
16
|
+
Requires-Dist: typing-extensions (==4.7.1)
|
17
|
+
Description-Content-Type: text/markdown
|
18
|
+
|
19
|
+
### solax common module
|
20
|
+
|
21
|
+
#### install
|
22
|
+
|
23
|
+
```shell
|
24
|
+
pip install solax_py_library
|
25
|
+
```
|
26
|
+
|
27
|
+
#### struction
|
28
|
+
|
29
|
+
module:
|
30
|
+
- api: provide the api
|
31
|
+
- core: core code
|
32
|
+
- errors: define errors
|
33
|
+
- test: unit tests
|
34
|
+
- types: modle define
|
35
|
+
|
36
|
+
#### module
|
37
|
+
|
38
|
+
This package provide some general modules to help us can focus on the real project coding.It`s our own package,we can add more and more general modules.
|
39
|
+
|
40
|
+
- upload: The module define the upload tool.It support the way by Ftp.
|
41
|
+
|
42
|
+
|
43
|
+
#### quick start
|
44
|
+
|
45
|
+
```python
|
46
|
+
await upload(
|
47
|
+
upload_type=UploadType.FTP,
|
48
|
+
configuration=ftp_config,
|
49
|
+
upload_data=UploadData(
|
50
|
+
upload_type=UploadType.FTP,
|
51
|
+
data=dict(
|
52
|
+
file_type=FTPFileType.CSV,
|
53
|
+
file_name="new_file.csv",
|
54
|
+
data=[
|
55
|
+
{
|
56
|
+
"EMS1000序列号": "XMG11A011L",
|
57
|
+
"EMS1000本地时间": "2025-02-11 15:39:10",
|
58
|
+
"EMS1000版本号": "V007.11.1",
|
59
|
+
"电站所在国家和地区": None,
|
60
|
+
"电站所在当前时区": None,
|
61
|
+
"电站系统类型": None,
|
62
|
+
}
|
63
|
+
],
|
64
|
+
),
|
65
|
+
),
|
66
|
+
)
|
67
|
+
```
|
68
|
+
|
69
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
### solax common module
|
2
|
+
|
3
|
+
#### install
|
4
|
+
|
5
|
+
```shell
|
6
|
+
pip install solax_py_library
|
7
|
+
```
|
8
|
+
|
9
|
+
#### struction
|
10
|
+
|
11
|
+
module:
|
12
|
+
- api: provide the api
|
13
|
+
- core: core code
|
14
|
+
- errors: define errors
|
15
|
+
- test: unit tests
|
16
|
+
- types: modle define
|
17
|
+
|
18
|
+
#### module
|
19
|
+
|
20
|
+
This package provide some general modules to help us can focus on the real project coding.It`s our own package,we can add more and more general modules.
|
21
|
+
|
22
|
+
- upload: The module define the upload tool.It support the way by Ftp.
|
23
|
+
|
24
|
+
|
25
|
+
#### quick start
|
26
|
+
|
27
|
+
```python
|
28
|
+
await upload(
|
29
|
+
upload_type=UploadType.FTP,
|
30
|
+
configuration=ftp_config,
|
31
|
+
upload_data=UploadData(
|
32
|
+
upload_type=UploadType.FTP,
|
33
|
+
data=dict(
|
34
|
+
file_type=FTPFileType.CSV,
|
35
|
+
file_name="new_file.csv",
|
36
|
+
data=[
|
37
|
+
{
|
38
|
+
"EMS1000序列号": "XMG11A011L",
|
39
|
+
"EMS1000本地时间": "2025-02-11 15:39:10",
|
40
|
+
"EMS1000版本号": "V007.11.1",
|
41
|
+
"电站所在国家和地区": None,
|
42
|
+
"电站所在当前时区": None,
|
43
|
+
"电站系统类型": None,
|
44
|
+
}
|
45
|
+
],
|
46
|
+
),
|
47
|
+
),
|
48
|
+
)
|
49
|
+
```
|
50
|
+
|
@@ -18,7 +18,7 @@ from solax_py_library.upload.errors.upload_error import (
|
|
18
18
|
|
19
19
|
|
20
20
|
class FTPUploadService(BaseUploadService):
|
21
|
-
upload_type = UploadType.FTP
|
21
|
+
upload_type = UploadType.FTP.value
|
22
22
|
|
23
23
|
def __init__(self, **kwargs):
|
24
24
|
super().__init__(**kwargs)
|
@@ -39,7 +39,7 @@ class FTPUploadService(BaseUploadService):
|
|
39
39
|
if self._client is not None:
|
40
40
|
self.close()
|
41
41
|
try:
|
42
|
-
self._client = ftplib.FTP(self.host)
|
42
|
+
self._client = ftplib.FTP(self.host, timeout=self.timeout)
|
43
43
|
self._client.login(self.user, self.password)
|
44
44
|
print(f"Connected to {self.host}")
|
45
45
|
self._is_connect = True
|
@@ -55,13 +55,13 @@ class FTPUploadService(BaseUploadService):
|
|
55
55
|
print("Connection closed.")
|
56
56
|
|
57
57
|
def _parse(self, upload_data: FTPData) -> FTPParsedData:
|
58
|
-
if upload_data.file_type == FTPFileType.CSV:
|
58
|
+
if upload_data.file_type == FTPFileType.CSV.value:
|
59
59
|
parsed_data = CSVDataAdapter.parse_data(upload_data.data)
|
60
60
|
else:
|
61
61
|
raise NotImplementedError
|
62
62
|
return FTPParsedData(
|
63
63
|
file_name=upload_data.build_full_path(self.remote_path)
|
64
|
-
+ upload_data.file_type
|
64
|
+
+ FTPFileType.get_file_suffix(upload_data.file_type),
|
65
65
|
file_path=parsed_data,
|
66
66
|
)
|
67
67
|
|
{solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/test/test_ftp.py
RENAMED
@@ -15,13 +15,13 @@ class FTPTest(unittest.TestCase):
|
|
15
15
|
"remote_path": "/xixi",
|
16
16
|
}
|
17
17
|
asyncio.run(upload(
|
18
|
-
upload_type=UploadType.FTP,
|
18
|
+
upload_type=UploadType.FTP.value,
|
19
19
|
configuration=ftp_config,
|
20
20
|
upload_data=UploadData(
|
21
|
-
upload_type=UploadType.FTP,
|
21
|
+
upload_type=UploadType.FTP.value,
|
22
22
|
data=dict(
|
23
|
-
file_type=FTPFileType.CSV,
|
24
|
-
file_name="new_file
|
23
|
+
file_type=FTPFileType.CSV.value,
|
24
|
+
file_name="new_file",
|
25
25
|
data=[
|
26
26
|
{
|
27
27
|
"EMS1000序列号": "XMG11A011L",
|
{solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/types/client.py
RENAMED
@@ -1,19 +1,19 @@
|
|
1
|
-
from enum import
|
1
|
+
from enum import IntEnum
|
2
2
|
from pydantic import BaseModel
|
3
3
|
from typing import Optional, Union
|
4
4
|
|
5
5
|
from solax_py_library.upload.types.ftp import FTPData
|
6
6
|
|
7
7
|
|
8
|
-
class UploadType(
|
9
|
-
FTP =
|
8
|
+
class UploadType(IntEnum):
|
9
|
+
FTP = 1
|
10
10
|
|
11
11
|
|
12
12
|
class UploadData(BaseModel):
|
13
13
|
data: Optional[Union[dict, FTPData]]
|
14
|
-
upload_type:
|
14
|
+
upload_type: UploadType
|
15
15
|
|
16
16
|
def build_data(self):
|
17
17
|
dict_obj_data = self.data if isinstance(self.data, dict) else self.data.dict()
|
18
|
-
if self.upload_type == UploadType.FTP:
|
18
|
+
if self.upload_type == UploadType.FTP.value:
|
19
19
|
return FTPData(**dict_obj_data)
|
@@ -1,17 +1,18 @@
|
|
1
1
|
import os
|
2
|
-
from enum import
|
2
|
+
from enum import IntEnum
|
3
3
|
from typing import Any, Optional
|
4
4
|
|
5
5
|
from pydantic import BaseModel
|
6
6
|
|
7
7
|
|
8
|
-
class FTPFileType(
|
9
|
-
CSV =
|
8
|
+
class FTPFileType(IntEnum):
|
9
|
+
CSV = 1
|
10
10
|
|
11
|
-
|
11
|
+
@classmethod
|
12
|
+
def get_file_suffix(cls, value):
|
12
13
|
return {
|
13
|
-
FTPFileType.CSV: ".csv",
|
14
|
-
}.get(
|
14
|
+
FTPFileType.CSV.value: ".csv",
|
15
|
+
}.get(value)
|
15
16
|
|
16
17
|
|
17
18
|
class FTPData(BaseModel):
|
@@ -1,20 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: solax-py-library
|
3
|
-
Version: 1.0.0.5
|
4
|
-
Summary: some common tool
|
5
|
-
Author: shenlvyu
|
6
|
-
Author-email: 13296718439@163.com
|
7
|
-
Requires-Python: >=3.8,<4.0
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: Programming Language :: Python :: 3.8
|
10
|
-
Classifier: Programming Language :: Python :: 3.9
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
15
|
-
Requires-Dist: pydantic (>=1.10.0,<2.0.0)
|
16
|
-
Requires-Dist: typing-extensions (==4.7.1)
|
17
|
-
Description-Content-Type: text/markdown
|
18
|
-
|
19
|
-
### solax common module
|
20
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
### solax common module
|
File without changes
|
File without changes
|
{solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/api/__init__.py
RENAMED
File without changes
|
{solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/api/service.py
RENAMED
File without changes
|
{solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/core/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/errors/__init__.py
RENAMED
File without changes
|
{solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/errors/base.py
RENAMED
File without changes
|
{solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/errors/upload_error.py
RENAMED
File without changes
|
{solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/test/__init__.py
RENAMED
File without changes
|
{solax_py_library-1.0.0.5 → solax_py_library-1.0.0.7}/solax_py_library/upload/types/__init__.py
RENAMED
File without changes
|