Created
June 26, 2012 03:40
-
-
Save fastmover/2993125 to your computer and use it in GitHub Desktop.
Install li3_users into libraries.php and add new connection to connections.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fileinput | |
import sys, os | |
def addBefore(file,searchExp,inputExp): | |
if(os.path.isfile(file)): | |
for line in fileinput.input(file, inplace=1): | |
if searchExp in line: | |
sys.stdout.write(inputExp) | |
#line = line.replace(searchExp,replaceExp) | |
sys.stdout.write(line) | |
if __name__ == '__main__': | |
file = "/li3/app/config/bootstrap/libraries.php" | |
file = os.getcwd() + file | |
addBefore(file,"?>","Libraries::add('li3_users');\n\n") | |
addBefore( | |
os.getcwd() + "/li3/app/config/bootstrap/connections.php", | |
"?>", | |
""" | |
Connections::add('li3_users', array( | |
'type' => 'MongoDb', | |
'host' => 'localhost', | |
'database' => 'my_app' | |
)); | |
""" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment