doc_infra/parsers/base.py

37 lines
924 B
Python
Raw Normal View History

#!/bin/env python3
import sys
from os import listdir
from os.path import isfile, join
from debian import parse_debian
from freebsd import parse_freebsd
from freebox import parse_freebox
def find_os(content):
version = content.split("###### VERSION ######")[-1]
osystem = [line.split("=")[-1] for line in version.splitlines() if line.startswith("ID=")]
if osystem:
return osystem[0]
else:
return "freebox"
def main():
mypath = "../oxidized/"
onlyfiles = [mypath + f for f in listdir(mypath) if isfile(join(mypath, f))]
for file in onlyfiles:
with open(file,"r") as f:
content = f.read()
current_os = find_os(content)
if "freebsd" in current_os:
parse_freebsd(content)
elif "debian" in current_os:
parse_debian(content)
else:
parse_freebox(content)
if __name__ == "__main__":
main()