Example #1
0
 def __init__(self, file_name, **kw):
     self._file_name = file_name
     if pon_available:
         try:
             self._data = pon.PON(open(file_name).readlines())
         except IOError:
             self._data = {}
     else:
         try:
             self._data = loads(open(file_name).read(),
                                file_name=file_name)
         except IOError:
             self._data = {}
Example #2
0
        def update(self):
            for c in self._args.config:
                base_name, ext = os.path.splitext(c)
                print('c', c)
                if ext in ['.yaml', '.yml']:
                    data = ruamel.yaml.round_trip_load(open(c))
                elif ext in ['.ini', '.cfg']:
                    data = configobj.ConfigObj(c)

                odata = pon.ordereddict()
                for k in data:
                    if k == 'global':
                        odata['glbl'] = data[k]
                        continue
                    odata[k] = data[k]
                pon_name = base_name + '.pon'
                if not os.path.exists(pon_name):
                    pd = pon.PON(obj=odata)
                    with open(pon_name, 'w') as fp:
                        pd.dump(fp)
Example #3
0
 def write(self):
     if isinstance(self._data, pon.PON):
         self._data.dump(open(self._file_name, 'w'))
     else:
         pon.PON(obj=self._data).dump(open(self._file_name, 'w'))