Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle the "bits" type #315

Merged
merged 1 commit into from
Sep 28, 2023
Merged

Conversation

fperrin
Copy link
Contributor

@fperrin fperrin commented Sep 4, 2023

The YANG "bits" type gets mapped to a Set[str] object in Python. The set object is augmented with a dictionary keeping track of the bit positions. This is used when forming the JSON or XML serialisation.

closes #314

Copy link
Collaborator

@JoseIgnacioTamayo JoseIgnacioTamayo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks.

I did not like the name 'YANGBitsFactory', but I could not think of a better name for a method that creates a class. So it is fine by me.

@fperrin
Copy link
Contributor Author

fperrin commented Sep 22, 2023

That can be renamed to YANGBitsType returning YANGbits to follow the same pattern as other types. I'll do that now

def RestrictedPrecisionDecimalType(*args, **kwargs):
    """
    Function to return a new type that is based on decimal.Decimal with
    an arbitrary restricted precision.
    """
    precision = kwargs.pop("precision", False)

    class RestrictedPrecisionDecimal(Decimal):
        ...

def YANGListType(*args, **kwargs):
    class YANGList(object):
        ...

The YANG "bits" type gets mapped to a Set[str] object in Python. The
set object is augmented with a dictionary keeping track of the bit
positions. This is used when forming the JSON or XML serialisation.
@JoseIgnacioTamayo JoseIgnacioTamayo merged commit 55d80eb into robshakir:master Sep 28, 2023
5 checks passed
JoseIgnacioTamayo pushed a commit that referenced this pull request Dec 11, 2023
The YANG "bits" type gets mapped to a Set[str] object in Python. The
set object is augmented with a dictionary keeping track of the bit
positions. This is used when forming the JSON or XML serialisation.
JoseIgnacioTamayo pushed a commit that referenced this pull request Dec 11, 2023
The YANG "bits" type gets mapped to a Set[str] object in Python. The
set object is augmented with a dictionary keeping track of the bit
positions. This is used when forming the JSON or XML serialisation.
This was referenced Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support bits type
2 participants