mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* Compatibility with python2 and python3 * Formatting * Updated to use a function instead of decoding bytes in multiple places. * Formatting and whitespace cleanup. * Fix import statement. * Linter change for docstring. * Formatting. * Remove function from run_tests.py since it is a pain to import. * Add todo message for python 2 deprecation. * Updated copyright year.
26 lines
808 B
Python
26 lines
808 B
Python
#!/usr/bin/env python3
|
|
#
|
|
# Copyright 2013 The Flutter Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
#
|
|
# This script contains helper function(s) for supporting both
|
|
# python 2 and python 3 infrastructure code.
|
|
|
|
ENCODING = 'UTF-8'
|
|
|
|
|
|
def byte_str_decode(str_or_bytes):
|
|
"""Returns a string if given either a string or bytes.
|
|
|
|
TODO: This function should be removed when the supported python
|
|
version is only python 3.
|
|
|
|
Args:
|
|
str_or_bytes (string or bytes) we want to convert or return as
|
|
the possible value changes depending on the version of python
|
|
used.
|
|
"""
|
|
return str_or_bytes if isinstance(str_or_bytes,
|
|
str) else str_or_bytes.decode(ENCODING)
|