Skip to content

Conversation

@rvelaVenafi
Copy link
Contributor

No description provided.

@tr1ck3r tr1ck3r merged commit c6b3e6f into master Sep 22, 2020
@tr1ck3r tr1ck3r deleted the token_support_python27 branch September 22, 2020 16:29
Comment on lines +73 to +76
def __setattr__(self, key, value):
if key == "_base_url":
value = self._normalize_and_verify_base_url(value)
self.__dict__[key] = value
Copy link

Choose a reason for hiding this comment

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

There is a handy Python wrapper called @Property. This can be handy here. It would look like this:
@Property
def base_url(self):
# This is a getter
return self._base_url

@base_url.setter
def base_url(self, value):
# This is the setter method
self._base_url = self._normalize_and_verify_base_url(value)

It's nicer for refactoring and is pretty explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this suggestion @HELGAHR , we will look into it.

@staticmethod
def _parse_zone_config_to_policy(data):
# todo: parse over values to regexps (dont forget tests!)
p = data["Policy"]
Copy link

Choose a reason for hiding this comment

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

How safe is it in this method to assume that these dictionary keys resolve? I'm new to this code, but I usually think thrice before trying to access a node in the dictionary without .get().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this suggestion as well. Although the code itself was not added in this PR (it was present before), it is nice to have potentially dangerous code design choices pinpointed

if re.match(r"^\\\\VED\\\\Policy", zone):
return zone
else:
if re.match(r"^\\\\", zone):
Copy link

Choose a reason for hiding this comment

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

Just a tidbit of input: Python string objects have a .startswith() method that's easier to read than a regex, although a regex works fine.

Comment on lines +69 to +74
:param str url:
:param str user:
:param str password:
:param str access_token:
:param str refresh_token:
:param dict[str,Any] http_request_kwargs:
Copy link

Choose a reason for hiding this comment

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

No use in having a doc string if the parameters aren't described, IMO.

Comment on lines +86 to +88
if key == "_base_url":
value = self._normalize_and_verify_base_url(value)
self.__dict__[key] = value
Copy link

Choose a reason for hiding this comment

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

There is a Python wrapper called @Property. Its purpose is to define a getter, setter, and/or deleter method to an instance or class variable. It's nicer for refactoring, mostly. Worth noting if you're interested.

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.

6 participants