#!/usr/bin/env python
conf = file('.xconfigure/workingconf.txt')
#loads the working conf file for reading
sect = file('.xconfigure/modules/keyboardrepeatrate/section.txt')
#opens the file containing the split section (you will want this to point to the same directory as your module)
section2split = "InputDevice"
#CHANGE THIS TO CHANGE WHAT SECTION WAS SPLIT
startsection = 'Section "' + section2split + '"\n'
#Turns the section name into the full line
count = 0
#sets the counter
section = 'no'
#makes sure that it doesn't automatically go from the start
splitoff = ''
#sets up the splitoff string (doesn't hold any value)
splitsection = True
#sets the loop
rightone = 'n'
lineholder = ''
part = 1
#part is 1
part1 = ''
part2 = ''
while splitsection:
#loop
line = conf.readline()
#reads the conf line by line
if line == startsection:
#if the line is the first one of the section
section = 'yes'
#section is yes
if part == 1:
part1 = part1 + line
else:
part2 = part2 + line
#adds line to part 1
else:
if part == 1:
if line == 'EndSection\n':
#if it's the end of a section
section = 'no'
#section is no
if rightone == 'y':
part = 2
part2 = part2 + line
else:
part1 = part1 + lineholder
part1 = part1 + line
else:
#otherwise
if section == 'yes':
#if section is yes
lineholder = lineholder + line
if line.count('AutoRepeat') == 1:
rightone = 'y'
else:
#otherwise
if len(line) == 0:
#if the length of line = 0
count = count + 1
#add one to the counter
part1 = part1 + line
if count == 2:
#if there are 2 on the counter
splitsection = False
#stop looping
else:
#otherwise
part1 = part1 + line
count = 0
#reset counter
else:
part2 = part2 + line
if len(line) == 0:
#if the length of line = 0
count = count + 1
#add one to the counter
if count == 2:
#if there are 2 on the counter
splitsection = False
#stop looping
else:
#otherwise
count = 0
#reset counter
conf.close()
#closes the conf file in read mode
loopy = True
#prepares the next loop
secti = ''
#creates the secti string
while loopy:
#loop
se = sect.readline()
#read file one line at a time
if len(se) == 0:
#if the line has no characters
loopy = False
#stop the loop
else:
#otherwise
secti = secti + se
#add the line to the secti string
all = part1 + secti + part2
#puts it all together
conf = file('.xconfigure/workingconf.txt', 'w')
#loads the working conf file for writing
conf.write(all)
#write all to the workingconf.txt file