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"
    - ""
    - ""
    - ""
    - ""
    - ""

The following script converted dgplug's planet configuration into Dragobah.

def parse_file(filename):
    f = open(filename)
    lines = f.readlines()
    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('[]'))

if __name__ == "__main__":

You can see Dragobah in action here.

Show Comments