excel-list-transform 0.7.7__tar.gz → 0.7.9__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 (41) hide show
  1. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/LICENSE.txt +1 -1
  2. {excel_list_transform-0.7.7/excel_list_transform.egg-info → excel_list_transform-0.7.9}/PKG-INFO +11 -5
  3. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/README.md +1 -1
  4. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/README_pypi.md +6 -0
  5. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9/excel_list_transform.egg-info}/PKG-INFO +11 -5
  6. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/excel_list_transform.egg-info/SOURCES.txt +2 -1
  7. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/excel_list_transform.egg-info/requires.txt +3 -3
  8. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/pyproject.toml +2 -2
  9. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/setup.py +5 -5
  10. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/__main__.py +1 -1
  11. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/check_indata_common.py +1 -1
  12. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/commontypes.py +1 -1
  13. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/config.py +6 -1
  14. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/config_enums.py +1 -1
  15. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/config_excel_list_transform.py +15 -3
  16. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/config_factory.py +1 -1
  17. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/config_xls_list_refmt_name.py +1 -1
  18. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/config_xls_list_refmt_num.py +1 -1
  19. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/file_extension.py +1 -1
  20. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/file_must_exist.py +1 -1
  21. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/generate_cfg.py +1 -1
  22. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/generate_txt.py +1 -1
  23. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/handle_csv.py +1 -1
  24. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/handle_empty_column.py +1 -1
  25. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/handle_excel.py +54 -6
  26. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/num_named_conversion.py +1 -1
  27. excel_list_transform-0.7.9/src/excel_list_transform/py.typed +2 -0
  28. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/rewrite_value.py +3 -2
  29. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/str_to_enum.py +1 -1
  30. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/transform_cmd.py +39 -18
  31. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/transform_func.py +1 -1
  32. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/transform_func_common.py +1 -1
  33. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/transform_func_named.py +1 -1
  34. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/transform_func_num.py +1 -1
  35. excel_list_transform-0.7.9/src/excel_list_transform/version.py +61 -0
  36. excel_list_transform-0.7.7/src/excel_list_transform/py.typed +0 -2
  37. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/excel_list_transform.egg-info/dependency_links.txt +0 -0
  38. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/excel_list_transform.egg-info/top_level.txt +0 -0
  39. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/setup.cfg +0 -0
  40. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/__init__.py +0 -0
  41. {excel_list_transform-0.7.7 → excel_list_transform-0.7.9}/src/excel_list_transform/recode.py +0 -0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Tom Björkholm
3
+ Copyright (c) 2024-2025 Tom Björkholm
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: excel-list-transform
3
- Version: 0.7.7
3
+ Version: 0.7.9
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,15 +8,15 @@ 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.13.3
11
+ Requires-Python: <3.11,>=3.10
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.20250306
15
+ Requires-Dist: types-openpyxl>=3.1.5.20250602
16
16
  Requires-Dist: pylightxl>=1.61
17
- Requires-Dist: XlsxWriter>=3.2.2
17
+ Requires-Dist: XlsxWriter>=3.2.3
18
18
  Requires-Dist: pip>=25.0.1
19
- Requires-Dist: setuptools>=78.1.0
19
+ Requires-Dist: setuptools>=80.9.0
20
20
  Requires-Dist: build>=1.2.2.post1
21
21
  Requires-Dist: wheel>=0.45.1
22
22
  Dynamic: author
@@ -76,6 +76,10 @@ pip install --upgrade excel-list-transform
76
76
  | 0.7.5 | 21 Mar 2025 | 3.12.6 or newer | Example config for Sailarena to RRS |
77
77
  | 0.7.6 | 21 Mar 2025 | 3.13.2 or newer | Adapted to Python 3.13.2 |
78
78
  | 0.7.7 | 09 Apr 2025 | 3.13.3 or newer | refactor phone number rewrite cfg |
79
+ | 0.7.9 | 09 Jun 2025 | 3.10.x | Backport 0.7.12 to Python 3.10 |
80
+ | 0.7.10 | 09 Jun 2025 | 3.11.x | Backport 0.7.12 to Python 3.11 |
81
+ | 0.7.11 | 09 Jun 2025 | 3.12.x | Backport 0.7.12 to Python 3.12 |
82
+ | 0.7.12 | 09 Jun 2025 | 3.13 or newer | Add version sub-command |
79
83
 
80
84
  ## Running the application
81
85
 
@@ -83,6 +87,7 @@ pip install --upgrade excel-list-transform
83
87
 
