Skip to content

Commit

Permalink
extract RELTYPE_REVERSER constant from method
Browse files Browse the repository at this point in the history
  • Loading branch information
Zocker1999NET authored and tobixen committed Sep 19, 2023
1 parent 9d92ce3 commit 03fe7f7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions caldav/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class hierarchy into a separate file)
from urllib import unquote, quote

try:
from typing import Union, Optional
from typing import ClassVar, Union, Optional

TimeStamp = Optional[Union[date, datetime]]
except:
Expand Down Expand Up @@ -1709,6 +1709,12 @@ class CalendarObjectResource(DAVObject):
event, a todo-item, a journal entry, or a free/busy entry
"""

RELTYPE_REVERSER: ClassVar = {
"PARENT": "CHILD",
"CHILD": "PARENT",
"SIBLING": "SIBLING",
}

_ENDPARAM = None

_vobject_instance = None
Expand Down Expand Up @@ -1811,9 +1817,7 @@ def set_relation(
"""
##TODO: test coverage
reltype = reltype.upper()
reltype_reverse = {"CHILD": "PARENT", "PARENT": "CHILD", "SIBLING": "SIBLING"}[
reltype
]
reltype_reverse = self.RELTYPE_REVERSER[reltype]
if isinstance(other, CalendarObjectResource):
if other.id:
uid = other.id
Expand Down

0 comments on commit 03fe7f7

Please sign in to comment.