Flutter Engine
The Flutter Engine
compatibility_helper.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2#
3# Copyright 2013 The Flutter Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6#
7# This script contains helper function(s) for supporting both
8# python 2 and python 3 infrastructure code.
9
10ENCODING = 'UTF-8'
11
12
13def byte_str_decode(str_or_bytes):
14 """Returns a string if given either a string or bytes.
15
16 TODO: This function should be removed when the supported python
17 version is only python 3.
18
19 Args:
20 str_or_bytes (string or bytes) we want to convert or return as
21 the possible value changes depending on the version of python
22 used.
23 """
24 return str_or_bytes if isinstance(str_or_bytes, str) else str_or_bytes.decode(ENCODING)
def byte_str_decode(str_or_bytes)