mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 18:19:09 +00:00
![Gabriel Arazas](/assets/img/avatar_default.png)
I think this is better for separating modules explicitly. This is also considered as there are similar objects between modules (e.g., NixOS and home-manager modules and users). Revert users module to old position
23 lines
818 B
Python
Executable File
23 lines
818 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
# TODO:
|
|
# Given a OPML file, convert the OPML into a `urls` file compatible for newsboat.
|
|
# It could also accept an OPML through stdin.
|
|
|
|
import itertools
|
|
import fileinput
|
|
from pathlib import Path
|
|
import sys
|
|
import xml.etree.ElementTree as ET
|
|
|
|
if len(sys.argv) > 1:
|
|
opml = ET.parse(sys.argv[1])
|
|
else:
|
|
opml = ET.fromstring(fileinput.input())
|
|
|
|
for outline in opml.findall("body/outline"):
|
|
categories = [category.strip("/") for category in outline.get("category", "").split(",") if category]
|
|
print('{xmlUrl} "~{text}" {category}'.format(xmlUrl = outline.get("xmlUrl"),
|
|
text = outline.get("text"),
|
|
category = " ".join([ f'"{tag}"' for tag in categories ]) if len(categories) else " "))
|