Skip to content

Commit

Permalink
better name for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Sep 15, 2022
1 parent f144254 commit 79f2e09
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 100 deletions.
4 changes: 2 additions & 2 deletions spacepackets/cfdp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .defs import (
PduType,
PduTypes,
ChecksumTypes,
Direction,
CrcFlag,
Expand Down Expand Up @@ -27,4 +27,4 @@
)
from .lv import CfdpLv
from .conf import PduConfig
from .pdu import DirectiveType, PduHolder, PduFactory, GenericPduPacket
from .pdu import DirectiveTypes, PduHolder, PduFactory, GenericPduPacket
2 changes: 1 addition & 1 deletion spacepackets/cfdp/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __str__(self):
return f"Unsupported CFDP version {self.version}"


class PduType(enum.IntEnum):
class PduTypes(enum.IntEnum):
FILE_DIRECTIVE = 0
FILE_DATA = 1

Expand Down
4 changes: 2 additions & 2 deletions spacepackets/cfdp/pdu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# noinspection PyUnresolvedReferences
from spacepackets.cfdp.defs import SegmentMetadataFlag, PduType
from spacepackets.cfdp.defs import SegmentMetadataFlag, PduTypes

# noinspection PyUnresolvedReferences
from .header import PduHeader, PduConfig
from .ack import TransactionStatus, AckPdu
from .eof import EofPdu
from .file_directive import (
FileDirectivePduBase,
DirectiveType,
DirectiveTypes,
AbstractFileDirectiveBase,
)
from .finished import FinishedPdu, FileDeliveryStatus, DeliveryCode
Expand Down
18 changes: 9 additions & 9 deletions spacepackets/cfdp/pdu/ack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from spacepackets.cfdp.pdu import PduHeader
from spacepackets.cfdp.pdu.file_directive import (
FileDirectivePduBase,
DirectiveType,
DirectiveTypes,
AbstractFileDirectiveBase,
)
from spacepackets.cfdp.defs import ConditionCode
Expand All @@ -25,7 +25,7 @@ class AckPdu(AbstractFileDirectiveBase):

