|
22 | 22 |
|
23 | 23 | import logging |
24 | 24 | import textwrap |
25 | | -from num2words import num2words as num |
26 | 25 | from typing import List |
27 | 26 | import warnings |
28 | 27 |
|
29 | 28 | from lxml.etree import tostring |
30 | 29 | from lxml.html import fromstring |
| 30 | +from num2words import num2words as num |
31 | 31 | from pyconverter.xml2py.utils.utils import is_numeric, split_trail_alpha |
32 | 32 | import regex as re |
33 | 33 |
|
@@ -142,9 +142,11 @@ def to_py_arg_name(name: str) -> str: |
142 | 142 | if arg[1].isdigit(): |
143 | 143 | raise ValueError(f"The code needs to be expanded to handle numbers") |
144 | 144 | elif arg[1:3] not in superlatif: |
145 | | - arg = f"{num(arg[0])}{arg[1:]}" |
| 145 | + num_value = num(arg[0]) |
| 146 | + arg = f"{num_value}{arg[1:]}" |
146 | 147 | else: |
147 | | - arg = f"{num(arg[0], to="ordinal")}{arg[3:]}" |
| 148 | + num_value = num(arg[0], to="ordinal") |
| 149 | + arg = f"{num_value}{arg[3:]}" |
148 | 150 | print(arg) |
149 | 151 |
|
150 | 152 | if ("," in arg and "--" in arg) or arg == "–": |
@@ -2854,11 +2856,11 @@ def py_source(self, custom_functions=None, indent=""): |
2854 | 2856 | if custom_functions is None or self.py_name not in custom_functions.py_names: |
2855 | 2857 |
|
2856 | 2858 | if len(self.arg_desc) > 0: |
2857 | | - command = 'command = f"' + self.name |
| 2859 | + command = 'command = f"' + self.name |
2858 | 2860 | for arg in self.arg_desc: |
2859 | | - command += ',{' |
| 2861 | + command += ",{" |
2860 | 2862 | command += arg.py_arg_name |
2861 | | - command += '}' |
| 2863 | + command += "}" |
2862 | 2864 | command += '"\n' |
2863 | 2865 | # ",{" + "},{".join(self.arg_desc.py_arg_name) + '}"\n' |
2864 | 2866 | else: |
|
0 commit comments