Advertisement
alacercogitatus

tags.conf gen script

Dec 18th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import re
  4.  
  5. tags_source = "../lookups/tags.csv"
  6. tags_conf = "../default/tags.conf"
  7.  
  8. ti = open(tags_source)
  9. to = open(tags_conf,"w")
  10.  
  11. line = ti.readline()
  12. comment_line = re.compile("^[\s#]+")
  13. while line:
  14. if not comment_line.match(line):
  15. parts = line.split(",")
  16. if len(parts[0]) > 0 and len(parts[1]) > 0 :
  17. tmpStr = "[%s=%s]\n"%(parts[0].strip(),parts[1].strip())
  18. for tag in parts[2:]:
  19. if len(tag) > 1:
  20. tmpStr = tmpStr + "%s = enabled\n"%tag.strip()
  21. tmpStr = tmpStr + "\n"
  22. to.write(tmpStr)
  23. line = ti.readline()
  24.  
  25. to.close()
  26. ti.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement