Commit 2c675356 authored by Lukas Appelhans's avatar Lukas Appelhans

Skip [options]

parent 6d7e23e9
......@@ -29,17 +29,17 @@ def parseOptionLine(line, akabeiConf):
name = separatedOption[0]
sep = separatedOption[1]
value = separatedOption[2]
nameNoSpace = name.rstrip()
# Lines like [core] are copied verbatim
if nameNoSpace.startswith("["):
akabeiConf.write(name)
return
if nameNoSpace in correspondences:
if len(correspondences[nameNoSpace]) > 0:
# Replaces the option name with that used by Akabei and writes again the line
name = name.replace(nameNoSpace, correspondences[nameNoSpace])
akabeiConf.write(name)
......@@ -65,14 +65,14 @@ if __name__ == "__main__":
pacmanFile = "/etc/pacman.conf"
akabeiFile = "/etc/akabei.conf"
opts = None
try:
opts = getopt.getopt(sys.argv[1:], "hp:a:", ["help", "pacman=", "akabei="])
except getopt.GetoptError, error:
print str(error)
usage()
sys.exit(-1)
for opt, arg in opts[0]:
if opt in ("-h", "--help"):
usage()
......@@ -81,37 +81,37 @@ if __name__ == "__main__":
pacmanFile = arg
elif opt in ("-a", "--akabei"):
akabeiFile = arg
pacmanConf = None
akabeiConf = None
try:
pacmanConf = open(pacmanFile, "r")
akabeiConf = open(akabeiFile, "w")
except IOError, error:
print str(error)
sys.exit(-1)
for pacmanLine in pacmanConf.readlines():
if pacmanLine == "\n":
if pacmanLine == "\n" or "[options]" in pacmanLine:
akabeiConf.write("\n")
continue
pacmanLine = pacmanLine.replace("pacman", "akabei")
# Skips the trailing whitespaces
ch = 0
while pacmanLine[ch] == ' ':
ch += 1
separatedLine = pacmanLine.partition('#')
# These are all the normal lines in the form name=value
parseOptionLine(separatedLine[0], akabeiConf)
# The separator if present
akabeiConf.write(separatedLine[1])
# After the separator there could be some commented options.
# If they're not supported by akabei or changed name
# they are be deleted/modified to avoid confusion for the reader
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment