[go: up one dir, main page]

Skip to content

Commit

Permalink
Remove unnecessary f-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAnotherArchivist committed Jan 28, 2022
1 parent 7f88678 commit 107c3c7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions snscrape/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _requests_response_repr(name, response, withHistory = True):
if withHistory and response.history:
ret.append(f'\n {name}.history = [')
for previousResponse in response.history:
ret.append(f'\n ')
ret.append('\n ')
ret.append(_requests_response_repr('_', previousResponse, withHistory = False).replace('\n', '\n '))
ret.append('\n ]')
ret.append(f'\n {name}.status_code = {response.status_code}')
Expand All @@ -83,8 +83,8 @@ def _requests_response_repr(name, response, withHistory = True):
def _requests_exception_repr(name, exc):
ret = []
ret.append(f'{name} = {exc!r}')
ret.append(f'\n ' + _repr(f'{name}.request', exc.request).replace('\n', '\n '))
ret.append(f'\n ' + _repr(f'{name}.response', exc.response).replace('\n', '\n '))
ret.append('\n ' + _repr(f'{name}.request', exc.request).replace('\n', '\n '))
ret.append('\n ' + _repr(f'{name}.response', exc.response).replace('\n', '\n '))
return ''.join(ret)


Expand Down Expand Up @@ -151,7 +151,7 @@ def _dump_stack_and_locals(trace, exc = None):
fp.write('\n')
fp.write('\n')
if 'self' in locals_ and hasattr(locals_['self'], '__dict__'):
fp.write(f'Object dict:\n')
fp.write('Object dict:\n')
fp.write(repr(locals_['self'].__dict__))
fp.write('\n\n')
name = fp.name
Expand Down
2 changes: 1 addition & 1 deletion snscrape/modules/facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def get_items(self):
while (data := pageletDataPattern.search(r.text).group(0)[pageletDataPrefixLength:]):
# As on the user profile pages, the web app sends a lot of additional parameters, but those all seem to be unnecessary (although some change the response format, e.g. from JSON to HTML)
r = self._get(
f'https://upload.facebook.com/ajax/pagelet/generic.php/GroupEntstreamPagelet',
'https://upload.facebook.com/ajax/pagelet/generic.php/GroupEntstreamPagelet',
params = {'data': data, '__a': 1},
headers = headers,
)
Expand Down
4 changes: 2 additions & 2 deletions snscrape/modules/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ def _check_json_callback(self, r):
def get_items(self):
r = self._initial_page()
if r.status_code == 404:
_logger.warning(f'Page does not exist')
_logger.warning('Page does not exist')
return
response = r._snscrape_json_obj
rhxGis = response['rhx_gis'] if 'rhx_gis' in response else ''
if response['entry_data'][self._pageName][0]['graphql'][self._responseContainer][self._edgeXToMedia]['count'] == 0:
_logger.info(f'Page has no posts')
_logger.info('Page has no posts')
return
if not response['entry_data'][self._pageName][0]['graphql'][self._responseContainer][self._edgeXToMedia]['edges']:
_logger.warning('Private account')
Expand Down
2 changes: 1 addition & 1 deletion snscrape/modules/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _api_obj_to_item(self, d):
else: # E.g. submission 617p51 but can likely happen for comments as well
permalink = f'/comments/{d["link_id"][3:]}/_/{d["id"]}/'
else:
_logger.warning(f'Unable to find or construct permalink')
_logger.warning('Unable to find or construct permalink')
permalink = '/'

kwargs = {
Expand Down
6 changes: 3 additions & 3 deletions snscrape/modules/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def _iter_api_data(self, endpoint, params, paginationParams = None, cursor = Non
stopOnEmptyResponse = entry['content']['operation']['cursor']['stopOnEmptyResponse']
elif entry['entryId'].startswith('cursor-showMoreThreadsPrompt-'): # E.g. 'offensive' replies button
promptCursor = entry['content']['operation']['cursor']['value']
elif direction is _ScrollDirection.BOTH and bottomCursorAndStop is None and (entry['entryId'] == f'sq-cursor-bottom' or entry['entryId'].startswith('cursor-bottom-')):
elif direction is _ScrollDirection.BOTH and bottomCursorAndStop is None and (entry['entryId'] == 'sq-cursor-bottom' or entry['entryId'].startswith('cursor-bottom-')):
newBottomCursorAndStop = (entry['content']['operation']['cursor']['value'], entry['content']['operation']['cursor'].get('stopOnEmptyResponse', False))
if bottomCursorAndStop is None and newBottomCursorAndStop is not None:
bottomCursorAndStop = newBottomCursorAndStop
Expand Down Expand Up @@ -631,9 +631,9 @@ def _check_scroll_response(self, r):
# Accept a 429 response as "valid" to prevent retries; handled explicitly in get_items
return True, None
if r.headers.get('content-type').replace(' ', '') != 'application/json;charset=utf-8':
return False, f'content type is not JSON'
return False, 'content type is not JSON'
if r.status_code != 200:
return False, f'non-200 status code'
return False, 'non-200 status code'
return True, None

def get_items(self):
Expand Down

0 comments on commit 107c3c7

Please sign in to comment.