Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
Bauke | 8fb985923f | |
Bauke | a9f357cf0c | |
Bauke | cc8bd20a54 | |
Bauke | 7cd53f56ad |
|
@ -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
|
||||
|
|
|
@ -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`.
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Text,Url
|
||||
Example,https://example.org
|
||||
Another Example,https://example.org/another
|
|
|
@ -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()
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue