-
Notifications
You must be signed in to change notification settings - Fork 3.2k
File rest parity #7001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File rest parity #7001
Changes from 13 commits
512d5a4
8bed721
22b801a
bfd3fbd
7707acf
e945a70
8c821a6
8c5c22c
d46e3dc
fcf0ec6
3c6b3e0
62dc377
3d00c52
9afed1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| import sys | ||
|
|
||
| if sys.version_info < (3,): | ||
| def _str(value): | ||
| if isinstance(value, unicode): # pylint: disable=undefined-variable | ||
| return value.encode('utf-8') | ||
|
|
||
| return str(value) | ||
| else: | ||
| _str = str | ||
|
|
||
|
|
||
| def _to_utc_datetime(value): | ||
| return value.strftime('%Y-%m-%dT%H:%M:%SZ') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| from datetime import datetime, timedelta | ||
xiafu-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| _ERROR_TOO_MANY_FILE_PERMISSIONS = 'file_permission and file_permission_key should not be set at the same time' | ||
| _FILE_PERMISSION_TOO_LONG = 'Size of file_permission is too large. file_permission should be <=8KB, else' \ | ||
| 'please use file_permission_key' | ||
|
|
||
|
|
||
| def _get_file_permission(file_permission, file_permission_key, default_permission): | ||
| # if file_permission and file_permission_key are both empty, then use the default_permission | ||
| # value as file permission, file_permission size should be <= 8KB, else file permission_key should be used | ||
| empty_file_permission = not file_permission | ||
| empty_file_permission_key = not file_permission_key | ||
| file_permission_size_too_big = False if file_permission is None \ | ||
| else len(str(file_permission).encode('utf-8')) > 8 * 1024 | ||
|
|
||
| if file_permission_size_too_big: | ||
| raise ValueError(_FILE_PERMISSION_TOO_LONG) | ||
|
|
||
| if empty_file_permission: | ||
| if empty_file_permission_key: | ||
| return default_permission | ||
|
|
||
| return None | ||
|
||
|
|
||
| if empty_file_permission_key: | ||
| return file_permission | ||
|
|
||
| raise ValueError(_ERROR_TOO_MANY_FILE_PERMISSIONS) | ||
|
|
||
|
|
||
| def _parse_datetime_from_str(string_datetime): | ||
| if not string_datetime: | ||
| return None | ||
| dt, _, us = string_datetime.partition(".") | ||
| dt = datetime.strptime(dt, "%Y-%m-%dT%H:%M:%S") | ||
| us = int(us[:-2]) # microseconds | ||
| datetime_obj = dt + timedelta(microseconds=us) | ||
| return datetime_obj | ||
|
|
||
|
|
||
| def _datetime_to_str(datetime_obj): | ||
| return datetime_obj if isinstance(datetime_obj, str) else datetime_obj.isoformat() + '0Z' | ||
Uh oh!
There was an error while loading. Please reload this page.