Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshadfield committed Feb 12, 2025
1 parent c621312 commit 0c4004e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 1 addition & 5 deletions augur/export_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,6 @@ def _add_title_and_type(coloring):
return coloring

def _add_coloring(colorings, key):
# handle deprecations
if key == "authors":
deprecated("[colorings] The 'authors' key is now called 'author'")
key = "author"
# check if the key has already been added by another part of the color-creating logic
if key not in {x['key'] for x in colorings}:
colorings.append({"key": key})
Expand Down Expand Up @@ -1151,7 +1147,7 @@ def get_additional_metadata_columns(config, command_line_metadata_columns, metad
"It will be ignored during export, please rename field if you would like to include as a metadata field.")
continue
# Match the column names corrected within parse_node_data_and_metadata
corrected_col = update_deprecated_names(col)
# corrected_col = update_deprecated_names(col)
if corrected_col not in metadata_names:
warn(f"Requested metadata column {col!r} does not exist and will not be exported")
continue
Expand Down
17 changes: 17 additions & 0 deletions augur/util_support/auspice_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ def _rename_display_keys(display: dict) -> dict:
return defaults


def _update_deprecated_values(config):
# The 'authors' coloring is now called 'author' (and remapped as such)
author = [[idx, c] for [idx, c] in enumerate(config.get('colorings', [])) if c['key']=='author' ]
authors = [[idx, c] for [idx, c] in enumerate(config.get('colorings', [])) if c['key']=='authors']
if authors:
if author:
deprecated("[config file] coloring 'authors' has been renamed 'author', however a " +
"coloring for 'author' already exists. 'authors' will be ignored")
config['colorings'] = [c for [idx, c] in enumerate(config['colorings']) if idx!=authors[0][0]]
else:
deprecated("[config file] renaming coloring 'authors' to 'author'")
config['colorings'][authors[0][0]]['key'] = "author"


TOP_LEVEL_DEPRECATED_KEYS = [
# [ <old key>, <new key>, <modify func>] #
["defaults", "display_defaults", _rename_display_keys],
Expand All @@ -106,5 +120,8 @@ def read_auspice_config(fname):
_replace_deprecated(config, *keys)
for key in TOP_LEVEL_UNUSED_KEYS:
_remove_deprecated(config, key)
_update_deprecated_values(config)

import pprint; pprint.pp(config)

return config

0 comments on commit 0c4004e

Please sign in to comment.