本文整理汇总了Python中exe.engine.path.Path.islink方法的典型用法代码示例。如果您正苦于以下问题:Python Path.islink方法的具体用法?Python Path.islink怎么用?Python Path.islink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.path.Path
的用法示例。
在下文中一共展示了Path.islink方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testUpgradeTo0_20
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import islink [as 别名]
def testUpgradeTo0_20(self):
"""
Creates a package similar to what 0.19 would
and tests if it upgrades ok
"""
fn = Path('0.19 resources upgrade test.elp')
assert fn.isfile() or fn.islink()
package = self.package.__class__.load(fn)
assert hasattr(package, 'resources')
assert len(package.resources) == 8, len(package.resources)
for checksum, resources in package.resources.items():
storageNames = []
userNames = []
for res in resources:
storageNames.append(res.storageName)
userNames.append(res.userName)
assert len(set(storageNames)) == 1, 'Two identical resources have different storage names:\n%s' % storageNames
allResourceNames = []
for reses in package.resources.values():
allResourceNames.append(reses[0].storageName)
filenames = [path.basename() for path in package.resourceDir.files()]
withoutDups = set(filenames) - set(allResourceNames)
assert withoutDups == set([]), "Duplicate files weren't deleted %s" % withoutDups
assert len(filenames) == len(allResourceNames)
assert len(filenames) > 0, 'All resources have been deleted!'
示例2: render
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import islink [as 别名]
def render(self, request):
if "sendWhat" in request.args:
if request.args['sendWhat'][0] == 'dirs':
pathdir = Path(unquote(request.args['node'][0].decode('utf-8')))
l = []
if pathdir == '/' and sys.platform[:3] == "win":
for d in get_drives():
try:
if is_readable(Path(d)):
icon = None
else:
icon = '../jsui/extjs/resources/themes/images/gray/grid/hmenu-lock.gif'
l.append({"realtext": d, "text": d, "id": d + '\\', "icon": icon})
except:
pass
else:
for d in pathdir.dirs():
try:
if not d.name.startswith('.') or sys.platform[:3] == "win":
if not iswinlink(d.abspath()):
if is_readable(d):
icon = None
else:
icon = '../jsui/extjs/resources/themes/images/gray/grid/hmenu-lock.gif'
l.append({"realtext": d.name, "text": getname(d), "id": d.abspath(), "icon": icon})
except:
pass
elif request.args['sendWhat'][0] == 'both':
pathdir = Path(unquote(request.args['dir'][0].decode('utf-8')))
items = []
if pathdir == '/' and sys.platform[:3] == "win":
for drive in get_drives():
d = Path(drive + '\\')
items.append({"name": drive, "realname": drive + '\\', "size": 0, "type": 'directory', "modified": 0,
"is_readable": is_readable(d),
"is_writable": is_writable(d)})
else:
parent = pathdir.parent
if (parent == pathdir):
realname = '/'
else:
realname = parent.abspath()
items.append({"name": '.', "realname": pathdir.abspath(), "size": pathdir.size, "type": "directory", "modified": int(pathdir.mtime),
"is_readable": is_readable(pathdir),
"is_writable": is_writable(pathdir)})
items.append({"name": '..', "realname": realname, "size": parent.size, "type": "directory", "modified": int(parent.mtime),
"is_readable": is_readable(parent),
"is_writable": is_writable(parent)})
try:
for d in pathdir.listdir():
try:
if not d.name.startswith('.') or sys.platform[:3] == "win":
if not iswinlink(d.abspath()):
if d.isdir():
pathtype = "directory"
elif d.isfile():
if is_readable(d):
pathtype = repr(mimetypes.guess_type(d.name, False)[0])
else:
pathtype = "file"
elif d.islink():
pathtype = "link"
else:
pathtype = "None"
items.append({"name": getname(d), "realname": d.abspath(), "size": d.size, "type": pathtype, "modified": int(d.mtime),
"is_readable": is_readable(d),
"is_writable": is_writable(d)})
except:
pass
G.application.config.lastDir = pathdir
except:
pass
l = {"totalCount": len(items), 'results': len(items), 'items': items}
return json.dumps(l).encode('utf-8')
elif "query" in request.args:
query = request.args['query'][0]
pathdir = Path(unquote(request.args['dir'][0].decode('utf-8')))
items = []
if pathdir == '/' and sys.platform[:3] == "win":
for d in get_drives():
items.append({"name": d, "realname": d + '\\', "size": 0, "type": 'directory', "modified": 0})
else:
parent = pathdir.parent
if (parent == pathdir):
realname = '/'
else:
realname = parent.abspath()
for d in pathdir.listdir():
try:
if d.isdir():
pathtype = "directory"
elif d.isfile():
if is_readable(d):
pathtype = repr(mimetypes.guess_type(d.name, False)[0])
else:
pathtype = "file"
elif d.islink():
pathtype = "link"
else:
pathtype = "None"
#.........这里部分代码省略.........
示例3: render
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import islink [as 别名]
def render(self, request):
if "sendWhat" in request.args:
if request.args['sendWhat'][0] == 'dirs':
#Because this might be absolute and mess up...
path_dir_str = unquote(request.args['node'][0].decode('utf-8'))
path_dir_str = self.get_dirpath_for_request(
request, path_dir_str)
pathdir = Path(path_dir_str)
l = []
if pathdir == '/' and sys.platform[:3] == "win":
for d in get_drives():
try:
if is_readable(Path(d)):
icon = None
else:
icon = '../jsui/extjs/resources/themes/images/gray/grid/hmenu-lock.gif'
l.append({"realtext": d, "text": d, "id": d + '\\', "icon": icon})
except:
pass
else:
for d in pathdir.dirs():
try:
if not d.name.startswith('.') or sys.platform[:3] == "win":
if not iswinlink(d.abspath()):
if is_readable(d):
icon = None
else:
icon = '../jsui/extjs/resources/themes/images/gray/grid/hmenu-lock.gif'
l.append({"realtext": d.name, "text": getname(d), "id": self.abs_to_user_path(d.abspath(), request), "icon": icon})
except:
pass
elif request.args['sendWhat'][0] == 'both':
req_pathdir_str = unquote(request.args['dir'][0].decode('utf-8'))
pathdir_str = self.get_dirpath_for_request(
request, req_pathdir_str)
pathdir = Path(pathdir_str)
items = []
if pathdir == '/' and sys.platform[:3] == "win":
for drive in get_drives():
d = Path(drive + '\\')
items.append({"name": drive, "realname": drive + '\\', "size": 0, "type": 'directory', "modified": 0,
"is_readable": is_readable(d),
"is_writable": is_writable(d)})
else:
parent = pathdir.parent
if (parent == pathdir):
realname = '/'
else:
realname = self.abs_to_user_path(parent.abspath(), request)
items.append({"name": '.', "realname": self.abs_to_user_path(pathdir.abspath(), request), "size": pathdir.size, "type": "directory", "modified": int(pathdir.mtime),
"is_readable": is_readable(pathdir),
"is_writable": is_writable(pathdir)})
items.append({"name": '..', "realname": realname, "size": parent.size, "type": "directory", "modified": int(parent.mtime),
"is_readable": is_readable(parent),
"is_writable": is_writable(parent)})
try:
for d in pathdir.listdir():
try:
if not d.name.startswith('.') or sys.platform[:3] == "win":
if not iswinlink(d.abspath()):
if d.isdir():
pathtype = "directory"
elif d.isfile():
if is_readable(d):
pathtype = repr(mimetypes.guess_type(d.name, False)[0])
else:
pathtype = "file"
elif d.islink():
pathtype = "link"
else:
pathtype = "None"
items.append({"name": getname(d), "realname": self.abs_to_user_path(d.abspath(), request), "size": d.size, "type": pathtype, "modified": int(d.mtime),
"is_readable": is_readable(d),
"is_writable": is_writable(d)})
except:
pass
#this was before just pathdir - check this
if G.application.config.appMode != Config.MODE_WEBAPP:
G.application.config.lastDir = pathdir
else:
self.session.webservice_config.lastDir = req_pathdir_str
except:
pass
l = {"totalCount": len(items), 'results': len(items), 'items': items}
return json.dumps(l).encode('utf-8')
elif "query" in request.args:
query = request.args['query'][0]
path_dir_str = unquote(request.args['dir'][0].decode('utf-8'))
path_dir_str = self.get_dirpath_for_request(request,path_dir_str)
pathdir = Path(path_dir_str)
items = []
if pathdir == '/' and sys.platform[:3] == "win":
for d in get_drives():
items.append({"name": d, "realname": d + '\\', "size": 0, "type": 'directory', "modified": 0})
else:
parent = pathdir.parent
#.........这里部分代码省略.........