Coverage for src/debputy/dh_migration/migrators.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-10-12 15:06 +0000

1from typing import List, Optional, Literal, Union 

2from collections.abc import Callable, Mapping 

3 

4from debputy.dh_migration.dh_related_migrations import ( 

5 dh_mbm_migrate_package_files, 

6 dh_mbm_migrate_manual_warnings, 

7) 

8from debputy.dh_migration.migrators_impl import ( 

9 migrate_links_files, 

10 migrate_maintscript, 

11 migrate_tmpfile, 

12 migrate_install_file, 

13 migrate_installdocs_file, 

14 migrate_installexamples_file, 

15 migrate_dh_hook_targets, 

16 migrate_misspelled_readme_debian_files, 

17 migrate_doc_base_files, 

18 migrate_lintian_overrides_files, 

19 detect_unsupported_zz_debputy_features, 

20 detect_pam_files, 

21 detect_dh_addons_with_zz_integration, 

22 migrate_not_installed_file, 

23 migrate_installman_file, 

24 migrate_bash_completion, 

25 migrate_installinfo_file, 

26 migrate_dh_installsystemd_files, 

27 detect_obsolete_substvars, 

28 detect_dh_addons_zz_debputy_rrr, 

29 detect_dh_addons_with_full_integration, 

30 migrate_shell_completions, 

31 migrate_clean_file, 

32 min_dh_compat_check, 

33) 

34from debputy.dh_migration.models import AcceptableMigrationIssues, FeatureMigration 

35from debputy.highlevel_manifest import HighLevelManifest 

36from debputy.plugin.api import VirtualPath 

37from debputy.plugin.api.spec import ( 

38 DebputyIntegrationMode, 

39 INTEGRATION_MODE_DH_DEBPUTY_RRR, 

40 INTEGRATION_MODE_DH_DEBPUTY, 

41 INTEGRATION_MODE_FULL, 

42) 

43 

44Migrator = Callable[ 

45 [ 

46 VirtualPath, 

47 HighLevelManifest, 

48 AcceptableMigrationIssues, 

49 FeatureMigration, 

50 Optional[DebputyIntegrationMode], 

51 ], 

52 None, 

53] 

54 

55_DH_DEBPUTY_MIGRATORS = [ 

56 detect_unsupported_zz_debputy_features, 

57 detect_pam_files, 

58 migrate_dh_hook_targets, 

59 migrate_dh_installsystemd_files, 

60 migrate_install_file, 

61 migrate_installdocs_file, 

62 migrate_installexamples_file, 

63 migrate_installman_file, 

64 migrate_installinfo_file, 

65 migrate_misspelled_readme_debian_files, 

66 migrate_doc_base_files, 

67 migrate_links_files, 

68 migrate_maintscript, 

69 migrate_tmpfile, 

70 migrate_lintian_overrides_files, 

71 migrate_bash_completion, 

72 migrate_shell_completions, 

73 detect_obsolete_substvars, 

74 # not-installed should go last, so its rules appear after other installations 

75 # It is not perfect, but it is a start. 

76 migrate_not_installed_file, 

77 min_dh_compat_check, 

78] 

79 

80 

81MigrationTarget = Union[ 

82 DebputyIntegrationMode, 

83 Literal[ 

84 "dh-single-to-multi-binary", 

85 "dh-package-prefixed-config-files", 

86 ], 

87] 

88 

89MIGRATORS: Mapping[MigrationTarget, list[Migrator]] = { 

90 INTEGRATION_MODE_DH_DEBPUTY_RRR: [ 

91 migrate_dh_hook_targets, 

92 migrate_misspelled_readme_debian_files, 

93 detect_dh_addons_zz_debputy_rrr, 

94 detect_obsolete_substvars, 

95 ], 

96 INTEGRATION_MODE_DH_DEBPUTY: [ 

97 *_DH_DEBPUTY_MIGRATORS, 

98 detect_dh_addons_with_zz_integration, 

99 ], 

100 INTEGRATION_MODE_FULL: [ 

101 *_DH_DEBPUTY_MIGRATORS, 

102 detect_dh_addons_with_full_integration, 

103 migrate_clean_file, 

104 ], 

105 "dh-package-prefixed-config-files": [ 

106 dh_mbm_migrate_package_files, 

107 ], 

108 "dh-single-to-multi-binary": [ 

109 dh_mbm_migrate_package_files, 

110 dh_mbm_migrate_manual_warnings, 

111 ], 

112} 

113del _DH_DEBPUTY_MIGRATORS