Reformat some code

This commit is contained in:
jeancf 2023-09-14 11:30:55 +02:00
parent 22a8df8983
commit 9b29471140

View File

@ -29,7 +29,7 @@ import sqlite3
import sys
import time
from pathlib import Path
from urllib.parse import urlparse, parse_qsl, urlencode, urlunparse, urljoin, unquote
from urllib.parse import urlparse, parse_qsl, urlencode, urlunparse, urljoin
import requests
from bs4 import BeautifulSoup, element
@ -172,16 +172,16 @@ def build_config(args):
exit(-1)
"""
Dowload page with full thread of tweets and extract all replied to tweet reference by url.
Only used by `get_timeline()`.
:param session: Existing HTTP session with Nitter instance
:param headers: HTTP headers to use
:param nitter url: url of the nitter instance to use
:param thread_url: url of the first tweet in thread
:return: list of tuples with url of tweet replied-to (or None) and content of tweet
"""
def _get_rest_of_thread(session, headers, nitter_url, thread_url, first_item):
"""
Dowload page with full thread of tweets and extract all replied to tweet reference by url.
Only used by `get_timeline()`.
:param session: Existing HTTP session with Nitter instance
:param headers: HTTP headers to use
:param nitter url: url of the nitter instance to use
:param thread_url: url of the first tweet in thread
:return: list of tuples with url of tweet replied-to (or None) and content of tweet
"""
# Add first item to timeline
timeline = [(None, first_item)]
@ -235,12 +235,12 @@ def _get_rest_of_thread(session, headers, nitter_url, thread_url, first_item):
return timeline
"""
Download timeline of twitter account
:param url: url of the account page to download
:return: list of tuples with url of tweet replied-to (or None) and content of tweet
"""
def get_timeline(nitter_url):
"""
Download timeline of twitter account
:param url: url of the account page to download
:return: list of tuples with url of tweet replied-to (or None) and content of tweet
"""
# Define url to use
url = nitter_url + '/' + TOML['config']['twitter_account']
@ -419,6 +419,7 @@ def update_profile(nitter_url, soup, sql, mast_password):
return mastodon
def deredir_url(url):
"""
Given a URL, return the URL that the page really downloads from
@ -1174,7 +1175,7 @@ def main(argv):
if mastodon is not None:
try:
max_characters = mastodon.instance().configuration.statuses['max_characters']
logging.debug('Instance character limit is '+ str(max_characters))
logging.debug('Instance character limit is ' + str(max_characters))
except Exception:
# Default value for Mastodon
max_characters = 500