84
88
  ````sh
85
89
  python3 -m excel_list_transform --help
90
+ python3 -m excel_list_transform version
86
91
  python3 -m excel_list_transform cfg-example --help
87
92
  python3 -m excel_list_transform transform --help
88
93
  python3 -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -93,6 +98,7 @@ python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output
93
98
 
94
99
  ````sh
95
100
  python -m excel_list_transform --help
101
+ python -m excel_list_transform version
96
102
  python -m excel_list_transform cfg-example --help
97
103
  python -m excel_list_transform transform --help
98
104
  python -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -50,7 +50,7 @@ For running the script and running the test suite you need a mac or a Linux comp
50
50
 
51
51
  #### Python version
52
52
 
53
- Please see README_pypi.md for information on needed python version.
53
+ Please see README_pypi.md for information on needed python version. Main development is on newest Python version, and may be backported to older Python version on a branch.
54
54
 
55
55
  #### Zsh
56
56
 
@@ -50,6 +50,10 @@ pip install --upgrade excel-list-transform
50
50
  | 0.7.5 | 21 Mar 2025 | 3.12.6 or newer | Example config for Sailarena to RRS |
51
51
  | 0.7.6 | 21 Mar 2025 | 3.13.2 or newer | Adapted to Python 3.13.2 |
52
52
  | 0.7.7 | 09 Apr 2025 | 3.13.3 or newer | refactor phone number rewrite cfg |
53
+ | 0.7.9 | 09 Jun 2025 | 3.10.x | Backport 0.7.12 to Python 3.10 |
54
+ | 0.7.10 | 09 Jun 2025 | 3.11.x | Backport 0.7.12 to Python 3.11 |
55
+ | 0.7.11 | 09 Jun 2025 | 3.12.x | Backport 0.7.12 to Python 3.12 |
56
+ | 0.7.12 | 09 Jun 2025 | 3.13 or newer | Add version sub-command |
53
57
 
54
58
  ## Running the application
55
59
 
@@ -57,6 +61,7 @@ pip install --upgrade excel-list-transform
57
61
 
58
62
  ````sh
59
63
  python3 -m excel_list_transform --help
64
+ python3 -m excel_list_transform version
60
65
  python3 -m excel_list_transform cfg-example --help
61
66
  python3 -m excel_list_transform transform --help
62
67
  python3 -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -67,6 +72,7 @@ python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output
67
72
 
68
73
  ````sh
69
74
  python -m excel_list_transform --help
75
+ python -m excel_list_transform version
70
76
  python -m excel_list_transform cfg-example --help
71
77
  python -m excel_list_transform transform --help
72
78
  python -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: excel-list-transform
3
- Version: 0.7.7
3
+ Version: 0.7.9
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,15 +8,15 @@ 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.13.3
11
+ Requires-Python: <3.11,>=3.10
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.20250306
15
+ Requires-Dist: types-openpyxl>=3.1.5.20250602
16
16
  Requires-Dist: pylightxl>=1.61
17
- Requires-Dist: XlsxWriter>=3.2.2
17
+ Requires-Dist: XlsxWriter>=3.2.3
18
18
  Requires-Dist: pip>=25.0.1
19
- Requires-Dist: setuptools>=78.1.0
19
+ Requires-Dist: setuptools>=80.9.0
20
20
  Requires-Dist: build>=1.2.2.post1
21
21
  Requires-Dist: wheel>=0.45.1
22
22
  Dynamic: author
@@ -76,6 +76,10 @@ pip install --upgrade excel-list-transform
76
76
  | 0.7.5 | 21 Mar 2025 | 3.12.6 or newer | Example config for Sailarena to RRS |
77
77
  | 0.7.6 | 21 Mar 2025 | 3.13.2 or newer | Adapted to Python 3.13.2 |
78
78
  | 0.7.7 | 09 Apr 2025 | 3.13.3 or newer | refactor phone number rewrite cfg |
79
+ | 0.7.9 | 09 Jun 2025 | 3.10.x | Backport 0.7.12 to Python 3.10 |
80
+ | 0.7.10 | 09 Jun 2025 | 3.11.x | Backport 0.7.12 to Python 3.11 |
81
+ | 0.7.11 | 09 Jun 2025 | 3.12.x | Backport 0.7.12 to Python 3.12 |
82
+ | 0.7.12 | 09 Jun 2025 | 3.13 or newer | Add version sub-command |
79
83
 
80
84
  ## Running the application
81
85
 