def __init__(
self,
directive_code_of_acked_pdu: DirectiveType,
directive_code_of_acked_pdu: DirectiveTypes,
condition_code_of_acked_pdu: ConditionCode,
transaction_status: TransactionStatus,
pdu_conf: PduConfig,
Expand All @@ -39,27 +39,27 @@ def __init__(
:raises ValueError: Directive code invalid. Only EOF and Finished PDUs can be acknowledged
"""
self.pdu_file_directive = FileDirectivePduBase(
directive_code=DirectiveType.ACK_PDU,
directive_code=DirectiveTypes.ACK_PDU,
directive_param_field_len=2,
pdu_conf=pdu_conf,
)
if directive_code_of_acked_pdu not in [
DirectiveType.FINISHED_PDU,
DirectiveType.EOF_PDU,
DirectiveTypes.FINISHED_PDU,
DirectiveTypes.EOF_PDU,
]:
raise ValueError
self.directive_code_of_acked_pdu = directive_code_of_acked_pdu
self.directive_subtype_code = 0
if self.directive_code_of_acked_pdu == DirectiveType.FINISHED_PDU:
if self.directive_code_of_acked_pdu == DirectiveTypes.FINISHED_PDU:
self.directive_subtype_code = 0b0001
else:
self.directive_subtype_code = 0b0000
self.condition_code_of_acked_pdu = condition_code_of_acked_pdu
self.transaction_status = transaction_status

@property
def directive_type(self) -> DirectiveType:
return DirectiveType.ACK_PDU
def directive_type(self) -> DirectiveTypes:
return DirectiveTypes.ACK_PDU

@property
def pdu_header(self) -> PduHeader:
Expand All @@ -79,7 +79,7 @@ def __empty(cls) -> AckPdu:
empty_conf = PduConfig.empty()
return cls(
# Still set valid directive code, otherwise ctor will explode
directive_code_of_acked_pdu=DirectiveType.FINISHED_PDU,
directive_code_of_acked_pdu=DirectiveTypes.FINISHED_PDU,
condition_code_of_acked_pdu=ConditionCode.NO_ERROR,
transaction_status=TransactionStatus.UNDEFINED,
pdu_conf=empty_conf,
Expand Down
6 changes: 3 additions & 3 deletions spacepackets/cfdp/pdu/eof.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from spacepackets.cfdp.pdu import PduHeader
from spacepackets.cfdp.pdu.file_directive import (
FileDirectivePduBase,
DirectiveType,
DirectiveTypes,
AbstractFileDirectiveBase,
)
from spacepackets.cfdp.defs import ConditionCode
Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(
self.condition_code = condition_code
self.file_checksum = file_checksum
self.pdu_file_directive = FileDirectivePduBase(
directive_code=DirectiveType.EOF_PDU,
directive_code=DirectiveTypes.EOF_PDU,
pdu_conf=pdu_conf,
directive_param_field_len=0,
)
Expand All @@ -48,7 +48,7 @@ def __init__(
self._calculate_directive_param_field_len()

@property
def directive_type(self) -> DirectiveType:
def directive_type(self) -> DirectiveTypes:
return self.pdu_file_directive.directive_type

@property
Expand Down
6 changes: 3 additions & 3 deletions spacepackets/cfdp/pdu/file_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import struct

from spacepackets.cfdp import LargeFileFlag
from spacepackets.cfdp.pdu.file_directive import SegmentMetadataFlag, PduType
from spacepackets.cfdp.pdu.file_directive import SegmentMetadataFlag, PduTypes
from spacepackets.cfdp.conf import PduConfig
from spacepackets.cfdp.pdu.header import PduHeader, AbstractPduBase
from spacepackets.log import get_console_logger
Expand Down Expand Up @@ -58,7 +58,7 @@ def __init__(self, params: FileDataParams, pdu_conf: PduConfig):
raise ValueError("Record continuation state must be specified")
self.pdu_header = PduHeader(
segment_metadata_flag=self._params.segment_metadata_flag,
pdu_type=PduType.FILE_DATA,
pdu_type=PduTypes.FILE_DATA,
pdu_conf=pdu_conf,
pdu_data_field_len=0,
)
Expand All @@ -81,7 +81,7 @@ def pdu_data_field_len(self) -> int:
return self.pdu_header.pdu_data_field_len

@property
def pdu_type(self) -> PduType:
def pdu_type(self) -> PduTypes:
return self.pdu_header.pdu_type

@property
Expand Down
18 changes: 9 additions & 9 deletions spacepackets/cfdp/pdu/file_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from spacepackets.cfdp.pdu.header import (
PduHeader,
PduType,
PduTypes,
SegmentMetadataFlag,
AbstractPduBase,
)
Expand All @@ -16,7 +16,7 @@
from spacepackets.util import UnsignedByteField


class DirectiveType(enum.IntEnum):
class DirectiveTypes(enum.IntEnum):
EOF_PDU = 0x04
FINISHED_PDU = 0x05
ACK_PDU = 0x06
Expand All @@ -32,7 +32,7 @@ class AbstractFileDirectiveBase(AbstractPduBase):

@property
@abc.abstractmethod
def directive_type(self) -> DirectiveType:
def directive_type(self) -> DirectiveTypes:
pass

@property
Expand All @@ -43,8 +43,8 @@ def pdu_header(self) -> PduHeader:
pass

@property
def pdu_type(self) -> PduType:
return PduType.FILE_DIRECTIVE
def pdu_type(self) -> PduTypes:
return PduTypes.FILE_DIRECTIVE

@property
def file_flag(self) -> LargeFileFlag:
Expand Down Expand Up @@ -110,7 +110,7 @@ class FileDirectivePduBase(AbstractFileDirectiveBase):

def __init__(
self,
directive_code: DirectiveType,
directive_code: DirectiveTypes,
directive_param_field_len: int,
pdu_conf: PduConfig,
):
Expand All @@ -124,7 +124,7 @@ def __init__(
"""

self._pdu_header = PduHeader(
pdu_type=PduType.FILE_DIRECTIVE,
pdu_type=PduTypes.FILE_DIRECTIVE,
pdu_data_field_len=directive_param_field_len + 1,
pdu_conf=pdu_conf,
# This flag is not relevant for file directive PDUs
Expand All @@ -141,7 +141,7 @@ def pdu_header(self) -> PduHeader:
return self._pdu_header

@property
def directive_type(self) -> DirectiveType:
def directive_type(self) -> DirectiveTypes:
return self._directive_type

@property
Expand All @@ -156,7 +156,7 @@ def directive_param_field_len(self, directive_param_field_len: int):
def __empty(cls) -> FileDirectivePduBase:
empty_conf = PduConfig.empty()
return cls(
directive_code=DirectiveType.NONE,
directive_code=DirectiveTypes.NONE,
directive_param_field_len=0,
pdu_conf=empty_conf,
)
Expand Down
8 changes: 4 additions & 4 deletions spacepackets/cfdp/pdu/finished.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from spacepackets.cfdp.pdu import PduHeader
from spacepackets.cfdp.pdu.file_directive import (
FileDirectivePduBase,
DirectiveType,
DirectiveTypes,
AbstractFileDirectiveBase,
)
from spacepackets.cfdp.defs import ConditionCode
Expand Down Expand Up @@ -52,7 +52,7 @@ def __init__(
pdu_conf: PduConfig,
):
self.pdu_file_directive = FileDirectivePduBase(
directive_code=DirectiveType.FINISHED_PDU,
directive_code=DirectiveTypes.FINISHED_PDU,
pdu_conf=pdu_conf,
directive_param_field_len=1,
)
Expand All @@ -63,8 +63,8 @@ def __init__(
self.file_store_responses = self._params.file_store_responses

@property
def directive_type(self) -> DirectiveType:
return DirectiveType.FINISHED_PDU
def directive_type(self) -> DirectiveTypes:
return DirectiveTypes.FINISHED_PDU

@property
def pdu_header(self) -> PduHeader:
Expand Down
12 changes: 6 additions & 6 deletions spacepackets/cfdp/pdu/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from spacepackets.cfdp.defs import (
LargeFileFlag,
PduType,
PduTypes,
SegmentMetadataFlag,
CrcFlag,
TransmissionModes,
Expand Down Expand Up @@ -38,7 +38,7 @@ def pack(self) -> bytearray:

@property
@abc.abstractmethod
def pdu_type(self) -> PduType:
def pdu_type(self) -> PduTypes:
pass

@property
Expand Down Expand Up @@ -121,7 +121,7 @@ class PduHeader(AbstractPduBase):

def __init__(
self,
pdu_type: PduType,
pdu_type: PduTypes,
segment_metadata_flag: SegmentMetadataFlag,
pdu_data_field_len: int,
pdu_conf: PduConfig,
Expand All @@ -146,11 +146,11 @@ def __init__(
self.segment_metadata_flag = segment_metadata_flag

@property
def pdu_type(self) -> PduType:
def pdu_type(self) -> PduTypes:
return self._pdu_type

@pdu_type.setter
def pdu_type(self, pdu_type: PduType):
def pdu_type(self, pdu_type: PduTypes):
self._pdu_type = pdu_type

@property
Expand Down Expand Up @@ -274,7 +274,7 @@ def pack(self) -> bytearray:
def __empty(cls) -> PduHeader:
empty_conf = PduConfig.empty()
return cls(
pdu_type=PduType.FILE_DIRECTIVE,
pdu_type=PduTypes.FILE_DIRECTIVE,
segment_metadata_flag=SegmentMetadataFlag.NOT_PRESENT,
pdu_data_field_len=0,
pdu_conf=empty_conf,
Expand Down
Loading

0 comments on commit 79f2e09

Please sign in to comment.