diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 20:11:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 20:11:46 +0000 |
commit | 120c888606816c46ca35d5a18eba2a8be896c3eb (patch) | |
tree | 64f7ef3faa198810d6eb204afabf3ac726e99b41 | |
parent | Adding upstream version 0.1.22. (diff) | |
download | debputy-120c888606816c46ca35d5a18eba2a8be896c3eb.tar.xz debputy-120c888606816c46ca35d5a18eba2a8be896c3eb.zip |
Adding upstream version 0.1.22.1.upstream/0.1.22.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r-- | src/debputy/linting/lint_impl.py | 4 | ||||
-rw-r--r-- | src/debputy/lsp/lsp_debian_changelog.py | 15 | ||||
-rw-r--r-- | src/debputy/lsp/lsp_debian_control.py | 10 | ||||
-rw-r--r-- | src/debputy/lsp/lsp_debian_copyright.py | 9 | ||||
-rw-r--r-- | src/debputy/lsp/lsp_features.py | 2 | ||||
-rw-r--r-- | src/debputy/lsp/quickfixes.py | 1 | ||||
-rw-r--r-- | src/debputy/packaging/alternatives.py | 2 | ||||
-rw-r--r-- | tests/test_alternatives.py | 85 |
8 files changed, 90 insertions, 38 deletions
diff --git a/src/debputy/linting/lint_impl.py b/src/debputy/linting/lint_impl.py index 7248022..5df76c4 100644 --- a/src/debputy/linting/lint_impl.py +++ b/src/debputy/linting/lint_impl.py @@ -139,7 +139,7 @@ def _auto_fix_run( CodeActionContext( [diagnostic], ), - ) + ), ) auto_fixing_edits = resolve_auto_fixer(filename, actions) @@ -285,7 +285,7 @@ def _diagnostics_run( CodeActionContext( [diagnostic], ), - ) + ), ) auto_fixer = resolve_auto_fixer(filename, actions) has_auto_fixer = bool(auto_fixer) diff --git a/src/debputy/lsp/lsp_debian_changelog.py b/src/debputy/lsp/lsp_debian_changelog.py index 77df145..f99a63b 100644 --- a/src/debputy/lsp/lsp_debian_changelog.py +++ b/src/debputy/lsp/lsp_debian_changelog.py @@ -13,11 +13,8 @@ from lsprotocol.types import ( Diagnostic, DidOpenTextDocumentParams, DidChangeTextDocumentParams, - TEXT_DOCUMENT_DID_OPEN, - TEXT_DOCUMENT_DID_CHANGE, TEXT_DOCUMENT_WILL_SAVE_WAIT_UNTIL, TEXT_DOCUMENT_CODE_ACTION, - TEXT_DOCUMENT_DID_CLOSE, DidCloseTextDocumentParams, Range, Position, @@ -26,12 +23,10 @@ from lsprotocol.types import ( from debputy.lsp.lsp_features import lsp_diagnostics, lsp_standard_handler from debputy.lsp.quickfixes import ( - provide_standard_quickfixes_from_diagnostics, propose_correct_text_quick_fix, ) from debputy.lsp.spellchecking import spellcheck_line from debputy.lsp.text_util import ( - on_save_trim_end_of_line_whitespace, LintCapablePositionCodec, ) @@ -68,16 +63,6 @@ _KNOWN_WEEK_DAYS = frozenset(_WEEKDAYS_BY_IDX) DOCUMENT_VERSION_TABLE: Dict[str, int] = {} -def register_dch_lsp(ls: "LanguageServer") -> None: - ls.feature(TEXT_DOCUMENT_DID_OPEN)(_diagnostics_debian_changelog) - ls.feature(TEXT_DOCUMENT_DID_CHANGE)(_diagnostics_debian_changelog) - ls.feature(TEXT_DOCUMENT_DID_CLOSE)(_handle_close) - ls.feature(TEXT_DOCUMENT_CODE_ACTION)( - ls.thread()(provide_standard_quickfixes_from_diagnostics) - ) - ls.feature(TEXT_DOCUMENT_WILL_SAVE_WAIT_UNTIL)(on_save_trim_end_of_line_whitespace) - - def _handle_close( ls: "LanguageServer", params: DidCloseTextDocumentParams, diff --git a/src/debputy/lsp/lsp_debian_control.py b/src/debputy/lsp/lsp_debian_control.py index f73612f..8b6238c 100644 --- a/src/debputy/lsp/lsp_debian_control.py +++ b/src/debputy/lsp/lsp_debian_control.py @@ -21,19 +21,13 @@ from lsprotocol.types import ( CompletionItem, CompletionList, CompletionParams, - TEXT_DOCUMENT_DID_OPEN, - TEXT_DOCUMENT_DID_CHANGE, - TEXT_DOCUMENT_COMPLETION, TEXT_DOCUMENT_WILL_SAVE_WAIT_UNTIL, DiagnosticRelatedInformation, Location, - TEXT_DOCUMENT_HOVER, HoverParams, Hover, TEXT_DOCUMENT_CODE_ACTION, DiagnosticTag, - SemanticTokensLegend, - TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL, SemanticTokens, SemanticTokensParams, ) @@ -62,11 +56,9 @@ from debputy.lsp.quickfixes import ( propose_remove_line_quick_fix, range_compatible_with_remove_line_fix, propose_correct_text_quick_fix, - provide_standard_quickfixes_from_diagnostics, ) from debputy.lsp.spellchecking import default_spellchecker from debputy.lsp.text_util import ( - on_save_trim_end_of_line_whitespace, normalize_dctrl_field_name, LintCapablePositionCodec, detect_possible_typo, @@ -85,7 +77,7 @@ from debputy.lsp.vendoring._deb822_repro.tokens import ( Deb822Token, Deb822FieldNameToken, ) -from debputy.util import _info, _error +from debputy.util import _info try: from debputy.lsp.vendoring._deb822_repro.locatable import ( diff --git a/src/debputy/lsp/lsp_debian_copyright.py b/src/debputy/lsp/lsp_debian_copyright.py index f22bd0b..995d93f 100644 --- a/src/debputy/lsp/lsp_debian_copyright.py +++ b/src/debputy/lsp/lsp_debian_copyright.py @@ -18,19 +18,13 @@ from lsprotocol.types import ( CompletionItem, CompletionList, CompletionParams, - TEXT_DOCUMENT_DID_OPEN, - TEXT_DOCUMENT_DID_CHANGE, - TEXT_DOCUMENT_COMPLETION, TEXT_DOCUMENT_WILL_SAVE_WAIT_UNTIL, DiagnosticRelatedInformation, Location, - TEXT_DOCUMENT_HOVER, HoverParams, Hover, TEXT_DOCUMENT_CODE_ACTION, DiagnosticTag, - SemanticTokensLegend, - TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL, SemanticTokens, SemanticTokensParams, FoldingRangeParams, @@ -61,11 +55,9 @@ from debputy.lsp.lsp_generic_deb822 import ( from debputy.lsp.quickfixes import ( propose_remove_line_quick_fix, propose_correct_text_quick_fix, - provide_standard_quickfixes_from_diagnostics, ) from debputy.lsp.spellchecking import default_spellchecker from debputy.lsp.text_util import ( - on_save_trim_end_of_line_whitespace, normalize_dctrl_field_name, LintCapablePositionCodec, detect_possible_typo, @@ -84,7 +76,6 @@ from debputy.lsp.vendoring._deb822_repro.tokens import ( Deb822Token, Deb822FieldNameToken, ) -from debputy.util import _error try: from debputy.lsp.vendoring._deb822_repro.locatable import ( diff --git a/src/debputy/lsp/lsp_features.py b/src/debputy/lsp/lsp_features.py index 8260675..5b01266 100644 --- a/src/debputy/lsp/lsp_features.py +++ b/src/debputy/lsp/lsp_features.py @@ -42,7 +42,7 @@ _ALIAS_OF = {} _STANDARD_HANDLERS = { TEXT_DOCUMENT_CODE_ACTION: ( CODE_ACTION_HANDLERS, - provide_standard_quickfixes_from_diagnostics, + lambda ls, params: provide_standard_quickfixes_from_diagnostics(params), ), TEXT_DOCUMENT_WILL_SAVE_WAIT_UNTIL: ( WILL_SAVE_WAIT_UNTIL_HANDLERS, diff --git a/src/debputy/lsp/quickfixes.py b/src/debputy/lsp/quickfixes.py index 7ae0324..d911961 100644 --- a/src/debputy/lsp/quickfixes.py +++ b/src/debputy/lsp/quickfixes.py @@ -172,7 +172,6 @@ def _correct_value_code_action( def provide_standard_quickfixes_from_diagnostics( - ls: "LanguageServer", code_action_params: CodeActionParams, ) -> Optional[List[Union[Command, CodeAction]]]: actions = [] diff --git a/src/debputy/packaging/alternatives.py b/src/debputy/packaging/alternatives.py index 249fa9e..53e337d 100644 --- a/src/debputy/packaging/alternatives.py +++ b/src/debputy/packaging/alternatives.py @@ -113,7 +113,7 @@ def process_alternative( escape_shell( "update-alternatives", "--remove", - link_path, + name, impl_path, ) ] diff --git a/tests/test_alternatives.py b/tests/test_alternatives.py new file mode 100644 index 0000000..2a42d69 --- /dev/null +++ b/tests/test_alternatives.py @@ -0,0 +1,85 @@ +import textwrap +from typing import Mapping + +from debputy.maintscript_snippet import MaintscriptSnippetContainer +from debputy.packager_provided_files import PackagerProvidedFile +from debputy.packages import BinaryPackage +from debputy.packaging.alternatives import process_alternatives +from debputy.plugin.api import virtual_path_def, VirtualPath +from debputy.plugin.api.impl import plugin_metadata_for_debputys_own_plugin +from debputy.plugin.api.impl_types import PackagerProvidedFileClassSpec +from debputy.plugin.api.test_api import build_virtual_file_system + + +def _ppf_for(pkg: BinaryPackage, path: VirtualPath) -> PackagerProvidedFile: + plugin_metadata = plugin_metadata_for_debputys_own_plugin() + return PackagerProvidedFile( + path, + pkg.name, + "irrelevant", + "irrelevant", + PackagerProvidedFileClassSpec( + plugin_metadata, + "alternatives", + "DEBIAN/alternatives", + 0o0644, + None, + False, + False, + None, + False, + True, + None, + None, + False, + ), + ) + + +def test_alternatives( + package_single_foo_arch_all_cxt_amd64: Mapping[str, BinaryPackage], +) -> None: + pkg = package_single_foo_arch_all_cxt_amd64["foo"] + debian_dir = build_virtual_file_system( + [ + virtual_path_def( + "alternatives", + fs_path="debian/alternatives", + content=textwrap.dedent( + """\ + Name: x-terminal-emulator + Link: /usr/bin/x-terminal-emulator + Alternative: /usr/bin/xterm + Dependents: + /usr/share/man/man1/x-terminal-emulator.1.gz x-terminal-emulator.1.gz /usr/share/man/man1/xterm.1.gz + Priority: 20 + """ + ), + ), + ] + ) + fs_root = build_virtual_file_system( + [ + "./usr/bin/xterm", + "./usr/share/man/man1/xterm.1.gz", + ] + ) + reserved_ppfs = {"alternatives": [_ppf_for(pkg, debian_dir["alternatives"])]} + maintscript_snippets = { + "prerm": MaintscriptSnippetContainer(), + "postinst": MaintscriptSnippetContainer(), + } + process_alternatives( + pkg, + fs_root, + reserved_ppfs, + maintscript_snippets, + ) + + prerm = maintscript_snippets["prerm"].generate_snippet(reverse=True) + postinst = maintscript_snippets["postinst"].generate_snippet(reverse=True) + + assert "--remove x-terminal-emulator /usr/bin/xterm" in prerm + assert ( + "--install /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/xterm 20" + ) in postinst |