excel-list-transform 0.7.3__tar.gz → 0.7.6__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 (40) hide show
  1. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/PKG-INFO +31 -14
  2. excel_list_transform-0.7.3/excel_list_transform.egg-info/PKG-INFO → excel_list_transform-0.7.6/README_pypi.md +19 -28
  3. excel_list_transform-0.7.3/README_pypi.md → excel_list_transform-0.7.6/excel_list_transform.egg-info/PKG-INFO +45 -6
  4. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/excel_list_transform.egg-info/SOURCES.txt +1 -0
  5. excel_list_transform-0.7.6/excel_list_transform.egg-info/requires.txt +8 -0
  6. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/pyproject.toml +2 -2
  7. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/setup.py +7 -7
  8. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/generate_cfg.py +105 -17
  9. excel_list_transform-0.7.6/src/excel_list_transform/recode.py +76 -0
  10. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/transform_cmd.py +11 -3
  11. excel_list_transform-0.7.3/excel_list_transform.egg-info/requires.txt +0 -8
  12. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/LICENSE.txt +0 -0
  13. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/README.md +0 -0
  14. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/excel_list_transform.egg-info/dependency_links.txt +0 -0
  15. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/excel_list_transform.egg-info/top_level.txt +0 -0
  16. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/setup.cfg +0 -0
  17. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/__init__.py +0 -0
  18. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/__main__.py +0 -0
  19. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/check_indata_common.py +0 -0
  20. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/commontypes.py +0 -0
  21. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/config.py +0 -0
  22. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/config_enums.py +0 -0
  23. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/config_excel_list_transform.py +0 -0
  24. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/config_factory.py +0 -0
  25. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/config_xls_list_refmt_name.py +0 -0
  26. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/config_xls_list_refmt_num.py +0 -0
  27. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/file_extension.py +0 -0
  28. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/file_must_exist.py +0 -0
  29. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/generate_txt.py +0 -0
  30. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/handle_csv.py +0 -0
  31. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/handle_empty_column.py +0 -0
  32. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/handle_excel.py +0 -0
  33. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/num_named_conversion.py +0 -0
  34. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/py.typed +0 -0
  35. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/rewrite_value.py +0 -0
  36. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/str_to_enum.py +0 -0
  37. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/transform_func.py +0 -0
  38. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/transform_func_common.py +0 -0
  39. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/transform_func_named.py +0 -0
  40. {excel_list_transform-0.7.3 → excel_list_transform-0.7.6}/src/excel_list_transform/transform_func_num.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: excel-list-transform
3
- Version: 0.7.3
3
+ Version: 0.7.6
4
4
  Summary: Transform a list in excel or CSV
5
5
  Author: Tom Björkholm
6
6
  Author-email: Tom Björkholm <klausuler_linnet0q@icloud.com>
@@ -8,17 +8,21 @@ Project-URL: Source code, https://bitbucket.org/tom-bjorkholm/excel-list-transfo
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.12.6
11
+ Requires-Python: >=3.13.2
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE.txt
14
14
  Requires-Dist: openpyxl>=3.1.5
15
- Requires-Dist: types-openpyxl>=3.1.5.20241225
15
+ Requires-Dist: types-openpyxl>=3.1.5.20250306
16
16
  Requires-Dist: pylightxl>=1.61
17
- Requires-Dist: XlsxWriter>=3.2.0
18
- Requires-Dist: pip>=24.2
19
- Requires-Dist: setuptools>=75.6.0
20
- Requires-Dist: build>=1.2.2
17
+ Requires-Dist: XlsxWriter>=3.2.2
18
+ Requires-Dist: pip>=25.0.1
19
+ Requires-Dist: setuptools>=77.0.3
20
+ Requires-Dist: build>=1.2.2.post1
21
21
  Requires-Dist: wheel>=0.45.1
22
+ Dynamic: author
23
+ Dynamic: license-file
24
+ Dynamic: requires-dist
25
+ Dynamic: requires-python
22
26
 
23
27
  # excel-list-transform
24
28
 
@@ -59,15 +63,28 @@ pip3 install excel-list-transform
59
63
  pip install excel-list-transform
60
64
  ````
61
65
 
