with open("/Users/viktorognev/work/Workspace/ci/chef/cookbooks/ci/files/default/pssconfig.reg") as fp:
res = ""
for line in fp.readlines():
if '=' in line:
print line
name, value = line.split('=', 1)
if ':' in value:
if 'C:\\' in value:
vtype, data = "expand_string", value
else:
vtype, data = value.split(':')
if vtype not in ('dword'):
vtype, data = 'string', value
else:
vtype, data = "string", value
data = data.strip()
data = '"{0}"'.format(data) if '"' not in data else data
res += ' {:name => %(name)s, :type => :%(type)s, :data => %(data)s},\n' % {'name':
name, 'type': vtype, 'data': data}
elif any([symbol.isalnum() for symbol in line]):
line = line[1:-2].replace('\\', '\\\\')
if res:
res = res[:-2] + '''
]
action :create
end
'''
res += '''
registry_key "{0}" do
values [
'''.format(line)
res = res[:-2] + '''
]
action :create
end
'''
print res