@@ -83,6 +87,7 @@ pip install --upgrade excel-list-transform
83
87
 
84
88
  ````sh
85
89
  python3 -m excel_list_transform --help
90
+ python3 -m excel_list_transform version
86
91
  python3 -m excel_list_transform cfg-example --help
87
92
  python3 -m excel_list_transform transform --help
88
93
  python3 -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -93,6 +98,7 @@ python3 -m excel_list_transform transform -c example.cfg -i input.xlsx -o output
93
98
 
94
99
  ````sh
95
100
  python -m excel_list_transform --help
101
+ python -m excel_list_transform version
96
102
  python -m excel_list_transform cfg-example --help
97
103
  python -m excel_list_transform transform --help
98
104
  python -m excel_list_transform cfg-example -k forms_to_rrs -r by_name -o example.cfg
@@ -34,4 +34,5 @@ src/excel_list_transform/transform_cmd.py
34
34
  src/excel_list_transform/transform_func.py
35
35
  src/excel_list_transform/transform_func_common.py
36
36
  src/excel_list_transform/transform_func_named.py
37
- src/excel_list_transform/transform_func_num.py
37
+ src/excel_list_transform/transform_func_num.py
38
+ src/excel_list_transform/version.py
@@ -1,8 +1,8 @@
1
1
  openpyxl>=3.1.5
2
- types-openpyxl>=3.1.5.20250306
2
+ types-openpyxl>=3.1.5.20250602
3
3
  pylightxl>=1.61
4
- XlsxWriter>=3.2.2
4
+ XlsxWriter>=3.2.3
5
5
  pip>=25.0.1
6
- setuptools>=78.1.0
6
+ setuptools>=80.9.0
7
7
  build>=1.2.2.post1
