#!/usr/bin/env python
#
# Copyright 2016 Steve Kyle. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
Configure Serengeti TAXII Client
"""
from __future__ import print_function
import sys
import os

from ConfigParser import SafeConfigParser as ConfigParser
CONF_FILE = '.serengeti.client'

CONF_OPTIONS = {'CLIENT': { 'cert':None,
                            'cert_key': None,
                            'ca':None,
                            },
                            
                'TAXII':  { 'discovery':None,
                            'poll': None,
                            'inbox':None,
                            'collection': None,
                            'channels':None,                            
                            },
                }

config = ConfigParser()

if os.path.exists(CONF_FILE) is False:
    cfg_file = open(CONF_FILE, 'w')
    config.add_section('USER')
    config.set('USER','cert','')
    config.set('USER','key','')
    config.set('USER','ca','')
    config.set('USER','ua','')

    config.add_section('TAXII')
    config.set('TAXII','host','')
    config.set('TAXII','poll','')
    config.set('TAXII','disc','')

    config.write(cfg_file)
    cfg_file.close()

config.read(CONF_FILE)

@@ -715,16 +715,51 @@
 port os%0A
+from collections import OrderedDict
 %0Afrom Co
@@ -780,12 +780,8 @@
 ort 
-Safe
 Conf
@@ -792,16 +792,17 @@
 rser as 
+_
 ConfigPa
@@ -806,16 +806,17 @@
 gParser%0A
+%0A
 CONF_FIL
@@ -1331,31 +1331,1026 @@
  %7D%0A%0A
-config = ConfigParser()
+%0Aclass ConfigParser(_ConfigParser):%0A%0A    # modified to accept file names as input%0A    def write(self, fp):%0A        %22%22%22Write an .ini-format representation of the configuration state.%22%22%22%0A        if isinstance(fp, file):%0A            _ConfigParser.write(self, fp)%0A        elif isinstance(fp, basestring):%0A            with open(fp, 'wb') as fpp:%0A                _ConfigParser.write(self, fpp)%0A        else:%0A            raise TypeError('fp must be of type file or basestring')%0A%0A    def to_dict(self):%0A        %22%22%22Export ConfigParser Object to OrderedDict%22%22%22%0A        d = OrderedDict.fromkeys(self.sections())%0A        for section in d.keys():%0A            d%5Bsection%5D = dict(self.items(section))%0A        return d%0A%0A    @staticmethod%0A    def from_dict(d):%0A        %22%22%22Import Dict to create new ConfigParser Object%22%22%22%0A        c = ConfigParser()%0A        for section in d.keys():%0A            c.add_section(section)%0A            for option, value in d%5Bsection%5D.iteritems():%0A                c.set(section, option, value)%0A        return c%0A
 %0A%0Aif

Update config.py