Commit 3f093573 by JR Dalrymple

Breaks everything out, time to make classes

parent 76c93eb4
...@@ -3,11 +3,18 @@ import sys ...@@ -3,11 +3,18 @@ import sys
import os import os
import re import re
# Definitions
objType = None
objDef = []
objects = []
# Strings we have to match # Strings we have to match
# Match something like "define host {" and explode it so we can grab the "host" bit # Match something like "define host {" and explode it so we can grab the "host" bit
startObjMatch = re.compile(r"(^\s*define\s*)(\S*)(.*{\s*$)") startObjMatch = re.compile(r"(^\s*define\s*)(\S*)(.*{\s*$)")
# Match something like " }" # Match something like " }"
endObjMatch = re.compile(r"^\s*}\s*$") endObjMatch = re.compile(r"^\s*}\s*$")
# Match all of the directives between
midObjMatch = re.compile(r"^\s*(\S*)\s*(.*)\s*")
# Open the objects.cache file # Open the objects.cache file
with open('objects.cache') as f: with open('objects.cache') as f:
...@@ -18,7 +25,18 @@ f.close() ...@@ -18,7 +25,18 @@ f.close()
#Loop through the file #Loop through the file
for line in statusdat: for line in statusdat:
if startObjMatch.match(line): if startObjMatch.match(line):
print line
objType = startObjMatch.search(line).group(2) objType = startObjMatch.search(line).group(2)
objDef.append(objType)
continue
if endObjMatch.match(line): if endObjMatch.match(line):
print line objects.append(objDef)
objType = None
objDef = []
continue
if objType:
objDef.append(midObjMatch.search(line).group(1))
objDef.append(midObjMatch.search(line).group(2))
for object in objects:
for directive in object:
print directive
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment