Merge pull request #15 from looooo/master

py3-fixes
This commit is contained in:
realthunder 2018-07-02 16:52:08 +08:00 committed by GitHub
commit 2ac3d2db98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 19 additions and 19 deletions

View File

@ -110,4 +110,4 @@ class FCADLogger:
import PySide
PySide.QtGui.QMessageBox.critical(
FreeCADGui.getMainWindow(),'Assembly',e.message)
FreeCADGui.getMainWindow(),'Assembly',str(e))

View File

@ -1,3 +1,4 @@
from six import with_metaclass
from collections import namedtuple
import FreeCAD, FreeCADGui, Part
from . import utils, gui
@ -583,8 +584,7 @@ def cstrName(obj):
return '{}<{}>'.format(objName(obj),Constraint.getTypeName(obj))
class Base(object):
__metaclass__ = Constraint
class Base(with_metaclass(Constraint, object)):
_id = -1
_entityDef = ()
_workplane = False

4
gui.py
View File

@ -1,3 +1,4 @@
from six import with_metaclass
from collections import OrderedDict
import FreeCAD, FreeCADGui
from .utils import getElementPos,objName,addIconToFCAD,guilogger as logger
@ -177,8 +178,7 @@ class AsmCmdManager(ProxyType):
def onClearSelection(cls):
pass
class AsmCmdBase(object):
__metaclass__ = AsmCmdManager
class AsmCmdBase(with_metaclass(AsmCmdManager, object)):
_id = -1
_active = None
_toolbarName = 'Assembly3'

View File

@ -61,7 +61,7 @@ class ProxyType(type):
@classmethod
def getType(mcs,tp):
if isinstance(tp,basestring):
if isinstance(tp,str):
return mcs.getInfo().TypeNameMap[tp]
if not isinstance(tp,int):
tp = mcs.getTypeID(tp)

View File

@ -110,7 +110,7 @@ class Solver(object):
msg += '\n{}, handle: {}'.format(cstrName(cstr),h)
logger.error(msg)
raise RuntimeError('Failed to solve {}: {}'.format(
objName(assembly),e.message))
objName(assembly),str(e)))
self.system.log('done solving')
touched = False

View File

@ -1,3 +1,4 @@
from six import with_metaclass
from .system import System, SystemBase, SystemExtension
from .utils import syslogger as logger, objName
import platform
@ -5,10 +6,12 @@ import platform
if platform.system() == 'Darwin':
from .py_slvs_mac import slvs
else:
from .py_slvs import slvs
try:
from py_slvs import slvs
except ImportError:
from .py_slvs import slvs
class SystemSlvs(SystemBase):
__metaclass__ = System
class SystemSlvs(with_metaclass(System, SystemBase)):
_id = 1
def __init__(self,obj):

View File

@ -1,3 +1,4 @@
from six import with_metaclass
from collections import namedtuple
import pprint
from .proxy import ProxyType, PropertyInfo
@ -30,8 +31,7 @@ def _makeProp(name,doc='',tp='App::PropertyFloat',group=None):
_makeProp('Tolerance','','App::PropertyPrecision','Solver')
class _AlgoBase(object):
__metaclass__ = _AlgoType
class _AlgoBase(with_metaclass(_AlgoType, object)):
_id = -2
_common_options = [_makeProp('maxiter',
'Maximum number of function evaluations','App::PropertyInteger')]
@ -207,8 +207,7 @@ class _Algodogleg(_AlgoNeedHessian):
class _Algotrust_ncg(_Algodogleg):
_id = 10
class SystemSymPy(SystemBase):
__metaclass__ = System
class SystemSymPy(with_metaclass(System, SystemBase)):
_id = 2
def __init__(self,obj):
@ -319,8 +318,7 @@ class _MetaType(type):
return issubclass(cls,_Constraint)
class _MetaBase(_Base):
__metaclass__ = _MetaType
class _MetaBase(with_metaclass(_MetaType, _Base)):
_args = ()
_opts = ()
_vargs = ()

View File

@ -1,3 +1,4 @@
from six import with_metaclass
import os
import FreeCAD
from .constraint import cstrName, PlaneInfo, NormalInfo
@ -76,8 +77,7 @@ def _makePropInfo(name,tp,doc='',default=None):
_makePropInfo('Verbose','App::PropertyBool')
_makePropInfo('AutoRelax','App::PropertyBool')
class SystemBase(object):
__metaclass__ = System
class SystemBase(with_metaclass(System, object)):
_id = 0
_props = ['Verbose','AutoRelax']

View File

@ -590,4 +590,3 @@ def project2D(rot,*vectors):
vx = rot.multVec(FreeCAD.Vector(1,0,0))
vy = rot.multVec(FreeCAD.Vector(0,1,0))
return [FreeCAD.Vector(v.dot(vx),v.dot(vy),0) for v in vectors]