本文整理匯總了Python中MMTK.Utility.isURL方法的典型用法代碼示例。如果您正苦於以下問題:Python Utility.isURL方法的具體用法?Python Utility.isURL怎麽用?Python Utility.isURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MMTK.Utility
的用法示例。
在下文中一共展示了Utility.isURL方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: databasePath
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import isURL [as 別名]
def databasePath(filename, directory, try_direct = False):
if Utility.isURL(filename):
return filename
filename = os.path.expanduser(filename)
if try_direct and os.path.exists(filename):
return os.path.normcase(filename)
entries = []
if os.path.split(filename)[0] == '':
for p in path:
if Utility.isURL(p):
url = Utility.joinURL(p, directory+'/'+filename)
if Utility.checkURL(url):
entries.append(url)
else:
full_name = os.path.join(os.path.join(p, directory), filename)
if os.path.exists(full_name):
entries.append(os.path.normcase(full_name))
if len(entries) == 0:
raise IOError("Database entry %s/%s not found" % (directory, filename))
else:
if len(entries) > 1:
Utility.warning("multiple database entries for %s/%s, using first one"
% (directory, filename))
for e in entries:
sys.stderr.write(e+'\n')
return entries[0]
示例2: addDatabaseDirectory
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import isURL [as 別名]
def addDatabaseDirectory(directory):
"Add a directory to the database search path"
if not Utility.isURL(directory):
directory = os.path.expanduser(directory)
path.append(directory)
示例3: range
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import isURL [as 別名]
from MMTK import Utility
import copy
import os
import sys
#
# Find database path
#
try:
path = os.environ['MMTKDATABASE'].split()
except KeyError:
path = ['~/.mmtk/Database',
os.path.join(os.path.split(__file__)[0], 'Database')]
for i in range(len(path)):
if not Utility.isURL(path[i]):
path[i] = os.path.expanduser(path[i])
#
# Some miscellaneous functions for use by other modules
#
def databasePath(filename, directory, try_direct = False):
if Utility.isURL(filename):
return filename
filename = os.path.expanduser(filename)
if try_direct and os.path.exists(filename):
return os.path.normcase(filename)
entries = []
if os.path.split(filename)[0] == '':
for p in path:
if Utility.isURL(p):