Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code with yapf and isort #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,20 @@ def read_config(key: str) -> typing.Any:
"""
return config.get_config("pywallpaper")[key]

def get_page(url, headers: dict[str, str]=None):

def get_page(url, headers: dict[str, str] = None):
"""
Get a page from network.

Arguments:
url: Remote address.
"""
if headers is None:
headers = {}
headers.setdefault("user-agent", "Python/Urllib/Pywallpaper/Spider keyword:Gecko")
return req.urlopen(req.Request(url, headers=headers)) # skipcq: BAN-B310 # This is INTENTIONAL, this is use to allow user define special url.
return req.urlopen(
req.Request(url, headers=headers)
) # skipcq: BAN-B310 # This is INTENTIONAL, this is use to allow user define special url.


def get_source() -> dict[str, str]:
Expand All @@ -75,7 +78,9 @@ def get_wallpaper(day: int = 0) -> tuple:
except KeyError:
pass

exec(source["filter"], None, pkg_locals) # skipcq: PYL-W0122 # This is INTENTIONAL to run USER DEFINED filter script.
exec(
source["filter"], None, pkg_locals
) # skipcq: PYL-W0122 # This is INTENTIONAL to run USER DEFINED filter script.
pic_title, link = pkg_locals["pic_title"], pkg_locals["links"]

return pic_title, link
Expand Down