Skip to content

Commit

Permalink
change object copy to deepcopy and object list fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpdx committed Apr 22, 2023
1 parent 2e92549 commit 5ab5c0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions eds_utils/core/eds.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime
from dataclasses import dataclass, field
from typing import Dict, List
from copy import deepcopy

from . import DataType
from .objects import Variable, Record
Expand Down Expand Up @@ -301,7 +302,7 @@ def tpdos(self) -> int:
def indexes(self) -> List[int]:
'''The list of indexes in the OD'''

return sorted(self._data.keys())
return list(self._data.keys())

@property
def mandatory_objects(self) -> List[int]:
Expand Down Expand Up @@ -375,9 +376,9 @@ def copy_object(self, index: int, subindex: int, new_index: int, new_subindex: i
obj = self._data[index] if subindex is None else self._data[index][subindex]

if new_subindex is None:
self._data[new_index] = obj
self._data[new_index] = deepcopy(obj)
else:
self._data[new_index][new_subindex] = obj
self._data[new_index][new_subindex] = deepcopy(obj)

if move:
if subindex is None:
Expand Down
5 changes: 3 additions & 2 deletions eds_utils/core/objects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'''All the object class for the object dictionary'''

from dataclasses import dataclass
from typing import List

from . import DataType, AccessType, ObjectType

Expand Down Expand Up @@ -109,10 +110,10 @@ def __delitem__(self, subindex: int):
self._data[0].default_value = f'0x{len(self._data) - 1:02X}'

@property
def subindexes(self) -> list:
def subindexes(self) -> List[int]:
'''Get the list of subindexes'''

return self._data.keys()
return list(self._data.keys())

@property
def storage_location(self) -> str:
Expand Down

0 comments on commit 5ab5c0f

Please sign in to comment.