Fix lint
This commit is contained in:
parent
81e5173c9c
commit
4b13609553
@ -18,8 +18,6 @@ python-dateutil==2.7.3
|
|||||||
./scripts/dev/pylint_checkers
|
./scripts/dev/pylint_checkers
|
||||||
requests==2.19.1
|
requests==2.19.1
|
||||||
six==1.11.0
|
six==1.11.0
|
||||||
typed-ast==1.1.0
|
|
||||||
typing==3.6.4
|
|
||||||
uritemplate==3.0.0
|
uritemplate==3.0.0
|
||||||
urllib3==1.23
|
urllib3==1.23
|
||||||
wrapt==1.10.11
|
wrapt==1.10.11
|
||||||
|
@ -51,40 +51,45 @@ def _delete_quickmark(data):
|
|||||||
|
|
||||||
|
|
||||||
def url(*, info):
|
def url(*, info):
|
||||||
"""A model which combines bookmarks, quickmarks, search engines and web
|
"""A model which combines various URLs.
|
||||||
history URLs.
|
|
||||||
|
This combines:
|
||||||
|
- bookmarks
|
||||||
|
- quickmarks
|
||||||
|
- search engines
|
||||||
|
- web history URLs
|
||||||
|
|
||||||
Used for the `open` command.
|
Used for the `open` command.
|
||||||
"""
|
"""
|
||||||
model = completionmodel.CompletionModel(column_widths=(40, 50, 10))
|
model = completionmodel.CompletionModel(column_widths=(40, 50, 10))
|
||||||
|
|
||||||
|
# pylint: disable=bad-config-option
|
||||||
quickmarks = [(url, name) for (name, url)
|
quickmarks = [(url, name) for (name, url)
|
||||||
in objreg.get('quickmark-manager').marks.items()]
|
in objreg.get('quickmark-manager').marks.items()]
|
||||||
bookmarks = objreg.get('bookmark-manager').marks.items()
|
bookmarks = objreg.get('bookmark-manager').marks.items()
|
||||||
# pylint: disable=bad-config-option
|
|
||||||
searchengines = [(k, v) for k, v
|
searchengines = [(k, v) for k, v
|
||||||
in sorted(config.val.url.searchengines.items())
|
in sorted(config.val.url.searchengines.items())
|
||||||
if k != "DEFAULT"]
|
if k != 'DEFAULT']
|
||||||
# pylint: enable=bad-config-option
|
# pylint: enable=bad-config-option
|
||||||
categories = config.val.completion.open_categories
|
categories = config.val.completion.open_categories
|
||||||
models = {}
|
models = {}
|
||||||
|
|
||||||
|
if searchengines and 'searchengines' in categories:
|
||||||
if searchengines and "searchengines" in categories:
|
models['searchengines'] = listcategory.ListCategory(
|
||||||
models["searchengines"] = listcategory.ListCategory(
|
|
||||||
'Search engines', searchengines, sort=False)
|
'Search engines', searchengines, sort=False)
|
||||||
|
|
||||||
if quickmarks and "quickmarks" in categories:
|
if quickmarks and 'quickmarks' in categories:
|
||||||
models["quickmarks"] = listcategory.ListCategory(
|
models['quickmarks'] = listcategory.ListCategory(
|
||||||
'Quickmarks', quickmarks, delete_func=_delete_quickmark,
|
'Quickmarks', quickmarks, delete_func=_delete_quickmark,
|
||||||
sort=False)
|
sort=False)
|
||||||
if bookmarks and "bookmarks" in categories:
|
if bookmarks and 'bookmarks' in categories:
|
||||||
models["bookmarks"] = listcategory.ListCategory(
|
models['bookmarks'] = listcategory.ListCategory(
|
||||||
'Bookmarks', bookmarks, delete_func=_delete_bookmark, sort=False)
|
'Bookmarks', bookmarks, delete_func=_delete_bookmark, sort=False)
|
||||||
|
|
||||||
if info.config.get('completion.web_history.max_items') != 0 and "history" in categories:
|
history_disabled = info.config.get('completion.web_history.max_items') == 0
|
||||||
|
if not history_disabled and 'history' in categories:
|
||||||
hist_cat = histcategory.HistoryCategory(delete_func=_delete_history)
|
hist_cat = histcategory.HistoryCategory(delete_func=_delete_history)
|
||||||
models["history"] = hist_cat
|
models['history'] = hist_cat
|
||||||
|
|
||||||
for category in categories:
|
for category in categories:
|
||||||
if category in models:
|
if category in models:
|
||||||
|
@ -459,12 +459,6 @@ class BookmarkManagerStub(UrlMarkManagerStub):
|
|||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class SearchenginesManagerStub(UrlMarkManagerStub):
|
|
||||||
|
|
||||||
"""Stub for the bookmark-manager object."""
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class QuickmarkManagerStub(UrlMarkManagerStub):
|
class QuickmarkManagerStub(UrlMarkManagerStub):
|
||||||
|
|
||||||
|
@ -143,9 +143,9 @@ def configdata_stub(config_stub, monkeypatch, configdata_init):
|
|||||||
raw_backends=None)),
|
raw_backends=None)),
|
||||||
('completion.open_categories', configdata.Option(
|
('completion.open_categories', configdata.Option(
|
||||||
name='completion.open_categories',
|
name='completion.open_categories',
|
||||||
description='Which categories to show (in which order) in the :open completion.',
|
description=('Which categories to show (in which order) in the '
|
||||||
typ=configtypes.FlagList(
|
':open completion.'),
|
||||||
),
|
typ=configtypes.FlagList(),
|
||||||
default=["searchengines", "quickmarks", "bookmarks", "history"],
|
default=["searchengines", "quickmarks", "bookmarks", "history"],
|
||||||
backends=[],
|
backends=[],
|
||||||
raw_backends=None)),
|
raw_backends=None)),
|
||||||
@ -265,7 +265,8 @@ def test_help_completion(qtmodeltester, cmdutils_stub, key_config_stub,
|
|||||||
('aliases', 'Aliases for commands.', None),
|
('aliases', 'Aliases for commands.', None),
|
||||||
('bindings.commands', 'Default keybindings', None),
|
('bindings.commands', 'Default keybindings', None),
|
||||||
('bindings.default', 'Default keybindings', None),
|
('bindings.default', 'Default keybindings', None),
|
||||||
('completion.open_categories', 'Which categories to show (in which order) in the :open completion.', None),
|
('completion.open_categories', 'Which categories to show (in '
|
||||||
|
'which order) in the :open completion.', None),
|
||||||
('content.javascript.enabled', 'Enable/Disable JavaScript', None),
|
('content.javascript.enabled', 'Enable/Disable JavaScript', None),
|
||||||
('url.searchengines', 'searchengines list', None),
|
('url.searchengines', 'searchengines list', None),
|
||||||
],
|
],
|
||||||
@ -274,14 +275,22 @@ def test_help_completion(qtmodeltester, cmdutils_stub, key_config_stub,
|
|||||||
|
|
||||||
def test_open_categories(qtmodeltester, config_stub, web_history_populated,
|
def test_open_categories(qtmodeltester, config_stub, web_history_populated,
|
||||||
quickmarks, bookmarks, info):
|
quickmarks, bookmarks, info):
|
||||||
"""Test that open_categories settings has the desired effect.
|
"""Test that the open_categories setting has the desired effect.
|
||||||
|
|
||||||
Verify that:
|
Verify that:
|
||||||
- All categories are listed when they are defined in the completion.open_categories list
|
- All categories are listed when they are defined in the
|
||||||
|
completion.open_categories list.
|
||||||
"""
|
"""
|
||||||
config_stub.val.url.searchengines = {"DEFAULT": "https://duckduckgo.com/?q={}",
|
config_stub.val.url.searchengines = {
|
||||||
"google": "https://google.com/?q={}"}
|
"DEFAULT": "https://duckduckgo.com/?q={}",
|
||||||
config_stub.val.completion.open_categories = ["searchengines", "quickmarks", "bookmarks", "history"]
|
"google": "https://google.com/?q={}",
|
||||||
|
}
|
||||||
|
config_stub.val.completion.open_categories = [
|
||||||
|
"searchengines",
|
||||||
|
"quickmarks",
|
||||||
|
"bookmarks",
|
||||||
|
"history",
|
||||||
|
]
|
||||||
model = urlmodel.url(info=info)
|
model = urlmodel.url(info=info)
|
||||||
model.set_pattern('')
|
model.set_pattern('')
|
||||||
qtmodeltester.data_display_may_return_none = True
|
qtmodeltester.data_display_may_return_none = True
|
||||||
@ -311,33 +320,29 @@ def test_open_categories(qtmodeltester, config_stub, web_history_populated,
|
|||||||
|
|
||||||
def test_open_categories_remove_all(qtmodeltester, config_stub, web_history_populated,
|
def test_open_categories_remove_all(qtmodeltester, config_stub, web_history_populated,
|
||||||
quickmarks, bookmarks, info):
|
quickmarks, bookmarks, info):
|
||||||
"""Test that removing an item (boookmarks) from the open_categories settings has the desired effect.
|
"""Test removing all items from open_categories."""
|
||||||
|
config_stub.val.url.searchengines = {
|
||||||
Verify that:
|
"DEFAULT": "https://duckduckgo.com/?q={}",
|
||||||
- Only categories
|
"google": "https://google.com/?q={}",
|
||||||
"""
|
}
|
||||||
config_stub.val.url.searchengines = {"DEFAULT": "https://duckduckgo.com/?q={}",
|
|
||||||
"google": "https://google.com/?q={}"}
|
|
||||||
config_stub.val.completion.open_categories = []
|
config_stub.val.completion.open_categories = []
|
||||||
model = urlmodel.url(info=info)
|
model = urlmodel.url(info=info)
|
||||||
model.set_pattern('')
|
model.set_pattern('')
|
||||||
qtmodeltester.data_display_may_return_none = True
|
qtmodeltester.data_display_may_return_none = True
|
||||||
qtmodeltester.check(model)
|
qtmodeltester.check(model)
|
||||||
|
|
||||||
_check_completions(model, {
|
_check_completions(model, {})
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
def test_open_categories_remove_one(qtmodeltester, config_stub, web_history_populated,
|
def test_open_categories_remove_one(qtmodeltester, config_stub, web_history_populated,
|
||||||
quickmarks, bookmarks, info):
|
quickmarks, bookmarks, info):
|
||||||
"""Test that removing an item (boookmarks) from the open_categories settings has the desired effect.
|
"""Test removing an item (boookmarks) from open_categories."""
|
||||||
|
config_stub.val.url.searchengines = {
|
||||||
Verify that:
|
"DEFAULT": "https://duckduckgo.com/?q={}",
|
||||||
- Only categories
|
"google": "https://google.com/?q={}",
|
||||||
"""
|
}
|
||||||
config_stub.val.url.searchengines = {"DEFAULT": "https://duckduckgo.com/?q={}",
|
config_stub.val.completion.open_categories = [
|
||||||
"google": "https://google.com/?q={}"}
|
"searchengines", "quickmarks", "history"]
|
||||||
config_stub.val.completion.open_categories = ["searchengines", "quickmarks", "history"]
|
|
||||||
model = urlmodel.url(info=info)
|
model = urlmodel.url(info=info)
|
||||||
model.set_pattern('')
|
model.set_pattern('')
|
||||||
qtmodeltester.data_display_may_return_none = True
|
qtmodeltester.data_display_may_return_none = True
|
||||||
@ -359,6 +364,7 @@ def test_open_categories_remove_one(qtmodeltester, config_stub, web_history_popu
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def test_quickmark_completion(qtmodeltester, quickmarks):
|
def test_quickmark_completion(qtmodeltester, quickmarks):
|
||||||
"""Test the results of quickmark completion."""
|
"""Test the results of quickmark completion."""
|
||||||
model = miscmodels.quickmark()
|
model = miscmodels.quickmark()
|
||||||
@ -449,8 +455,16 @@ def test_url_completion(qtmodeltester, config_stub, web_history_populated,
|
|||||||
- entries are sorted by access time
|
- entries are sorted by access time
|
||||||
- only the most recent entry is included for each url
|
- only the most recent entry is included for each url
|
||||||
"""
|
"""
|
||||||
config_stub.val.completion.open_categories = ["searchengines", "quickmarks", "bookmarks", "history"]
|
config_stub.val.completion.open_categories = [
|
||||||
config_stub.val.url.searchengines = {"DEFAULT": "https://duckduckgo.com/?q={}", "google": "https://google.com/?q={}"}
|
"searchengines",
|
||||||
|
"quickmarks",
|
||||||
|
"bookmarks",
|
||||||
|
"history",
|
||||||
|
]
|
||||||
|
config_stub.val.url.searchengines = {
|
||||||
|
"DEFAULT": "https://duckduckgo.com/?q={}",
|
||||||
|
"google": "https://google.com/?q={}"
|
||||||
|
}
|
||||||
model = urlmodel.url(info=info)
|
model = urlmodel.url(info=info)
|
||||||
model.set_pattern('')
|
model.set_pattern('')
|
||||||
qtmodeltester.data_display_may_return_none = True
|
qtmodeltester.data_display_may_return_none = True
|
||||||
@ -477,15 +491,19 @@ def test_url_completion(qtmodeltester, config_stub, web_history_populated,
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def test_search_only_default(qtmodeltester, config_stub, web_history_populated,
|
def test_search_only_default(qtmodeltester, config_stub, web_history_populated,
|
||||||
quickmarks, bookmarks, info):
|
quickmarks, bookmarks, info):
|
||||||
"""Test that Seardh engines is not shown when only default search engine is set in settings.
|
"""Test that search engines are not shown with only the default engine."""
|
||||||
|
config_stub.val.completion.open_categories = [
|
||||||
Verify that:
|
"searchengines",
|
||||||
- No Search engines categories is shown
|
"quickmarks",
|
||||||
"""
|
"bookmarks",
|
||||||
config_stub.val.completion.open_categories = ["searchengines", "quickmarks", "bookmarks", "history"]
|
"history",
|
||||||
config_stub.val.url.searchengines = {"DEFAULT": "https://duckduckgo.com/?q={}",}
|
]
|
||||||
|
config_stub.val.url.searchengines = {
|
||||||
|
"DEFAULT": "https://duckduckgo.com/?q={}",
|
||||||
|
}
|
||||||
model = urlmodel.url(info=info)
|
model = urlmodel.url(info=info)
|
||||||
model.set_pattern('')
|
model.set_pattern('')
|
||||||
qtmodeltester.data_display_may_return_none = True
|
qtmodeltester.data_display_may_return_none = True
|
||||||
@ -509,6 +527,7 @@ def test_search_only_default(qtmodeltester, config_stub, web_history_populated,
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def test_url_completion_no_quickmarks(qtmodeltester, web_history_populated,
|
def test_url_completion_no_quickmarks(qtmodeltester, web_history_populated,
|
||||||
quickmark_manager_stub, bookmarks, info):
|
quickmark_manager_stub, bookmarks, info):
|
||||||
"""Test that the quickmark category is gone with no quickmarks."""
|
"""Test that the quickmark category is gone with no quickmarks."""
|
||||||
@ -651,8 +670,16 @@ def test_url_completion_zero_limit(config_stub, web_history, quickmarks, info,
|
|||||||
bookmarks):
|
bookmarks):
|
||||||
"""Make sure there's no history if the limit was set to zero."""
|
"""Make sure there's no history if the limit was set to zero."""
|
||||||
config_stub.val.completion.web_history.max_items = 0
|
config_stub.val.completion.web_history.max_items = 0
|
||||||
config_stub.val.completion.open_categories = ["searchengines", "quickmarks", "bookmarks", "history"]
|
config_stub.val.completion.open_categories = [
|
||||||
config_stub.val.url.searchengines = {"DEFAULT": "https://duckduckgo.com/?q={}", "google": "https://google.com/?q={}"}
|
"searchengines",
|
||||||
|
"quickmarks",
|
||||||
|
"bookmarks",
|
||||||
|
"history",
|
||||||
|
]
|
||||||
|
config_stub.val.url.searchengines = {
|
||||||
|
"DEFAULT": "https://duckduckgo.com/?q={}",
|
||||||
|
"google": "https://google.com/?q={}",
|
||||||
|
}
|
||||||
model = urlmodel.url(info=info)
|
model = urlmodel.url(info=info)
|
||||||
model.set_pattern('')
|
model.set_pattern('')
|
||||||
category = model.index(3, 0) # "History" normally
|
category = model.index(3, 0) # "History" normally
|
||||||
@ -843,12 +870,14 @@ def test_setting_option_completion(qtmodeltester, config_stub,
|
|||||||
('bindings.commands', 'Default keybindings', (
|
('bindings.commands', 'Default keybindings', (
|
||||||
'{"normal": {"<Ctrl+q>": "quit", "ZQ": "quit", '
|
'{"normal": {"<Ctrl+q>": "quit", "ZQ": "quit", '
|
||||||
'"I": "invalid", "d": "scroll down"}}')),
|
'"I": "invalid", "d": "scroll down"}}')),
|
||||||
('completion.open_categories', 'Which categories to show (in which order) in the :open completion.',
|
('completion.open_categories', 'Which categories to show (in '
|
||||||
|
'which order) in the :open completion.',
|
||||||
'["searchengines", "quickmarks", "bookmarks", "history"]'),
|
'["searchengines", "quickmarks", "bookmarks", "history"]'),
|
||||||
('content.javascript.enabled', 'Enable/Disable JavaScript',
|
('content.javascript.enabled', 'Enable/Disable JavaScript',
|
||||||
'true'),
|
'true'),
|
||||||
('url.searchengines', 'searchengines list',
|
('url.searchengines', 'searchengines list',
|
||||||
'{"DEFAULT": "https://duckduckgo.com/?q={}", "google": "https://google.com/?q={}"}'),
|
'{"DEFAULT": "https://duckduckgo.com/?q={}", '
|
||||||
|
'"google": "https://google.com/?q={}"}'),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user