66
+ ## Version history
67
+
68
+ | Version | Date | Python version | Description |
69
+ |---------|-------------|-----------------|-------------------------------------|
70
+ | 0.5 | 10 Sep 2024 | 3.10.5 or newer | First released version |
71
+ | 0.6 | 22 Sep 2024 | 3.12.6 or newer | Configured encoding for CSV |
72
+ | 0.6.2 | 28 Sep 2024 | 3.12.6 or newer | Fix name in test report |
73
+ | 0.7.0 | 03 Nov 2024 | 3.12.6 or newer | Option to strip space in excel |
74
+ | 0.7.1 | 15 Dec 2024 | 3.12.6 or newer | Refactor tests |
75
+ | 0.7.3 | 06 Jan 2025 | 3.12.6 or newer | Example config for Sailwave to RRS |
76
+ | 0.7.5 | 21 Mar 2025 | 3.12.6 or newer | Example config for Sailarena to RRS |
77
+ | 0.7.6 | 21 Mar 2025 | 3.13.2 or newer | Adapted to Python 3.13.2 |
78
+
62
79
  ## Running the application
63
80
 
64
81
  ### Running the application on mac and Linux
65
82
 
66
83
  ````sh
67
84
  python3 -m excel_list_transform --help
68
- python3 -m excel_list_transform example --help
85
+ python3 -m excel_list_transform cfg-example --help
69
86
  python3 -m excel_list_transform transform --help
70
- python3 -m excel_list_transform example -k forms_to_rrs -r by_name -o example.cfg
87
+ python3 -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
71
88
  python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output.xlsx
72
89
  ````
73
90
 
@@ -75,15 +92,15 @@ python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output
75
92
 
76
93
  ````sh
77
94
  python -m excel_list_transform --help
78
- python -m excel_list_transform example --help
95
+ python -m excel_list_transform cfg-example --help
79
96
  python -m excel_list_transform transform --help
80
- python -m excel_list_transform example -k forms_to_rrs -r by_name -o example.cfg
97
+ python -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
81
98
  python -m excel_list_transform transform -c example.cfg -i input.xlsx -o output.xlsx
82
99
  ````
83
100
 
84
101
  ## Suggested way to get started
85
102
 
86
- 1. Use the "example" sub-command to generate a few example configuration (.cfg) files with description (.txt) files.
103
+ 1. Use the "cfg-example" sub-command to generate a few example configuration (.cfg) files with description (.txt) files.
87
104
  2. Read the example configuration (.cfg) files and the accompanying description (.txt) files.
88
105
  3. Find an example that is close to what you want to achieve.
89
106
  4. Modify that configuration file to achieve what you want to achieve.
@@ -92,7 +109,7 @@ python -m excel_list_transform transform -c example.cfg -i input.xlsx -o output.
92
109
 
93
110
  ### Example configuration files
94
111
 
95
- When using the "example" sub-command to generate an example configuration file (say example.cfg) a text file describing the configuration and the syntax of the configuration file is also generated. If the example configuration file is named example.cfg, then the text file descriging the configuration is named example.txt.
112
+ When using the "cfg-example" sub-command to generate an example configuration file (say example.cfg) a text file describing the configuration and the syntax of the configuration file is also generated. If the example configuration file is named example.cfg, then the text file descriging the configuration is named example.txt.
96
113
 
97
114
  You can generate several example configuration files each with an accompanying text file descriping it.
98
115
 
@@ -1,25 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: excel-list-transform
3
- Version: 0.7.3
4
- Summary: Transform a list in excel or CSV
5
- Author: Tom Björkholm
6
- Author-email: Tom Björkholm <klausuler_linnet0q@icloud.com>
7
- Project-URL: Source code, https://bitbucket.org/tom-bjorkholm/excel-list-transform
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.12.6
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE.txt
14
- Requires-Dist: openpyxl>=3.1.5
15
- Requires-Dist: types-openpyxl>=3.1.5.20241225
16
- Requires-Dist: pylightxl>=1.61
17
- Requires-Dist: XlsxWriter>=3.2.0
18
- Requires-Dist: pip>=24.2
19
- Requires-Dist: setuptools>=75.6.0
20
- Requires-Dist: build>=1.2.2
21
- Requires-Dist: wheel>=0.45.1
22
-
23
1
  # excel-list-transform
24
2
 
25
3
  ## Background
@@ -59,15 +37,28 @@ pip3 install excel-list-transform
59
37
  pip install excel-list-transform
60
38
  ````
61
39
 
40
+ ## Version history
41
+
42
+ | Version | Date | Python version | Description |
43
+ |---------|-------------|-----------------|-------------------------------------|
44
+ | 0.5 | 10 Sep 2024 | 3.10.5 or newer | First released version |
45
+ | 0.6 | 22 Sep 2024 | 3.12.6 or newer | Configured encoding for CSV |
46
+ | 0.6.2 | 28 Sep 2024 | 3.12.6 or newer | Fix name in test report |
47
+ | 0.7.0 | 03 Nov 2024 | 3.12.6 or newer | Option to strip space in excel |
48
+ | 0.7.1 | 15 Dec 2024 | 3.12.6 or newer | Refactor tests |
49
+ | 0.7.3 | 06 Jan 2025 | 3.12.6 or newer | Example config for Sailwave to RRS |
50
+ | 0.7.5 | 21 Mar 2025 | 3.12.6 or newer | Example config for Sailarena to RRS |
51
+ | 0.7.6 | 21 Mar 2025 | 3.13.2 or newer | Adapted to Python 3.13.2 |
52
+
62
53
  ## Running the application
63
54
 
64
55
  ### Running the application on mac and Linux
65
56
 
66
57
  ````sh
67
58
  python3 -m excel_list_transform --help
68
- python3 -m excel_list_transform example --help
59
+ python3 -m excel_list_transform cfg-example --help
69
60
  python3 -m excel_list_transform transform --help
70
- python3 -m excel_list_transform example -k forms_to_rrs -r by_name -o example.cfg
61
+ python3 -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
71
62
  python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output.xlsx
72
63
  ````
73
64
 
@@ -75,15 +66,15 @@ python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output
75
66
 
76
67
  ````sh
77
68
  python -m excel_list_transform --help
78
- python -m excel_list_transform example --help
69
+ python -m excel_list_transform cfg-example --help
79
70
  python -m excel_list_transform transform --help
80
- python -m excel_list_transform example -k forms_to_rrs -r by_name -o example.cfg
71
+ python -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
81
72
  python -m excel_list_transform transform -c example.cfg -i input.xlsx -o output.xlsx
82
73
  ````
83
74
 
84
75
  ## Suggested way to get started
85
76
 
86
- 1. Use the "example" sub-command to generate a few example configuration (.cfg) files with description (.txt) files.
77
+ 1. Use the "cfg-example" sub-command to generate a few example configuration (.cfg) files with description (.txt) files.
87
78
  2. Read the example configuration (.cfg) files and the accompanying description (.txt) files.
88
79
  3. Find an example that is close to what you want to achieve.
89
80
  4. Modify that configuration file to achieve what you want to achieve.
@@ -92,7 +83,7 @@ python -m excel_list_transform transform -c example.cfg -i input.xlsx -o output.
92
83
 
93
84
  ### Example configuration files
94
85
 
95
- When using the "example" sub-command to generate an example configuration file (say example.cfg) a text file describing the configuration and the syntax of the configuration file is also generated. If the example configuration file is named example.cfg, then the text file descriging the configuration is named example.txt.
86
+ When using the "cfg-example" sub-command to generate an example configuration file (say example.cfg) a text file describing the configuration and the syntax of the configuration file is also generated. If the example configuration file is named example.cfg, then the text file descriging the configuration is named example.txt.
96
87
 
97
88
  You can generate several example configuration files each with an accompanying text file descriping it.
98
89
 
@@ -1,3 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: excel-list-transform
3
+ Version: 0.7.6
4
+ Summary: Transform a list in excel or CSV
5
+ Author: Tom Björkholm
6
+ Author-email: Tom Björkholm <klausuler_linnet0q@icloud.com>
7
+ Project-URL: Source code, https://bitbucket.org/tom-bjorkholm/excel-list-transform
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.13.2
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE.txt
14
+ Requires-Dist: openpyxl>=3.1.5
15
+ Requires-Dist: types-openpyxl>=3.1.5.20250306
16
+ Requires-Dist: pylightxl>=1.61
17
+ Requires-Dist: XlsxWriter>=3.2.2
18
+ Requires-Dist: pip>=25.0.1
19
+ Requires-Dist: setuptools>=77.0.3
20
+ Requires-Dist: build>=1.2.2.post1
21
+ Requires-Dist: wheel>=0.45.1
22
+ Dynamic: author
23
+ Dynamic: license-file
24
+ Dynamic: requires-dist
25
+ Dynamic: requires-python
26
+
1
27
  # excel-list-transform
2
28
 
3
29
  ## Background
@@ -37,15 +63,28 @@ pip3 install excel-list-transform
37
63
  pip install excel-list-transform
38
64
  ````
39
65
 
