本文整理匯總了Python中waterbutler.core.path.WaterButlerPath.validate_folder方法的典型用法代碼示例。如果您正苦於以下問題:Python WaterButlerPath.validate_folder方法的具體用法?Python WaterButlerPath.validate_folder怎麽用?Python WaterButlerPath.validate_folder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類waterbutler.core.path.WaterButlerPath
的用法示例。
在下文中一共展示了WaterButlerPath.validate_folder方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_folder
# 需要導入模塊: from waterbutler.core.path import WaterButlerPath [as 別名]
# 或者: from waterbutler.core.path.WaterButlerPath import validate_folder [as 別名]
def create_folder(self, path, **kwargs):
WaterButlerPath.validate_folder(path)
if path.identifier is not None:
raise exceptions.FolderNamingConflict(str(path))
resp = yield from self.make_request(
'POST',
self.build_url('folders'),
data={
'name': path.name,
'parent': {
'id': path.parent.identifier
}
},
expects=(201, 409),
throws=exceptions.CreateFolderError,
)
# Catch 409s to avoid race conditions
if resp.status == 409:
raise exceptions.FolderNamingConflict(str(path))
resp_json = yield from resp.json()
# save new folder's id into the WaterButlerPath object. logs will need it later.
path._parts[-1]._id = resp_json['id']
return BoxFolderMetadata(resp_json, path)
示例2: create_folder
# 需要導入模塊: from waterbutler.core.path import WaterButlerPath [as 別名]
# 或者: from waterbutler.core.path.WaterButlerPath import validate_folder [as 別名]
async def create_folder(self, path, **kwargs):
"""
:param str path: The path to create a folder at
"""
WaterButlerPath.validate_folder(path)
response = await self.make_request(
'POST',
self.build_url('fileops', 'create_folder'),
params={
'root': 'auto',
'path': path.full_path
},
expects=(200, 403),
throws=exceptions.CreateFolderError
)
data = await response.json()
if response.status == 403:
if 'because a file or folder already exists at path' in data.get('error'):
raise exceptions.FolderNamingConflict(str(path))
raise exceptions.CreateFolderError(data, code=403)
return DropboxFolderMetadata(data, self.folder)
示例3: create_folder
# 需要導入模塊: from waterbutler.core.path import WaterButlerPath [as 別名]
# 或者: from waterbutler.core.path.WaterButlerPath import validate_folder [as 別名]
def create_folder(self, path, **kwargs):
WaterButlerPath.validate_folder(path)
if path.identifier is not None:
raise exceptions.FolderNamingConflict(str(path))
resp = yield from self.make_request(
'POST',
self.build_url('folders'),
data={
'name': path.name,
'parent': {
'id': path.parent.identifier
}
},
expects=(201, 409),
throws=exceptions.CreateFolderError,
)
# Catch 409s to avoid race conditions
if resp.status == 409:
raise exceptions.FolderNamingConflict(str(path))
return BoxFolderMetadata(
(yield from resp.json()),
path
).serialized()
示例4: create_folder
# 需要導入模塊: from waterbutler.core.path import WaterButlerPath [as 別名]
# 或者: from waterbutler.core.path.WaterButlerPath import validate_folder [as 別名]
async def create_folder(self, path: WaterButlerPath, folder_precheck: bool=True,
**kwargs) -> BoxFolderMetadata:
WaterButlerPath.validate_folder(path)
if folder_precheck:
if path.identifier is not None:
raise exceptions.FolderNamingConflict(path.name)
async with self.request(
'POST',
self.build_url('folders'),
data={
'name': path.name,
'parent': {
'id': path.parent.identifier
}
},
expects=(201, 409),
throws=exceptions.CreateFolderError,
) as resp:
# Catch 409s to avoid race conditions
if resp.status == 409:
raise exceptions.FolderNamingConflict(path.name)
resp_json = await resp.json()
# save new folder's id into the WaterButlerPath object. logs will need it later.
path._parts[-1]._id = resp_json['id']
return BoxFolderMetadata(resp_json, path)
示例5: create_folder
# 需要導入模塊: from waterbutler.core.path import WaterButlerPath [as 別名]
# 或者: from waterbutler.core.path.WaterButlerPath import validate_folder [as 別名]
async def create_folder(self, path, **kwargs):
"""
:param str path: The path to create a folder at
"""
WaterButlerPath.validate_folder(path)
data = await self.dropbox_request(
self.build_url('files', 'create_folder'),
{'path': path.full_path.rstrip('/')},
throws=exceptions.CreateFolderError,
)
return DropboxFolderMetadata(data, self.folder)
示例6: create_folder
# 需要導入模塊: from waterbutler.core.path import WaterButlerPath [as 別名]
# 或者: from waterbutler.core.path.WaterButlerPath import validate_folder [as 別名]
def create_folder(self, path, **kwargs):
"""
:param str path: The path to create a folder at
"""
WaterButlerPath.validate_folder(path)
if (yield from self.exists(path)):
raise exceptions.FolderNamingConflict(str(path))
yield from self.make_request(
'PUT',
self.bucket.new_key(path.path).generate_url(settings.TEMP_URL_SECS, 'PUT'),
expects=(200, 201),
throws=exceptions.CreateFolderError
)
return S3FolderMetadata({'Prefix': path.path})