-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move tools.py code into polymorphic class methods
- Loading branch information
Showing
12 changed files
with
665 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
base.py | ||
Contains base datatype | ||
""" | ||
from abc import ABC, abstractmethod | ||
|
||
class AbstractDatatype(ABC): | ||
""" | ||
Root of entire datatype class hierarchy | ||
""" | ||
def __init__(self, name): | ||
self.name = name | ||
|
||
@abstractmethod | ||
def encode(self, attribute, decoded): | ||
""" | ||
turns python data structure into bytes | ||
:param attribute: | ||
:param decoded: python data structure to encode | ||
:return: encoded bytes | ||
""" | ||
|
||
@abstractmethod | ||
def print(self, decoded): | ||
""" | ||
returns string representation of decoding | ||
:param decoded: value pair | ||
:return: string | ||
""" | ||
|
||
@abstractmethod | ||
def get_value(self, attribute, packet, offset): | ||
""" | ||
retrieves the encapsulated value | ||
:param attribute: attribute value | ||
:param packet: packet | ||
:param offset: attribute starting position | ||
:return: encapsulated value, and bytes read | ||
""" |
Oops, something went wrong.