b2sdk.utils
¶
-
b2sdk.utils.
interruptible_get_result
(future)[source]¶ Wait for the result of a future in a way that can be interrupted by a KeyboardInterrupt.
This is not necessary in Python 3, but is needed for Python 2.
- Parameters
future (Future) – a future to get result of
-
b2sdk.utils.
b2_url_encode
(s)[source]¶ URL-encode a unicode string to be sent to B2 in an HTTP header.
-
b2sdk.utils.
choose_part_ranges
(content_length, minimum_part_size)[source]¶ Return a list of (offset, length) for the parts of a large file.
-
b2sdk.utils.
hex_sha1_of_stream
(input_stream, content_length)[source]¶ Return the 40-character hex SHA1 checksum of the first content_length bytes in the input stream.
-
b2sdk.utils.
validate_b2_file_name
(name)[source]¶ Raise a ValueError if the name is not a valid B2 file name.
- Parameters
name (str) – a string to check
-
b2sdk.utils.
is_file_readable
(local_path, reporter=None)[source]¶ Check if the local file has read permissions.
-
b2sdk.utils.
fix_windows_path_limit
(path)[source]¶ Prefix paths when running on Windows to overcome 260 character path length limit. See https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath
-
class
b2sdk.utils.
BytesIoContextManager
(byte_data)[source]¶ Bases:
object
A simple wrapper for a BytesIO that makes it look like a file-like object that can be a context manager.
-
class
b2sdk.utils.
TempDir
[source]¶ Bases:
object
Context manager that creates and destroys a temporary directory.
-
b2sdk.utils.
format_and_scale_number
(x, unit)[source]¶ Pick a good scale for representing a number and format it.
-
b2sdk.utils.
format_and_scale_fraction
(numerator, denominator, unit)[source]¶ Pick a good scale for representing a fraction, and format it.
-
b2sdk.utils.
camelcase_to_underscore
(input_)[source]¶ Convert a camel-cased string to a string with underscores.