remove Python2 code

This commit is contained in:
mosfet80
2023-03-04 19:36:18 +01:00
committed by Chris Hennes
parent d03f287cf4
commit 3137dea940
79 changed files with 28 additions and 200 deletions

View File

@@ -1,4 +0,0 @@
# remove this once python2 support has stopped
def __exec_new__(text, globals, locals):
exec(text, globals, locals)

View File

@@ -1,5 +0,0 @@
# remove this file once the python2 support has stopped
def __exec_old__(text, globals, locals):
exec text in globals, locals # noqa: E999 a Python 3 syntax error

View File

@@ -2386,7 +2386,6 @@ TEMPLATE_HEADER = """\
# WARNING! All changes made in this file will be lost!
#
from __future__ import print_function # this allows py2 to print(str1,str2) correctly
import sys
import getopt

View File

@@ -7,7 +7,6 @@
# WARNING! All changes made in this file will be lost!
#
from __future__ import print_function # this allows py2 to print(str1,str2) correctly
import sys
import getopt

View File

@@ -2,25 +2,9 @@
# -*- coding: utf-8 -*-
# (c) 2007 Jürgen Riegel
from __future__ import print_function # this allows py2 to print(str1,str2) correctly
import os
def temporary_exec(text, globals, locals):
"""this function is a dirty hack to allow using the copier from
python2 and python3. Once the support of python2 has stopped
feel free to remove this function and use the std exec function
instead"""
# maybe this should be fixed by rewriting the generators.
if sys.version_info[0] < 3:
from .__exec_old import __exec_old__
__exec_old__(text, globals, locals)
else:
from .__exec_new import __exec_new__
__exec_new__(text, globals, locals)
def ensureDir(path,mode=0o777):
try:
os.makedirs(path,mode)
@@ -92,7 +76,7 @@ class copier:
stat = self.preproc(stat, 'exec')
stat = '%s _cb(%s,%s)' % (stat,i+1,j)
# for debugging, uncomment...: print("-> Executing: {"+stat+"}")
temporary_exec(stat, self.globals, self.locals)
exec(stat, self.globals, self.locals)
i=j+1
else: # normal line, just copy with substitution
try: