-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathutils.py
33 lines (27 loc) · 1001 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
"""
Handy utility functions -- mostly for adjusting the sys path and/or
finding the Google App Engine SDK.
"""
import sys
import os
def adjust_sys_path(dir_name='libs'):
"""
Patch to search the libs folder. At the moment, I believe it's unable to
find .egg's, but it does search libs for imports before anything else.
"""
root_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(root_dir, dir_name))
def find_gae_sdk(dir_name='libs'):
"""
Correct any ImportError caused from being unable to find Google App
Engine's SDK. These normally occur when trying to run the application
from the commandline and/or when testing.
"""
adjust_sys_path(dir_name)
from gae_path.util import gae_sdk_path, add_gae_sdk_path
add_gae_sdk_path()
path = gae_sdk_path()
sys.path.extend([path + "/lib/yaml/lib",
path + "/lib/fancy_urllib",
path + "/lib/webob"])