solax-py-library 0.1.0.8__py3-none-any.whl → 0.1.0.10__py3-none-any.whl

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.
@@ -1,17 +1,24 @@
1
1
  import csv
2
2
  import tempfile
3
+ from typing import Any, Union, List, Dict
3
4
 
4
5
  from solax_py_library.upload.core.data_adapter.base import BaseDataAdapter
5
6
 
6
7
 
7
8
  class CSVDataAdapter(BaseDataAdapter):
8
9
  @classmethod
9
- def parse_data(cls, data):
10
+ def parse_data(cls, data: Union[List[List[Any]], List[Dict[str, Any]]]):
10
11
  with tempfile.NamedTemporaryFile(
11
12
  delete=False, mode="w", newline="", encoding="utf8"
12
13
  ) as temp_file:
13
- writer = csv.writer(temp_file)
14
- writer.writerows(data)
14
+
15
+ if isinstance(data[0], list):
16
+ writer = csv.writer(temp_file)
17
+ writer.writerows(data)
18
+ else:
19
+ headers = list(data[0].keys())
20
+ writer = csv.DictWriter(temp_file, fieldnames=headers)
21
+ writer.writerows(data)
15
22
 
16
23
  temp_file_path = temp_file.name
17
24
  temp_file.seek(0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: solax-py-library
3
- Version: 0.1.0.8
3
+ Version: 0.1.0.10
4
4
  Summary: some common tool
5
5
  Author: shenlvyu
6
6
  Author-email: 13296718439@163.com
@@ -5,7 +5,7 @@ solax_py_library/upload/api/service.py,sha256=RJ8oqIqsVA8d978UDGgNfxYTDJ44nWIfQB
5
5
  solax_py_library/upload/core/__init__.py,sha256=XMcnyDzCfsLwWaTAZt9-an7TuwYFqVNSt9W1_QRUrwA,89
6
6
  solax_py_library/upload/core/data_adapter/__init__.py,sha256=9CXepLZSOjZMfNjyYKAWQCWZt353kTL_0tFBlIeUIOo,116
7
7
  solax_py_library/upload/core/data_adapter/base.py,sha256=Va-SEe0eL3gobhNOnzHGkYBLIwf5RVawQdYRHHXg9g0,170
8
- solax_py_library/upload/core/data_adapter/csv.py,sha256=LR-45i1Guihrm_eN2Li9kNoutTAsiPeWQNTUz2HJmok,518
8
+ solax_py_library/upload/core/data_adapter/csv.py,sha256=G6RFXTzJX42mwZ86RpCp_PWmJRfnmNE7ulId0eIAq1s,832
9
9
  solax_py_library/upload/core/upload_service/__init__.py,sha256=uA-UeH31rDNxByeZwvPhNFHPV_-J8JyCev8geuc---k,269
10
10
  solax_py_library/upload/core/upload_service/base.py,sha256=vl6QTxcx-QVFv0J1VN7HSgh4opouKfTpmJDkwQYzLVU,881
11
11
  solax_py_library/upload/core/upload_service/ftp.py,sha256=EyqaCn6b24rOKDbf-DqZQirq5JuDaVuApsb48RADsfk,2432
@@ -17,6 +17,6 @@ solax_py_library/upload/test/test_ftp.py,sha256=a3-jNQVjkoo_gh45yvnicGitIeJX6pco
17
17
  solax_py_library/upload/types/__init__.py,sha256=og9KBpYbcs36_S1izURj3vyHeuNOLJQrD9GpxK_JJaw,244
18
18
  solax_py_library/upload/types/client.py,sha256=IE4tw2KFRmZABptmujB7SXG2-61cW7X7qN9b2IrBF3Y,505
19
19
  solax_py_library/upload/types/ftp.py,sha256=RTREbHwvGz6hrz_VUaw8Rx5utB4LQisytcsI2jGT6zc,533
20
- solax_py_library-0.1.0.8.dist-info/METADATA,sha256=gsU0pqfIGRpQG_33PXXDH-6B3UCKCaydmRL8VX-2bPE,670
21
- solax_py_library-0.1.0.8.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
22
- solax_py_library-0.1.0.8.dist-info/RECORD,,
20
+ solax_py_library-0.1.0.10.dist-info/METADATA,sha256=aj92DxpdIPJ_J7ijc3VE5IzsKtIZjha1Bmh_Ia7thp8,671
21
+ solax_py_library-0.1.0.10.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
22
+ solax_py_library-0.1.0.10.dist-info/RECORD,,