66
+ ## Version history
67
+
68
+ | Version | Date | Python version | Description |
69
+ |---------|-------------|-----------------|-------------------------------------|
70
+ | 0.5 | 10 Sep 2024 | 3.10.5 or newer | First released version |
71
+ | 0.6 | 22 Sep 2024 | 3.12.6 or newer | Configured encoding for CSV |
72
+ | 0.6.2 | 28 Sep 2024 | 3.12.6 or newer | Fix name in test report |
73
+ | 0.7.0 | 03 Nov 2024 | 3.12.6 or newer | Option to strip space in excel |
74
+ | 0.7.1 | 15 Dec 2024 | 3.12.6 or newer | Refactor tests |
75
+ | 0.7.3 | 06 Jan 2025 | 3.12.6 or newer | Example config for Sailwave to RRS |
76
+ | 0.7.5 | 21 Mar 2025 | 3.12.6 or newer | Example config for Sailarena to RRS |
77
+ | 0.7.6 | 21 Mar 2025 | 3.13.2 or newer | Adapted to Python 3.13.2 |
78
+
40
79
  ## Running the application
41
80
 
42
81
  ### Running the application on mac and Linux
43
82
 
44
83
  ````sh
45
84
  python3 -m excel_list_transform --help
46
- python3 -m excel_list_transform example --help
85
+ python3 -m excel_list_transform cfg-example --help
47
86
  python3 -m excel_list_transform transform --help
48
- python3 -m excel_list_transform example -k forms_to_rrs -r by_name -o example.cfg
87
+ python3 -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
49
88
  python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output.xlsx
50
89
  ````
51
90
 
@@ -53,15 +92,15 @@ python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output
53
92
 
54
93
  ````sh
55
94
  python -m excel_list_transform --help
56
- python -m excel_list_transform example --help
95
+ python -m excel_list_transform cfg-example --help
57
96
  python -m excel_list_transform transform --help
58
- python -m excel_list_transform example -k forms_to_rrs -r by_name -o example.cfg
97
+ python -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
59
98
  python -m excel_list_transform transform -c example.cfg -i input.xlsx -o output.xlsx
60
99
  ````
61
100
 
62
101
  ## Suggested way to get started
63
102
 
64
- 1. Use the "example" sub-command to generate a few example configuration (.cfg) files with description (.txt) files.
103
+ 1. Use the "cfg-example" sub-command to generate a few example configuration (.cfg) files with description (.txt) files.
65
104
  2. Read the example configuration (.cfg) files and the accompanying description (.txt) files.
66
105
  3. Find an example that is close to what you want to achieve.
67
106
  4. Modify that configuration file to achieve what you want to achieve.
@@ -70,7 +109,7 @@ python -m excel_list_transform transform -c example.cfg -i input.xlsx -o output.
70
109
 
71
110
  ### Example configuration files
72
111
 
73
- When using the "example" sub-command to generate an example configuration file (say example.cfg) a text file describing the configuration and the syntax of the configuration file is also generated. If the example configuration file is named example.cfg, then the text file descriging the configuration is named example.txt.
112
+ When using the "cfg-example" sub-command to generate an example configuration file (say example.cfg) a text file describing the configuration and the syntax of the configuration file is also generated. If the example configuration file is named example.cfg, then the text file descriging the configuration is named example.txt.
74
113
 
75
114
  You can generate several example configuration files each with an accompanying text file descriping it.
76
115
 
@@ -27,6 +27,7 @@ src/excel_list_transform/handle_empty_column.py
27
27
  src/excel_list_transform/handle_excel.py
28
28
  src/excel_list_transform/num_named_conversion.py
29
29
  src/excel_list_transform/py.typed
30
+ src/excel_list_transform/recode.py
30
31
  src/excel_list_transform/rewrite_value.py
31
32
  src/excel_list_transform/str_to_enum.py
32
33
  src/excel_list_transform/transform_cmd.py
@@ -0,0 +1,8 @@
1
+ openpyxl>=3.1.5
2
+ types-openpyxl>=3.1.5.20250306
3
+ pylightxl>=1.61
4
+ XlsxWriter>=3.2.2
5
+ pip>=25.0.1
6
+ setuptools>=77.0.3
7
+ build>=1.2.2.post1
8
+ wheel>=0.45.1
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "excel-list-transform"
7
- version = "0.7.3"
7
+ version = "0.7.6"
8
8
  authors = [
9
9
  { name="Tom Björkholm", email="klausuler_linnet0q@icloud.com" },
10
10
  ]
11
11
  description = "Transform a list in excel or CSV"
12
12
  readme = "README_pypi.md"
