add OMPL reader script
This commit is contained in:
parent
e97a6bd09b
commit
8e232ef264
2 changed files with 43 additions and 0 deletions
|
|
@ -3,3 +3,4 @@ readability-lxml
|
||||||
requests
|
requests
|
||||||
html2text
|
html2text
|
||||||
toml
|
toml
|
||||||
|
opml
|
||||||
|
|
|
||||||
42
scripts/ompl2spiderss.py
Executable file
42
scripts/ompl2spiderss.py
Executable file
|
|
@ -0,0 +1,42 @@
|
||||||
|
#/usr/bin/env python
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import opml
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Prints elements recursively for all outlines
|
||||||
|
def print_outline(outline, category):
|
||||||
|
if len(outline) > 0:
|
||||||
|
for o in outline:
|
||||||
|
print_outline(o, os.path.join(category, outline.text))
|
||||||
|
else:
|
||||||
|
print('[[feed]]')
|
||||||
|
print('category = \'{}\''.format(category))
|
||||||
|
print('name = \'{}\''.format(outline.text))
|
||||||
|
print('url = \'{}\''.format(outline.xmlUrl))
|
||||||
|
print('')
|
||||||
|
|
||||||
|
'''
|
||||||
|
Main
|
||||||
|
'''
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description = 'Read an OPML file and print spiderss TOML format to stdout.')
|
||||||
|
parser.add_argument('file', help = 'OPML input file')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
file = args.file
|
||||||
|
|
||||||
|
try:
|
||||||
|
outline = opml.parse(file)
|
||||||
|
for o in outline:
|
||||||
|
print_outline(o, '')
|
||||||
|
except Exception as e:
|
||||||
|
print('ERROR: {}'.format(e))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue