use keyword arguments for get_url_yank_text

This commit is contained in:
Michael M 2023-09-19 19:35:10 -05:00
parent d480ea833c
commit 7c8d5572f1
No known key found for this signature in database
GPG Key ID: 7744D0A113FFE5E1
6 changed files with 9 additions and 6 deletions

View File

@ -733,7 +733,8 @@ class CommandDispatcher:
':' + str(port) if port > -1 else '')
elif what in ['url', 'pretty-url']:
url = self._current_url()
s = urlutils.get_url_yank_text(url, what == 'pretty-url')
pretty = what == 'pretty-url'
s = urlutils.get_url_yank_text(url, is_pretty=pretty)
what = 'URL' # For printing
elif what == 'selection':
def _selection_callback(s):

View File

@ -237,7 +237,7 @@ class HintActions:
sel = (context.target == Target.yank_primary and
utils.supports_selection())
urlstr = urlutils.get_url_yank_text(url, False)
urlstr = urlutils.get_url_yank_text(url, is_pretty=False)
new_content = urlstr
# only second and consecutive yanks are to append to the clipboard

View File

@ -57,7 +57,8 @@ def _init_variable_replacements() -> Mapping[str, _ReplacementFunction]:
_url(tb).port()) if _url(tb).port() != -1 else "",
'url:path': lambda tb: _url(tb).path(),
'url:query': lambda tb: _url(tb).query(),
'url:yank': lambda tb: urlutils.get_url_yank_text(_url(tb), False),
'url:yank': lambda tb: urlutils.get_url_yank_text(_url(tb),
is_pretty=False),
'title': lambda tb: tb.widget.page_title(tb.widget.currentIndex()),
'clipboard': lambda _: utils.get_clipboard(),
'primary': lambda _: utils.get_clipboard(selection=True),

View File

@ -443,7 +443,8 @@ class PromptContainer(QWidget):
else:
sel = False
target = 'clipboard'
url_str = urlutils.get_url_yank_text(QUrl(question.url), False)
url_str = urlutils.get_url_yank_text(QUrl(question.url),
is_pretty=False)
utils.set_clipboard(url_str, sel)
message.info("Yanked to {}: {}".format(target, url_str))

View File

@ -684,7 +684,7 @@ def widened_hostnames(hostname: str) -> Iterable[str]:
hostname = hostname.partition(".")[-1]
def get_url_yank_text(url: QUrl, is_pretty: bool) -> str:
def get_url_yank_text(url: QUrl, *, is_pretty: bool) -> str:
"""Get the text that should be yanked for the given URL."""
flags = FormatOption.REMOVE_PASSWORD
if url.scheme() == 'mailto':

View File

@ -804,7 +804,7 @@ class TestParseJavascriptUrl:
(QUrl('https://example.com/?pipe=%7C'), True, 'https://example.com/?pipe=|'),
])
def test_get_url_yank_text(url, is_pretty, expected):
assert urlutils.get_url_yank_text(url, is_pretty) == expected
assert urlutils.get_url_yank_text(url, is_pretty=is_pretty) == expected
class TestWiden: