Lircrc builder
From MythTV
[edit]
Introduction
This is a simple python script I made to convert shorthand lirc config to full config. Remeber this is in beta and may have problems use at your own risk.
[edit]
Howto
For an example create this file
Then run
# python lrc.py
That will output this
#Generated by: t0ny's lircrc builder begin prog = mythtv button = Play-button repeat = 3 config = p end begin prog = mythtv button = Vol-up repeat = 3 config = F11 end begin prog = mythtv button = Vol-down repeat = 3 config = F10 end begin prog = mplayer button = Play-button repeat = 3 config = p end
[edit]
Source code
#!/usr/bin/python
import sys
#By Tony Speer 2007 under GPL v2
#USE AT YOUR OWN RISK!
#Version 0.1 Beta
#defaults
prog = "mythtv"
repeat = 3
fn = "lrc.txt"
x = 0
while x < len(sys.argv):
arg = sys.argv[x]
if arg == "--file":
fn = sys.argv[x + 1]
x += 1
f = open(fn, "r")
print "#Generated by: t0ny's lircrc builder\n"
for line in f.readlines():
if line.find("#") != -1: #check for comment
line = line.split("#")[1] # remove comments
line = line.replace("\n", "")
if line.startswith("prog"):
prog = line.split(" ")[1]
elif line.startswith("repeat"):
repeat = int(line.split(" ")[1])
else:
b = line.split(" ")
if len(b) > 1:
print """begin
prog = %s
button = %s
repeat = %s
config = %s
end\n""" % (prog, b[0], repeat, b[1])
f.close()
