Skip to content

Commit 4ced4f8

Browse files
author
Humberto Sanchez II
committed
<Refactor>[]: <DRY>
[] [#75]
1 parent 4adcc6d commit 4ced4f8

File tree

3 files changed

+11
-28
lines changed

3 files changed

+11
-28
lines changed

src/untanglepyut/Common.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/untanglepyut/Types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from untangle import Element
1212

13+
from codeallybasic.SecureConversions import SecureConversions
14+
1315
from miniogl.ControlPoint import ControlPoint
1416

1517
from ogl.OglActor import OglActor
@@ -22,7 +24,6 @@
2224
from ogl.sd.OglSDInstance import OglSDInstance
2325
from ogl.sd.OglSDMessage import OglSDMessage
2426

25-
from untanglepyut.Common import str2bool
2627
from untanglepyut.XmlVersion import XmlVersion
2728

2829
UntangledControlPoints = NewType('UntangledControlPoints', List[ControlPoint])
@@ -172,7 +173,7 @@ def fromGraphicLink(cls, xmlVersion: XmlVersion, graphicLink: Element) -> 'Graph
172173
gla.dstX = int(graphicLink['destinationAnchorX'])
173174
gla.dstY = int(graphicLink['destinationAnchorY'])
174175

175-
gla.spline = str2bool(graphicLink['spline'])
176+
gla.spline = SecureConversions.secureBoolean(graphicLink['spline'])
176177

177178
return gla
178179

src/untanglepyut/UnTanglePyut.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from untangle import Element
1212

13+
from codeallybasic.SecureConversions import SecureConversions
14+
1315
from pyutmodelv2.PyutField import PyutField
1416
from pyutmodelv2.PyutField import PyutFields
1517

@@ -41,8 +43,7 @@
4143
from untanglepyut import XmlConstants
4244

4345
from untanglepyut.XmlVersion import XmlVersion
44-
from untanglepyut.Common import secureInteger
45-
from untanglepyut.Common import str2bool
46+
4647
from untanglepyut.Types import Elements
4748

4849

@@ -158,7 +159,7 @@ def classToPyutClass(self, graphicClass: Element) -> PyutClass:
158159

159160
def textToPyutText(self, graphicText: Element) -> PyutText:
160161
"""
161-
Parses Text elements
162+
Parses the Text elements
162163
Args:
163164
graphicText: Of the form: <Text id="3" content="I am standalone text"/>
164165
@@ -249,7 +250,7 @@ def useCaseToPyutUseCase(self, graphicUseCase: Element) -> PyutUseCase:
249250
"""
250251
251252
Args:
252-
graphicUseCase: An untangle Element in the above format
253+
graphicUseCase: An `untangle` Element in the above format
253254
254255
Returns: PyutUseCase
255256
"""
@@ -270,7 +271,7 @@ def linkToPyutLink(self, singleLink: Element, source: PyutClass, destination: Py
270271
linkType: PyutLinkType = PyutLinkType.toEnum(linkTypeStr)
271272
cardSrc: str = singleLink[self._attrCardinalitySource]
272273
cardDest: str = singleLink[self._attrCardinalityDestination]
273-
bidir: bool = str2bool(singleLink[self._attrBidirectional])
274+
bidir: bool = SecureConversions.secureBoolean(singleLink[self._attrBidirectional])
274275
linkDescription: str = singleLink['name']
275276

276277
pyutLink: PyutLink = PyutLink(name=linkDescription,
@@ -292,7 +293,7 @@ def sdInstanceToPyutSDInstance(self, oglSDInstanceElement: Element) -> PyutSDIns
292293

293294
pyutSDInstance.id = int(instanceElement['id'])
294295
pyutSDInstance.instanceName = instanceElement['instanceName']
295-
pyutSDInstance.instanceLifeLineLength = secureInteger(instanceElement['lifeLineLength'])
296+
pyutSDInstance.instanceLifeLineLength = SecureConversions.secureInteger(instanceElement['lifeLineLength'])
296297

297298
return pyutSDInstance
298299

@@ -414,7 +415,7 @@ def _modifierToPyutMethodModifiers(self, methodElement: Element) -> PyutModifier
414415
Args:
415416
methodElement:
416417
417-
Returns: PyutModifiers if not exist returns an empty
418+
Returns: A PyutModifiers object that may be empty.
418419
"""
419420

420421
modifierElements = methodElement.get_elements('Modifier')

0 commit comments

Comments
 (0)