Weekend 22, some QoL improvements (added wiki_to_prefs_table.py, print wiki header in output as well)
This commit is contained in:
31
wiki_to_prefs_table.py
Executable file
31
wiki_to_prefs_table.py
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
def process_line(line):
|
||||
line = line.rstrip(" \n")
|
||||
if line == "|-":
|
||||
return
|
||||
if not line.startswith("|"):
|
||||
return
|
||||
line = line.lstrip("| ")
|
||||
line = line.replace("[[", "")
|
||||
line = line.replace("]]", "")
|
||||
line = line.replace("User:", "")
|
||||
|
||||
splitted = [x.strip() for x in line.split("||")]
|
||||
if len(splitted[0].split("|")) == 2:
|
||||
splitted[0] = splitted[0].split("|")[1]
|
||||
if splitted[1] == "":
|
||||
splitted[1] = "-"
|
||||
if splitted[2] == "":
|
||||
splitted[2] = "-"
|
||||
|
||||
print(f"{splitted[0]}\t{splitted[1]}\t{splitted[2]}")
|
||||
|
||||
def main():
|
||||
for line in sys.stdin:
|
||||
process_line(line)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user