Skip to content

Commit 16f9f0c

Browse files
committed
format and lint
1 parent 5dc24ad commit 16f9f0c

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

Pi_Bluesky_TFT_Scroller/code.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
import requests
1212
import webview
1313

14-
FEEDLINK_RETROCOMPUTING = "https://bsky.app/profile/did:plc:tbo4hkau3p2itkar2vsnb3gp/feed/aaabo5oe7bzok"
14+
FEEDLINK_RETROCOMPUTING = (
15+
"https://bsky.app/profile/did:plc:tbo4hkau3p2itkar2vsnb3gp/feed/aaabo5oe7bzok"
16+
)
1517

1618
# Un-comment a single key inside of FEED_ARGS and set it's value to the feed, list or search
1719
# that you want to scroll.
1820
FETCH_ARGS = {
1921
# "feed_share_link": FEEDLINK_RETROCOMPUTING,
20-
# "feed_share_link": "https://bsky.app/profile/did:plc:463touruejpokvutnn5ikxb5/lists/3lbfdtahfzt2a",
22+
# "feed_share_link": "https://bsky.app/profile/did:plc:463touruejpokvutnn5ikxb5/lists/3lbfdtahfzt2a", # pylint: disable=line-too-long
2123
# "search_args": {"q": "Adafruit", "sort": "latest"}
2224
"search_args": {"q": "#circuitpython", "sort": "latest"}
2325
}
@@ -51,6 +53,7 @@ def fetch_data(feed_share_link=None, search_args=None):
5153
the hashtag or term to search for. See bsky API docs for other supported keys.
5254
:return: None
5355
"""
56+
# pylint: disable=too-many-statements,too-many-branches
5457
if feed_share_link is None and search_args is None:
5558
# If both inputs are None, just use retrocomputing feed.
5659
feed_share_link = FEEDLINK_RETROCOMPUTING
@@ -62,19 +65,23 @@ def fetch_data(feed_share_link=None, search_args=None):
6265

6366
# if it's a feed
6467
if "/app.bsky.feed.generator/" in FEED_AT:
65-
URL = f"https://public.api.bsky.app/xrpc/app.bsky.feed.getFeed?feed={FEED_AT}&limit=30"
68+
URL = (f"https://public.api.bsky.app/xrpc/app.bsky.feed.getFeed?"
69+
f"feed={FEED_AT}&limit=30")
6670
headers = {"Accept-Language": "en"}
6771
resp = requests.get(URL, headers=headers)
6872

6973
# if it's a list
7074
elif "/app.bsky.graph.list/" in FEED_AT:
71-
URL = f"https://public.api.bsky.app/xrpc/app.bsky.feed.getListFeed?list={FEED_AT}&limit=30"
75+
URL = (f"https://public.api.bsky.app/xrpc/app.bsky.feed.getListFeed?"
76+
f"list={FEED_AT}&limit=30")
7277
headers = {"Accept-Language": "en"}
7378
resp = requests.get(URL, headers=headers)
7479

7580
# raise error if it's an unknown type
7681
else:
77-
raise ValueError("Only 'app.bsky.feed.generator' and 'app.bsky.graph.list' URIs are supported.")
82+
raise ValueError(
83+
"Only 'app.bsky.feed.generator' and 'app.bsky.graph.list' URIs are supported."
84+
)
7885

7986
# if a search input was provided
8087
if search_args is not None:
@@ -111,7 +118,10 @@ def fetch_data(feed_share_link=None, search_args=None):
111118
cur_post["image_url"] = post["embed"]["images"][0]["thumb"]
112119
elif "thumbnail" in post["embed"].keys():
113120
cur_post["image_url"] = post["embed"]["thumbnail"]
114-
elif "external" in post["embed"].keys() and "thumb" in post["embed"]["external"].keys():
121+
elif (
122+
"external" in post["embed"].keys()
123+
and "thumb" in post["embed"]["external"].keys()
124+
):
115125
cur_post["image_url"] = post["embed"]["external"]["thumb"]
116126

117127
# if we actually have an image to show
@@ -150,6 +160,7 @@ class Api:
150160
and JS code running inside the page.
151161
"""
152162

163+
# pylint: disable=no-self-use
153164
def get_posts(self):
154165
"""
155166
Fetch new posts data from Bluesky API, cache and return it.
@@ -166,11 +177,13 @@ def check_quit(self):
166177
167178
:return: None
168179
"""
180+
# pylint: disable=unnecessary-pass
169181
pass
170182

171183

172184
# create a webview and load the index.html page
173-
webview.create_window("bsky posts", "static/index.html",
174-
js_api=Api(), width=320, height=240)
185+
webview.create_window(
186+
"bsky posts", "static/index.html", js_api=Api(), width=320, height=240
187+
)
175188
webview.start()
176189
# webview.start(debug=True) # use this one to enable chromium dev tools to see console.log() output from the page.

0 commit comments

Comments
 (0)