Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
JR Dalrymple
/
nObjects
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3f093573
authored
Sep 01, 2015
by
JR Dalrymple
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Breaks everything out, time to make classes
parent
76c93eb4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
playground.py
+20
-2
No files found.
playground.py
View file @
3f093573
...
...
@@ -3,11 +3,18 @@ import sys
import
os
import
re
# Definitions
objType
=
None
objDef
=
[]
objects
=
[]
# Strings we have to match
# Match something like "define host {" and explode it so we can grab the "host" bit
startObjMatch
=
re
.
compile
(
r"(^\s*define\s*)(\S*)(.*{\s*$)"
)
# Match something like " }"
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
with
open
(
'objects.cache'
)
as
f
:
...
...
@@ -18,7 +25,18 @@ f.close()
#Loop through the file
for
line
in
statusdat
:
if
startObjMatch
.
match
(
line
):
print
line
objType
=
startObjMatch
.
search
(
line
)
.
group
(
2
)
objDef
.
append
(
objType
)
continue
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment