|
53 | 53 | "date_mdy": "xsd:date", # ?? new one TODO: not sure what to do with it, it's not xsd:date |
54 | 54 | "datetime_seconds_mdy": "xsd:date", # ?? new one TODO: not sure what to do with it, it's not xsd:date |
55 | 55 | "date_ymd": "xsd:date", # new one |
| 56 | + "date_dmy": "xsd:date", |
56 | 57 | "datetime_": "xsd:dateTime", |
| 58 | + "datetime_ymd": "xsd:dateTime", |
57 | 59 | "time_": "xsd:time", |
58 | 60 | "email": "xsd:string", |
59 | 61 | "phone": "xsd:string", |
@@ -200,25 +202,31 @@ def process_choices(choices_str, field_name): |
200 | 202 | choices_value_type = [] |
201 | 203 | for ii, choice in enumerate(choices_str.split("|")): |
202 | 204 | parts = choice.split(", ") |
203 | | - if len(parts) < 2: |
204 | | - print( |
205 | | - f"Warning: Invalid choice format '{choice}' in a {field_name} field, adding integer as a value" |
206 | | - ) |
207 | | - # TODO! I'm adding int by default, but there is probably some legend in the csv and this is not yet implemented |
208 | | - parts = [ii, parts[0]] |
| 205 | + |
| 206 | + # Handle the case where the choice is something like "1," |
| 207 | + if len(parts) == 1: |
| 208 | + if choice.endswith(","): |
| 209 | + parts = [parts[0][:-1], ""] |
| 210 | + else: |
| 211 | + print( |
| 212 | + f"Warning: Invalid choice format '{choice}' in a {field_name} field, adding integer as a value" |
| 213 | + ) |
| 214 | + parts = [ii, parts[0]] |
| 215 | + |
209 | 216 | # Try to convert the first part to an integer, if it fails, keep it as a string |
210 | 217 | try: |
211 | 218 | value = int(parts[0]) |
212 | 219 | choices_value_type.append("xsd:integer") |
213 | 220 | except ValueError: |
214 | 221 | value = parts[0] |
215 | 222 | choices_value_type.append("xsd:string") |
216 | | - choice_obj = {"name": {"en": " ".join(parts[1:])}, "value": value} |
217 | | - # remove image for now |
218 | | - # if len(parts) == 3: |
219 | | - # # Handle image url |
220 | | - # choice_obj["image"] = f"{parts[2]}.png" |
| 223 | + |
| 224 | + choice_obj = { |
| 225 | + "name": {"en": " ".join(parts[1:]).strip()}, |
| 226 | + "value": value, |
| 227 | + } |
221 | 228 | choices.append(choice_obj) |
| 229 | + |
222 | 230 | return choices, list(set(choices_value_type)) |
223 | 231 |
|
224 | 232 |
|
|
0 commit comments