Converting the configuration of planetplanet to Dragobah for dgplug
These days I am reading laws and side by side I am learning Python also. One task I received was to convert the configuration of planetplanet to Dragobah. In the old configuration file the feed url was written within []. The example configuration of Dragobah looks like
title: "Go Feeds Powered by Dagobah"
feeds:
- "http://spf13.com/index.xml"
- "http://dave.cheney.net/feed"
- "http://www.goinggo.net/feeds/posts/default"
- "http://blog.labix.org/feed"
- "http://blog.golang.org/feed.atom"
The following script converted dgplug's planet configuration into Dragobah.
def parse_file(filename):
f = open(filename)
lines = f.readlines()
f.close()
f = open("config.yaml","w")
f.write('title: "Go Feeds Powered by Dragobah"\nfeeds:\n')
for line in lines:
line = line.strip("\n")
if line.startswith("[http") and line.endswith("]"):
f.write(' - "%s"\n' % line.strip('[]'))
f.close()
if __name__ == "__main__":
parse_file("./planet.ini")
You can see Dragobah in action here.