Skip to content

Commit

Permalink
merged list functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Buhle79 committed Feb 14, 2024
1 parent 3bd17b2 commit 39b8cde
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions home/import_content_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ def from_flat(cls, row: dict[str, str]) -> "ContentRow":
related_pages=deserialise_list(row.pop("related_pages", "")),
example_values=deserialise_list(row.pop("example_values", "")),
buttons=json.loads(row.pop("buttons", "")) if row.get("buttons") else [],
list_items=deserialise_list_with_char(row.pop("list_items", "")),
list_items=deserialise_list(row.pop("list_items", "")),
footer=row.pop("footer") if row.get("footer") else "",
**row,
)
Expand Down Expand Up @@ -720,14 +720,7 @@ def deserialise_dict(value: str) -> dict[str, str]:
def deserialise_list(value: str) -> list[str]:
if not value:
return []
return [item.strip() for item in value.strip().split(",")]

items = list(csv.reader([value]))[0]
return [item.strip() for item in items]

def deserialise_list_with_char(value: str) -> list[str]:
if not value:
return []

data = io.StringIO(value)
reader = data.readlines()
items = csv.reader(reader)
return list(items)[0]

0 comments on commit 39b8cde

Please sign in to comment.