13
- requires-python = ">=3.12.6"
13
+ requires-python = ">=3.13.2"
14
14
  classifiers = [
15
15
  "Programming Language :: Python :: 3",
16
16
  "License :: OSI Approved :: MIT License",
@@ -5,22 +5,22 @@ from setuptools import setup
5
5
 
6
6
  setup(
7
7
  name='excel-list-transform',
8
- version='0.7.3',
8
+ version='0.7.6',
9
9
  description='Transform a list in excel or CSV.',
10
10
  author='Tom Björkholm',
11
11
  author_email='klausuler_linnet0q@icloud.com',
12
- python_requires='>=3.12.6',
12
+ python_requires='>=3.13.2',
13
13
  packages=['excel_list_transform'],
14
14
  package_dir={'excel_list_transform': 'src/excel_list_transform'},
15
15
  package_data={'excel_list_transform': ['src/py.typed']},
16
16
  install_requires=[
17
17
  'openpyxl >= 3.1.5',
18
- 'types-openpyxl >= 3.1.5.20241225',
18
+ 'types-openpyxl >= 3.1.5.20250306',
19
19
  'pylightxl >= 1.61',
20
- 'XlsxWriter >= 3.2.0',
21
- 'pip >= 24.2',
22
- 'setuptools >= 75.6.0',
23
- 'build >= 1.2.2',
20
+ 'XlsxWriter >= 3.2.2',
21
+ 'pip >= 25.0.1',
22
+ 'setuptools >= 77.0.3',
23
+ 'build >= 1.2.2.post1',
24
24
  'wheel>=0.45.1'
25
25
  ]
26
26
  )
@@ -63,13 +63,13 @@ is "BY_NAME".
63
63
 
64
64
  syntax_o2r_common: str = syntax_only_o2r_common + syntax_o2x_common
65
65
 
66
- syntax_s2r_common: str = '''
66
+ syntax_sw2r_common: str = '''
67
67
 
68
68
  In this example the input data is exported as JSON or XML from SailWave
69
69
  https://www.sailwave.com . The data as a list in excel format is then
70
- extracted using extract-list https://pypi.org/project/extract-list.
71
- As SW only has a name field and not first name and last name fields,
72
- and as SW has not field for WhatsApp, this processing of the data is needed
70
+ extracted using extract-list https://pypi.org/project/extract-list. As
71
+ SailWave only has a name field and not first name and last name fields, and as
72
+ SailWave has not field for WhatsApp, this processing of the data is needed
73
73
  before it can be imported into RRS https://www.racingrulesofsailing.org/
74
74
 
75
75
  The Name column is split into First Name and Last Name columns.
@@ -77,9 +77,56 @@ The column WhatsApp is added with no data.
77
77
 
78
78
  ''' + syntax_phone_fix
79
79
 
80
+ syntax_sa2r_common: str = '''
80
81
 
81
- def generate_syntax_s2r_name(filename: str, colref: ColumnRef) -> None:
82
- """Generate config example for office_forms_to_rrs."""
82
+ In this example the input data is exported from SailArena to RRS.
83
+ This input format is a comma separated values text file, with the
84
+ old character encoding scheme cp1252.
85
+
86
+ The only fixes needed are to read CSV in cp1252 encoding, fix the
87
+ format of the phone number and save to excel.
88
+ ''' + syntax_phone_fix
89
+
90
+
91
+ def generate_syntax_sa2r_name(filename: str, colref: ColumnRef) -> None:
92
+ """Generate config example for sa_to_rrs."""
93
+ assert colref == ColumnRef.BY_NAME
94
+ cfg = ConfigXlsListRefmtName()
95
+ cfg.out_excel_library = ExcelLib.OPENPYXL
96
+ cfg.in_type = FileType.CSV
97
+ cfg.out_type = FileType.EXCEL
98
+ cfg.in_csv_encoding = 'cp1252'
99
+ cfg.in_csv_dialect = {'name': 'csv.excel',
100
+ 'delimiter': ';', 'quoting': None,
101
+ 'quotechar': '"',
102
+ 'lineterminator': None,
103
+ 'escapechar': None}
104
+ cfg.s1_split_columns = []
105
+ cfg.s3_merge_columns = []
106
+ cfg.s5_rename_columns = []
107
+ cfg.s6_insert_columns = []
108
+ cfg.s7_rewrite_columns = [
109
+ {'column': 'Phone', 'kind': RewriteKind.STRIP,
110
+ 'chars': '', 'case': CaseSensitivity.IGNORE_CASE},
111
+ {'column': 'Phone', 'kind': RewriteKind.REMOVECHARS,
112
+ 'chars': [' ', '-'], 'case': CaseSensitivity.MATCH_CASE},
113
+ {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
114
+ 'from': '^07', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
115
+ {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
116
+ 'from': '^\\+4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
117
+ {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
118
+ 'from': '^467', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
119
+ {'column': 'Phone', 'kind': RewriteKind.REGEX_SUBSTITUTE,
120
+ 'from': '^4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE}]
121
+ cfg.s8_column_order = ['Class', 'Division', 'Nationality',
122
+ 'Sail Number', 'Boat Name', 'First Name',
123
+ 'Last Name', 'Club Name', 'Email', 'Phone',
124
+ 'WhatsApp']
125
+ cfg.write(to_json_filename=filename)
126
+
127
+
128
+ def generate_syntax_sw2r_name(filename: str, colref: ColumnRef) -> None:
129
+ """Generate config example for sw_to_rrs."""
83
130
  assert colref == ColumnRef.BY_NAME
84
131
  cfg = ConfigXlsListRefmtName()
85
132
  cfg.out_excel_library = ExcelLib.OPENPYXL
@@ -112,11 +159,47 @@ def generate_syntax_s2r_name(filename: str, colref: ColumnRef) -> None:
112
159
  cfg.write(to_json_filename=filename)
113
160
 
114
161
 
115
- TXT_S2R_NAME = syntax_s2r_common + by_name_common
162
+ TXT_SW2R_NAME = syntax_sw2r_common + by_name_common
163
+ TXT_SA2R_NAME = syntax_sa2r_common + by_name_common
116
164
 
117
165
 
118
- def generate_syntax_s2r_num(filename: str, colref: ColumnRef) -> None:
119
- """Generate config example for office_forms_to_rrs."""
166
+ def generate_syntax_sa2r_num(filename: str, colref: ColumnRef) -> None:
167
+ """Generate config example for sa_to_rrs."""
168
+ assert colref == ColumnRef.BY_NUMBER
169
+ cfg = ConfigXlsListRefmtNum()
170
+ cfg.out_excel_library = ExcelLib.OPENPYXL
171
+ cfg.in_type = FileType.CSV
172
+ cfg.out_type = FileType.EXCEL
173
+ cfg.in_csv_encoding = 'cp1252'
174
+ cfg.in_csv_dialect = {'name': 'csv.excel',
175
+ 'delimiter': ';', 'quoting': None,
176
+ 'quotechar': '"',
177
+ 'lineterminator': None,
178
+ 'escapechar': None}
179
+ cfg.s1_split_columns = []
180
+ cfg.s2_remove_columns = []
181
+ cfg.s3_merge_columns = []
182
+ cfg.s4_place_columns_first = []
183
+ cfg.s5_rename_columns = []
184
+ cfg.s6_insert_columns = []
185
+ cfg.s7_rewrite_columns = [
186
+ {'column': 9, 'kind': RewriteKind.STRIP,
187
+ 'chars': '', 'case': CaseSensitivity.IGNORE_CASE},
188
+ {'column': 9, 'kind': RewriteKind.REMOVECHARS,
189
+ 'chars': [' ', '-'], 'case': CaseSensitivity.MATCH_CASE},
190
+ {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
191
+ 'from': '^07', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
192
+ {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
193
+ 'from': '^\\+4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
194
+ {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
195
+ 'from': '^467', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE},
196
+ {'column': 9, 'kind': RewriteKind.REGEX_SUBSTITUTE,
197
+ 'from': '^4607', 'to': '+467', 'case': CaseSensitivity.MATCH_CASE}]
198
+ cfg.write(to_json_filename=filename)
199
+
200
+
201
+ def generate_syntax_sw2r_num(filename: str, colref: ColumnRef) -> None:
202
+ """Generate config example for sw_to_rrs."""
120
203
  assert colref == ColumnRef.BY_NUMBER
121
204
  cfg = ConfigXlsListRefmtNum()
122
205
  cfg.out_excel_library = ExcelLib.OPENPYXL
@@ -149,7 +232,8 @@ def generate_syntax_s2r_num(filename: str, colref: ColumnRef) -> None:
149
232
  cfg.write(to_json_filename=filename)
150
233
 
151
234
 
152
- TXT_S2R_NUM = syntax_s2r_common + by_number_common
235
+ TXT_SW2R_NUM = syntax_sw2r_common + by_number_common
236
+ TXT_SA2R_NUM = syntax_sa2r_common + by_number_common
153
237
 
154
238
 
155
239
  def generate_syntax_o2r_name(filename: str, colref: ColumnRef) -> None:
@@ -420,7 +504,7 @@ def generate_syntax_example(filename: str, colref: ColumnRef) -> None:
420
504
  cfg.write(to_json_filename=filename)
421
505
 
422
506
 
423
- TXT_SYNTAX_WXAMPLE = '''
507
+ TXT_SYNTAX_EXAMPLE = '''
424
508
  This example configuration file does not match any known use case.
425
509
  It is written as an example configuration with 2 objectives:
426
510
  to demonstrates all configuration options, and to be small.
@@ -432,8 +516,10 @@ dispatch = {'forms_to_rrs': {ColumnRef.BY_NAME: generate_syntax_o2r_name,
432
516
  ColumnRef.BY_NUMBER: generate_syntax_o2s_num},
433
517
  'rrs_to_sw': {ColumnRef.BY_NAME: generate_syntax_r2s_name,
434
518
  ColumnRef.BY_NUMBER: generate_syntax_r2s_num},
435
- 'sw_to_rrs': {ColumnRef.BY_NAME: generate_syntax_s2r_name,
436
- ColumnRef.BY_NUMBER: generate_syntax_s2r_num},
519
+ 'sw_to_rrs': {ColumnRef.BY_NAME: generate_syntax_sw2r_name,
520
+ ColumnRef.BY_NUMBER: generate_syntax_sw2r_num},
521
+ 'sa_to_rrs': {ColumnRef.BY_NAME: generate_syntax_sa2r_name,
522
+ ColumnRef.BY_NUMBER: generate_syntax_sa2r_num},
437
523
  'example': {ColumnRef.BY_NAME: generate_syntax_example,
438
524
  ColumnRef.BY_NUMBER: generate_syntax_example}}
439
525
 
@@ -443,10 +529,12 @@ txts = {'forms_to_rrs': {ColumnRef.BY_NAME: TXT_O2R_NAME,
443
529
  ColumnRef.BY_NUMBER: TXT_O2S_NUM},
444
530
  'rrs_to_sw': {ColumnRef.BY_NAME: TXT_R2S_NAME,
445
531
  ColumnRef.BY_NUMBER: TXT_R2S_NUM},
446
- 'sw_to_rrs': {ColumnRef.BY_NAME: TXT_S2R_NAME,
447
- ColumnRef.BY_NUMBER: TXT_S2R_NUM},
448
- 'example': {ColumnRef.BY_NAME: TXT_SYNTAX_WXAMPLE,
449
- ColumnRef.BY_NUMBER: TXT_SYNTAX_WXAMPLE}}
532
+ 'sw_to_rrs': {ColumnRef.BY_NAME: TXT_SW2R_NAME,
533
+ ColumnRef.BY_NUMBER: TXT_SW2R_NUM},
534
+ 'sa_to_rrs': {ColumnRef.BY_NAME: TXT_SA2R_NAME,
535
+ ColumnRef.BY_NUMBER: TXT_SA2R_NUM},
536
+ 'example': {ColumnRef.BY_NAME: TXT_SYNTAX_EXAMPLE,
537
+ ColumnRef.BY_NUMBER: TXT_SYNTAX_EXAMPLE}}
450
538
 
451
539
 
452
540
  def get_example_names() -> list[str]:
@@ -0,0 +1,76 @@
1
+ #! /usr/local/bin/python3
2
+ """Read with one encoding and write with another encoding."""
3
+
4
+ import sys
5
+ from copy import deepcopy
6
+ from typing import Optional
7
+ import argparse
8
+
9
+
10
+ def recode(infilename: str, inencoding: str,
11
+ outfilename: str, outencoding: str) -> None:
12
+ """Read with one encoding and write with another encoding."""
13
+ try:
14
+ with open(file=infilename, mode='r', errors='strict',
15
+ encoding=inencoding) as inf:
16
+ try:
17
+ with open(file=outfilename, mode='x', errors='strict',
18
+ encoding=outencoding) as outf:
19
+ for line in inf:
20
+ outf.write(line)
21
+ except FileExistsError:
22
+ print(f'Error: Output file {outfilename} already exists.',
23
+ file=sys.stderr)
24
+ sys.exit(1)
25
+ except LookupError:
26
+ print(f'Error: Unrecognized output encoding {outencoding}',
27
+ file=sys.stderr)
28
+ sys.exit(1)
29
+ except ValueError:
30
+ print('Error: file content cannot be decoded/encoded ' +
31
+ f'from {inencoding} to {outencoding}.',
32
+ file=sys.stderr)
33
+ sys.exit(1)
34
+ except FileNotFoundError:
35
+ print(f'Error: Input file {infilename} not found.',
36
+ file=sys.stderr)
37
+ sys.exit(1)
38
+ except LookupError:
39
+ print(f'Error: Unrecognized input encoding {inencoding}',
40
+ file=sys.stderr)
41
+ sys.exit(1)
42
+ except IOError as exc: # pragma: no cover
43
+ print(f'Unexpected I/O error: {exc.strerror}',
44
+ file=sys.stderr)
45
+ sys.exit(1)
46
+ print(f'Wrote file {outfilename}', file=sys.stderr)
47
+
48
+
49
+ def recode_cmd(args: Optional[list[str]] = None) -> None:
50
+ """Command to read with one encoding and write with another encoding."""
51
+ desc = 'Command to read with one encoding and write with another encoding.'
52
+ arguments = deepcopy(args) if args is not None else deepcopy(sys.argv)
53
+ parser = argparse.ArgumentParser(prog='recode', description=desc)
54
+ parser.add_argument('-i', '--input', dest='infile', type=str, nargs=1,
55
+ required=True, help='Input file name')
56
+ parser.add_argument('-o', '--output', dest='outfile', type=str, nargs=1,
57
+ required=True, help='Output file name')
58
+ parser.add_argument('-f', '--from', dest='fromenc', type=str, nargs=1,
59
+ required=True,
60
+ help='From encoding. Encoding in input file')
61
+ parser.add_argument('-t', '--to', dest='toenc', type=str, nargs=1,
62
+ required=True,
63
+ help='To encoding. Encoding in output file')
64
+ if len(arguments) > 2 and 'python' in arguments[0]:
65
+ del arguments[0]
66
+ if len(arguments) > 2 and '-m' == arguments[0]:
67
+ del arguments[0]
68
+ while len(arguments) >= 1 and arguments[0][-3:] == '.py':
69
+ del arguments[0]
70
+ parsed_arg = parser.parse_args(args=arguments)
71
+ recode(infilename=parsed_arg.infile[0], inencoding=parsed_arg.fromenc[0],
72
+ outfilename=parsed_arg.outfile[0], outencoding=parsed_arg.toenc[0])
73
+
74
+
75
+ if __name__ == '__main__': # pragma: no cover
76
+ recode_cmd()
@@ -74,12 +74,14 @@ See also help text for main command without sub-commands.
74
74
  SubParseAct: TypeAlias = 'argparse._SubParsersAction[argparse.ArgumentParser]'
75
75
 
76
76
 
77
- def gen_cfg_args(subparsers: SubParseAct) -> None:
78
- """Add arguments for generate example config sub-command."""
77
+ def gen_cfg_args_named(subparsers: SubParseAct, sub_pars_name: str) -> None:
78
+ """Add arguments for generate named example config sub-command."""
79
79
  cfg_help = 'Generate example configuration file (example .cfg file). '
80
80
  cfg_help += 'Arguments select the kind of configuration file that '
81
81
  cfg_help += 'is generated.'
82
- cfg_parser = subparsers.add_parser('example', help=cfg_help,
82
+ if sub_pars_name == 'example':
83
+ cfg_help = 'example is an alias for cfg-example.'
84
+ cfg_parser = subparsers.add_parser(sub_pars_name, help=cfg_help,
83
85
  epilog=USAGE_ORDER,
84
86
  description=cfg_help +
85
87
  TXT_DESCRIPTION + SEE_MAIN_HELP)
@@ -101,6 +103,12 @@ def gen_cfg_args(subparsers: SubParseAct) -> None:
101
103
  help=cfg_output_help, required=True)
102
104
 
103
105
 
106
+ def gen_cfg_args(subparsers: SubParseAct) -> None:
107
+ """Add arguments for generate example config sub-command."""
108
+ gen_cfg_args_named(subparsers=subparsers, sub_pars_name='example')
109
+ gen_cfg_args_named(subparsers=subparsers, sub_pars_name='cfg-example')
110
+
111
+
104
112
  def rfmt_args(subparsers: SubParseAct) -> None:
105
113
  """Add arguments for transform sub-command."""
106
114
  rfmt_help = 'Transform list in excel or CSV file. How data is transformed '
@@ -1,8 +0,0 @@
1
- openpyxl>=3.1.5
2
- types-openpyxl>=3.1.5.20241225
3
- pylightxl>=1.61
4
- XlsxWriter>=3.2.0
5
- pip>=24.2
6
- setuptools>=75.6.0
7
- build>=1.2.2
8
- wheel>=0.45.1