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

11 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2026-06-16 19:34 +0000

1from collections.abc import Callable, Mapping 

2from typing import Literal, Union 

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_modprobe_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 migrate_dh_builtusing, 

34) 

35from debputy.dh_migration.models import ( 

36 FeatureMigration, 

37 MigrationRequest, 

38) 

39from debputy.plugin.api.spec import ( 

40 DebputyIntegrationMode, 

41 INTEGRATION_MODE_DH_DEBPUTY_RRR, 

42 INTEGRATION_MODE_DH_DEBPUTY, 

43 INTEGRATION_MODE_FULL, 

44) 

45 

46Migrator = Callable[ 

47 [ 

48 MigrationRequest, 

49 FeatureMigration, 

50 ], 

51 None, 

52] 

53 

54_DH_DEBPUTY_MIGRATORS = [ 

55 detect_unsupported_zz_debputy_features, 

56 detect_modprobe_files, 

57 migrate_dh_hook_targets, 

58 migrate_dh_installsystemd_files, 

59 migrate_install_file, 

60 migrate_installdocs_file, 

61 migrate_installexamples_file, 

62 migrate_installman_file, 

63 migrate_installinfo_file, 

64 migrate_misspelled_readme_debian_files, 

65 migrate_doc_base_files, 

66 migrate_links_files, 

67 migrate_maintscript, 

68 migrate_tmpfile, 

69 migrate_lintian_overrides_files, 

70 migrate_bash_completion, 

71 migrate_shell_completions, 

72 migrate_dh_builtusing, 

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