Created
May 28, 2022 15:38
-
-
Save justxor/7c4fcc889006867451956e3f47af0a7b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def pop(self, key: str) -> Any: | |
"""Delete and return value at key. | |
Args: | |
key (str): Key to pop. | |
Returns: | |
Any: Popped value. | |
""" | |
path, target = self.parse_key(key) | |
value = self.get(key) | |
remapped = iterutils.remap(self._config, lambda p, k, | |
v: False if p == path and k == target else True) | |
self._config = remapped | |
self.log.debug(f"popped config value {value} <- [{key}]") | |
return self.sync() | |
#пример2 | |
def get_file_report(file_sha256, report_url, environment_id, type_, apikey, secret, verify): | |
user_agent = {'User-agent': 'VxStream Sandbox'} | |
params = {'apikey': apikey, 'secret': secret, 'environmentId': environment_id, 'type': type_} | |
resource_url = '%s/%s' % (report_url, file_sha256) | |
try: | |
res = requests.get(resource_url, headers=user_agent, params=params, verify=verify) | |
if res.status_code == 200: | |
# walk entire json blob to fix | |
# the keys known to cause issues | |
remapped = remap(res.json(), visit=visit) | |
return remapped | |
else: | |
print('Error code: {}, returned when getting report: {}'.format(res.status_code, file_sha256)) | |
return res | |
except requests.exceptions.HTTPError as err: | |
print(err) | |
#Пример3 | |
def pretty(self, attrs='class="table"'): | |
return display( | |
HTML(j2h.convert(json=remap(self, visit=visit), table_attributes=attrs)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment