configfiles/bspwm/.config/scripts/barformatter.py
2015-10-08 10:31:53 +02:00

25 lines
554 B
Python
Executable file

from sys import argv, exit
class DefaultDict(dict):
def __init__(self,default):
super(DefaultDict, self).__init__()
self.default = default
def __getitem__(self, key):
return self.get(key, self.default)
if len(argv) <= 1:
print("%s <format>" % argv[0])
exit(1)
format_str = argv[1]
cache = DefaultDict("")
while True:
print(format_str % cache)
data = input().rstrip('\n').split(' ',1)
if len(data) < 2:
tag,content = data[0],""
else:
tag,content = data
cache[tag] = content