8
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.7"
7
+ version = "0.7.9"
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.13.3"
13
+ requires-python = "<3.11,>=3.10"
14
14
  classifiers = [
15
15
  "Programming Language :: Python :: 3",
16
16
  "License :: OSI Approved :: MIT License",
@@ -5,21 +5,21 @@ from setuptools import setup
5
5
 
6
6
  setup(
7
7
  name='excel-list-transform',
8
- version='0.7.7',
8
+ version='0.7.9',
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.13.3',
12
+ python_requires='<3.11,>=3.10',
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.20250306',
18
+ 'types-openpyxl >= 3.1.5.20250602',
19
19
  'pylightxl >= 1.61',
20
- 'XlsxWriter >= 3.2.2',
20
+ 'XlsxWriter >= 3.2.3',
21
21
  'pip >= 25.0.1',
22
- 'setuptools >= 78.1.0',
22
+ 'setuptools >= 80.9.0',
23
23
  'build >= 1.2.2.post1',
24
24
  'wheel>=0.45.1'
25
25
  ]
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Take an excel file and and change columns before saving as excel or CSV."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Function for common indata checks.."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Common type definitions used for type hints."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Base class to read and write configurations."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -387,6 +387,11 @@ class Config():
387
387
  if 'unknown encoding' in str(exc):
388
388
  return False
389
389
  raise exc # pragma: no cover
390
+ except OSError as exc:
391
+ # workaround for Python 3.10 bug
392
+ if 'Bad file descriptor' in str(exc):
393
+ return False
394
+ raise exc # pragma: no cover
390
395
  return True
391
396
 
392
397
  @staticmethod
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Enumerations used in configuration of excel list transform."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,14 +1,14 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Read and write configuration of excel list transform."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
8
8
  import sys
9
9
  from copy import deepcopy
10
10
  from enum import Enum
11
- from typing import Optional, Callable, TypeAlias, TypeVar, NamedTuple, Generic
11
+ from typing import Optional, Callable, TypeAlias, TypeVar, Generic
12
12
  from csv import Dialect
13
13
  from excel_list_transform.config import Config, ParseConverter
14
14
  from excel_list_transform.config_enums import FileType, SplitWhere, \
@@ -45,7 +45,7 @@ NoDupKeydType: TypeAlias = \
45
45
  Rule[Column] | RuleMerge[Column] | RuleSplit[Column]
46
46
 
47
47
 
48
- class ColInfo(NamedTuple, Generic[Column]):
48
+ class ColInfo(Generic[Column]): # pylint: disable=too-few-public-methods
49
49
  """Information about columns to pass to ConfigExcelListTransform init."""
50
50
 
51
51
  split_last: str
@@ -55,6 +55,18 @@ class ColInfo(NamedTuple, Generic[Column]):
55
55
  col_to_use: list[Column]
56
56
  tinfo: Column
57
57
 
58
+ def __init__(self, # pylint: disable=too-many-arguments, too-many-positional-arguments # noqa: E501
59
+ split_last: str, insert_last: Optional[str],
60
+ s1: RuleSplit[Column], s6: Rule[Column],
61
+ col_to_use: list[Column], tinfo: Column):
62
+ """Create a ColInfo object."""
63
+ self.split_last = split_last
64
+ self.insert_last = insert_last
65
+ self.s1 = s1
66
+ self.s6 = s6
67
+ self.col_to_use = col_to_use
68
+ self.tinfo = tinfo
69
+
58
70
 
59
71
  class ConfigExcelListTransform(Config, Generic[Column]): # pylint: disable=too-many-instance-attributes, line-too-long # noqa: E501
60
72
  """Class with configuration for excel list transform."""
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Get correct configuration type."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Read and write configuration of CSV splitting."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Read and write configuration of CSV splitting."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions to add and remove file extensions."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Function for checking that file exists."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Generate example configuration files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
  from copy import deepcopy
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Generate example configuration files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Handle reading and writing of an excel file."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Handle empty column in input."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,28 +1,76 @@
1
1
  #! /usr/bin/python3
2
2
  """Handle reading and writing of an excel file."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
8
8
  # https://realpython.com/openpyxl-excel-spreadsheets-python/
9
9
 
10
10
  import sys
11
+ from datetime import datetime, date, time
11
12
  from copy import deepcopy
12
- from typing import Optional
13
- from openpyxl import load_workbook as openpyxl_load_workbook
14
- from openpyxl import Workbook as openpyxl_wb
13
+ from typing import Optional, TypeAlias, Any
14
+ from decimal import Decimal
15
15
  from xlsxwriter import Workbook as xlsxwriter_wb # type: ignore
16
16
  from pylightxl import readxl as pl_readxl # type: ignore
17
17
  from pylightxl import Database as pl_db, writexl as pl_writexl
18
+ from openpyxl import load_workbook as openpyxl_load_workbook
19
+ from openpyxl import Workbook as openpyxl_wb
20
+ try:
21
+ # only availabe in mypy, flake8 and pylint, not in python
22
+ from openpyxl.cell import _CellGetValue # pylint: disable=unused-import # noqa: F401,E501
23
+ except ImportError:
24
+ pass
18
25
  from excel_list_transform.commontypes import NameData, NameDataMap, \
19
- NumData, NumDataSeq
26
+ NumData, NumDataSeq, NumRow
20
27
  from excel_list_transform.config_enums import ExcelLib
21
28
  from excel_list_transform.handle_empty_column import handle_empty_column_in_lst
22
29
  from excel_list_transform.num_named_conversion import \
23
30
  named_cols_from_num_cols, num_cols_from_named_cols
24
31
 
25
32
 
33
+ _AnyCellValue: TypeAlias = Any # AnyOf _CellGetValue # noqa: Y047
34
+ seentypes: list[str] = []
35
+
36
+
37
+ def fix_row_openpyxl(row: tuple[_AnyCellValue, ...],
38
+ max_column_reed: int) -> NumRow:
39
+ """Convert types in row from openpyxl to those supported."""
40
+ ret: NumRow = []
41
+ colnum = 0
42
+ for cell in row:
43
+ if colnum >= max_column_reed:
44
+ continue
45
+ colnum += 1
46
+ if cell is None:
47
+ ret.append(None)
48
+ elif isinstance(cell, (str, int, float, datetime)):
49
+ assert isinstance(cell, (str, int, float, datetime))
50
+ ret.append(cell)
51
+ elif isinstance(cell, date):
52
+ assert isinstance(cell, date)
53
+ ret.append(datetime(year=cell.year,
54
+ month=cell.month,
55
+ day=cell.day))
56
+ elif isinstance(cell, Decimal):
57
+ assert isinstance(cell, Decimal)
58
+ ret.append(float(cell))
59
+ elif isinstance(cell, time):
60
+ assert isinstance(cell, time)
61
+ ret.append(cell.isoformat())
62
+ else:
63
+ typename = type(cell).__name__
64
+ if typename not in seentypes:
65
+ print('Sorry, cells with value of type ' +
66
+ f'{typename} are not supported\n' +
67
+ 'Trying to convert to string.',
68
+ file=sys.stderr)
69
+ seentypes.append(typename)
70
+ ret.append(str(cell))
71
+ return ret
72
+
73
+
26
74
  def read_excel_openpyxl(filename: str,
27
75
  max_column_read: int) \
28
76
  -> NumData:
@@ -33,7 +81,7 @@ def read_excel_openpyxl(filename: str,
33
81
  assert sheet is not None
34
82
  res: NumData = []
35
83
  for row in sheet.iter_rows(values_only=True):
36
- res.append(list(row)[:max_column_read])
84
+ res.append(fix_row_openpyxl(row, max_column_reed=max_column_read))
37
85
  return handle_empty_column_in_lst(res)
38
86
 
39
87
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Convert data between numbered columns and named columns."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -0,0 +1,2 @@
1
+ # Copyright (c) 2024-2025 Tom Björkholm
2
+ # MIT License
@@ -1,17 +1,18 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions for manipulating and rewriting a value."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
8
8
  from copy import deepcopy
9
9
  import sys
10
- from typing import Optional, assert_never
10
+ from typing import Optional
11
11
  from re import compile as re_compile
12
12
  from re import Pattern
13
13
  from re import IGNORECASE as re_IGNORECASE
14
14
  from re import error as re_error
15
+ from typing_extensions import assert_never
15
16
  from excel_list_transform.commontypes import get_checked_type
16
17
  from excel_list_transform.config_enums import RewriteKind, CaseSensitivity
17
18
  from excel_list_transform.config_excel_list_transform import \
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions to fuzzy parse string into enum."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Command to transform list in excel or CSV file."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -14,6 +14,7 @@ from excel_list_transform.generate_cfg import generate_examplecfg
14
14
  from excel_list_transform.generate_cfg import get_example_names
15
15
  from excel_list_transform.config_enums import ColumnRef
16
16
  from excel_list_transform.str_to_enum import string_to_enum_best_match
17
+ from excel_list_transform.version import Version
17
18
 
18
19
 
19
20
  def gen_cfg_cmd(args: argparse.Namespace) -> int:
@@ -36,6 +37,13 @@ def rfmt_cmd(args: argparse.Namespace) -> int:
36
37
  cfgfilename=cfgfilename)
37
38
 
38
39
 
40
+ def version_cmd(_: argparse.Namespace) -> int:
41
+ """Print version information."""
42
+ vers = Version()
43
+ vers.print()
44
+ return 0
45
+
46
+
39
47
  USAGE_ORDER = '''
40
48
  The normal way to use this command is:
41
49
  (1) Using the "example" sub-command a few example configuration (.cfg) files
@@ -109,23 +117,35 @@ def gen_cfg_args(subparsers: SubParseAct) -> None:
109
117
  gen_cfg_args_named(subparsers=subparsers, sub_pars_name='cfg-example')
110
118
 
111
119
 
112
- def rfmt_args(subparsers: SubParseAct) -> None:
120
+ def transf_args(subparsers: SubParseAct) -> None:
113
121
  """Add arguments for transform sub-command."""
114
- rfmt_help = 'Transform list in excel or CSV file. How data is transformed '
115
- rfmt_help += 'is described in a configuration file. Name of input file, '
116
- rfmt_help += 'output file and configuration file is given as command '
117
- rfmt_help += 'line arguments.'
118
- rfmt_parser = subparsers.add_parser('transform', help=rfmt_help,
119
- epilog=USAGE_ORDER,
120
- description=rfmt_help + SEE_MAIN_HELP)
121
- rfmt_parser.set_defaults(func=rfmt_cmd)
122
- rfmt_parser.add_argument('-c', '--cfg', nargs=1, required=True,
123
- help='Configuation file name to use.')
124
- rfmt_parser.add_argument('-i', '--input', nargs=1,
125
- help='Name of input file.', required=True)
126
- rfmt_parser.add_argument('-o', '--output', nargs=1,
127
- help='Name of output file to create.',
128
- required=True)
122
+ transf_help = 'Transform list in excel or CSV file. How data is '
123
+ transf_help += 'transformed is described in a configuration file. Name '
124
+ transf_help += 'of input file, output file and configuration file is '
125
+ transf_help += 'given as command line arguments.'
126
+ transf_parser = subparsers.add_parser('transform', help=transf_help,
127
+ epilog=USAGE_ORDER,
128
+ description=transf_help +
129
+ SEE_MAIN_HELP)
130
+ transf_parser.set_defaults(func=rfmt_cmd)
131
+ transf_parser.add_argument('-c', '--cfg', nargs=1, required=True,
132
+ help='Configuation file name to use.')
133
+ transf_parser.add_argument('-i', '--input', nargs=1,
134
+ help='Name of input file.', required=True)
135
+ transf_parser.add_argument('-o', '--output', nargs=1,
136
+ help='Name of output file to create.',
137
+ required=True)
138
+
139
+
140
+ def version_args(subparsers: SubParseAct) -> None:
141
+ """Add arguments for version sub-command."""
142
+ version_help = 'Only print versions of excel_list_transform '
143
+ version_help += 'and of main modules used by it and of Python.'
144
+ version_parser = subparsers.add_parser('version', help=version_help,
145
+ epilog=USAGE_ORDER,
146
+ description=version_help +
147
+ SEE_MAIN_HELP)
148
+ version_parser.set_defaults(func=version_cmd)
129
149
 
130
150
 
131
151
  def transform_cmd(arguments: Optional[list[str]] = None) -> None:
@@ -146,7 +166,8 @@ def transform_cmd(arguments: Optional[list[str]] = None) -> None:
146
166
  description=desc, epilog=epimain)
147
167
  subparsers = parser.add_subparsers(dest='subparser_name', required=True)
148
168
  gen_cfg_args(subparsers)
149
- rfmt_args(subparsers)
169
+ transf_args(subparsers)
170
+ version_args(subparsers)
150
171
  args = parser.parse_args(args=fixed_args)
151
172
  _ = args.func(args)
152
173
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Function for doing transform of lists excel files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions for doing transform of lists excel files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions for doing transform of lists excel files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  #! /usr/local/bin/python3
2
2
  """Functions for doing transform of lists excel files."""
3
3
 
4
- # Copyright (c) 2024 Tom Björkholm
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
5
  # MIT License
6
6
 
7
7
 
@@ -0,0 +1,61 @@
1
+ #! /usr/local/bin/python3
2
+ """Get and print version information."""
3
+
4
+ # Copyright (c) 2024-2025 Tom Björkholm
5
+ # MIT License
6
+
7
+
8
+ import sys
9
+ from importlib.metadata import version as metadata_version
10
+ from typing import Optional, TypeAlias
11
+
12
+ VersionInfo: TypeAlias = dict[str, str]
13
+
14
+
15
+ class Version():
16
+ """Get and print version information."""
17
+
18
+ def __init__(self) -> None:
19
+ """Create version information object."""
20
+ self.versions: Optional[VersionInfo] = None
21
+
22
+ def print(self, versions: Optional[VersionInfo] = None) -> None:
23
+ """Print version information."""
24
+ if versions is None:
25
+ if self.versions is None:
26
+ self.versions = self.get()
27
+ versions = self.versions
28
+ maxlen: int = max(map(len, versions.keys()))
29
+ for key, value in versions.items():
30
+ pad = '.' * (maxlen - len(key))
31
+ print(f'{key} {pad} {value}')
32
+ if 'Python' in versions and versions['Python'] < '3.13':
33
+ pip = 'pip3'
34
+ applic = list(versions.keys())[0].replace('_', '-')
35
+ if sys.platform.startswith('win') \
36
+ or sys.platform.startswith('Win'):
37
+ pip = 'pip'
38
+ txt = '\nYou are running an old Python version.\n'
39
+ txt += 'Upgrade Python to a new version.\n'
40
+ txt += '(Download Python from https://www.python.org/downloads/)\n'
41
+ txt += 'After installing new Python, upgrade application with\n'
42
+ txt += pip + ' install --upgrade excel-list-transform\n'
43
+ if applic != 'excel-list-transform':
44
+ txt += pip + ' install --upgrade ' + applic + '\n'
45
+ txt += '\n'
46
+ print(txt)
47
+
48
+ def get(self) -> VersionInfo:
49
+ """Get version information for module and dependencies."""
50
+ if self.versions is not None:
51
+ return self.versions
52
+ versions: VersionInfo = {i: metadata_version(i)
53
+ for i in self.module_names()}
54
+ versions['Python'] = '.'.join([str(i) for i in sys.version_info])
55
+ self.versions = versions
56
+ return versions
57
+
58
+ def module_names(self) -> list[str]:
59
+ """Get list of modules to get versions for."""
60
+ return ['excel_list_transform', 'openpyxl', 'pylightxl',
61
+ 'XlsxWriter']
@@ -1,2 +0,0 @@
1
- # Copyright (c) 2024 Tom Björkholm
2
- # MIT License