Commit 2b6b6d67 authored by Michael Büsch's avatar Michael Büsch

Improve Python2 compatibility

Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent ed0caa1d
......@@ -20,6 +20,8 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
import sys
import os
......
......@@ -20,6 +20,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
import sys
import getopt
......
from __future__ import division, absolute_import, print_function, unicode_literals
from __future__ import division, absolute_import, print_function, unicode_literals
import awlsim.cython_helper as __cython
if __cython.shouldUseCython():
......
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.main import *
from awlsim.core.cpu import *
from awlsim.core.hardware import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.labels import *
from awlsim.core.datastructure import *
from awlsim.core.datatypes import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.datatypes import *
from awlsim.core.blocks import *
from awlsim.core.parameters import *
......
# -*- coding: utf-8 -*-
#
# AWL simulator - utility functions
#
# Copyright 2012-2013 Michael Buesch <m@bues.ch>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
import sys
# isPyPy is True, if the interpreter is PyPy.
isPyPy = "PyPy" in sys.version
# isPy3Compat is True, if the interpreter is Python 3 compatible.
isPy3Compat = sys.version_info[0] == 3
# isPy2Compat is True, if the interpreter is Python 2 compatible.
isPy2Compat = sys.version_info[0] == 2
# Python 2/3 helper selection
def py23(py2, py3):
if isPy3Compat:
return py3
if isPy2Compat:
return py2
raise Exception("Failed to detect Python version")
# input() compatibility.
# Force Python3 behavior
if isPy2Compat:
input = raw_input
# range() compatibility.
# Force Python3 behavior
if isPy2Compat:
range = xrange
# Compat wrapper for monotonic time
import time
monotonic_time = py23(lambda: time.clock(),
lambda: time.monotonic())
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.util import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
import time
import datetime
import random
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.util import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.util import *
from awlsim.core.operators import *
from awlsim.core.datatypes import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.util import *
from awlsim.core.datatypes import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.util import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.util import *
from awlsim.core.timers import *
from awlsim.core.datatypehelpers import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
class MagicEnumerationGenerator(object):
"Magic enumeration generator"
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.enumeration import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.util import AwlSimError
......
......@@ -18,6 +18,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.util import *
from awlsim.core.instructions.all_insns import *
from awlsim.core.parser import *
......
from __future__ import division, absolute_import, print_function, unicode_literals
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.insn_abs import *
from awlsim.core.instructions.insn_acos import *
from awlsim.core.instructions.insn_asin import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *
......
......@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.core.compat import *
from awlsim.core.instructions.main import *