Compare commits

...

4 Commits
0.1.2 ... main

Author SHA1 Message Date
Bauke 8fb985923f
Add a link to the examples directory. 2022-09-26 10:41:05 +02:00
Bauke a9f357cf0c
Add a CSV to OPML example. 2022-09-26 10:34:34 +02:00
Bauke cc8bd20a54
Update authors email, again. 2022-09-26 00:15:29 +02:00
Bauke 7cd53f56ad
Update authors email. 2022-09-26 00:12:28 +02:00
5 changed files with 33 additions and 2 deletions

View File

@ -1,6 +1,6 @@
The MIT License
Copyright (c) 2021-2022 Holllo <helllo@holllo.cc>
Copyright (c) 2021-2022 Holllo <helllo@holllo.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -24,6 +24,8 @@ xml = document.to_xml()
document = OPML.from_xml(xml)
```
See also the [examples directory](https://git.bauke.xyz/Holllo/opyml/src/branch/main/examples).
## Development
* Install dependencies with `poetry shell && poetry install`.

3
examples/csv-to-opml.csv Normal file
View File

@ -0,0 +1,3 @@
Text,Url
Example,https://example.org
Another Example,https://example.org/another
1 Text Url
2 Example https://example.org
3 Another Example https://example.org/another

26
examples/csv-to-opml.py Normal file
View File

@ -0,0 +1,26 @@
import csv
from opyml import OPML, Outline
def main() -> None:
document = OPML()
with open("examples/csv-to-opml.csv", "r") as example_csv:
csv_reader = csv.DictReader(example_csv)
for row in csv_reader:
document.body.outlines.append(
Outline(
# Convert to str because text is a required OPML attribute
# and row.get() can return None.
text=str(row.get("Text")),
xml_url=row.get("Url"),
)
)
print(document.to_xml())
if __name__ == "__main__":
main()

View File

@ -4,7 +4,7 @@ description = "OPML library for Python."
repository = "https://git.bauke.xyz/Holllo/opyml"
license = "MIT OR Apache-2.0"
version = "0.1.2"
authors = ["Holllo <helllo@holllo.cc>"]
authors = ["Holllo <helllo@holllo.org>"]
readme = "README.md"
[tool.poetry.dependencies]