# Path: yubioath/yubicommon/compat.py
# def byte2int(i):
#     if _PY2:
#         return ord(i)
#     return i


from yubioath.yubicommon.compat import byte2int
from collections import namedtuple
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Additional permission under GNU GPL version 3 section 7
#
# If you modify this program, or any covered work, by linking or
# combining it with the OpenSSL project's OpenSSL library (or a
# modified version of that library), containing parts covered by the
# terms of the OpenSSL or SSLeay licenses, We grant you additional
# permission to convey the resulting work. Corresponding Source for a
# non-source form of such a combination shall include the source code
# for the parts of OpenSSL used as well as that of the covered work.

"""
Given an image, locates and parses the pixel data in QR codes.
"""

from __future__ import division


__all__ = ['parse_qr_codes']


Box = namedtuple('Box', ['x', 'y', 'w', 'h'])


def is_dark(color):  # If any R, G, or B value is < 200 we consider it dark.

# Path: yubioath/yubicommon/compat.py
# def byte2int(i):
#     if _PY2:
#         return ord(i)
#     return i


# Path: yubioath/gui/qrparse.py
from yubioath.yubicommon.compat import byte2int
from collections import namedtuple

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Additional permission under GNU GPL version 3 section 7
#
# If you modify this program, or any covered work, by linking or
# combining it with the OpenSSL project's OpenSSL library (or a
# modified version of that library), containing parts covered by the
# terms of the OpenSSL or SSLeay licenses, We grant you additional
# permission to convey the resulting work. Corresponding Source for a
# non-source form of such a combination shall include the source code
# for the parts of OpenSSL used as well as that of the covered work.

"""
Given an image, locates and parses the pixel data in QR codes.
"""

from __future__ import division


__all__ = ['parse_qr_codes']


Box = namedtuple('Box', ['x', 'y', 'w', 'h'])


def is_dark(color):  # If any R, G, or B value is < 200 we consider it dark.

    return any(byte2int(c) < 200 for c in color)