Skip to content

- add support for multi OPTIONAL_PARAMS hexcode#73

Open
jasonlazo wants to merge 1 commit intopython-smpplib:masterfrom
jasonlazo:ci/add_support_for_multihexcode
Open

- add support for multi OPTIONAL_PARAMS hexcode#73
jasonlazo wants to merge 1 commit intopython-smpplib:masterfrom
jasonlazo:ci/add_support_for_multihexcode

Conversation

@jasonlazo
Copy link

Some vendors use different hex code so i use a tuple instead of one specific hexcode.

Some vendors use different hex code so i use a tuple instead of one specific hexcode.
Copy link
Collaborator

@eigenein eigenein left a comment

Choose a reason for hiding this comment

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

Could you also add an item to CHANGELOG.md?

EIGHTBIT_PART_SIZE = 140 - MULTIPART_HEADER_SIZE
UCS2_PART_SIZE = 140 - MULTIPART_HEADER_SIZE # must be an even number anyway


Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you keep these empty lines that separate different groups of constants?


for key, value in six.iteritems(consts.OPTIONAL_PARAMS):
if value == code:
if code in value:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer to give it a plural name then:

Suggested change
if code in value:
for key, values in six.iteritems(consts.OPTIONAL_PARAMS):
if code in values:

}


OPTIONAL_PARAMS = {
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest keeping old ids for readability

OPTIONAL_PARAMS = {
    key: frozenset({value}) if not isinstance(value, Iterable) else frozenset(value)
    for key, value in six.iteritems({
#old values here,
'network_error_code': (0x0423, 0x1403,),
})}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Author's option for me is more explicit, no need to read the conversion code. It's faster to visually skip commas than understand the loop

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it is fine. I wouldn't insist

Actually what I was thinking about is to create a reverse of this mapping:

    for key, value in six.iteritems(consts.OPTIONAL_PARAMS):
        if code in value

can be probably translated into something like key = REV_OPTIONAL_PARAMS[code]

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.

3 participants