Skip to content

Commit

Permalink
<>[]: <Fix PyutNote>
Browse files Browse the repository at this point in the history
[
* Notes not have a name on untangle
* TODO:  Should have a name on serialization
* Make a unit test for it
* Update Ogl version while we are at it
]

[#77]
  • Loading branch information
Humberto Sanchez II committed Apr 28, 2024
1 parent e6c8d06 commit f589fce
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
pip install codeallybasic==1.3.0
pip install codeallyadvanced==1.3.1
pip install pyutmodelv2>=2.1.5
pip install ogl>=2.1.20
pip install ogl>=2.1.31
pip install untangle==1.2.1
pip install buildlackey==1.6.3
- run:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies = [
'codeallybasic>=1.3.0',
'codeallyadvanced>=1.3.1',
'pyutmodelv2>=2.1.5',
'ogl>=2.1.20',
'ogl>=2.1.31',
]

[project.urls]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ codeallybasic==1.3.0
codeallyadvanced==1.3.1

pyutmodelv2>=2.1.5
ogl>=2.1.20
ogl>=2.1.31
9 changes: 7 additions & 2 deletions src/untanglepyut/UnTanglePyut.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class UnTanglePyut:
"""
Converts pyutmodel Version 11 XML to Pyut Objects
"""
NOTE_NAME: str = 'Note'
noteCounter: int = 0

def __init__(self, xmlVersion: XmlVersion):

Expand Down Expand Up @@ -483,10 +485,13 @@ def _addPyutObjectAttributes(self, pyutElement: Element, pyutObject: PyutObject)
Returns: The updated pyutObject as
"""

pyutObject.id = int(pyutElement[self._attrId]) # TODO revisit this when we start using UUIDs
pyutObject.name = pyutElement['name']
pyutObject.id = int(pyutElement[self._attrId]) # TODO revisit this when we start using UUIDs
pyutObject.name = pyutElement['name']
pyutObject.fileName = pyutElement[self._attrFileName]

if pyutObject.name is None:
UnTanglePyut.noteCounter += 1
pyutObject.name = f'{UnTanglePyut.NOTE_NAME}-{UnTanglePyut.noteCounter}'
return pyutObject

def _securePyutDisplayMethods(self, displayStr: str) -> PyutDisplayMethods:
Expand Down
2 changes: 1 addition & 1 deletion src/untanglepyut/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__: str = '2.1.7'
__version__: str = '2.1.8'
10 changes: 10 additions & 0 deletions tests/untanglepyut/v11/TestUnTanglePyut.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ def setUp(self):
def tearDown(self):
super().tearDown()

def testNoteNameNone(self):

rootElement: Element = parse(V11_PYUT_NOTE)
oglNoteElement: Element = rootElement.OglNote

untanglepyut: UnTanglePyut = UnTanglePyut(xmlVersion=XmlVersion.V11)
pyutNote: PyutNote = untanglepyut.noteToPyutNote(graphicNote=oglNoteElement)

self.assertIsNotNone(pyutNote.name, 'Where is my update!')

def testPyutClass(self):
root: Element = parse(V11_PYUT_CLASS)
oglClass: Element = root.OglClass
Expand Down

0 comments on commit f589fce

Please sign in to comment.