Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-python
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-python
Commits
58c7c54f
Commit
58c7c54f
authored
May 18, 2011
by
Noah Zoschke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic error handling
parent
d43f1d6a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
inject_dbs
opt/inject_dbs
+10
-2
No files found.
opt/inject_dbs
View file @
58c7c54f
...
...
@@ -2,7 +2,7 @@
import
os
import
sys
from
lib2to3
import
pygram
,
pytree
from
lib2to3.pgen2
import
driver
from
lib2to3.pgen2
import
driver
,
parse
BIN_DIR
=
os
.
path
.
dirname
(
__file__
)
...
...
@@ -23,9 +23,17 @@ if __name__ == "__main__":
patch
=
os
.
path
.
join
(
BIN_DIR
,
"dbs.py.src"
)
drv
=
driver
.
Driver
(
pygram
.
python_grammar
,
pytree
.
convert
)
try
:
root
=
drv
.
parse_file
(
src
)
except
parse
.
ParseError
,
e
:
print
"fatal: could not parse file as Python"
sys
.
exit
(
1
)
node
=
find
(
root
,
pytree
.
Leaf
(
1
,
"DATABASES"
))
# Find node for DATABASES = { ... }
if
not
node
:
print
"fatal: could not find DATABASES = stmt"
sys
.
exit
(
1
)
end
=
node
.
parent
.
next_sibling
# calculate adjacent sibling
with
open
(
src
)
as
_src
:
...
...
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