Skip to content

Instantly share code, notes, and snippets.

@fastmover
Created June 26, 2012 03:40
Show Gist options
  • Save fastmover/2993125 to your computer and use it in GitHub Desktop.
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
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