Draft: Remove Python 2 type support
This commit is contained in:
@@ -35,7 +35,6 @@ but which can also be used in other workbenches and in macros.
|
||||
# flake8 --ignore=E226,E266,E401,W503
|
||||
|
||||
import math
|
||||
import sys
|
||||
|
||||
import FreeCAD
|
||||
from FreeCAD import Vector
|
||||
@@ -45,13 +44,6 @@ __title__ = "FreeCAD Draft Workbench - Vector library"
|
||||
__author__ = "Yorik van Havre, Werner Mayer, Martin Burbaum, Ken Cline"
|
||||
__url__ = "https://www.freecadweb.org"
|
||||
|
||||
# Python 2 has two integer types, int and long.
|
||||
# In Python 3 there is no 'long' anymore, so make it 'int'.
|
||||
try:
|
||||
long
|
||||
except NameError:
|
||||
long = int
|
||||
|
||||
params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
|
||||
|
||||
## \addtogroup DRAFTVECUTILS
|
||||
@@ -230,12 +222,7 @@ def scale(u, scalar):
|
||||
Base::Vector3
|
||||
The new vector with each of its elements multiplied by `scalar`.
|
||||
"""
|
||||
# Python 2 has two integer types, int and long.
|
||||
# In Python 3 there is no 'long' anymore.
|
||||
if sys.version_info.major < 3:
|
||||
typecheck([(u, Vector), (scalar, (long, int, float))], "scale")
|
||||
else:
|
||||
typecheck([(u, Vector), (scalar, (int, int, float))], "scale")
|
||||
typecheck([(u, Vector), (scalar, (int, int, float))], "scale")
|
||||
return Vector(u.x*scalar, u.y*scalar, u.z*scalar)
|
||||
|
||||
|
||||
@@ -265,12 +252,7 @@ def scaleTo(u, l):
|
||||
The new vector with each of its elements scaled by a factor.
|
||||
Or the same input vector `u`, if it is `(0, 0, 0)`.
|
||||
"""
|
||||
# Python 2 has two integer types, int and long.
|
||||
# In Python 3 there is no 'long' anymore.
|
||||
if sys.version_info.major < 3:
|
||||
typecheck([(u, Vector), (l, (long, int, float))], "scaleTo")
|
||||
else:
|
||||
typecheck([(u, Vector), (l, (int, int, float))], "scaleTo")
|
||||
typecheck([(u, Vector), (l, (int, int, float))], "scaleTo")
|
||||
if u.Length == 0:
|
||||
return Vector(u)
|
||||
else:
|
||||
|
||||
@@ -33,7 +33,6 @@ like Wire, BSpline, and BezCurve.
|
||||
|
||||
## \addtogroup draftguitools
|
||||
# @{
|
||||
import sys
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCAD as App
|
||||
@@ -76,9 +75,6 @@ class Line(gui_base_original.Creator):
|
||||
self.ui.wireUi(title=translate("draft", self.featureName), icon=icon)
|
||||
else:
|
||||
self.ui.lineUi(title=translate("draft", self.featureName), icon=icon)
|
||||
if sys.version_info.major < 3:
|
||||
if isinstance(self.featureName, unicode):
|
||||
self.featureName = self.featureName.encode("utf8")
|
||||
|
||||
self.obj = self.doc.addObject("Part::Feature", self.featureName)
|
||||
gui_utils.format_object(self.obj)
|
||||
|
||||
@@ -38,7 +38,6 @@ They are more complex that simple text annotations.
|
||||
## \addtogroup draftguitools
|
||||
# @{
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import sys
|
||||
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
@@ -105,13 +104,7 @@ class ShapeString(gui_base_original.Creator):
|
||||
# + str(type(self.SString)))
|
||||
|
||||
dquote = '"'
|
||||
if sys.version_info.major < 3:
|
||||
# Python2, string needs to be converted to unicode
|
||||
String = ('u' + dquote
|
||||
+ self.SString.encode('unicode_escape') + dquote)
|
||||
else:
|
||||
# Python3, string is already unicode
|
||||
String = dquote + self.SString + dquote
|
||||
String = dquote + self.SString + dquote
|
||||
|
||||
# Size and tracking are numbers;
|
||||
# they are ASCII so this conversion should always work
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
## \addtogroup draftobjects
|
||||
# @{
|
||||
import sys
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCAD as App
|
||||
@@ -61,17 +60,11 @@ class ShapeString(DraftObject):
|
||||
def execute(self, obj):
|
||||
import Part
|
||||
# import OpenSCAD2Dgeom
|
||||
import os
|
||||
if obj.String and obj.FontFile:
|
||||
if obj.Placement:
|
||||
plm = obj.Placement
|
||||
ff8 = obj.FontFile.encode('utf8') # 1947 accents in filepath
|
||||
# TODO: change for Py3?? bytes?
|
||||
# Part.makeWireString uses FontFile as char* string
|
||||
if sys.version_info.major < 3:
|
||||
CharList = Part.makeWireString(obj.String,ff8,obj.Size,obj.Tracking)
|
||||
else:
|
||||
CharList = Part.makeWireString(obj.String,obj.FontFile,obj.Size,obj.Tracking)
|
||||
|
||||
CharList = Part.makeWireString(obj.String,obj.FontFile,obj.Size,obj.Tracking)
|
||||
if len(CharList) == 0:
|
||||
App.Console.PrintWarning(translate("draft","ShapeString: string has no wires")+"\n")
|
||||
return
|
||||
@@ -79,10 +72,7 @@ class ShapeString(DraftObject):
|
||||
|
||||
# test a simple letter to know if we have a sticky font or not
|
||||
sticky = False
|
||||
if sys.version_info.major < 3:
|
||||
testWire = Part.makeWireString("L",ff8,obj.Size,obj.Tracking)[0][0]
|
||||
else:
|
||||
testWire = Part.makeWireString("L",obj.FontFile,obj.Size,obj.Tracking)[0][0]
|
||||
testWire = Part.makeWireString("L",obj.FontFile,obj.Size,obj.Tracking)[0][0]
|
||||
if testWire.isClosed:
|
||||
try:
|
||||
testFace = Part.Face(testWire)
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
## \addtogroup drafttaskpanels
|
||||
# @{
|
||||
import sys
|
||||
import PySide.QtCore as QtCore
|
||||
import PySide.QtGui as QtGui
|
||||
|
||||
@@ -120,10 +119,7 @@ class ShapeStringTaskPanel:
|
||||
def createObject(self):
|
||||
"""Create object in the current document."""
|
||||
dquote = '"'
|
||||
if sys.version_info.major < 3: # Python3: no more unicode
|
||||
String = 'u' + dquote + str(self.task.leString.text().encode('unicode_escape')) + dquote
|
||||
else:
|
||||
String = dquote + self.task.leString.text() + dquote
|
||||
String = dquote + self.task.leString.text() + dquote
|
||||
FFile = dquote + str(self.fileSpec) + dquote
|
||||
|
||||
Size = str(U.Quantity(self.task.sbHeight.text()).Value)
|
||||
|
||||
@@ -160,12 +160,7 @@ class ViewProviderText(ViewProviderDraftAnnotation):
|
||||
if prop == "Text" and obj.Text:
|
||||
self.text2d.string.setValue("")
|
||||
self.text3d.string.setValue("")
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
_list = [l for l in obj.Text if l]
|
||||
else:
|
||||
_list = [l.encode("utf8") for l in obj.Text if l]
|
||||
|
||||
_list = [l for l in obj.Text if l]
|
||||
self.text2d.string.setValues(_list)
|
||||
self.text3d.string.setValues(_list)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user