Skip to content

Commit f589fce

Browse files
author
Humberto Sanchez II
committed
<>[]: <Fix PyutNote>
[ * 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]
1 parent e6c8d06 commit f589fce

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
pip install codeallybasic==1.3.0
3737
pip install codeallyadvanced==1.3.1
3838
pip install pyutmodelv2>=2.1.5
39-
pip install ogl>=2.1.20
39+
pip install ogl>=2.1.31
4040
pip install untangle==1.2.1
4141
pip install buildlackey==1.6.3
4242
- run:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies = [
1717
'codeallybasic>=1.3.0',
1818
'codeallyadvanced>=1.3.1',
1919
'pyutmodelv2>=2.1.5',
20-
'ogl>=2.1.20',
20+
'ogl>=2.1.31',
2121
]
2222

2323
[project.urls]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ codeallybasic==1.3.0
2121
codeallyadvanced==1.3.1
2222

2323
pyutmodelv2>=2.1.5
24-
ogl>=2.1.20
24+
ogl>=2.1.31

src/untanglepyut/UnTanglePyut.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class UnTanglePyut:
6565
"""
6666
Converts pyutmodel Version 11 XML to Pyut Objects
6767
"""
68+
NOTE_NAME: str = 'Note'
69+
noteCounter: int = 0
6870

6971
def __init__(self, xmlVersion: XmlVersion):
7072

@@ -483,10 +485,13 @@ def _addPyutObjectAttributes(self, pyutElement: Element, pyutObject: PyutObject)
483485
Returns: The updated pyutObject as
484486
"""
485487

486-
pyutObject.id = int(pyutElement[self._attrId]) # TODO revisit this when we start using UUIDs
487-
pyutObject.name = pyutElement['name']
488+
pyutObject.id = int(pyutElement[self._attrId]) # TODO revisit this when we start using UUIDs
489+
pyutObject.name = pyutElement['name']
488490
pyutObject.fileName = pyutElement[self._attrFileName]
489491

492+
if pyutObject.name is None:
493+
UnTanglePyut.noteCounter += 1
494+
pyutObject.name = f'{UnTanglePyut.NOTE_NAME}-{UnTanglePyut.noteCounter}'
490495
return pyutObject
491496

492497
def _securePyutDisplayMethods(self, displayStr: str) -> PyutDisplayMethods:

src/untanglepyut/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__: str = '2.1.7'
1+
__version__: str = '2.1.8'

tests/untanglepyut/v11/TestUnTanglePyut.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ def setUp(self):
171171
def tearDown(self):
172172
super().tearDown()
173173

174+
def testNoteNameNone(self):
175+
176+
rootElement: Element = parse(V11_PYUT_NOTE)
177+
oglNoteElement: Element = rootElement.OglNote
178+
179+
untanglepyut: UnTanglePyut = UnTanglePyut(xmlVersion=XmlVersion.V11)
180+
pyutNote: PyutNote = untanglepyut.noteToPyutNote(graphicNote=oglNoteElement)
181+
182+
self.assertIsNotNone(pyutNote.name, 'Where is my update!')
183+
174184
def testPyutClass(self):
175185
root: Element = parse(V11_PYUT_CLASS)
176186
oglClass: Element = root.OglClass

0 commit comments

Comments
 (0)