Skip to content

Commit

Permalink
refactor: refactor debug output and remove caller function
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnsilva committed Mar 9, 2024
1 parent cc0d77e commit 2f788fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
9 changes: 0 additions & 9 deletions semanticscholar/ApiRequester.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,8 @@ def _curl_cmd(self, url: str, method: str, headers: dict, payload: dict = None)
curl_cmd += f' -d \'{json.dumps(payload)}\'' if payload else ''
curl_cmd += f' {url}'
return curl_cmd

def _get_caller_function_name(self) -> str:
stack = inspect.stack()
caller = stack[5]
frame = caller[0]
info = inspect.getframeinfo(frame)
return info.function

def _print_debug(self, url, headers, payload, method) -> None:
print('-' * 80)
print(f'Caller function: {self._get_caller_function_name()}')
print('-' * 80)
print(f'Method: {method}\n')
print(f'URL:\n{url}\n')
Expand Down
2 changes: 0 additions & 2 deletions tests/data/debug_output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
--------------------------------------------------------------------------------
Caller function: get_papers
--------------------------------------------------------------------------------
Method: POST

URL:
Expand Down
12 changes: 6 additions & 6 deletions tests/data/test_debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interactions:
host:
- api.semanticscholar.org
user-agent:
- python-httpx/0.25.2
- python-httpx/0.26.0
x-api-key:
- F@k3K3y
method: POST
Expand All @@ -30,21 +30,21 @@ interactions:
Content-Type:
- application/json
Date:
- Wed, 27 Dec 2023 21:46:32 GMT
- Sat, 09 Mar 2024 21:23:52 GMT
Via:
- 1.1 f5002d75963a7ac4e40089e827005b00.cloudfront.net (CloudFront)
- 1.1 b57cb95c712a6029fa533d1474f7a2d6.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- qvjDXlTb3_2JU8gYm-6cJXGQQbxQVatSZ0AR-mnNtdOFU_65m3CrJQ==
- uHH-ocFS2qfcKNUh7Hv044oFOoCoZIPv6XDyLi4b7NdPWWHh1KQzsQ==
X-Amz-Cf-Pop:
- GRU3-P4
X-Cache:
- Error from cloudfront
x-amz-apigw-id:
- Qn0w3FJXPHcEFXg=
- UYX4VGOJPHcEZqg=
x-amzn-ErrorType:
- ForbiddenException
x-amzn-RequestId:
- 4624eb7c-6580-49ce-9e6d-2afa641473cb
- 4eece2e2-7663-40d8-92df-6c1e6312e7d7
http_version: HTTP/1.1
status_code: 403
version: 1

0 comments on commit 2f788fc

Please sign in to comment.