Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 88e6f30
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
._* |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import os | ||
|
||
init_content = """from .base import * | ||
try: | ||
from .local import * | ||
except ImportError: | ||
pass | ||
""" | ||
|
||
def get_project_dir(): | ||
dir_list = os.path.abspath(__file__).split('/')[:-1] | ||
return '/'.join(dir_list) | ||
|
||
def awesomeness(): | ||
PROJECT_PATH = get_project_dir() | ||
|
||
if os.path.exists(PROJECT_PATH + '/settings'): | ||
raise Exception("A settings directory already exists.") | ||
|
||
try: | ||
settings = open(PROJECT_PATH + '/settings.py', 'r') | ||
except IOError: | ||
raise Exception("Cannot open your default settings file.") | ||
|
||
try: | ||
os.makedirs(PROJECT_PATH + '/settings') | ||
except Error: | ||
raise Exception("Could not create the settings folder.") | ||
|
||
try: | ||
init = open(PROJECT_PATH + '/settings/__init__.py', 'wb') | ||
init.write(init_content) | ||
init.close() | ||
except IOError: | ||
raise IOError("Could not create the __init__.py file.") | ||
|
||
try: | ||
base = open(PROJECT_PATH + '/settings/base.py', 'wb') | ||
base.write(settings.read()) | ||
base.close() | ||
settings.close() | ||
except IOError: | ||
raise IOError("WTF") | ||
|
||
try: | ||
os.remove(PROJECT_PATH + '/settings.py') | ||
except OSError: | ||
raise OSError("Cannot delete the default settings file.") | ||
|
||
try: | ||
local = open(PROJECT_PATH + '/settings/local.py', 'wb') | ||
local.write('# your local dev settings go here.') | ||
local.close() | ||
except IOError: | ||
raise IOError("Cannot write local.py file.") | ||
|
||
print("Done") | ||
|
||
|
||
if __name__ == '__main__': | ||
awesomeness() |