Skip to content

Commit

Permalink
Declare is_upgrade_hook() inside upgrade_config()
Browse files Browse the repository at this point in the history
It is only used there and once.
  • Loading branch information
zas committed Mar 29, 2024
1 parent 9a99170 commit 862e14c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions picard/config_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,17 @@ def rename_option(config, old_opt, new_opt, option_type, default):
_p['user_profile_settings'] = all_settings


def is_upgrade_hook(f):
"""Check if passed function is an upgrade hook"""
return (
isfunction(f)
and f.__module__ == __name__
and f.__name__.startswith(UPGRADE_FUNCTION_PREFIX)
)


def upgrade_config(config):
"""Detect upgrade hooks methods and register them"""

def is_upgrade_hook(f):
"""Check if passed function is an upgrade hook"""
return (
isfunction(f)
and f.__module__ == __name__
and f.__name__.startswith(UPGRADE_FUNCTION_PREFIX)
)

# Build a dict with version as key and function as value
hooks = {
Version.from_string(name[len(UPGRADE_FUNCTION_PREFIX):]): hook
Expand Down

0 comments on commit 862e14c

Please sign in to comment.