Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cf99650

Browse filesBrowse files
committed
minor refactoring to make it easier to call shorten()
1 parent ec03da7 commit cf99650
Copy full SHA for cf99650

File tree

1 file changed

+3
-3
lines changed
Filter options

1 file changed

+3
-3
lines changed

‎links/short.py

Copy file name to clipboardExpand all lines: links/short.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ def gen_unused_short(redirects: dict) -> Iterator[str]:
6060
yield short
6161

6262

63-
def shorten(urls: list[str], redirects: dict, targets: dict) -> list[tuple[str, str]]:
63+
def shorten(urls: list[str]) -> list[tuple[str, str]]:
6464
"""Return (short, long) pairs, appending directives to HTACCESS_SHORT as needed."""
65+
redirects, targets = load_redirects()
6566
iter_short = gen_unused_short(redirects)
6667
pairs = []
6768
timestamp = strftime('%Y-%m-%d %H:%M:%S')
@@ -86,8 +87,7 @@ def shorten(urls: list[str], redirects: dict, targets: dict) -> list[tuple[str,
8687
def main() -> None:
8788
"""read URLS from filename arguments or stdin"""
8889
urls = [line.strip() for line in fileinput.input(encoding='utf-8')]
89-
redirects, targets = load_redirects()
90-
for short, long in shorten(urls, redirects, targets):
90+
for short, long in shorten(urls):
9191
print(f'{BASE_DOMAIN}/{short}\t{long}')
9292

9393

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.