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

Require and validate mac address at the cli #4

Merged
merged 1 commit into from
Feb 28, 2017

Conversation

klemens
Copy link
Contributor

@klemens klemens commented Feb 23, 2017

This uses a click validation function and makes the mac argument required (also works when passed using the environment variable).

This does not add any validation to the library itself, but you can easily catch the ValueError exception yourself, and validating using a regular expression is probably overkill, as the mac usually comes from a config when using the library and was already validated elsewhere.

eq3bt/eq3cli.py Outdated
@@ -8,8 +8,13 @@
pass_dev = click.make_pass_decorator(Thermostat)


def validate_mac(ctx, param, mac):
if None == re.match('^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$', mac):

Choose a reason for hiding this comment

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

comparison to None should be 'if cond is None:'
undefined name 're'

@rytilahti
Copy link
Owner

Looks good, thanks!

@rytilahti rytilahti closed this Feb 28, 2017
@rytilahti rytilahti reopened this Feb 28, 2017
@rytilahti rytilahti merged commit d95b440 into rytilahti:master Feb 28, 2017
@rytilahti rytilahti mentioned this pull request Feb 28, 2017
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