本文整理匯總了Python中sys.path.insert方法的典型用法代碼示例。如果您正苦於以下問題:Python path.insert方法的具體用法?Python path.insert怎麽用?Python path.insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sys.path
的用法示例。
在下文中一共展示了path.insert方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from sys import path [as 別名]
# 或者: from sys.path import insert [as 別名]
def main(cpy_dir):
global CPY_DIR
global CPY_LIB_DIR
CPY_DIR = cpy_dir
CPY_LIB_DIR = cpy_dir + "\\Lib" #E.g., C:\Python25\Lib
path.append(CPY_LIB_DIR)
path.insert(0, ".")
print "------------------------------------------------------------------------"
print "--PACKAGES"
cwd = nt.getcwd()
nt.chdir(CPY_LIB_DIR)
for pack_name in nt.listdir(CPY_LIB_DIR):
if not is_package(pack_name):
continue
elif pack_name in BLACKLIST:
continue
check_package(pack_name)
print
nt.chdir(cwd)
print "------------------------------------------------------------------------"
print "--MODULES"
for x in nt.listdir(CPY_LIB_DIR):
if x.endswith(".py"):
mod_name = x.split(".py", 1)[0]
else:
continue
try:
import_helper(mod_name)
log_ok(mod_name)
except Exception, e:
log_broken(mod_name, e)
#Cleanup
示例2: main
# 需要導入模塊: from sys import path [as 別名]
# 或者: from sys.path import insert [as 別名]
def main(cpy_dir):
global CPY_DIR
global CPY_LIB_DIR
CPY_DIR = cpy_dir
CPY_LIB_DIR = cpy_dir + "\\Lib" #E.g., C:\Python25\Lib
path.append(CPY_LIB_DIR)
path.insert(0, ".")
print("------------------------------------------------------------------------")
print("--PACKAGES")
cwd = nt.getcwd()
nt.chdir(CPY_LIB_DIR)
for pack_name in nt.listdir(CPY_LIB_DIR):
if not is_package(pack_name):
continue
elif pack_name in BLACKLIST:
continue
check_package(pack_name)
print()
nt.chdir(cwd)
print("------------------------------------------------------------------------")
print("--MODULES")
for x in nt.listdir(CPY_LIB_DIR):
if x.endswith(".py"):
mod_name = x.split(".py", 1)[0]
else:
continue
try:
import_helper(mod_name)
log_ok(mod_name)
except Exception as e:
log_broken(mod_name, e)
#Cleanup
for f in FILE_LIST:
f.close()
return BROKEN_LIST