From e79877ee6a3f017ffabc6cab81a50890662fc939 2020-04-28 14:48:10 From: Brett Smith Date: 2020-04-28 14:48:10 Subject: [PATCH] data: Add rt-id to LINK_METADATA. This gets closer to our real intentions: anything that checks link metadata should check rt-id. MetaRepoLinks is the exception, not the rule, in ignoring rt-id. --- diff --git a/conservancy_beancount/data.py b/conservancy_beancount/data.py index 4d341ca277fd1de1c9078f081d9e8a4b2e6f76c8..515cb99344e0ecd775a1d1bb58beee0480575f34 100644 --- a/conservancy_beancount/data.py +++ b/conservancy_beancount/data.py @@ -56,6 +56,7 @@ LINK_METADATA = frozenset([ 'invoice', 'purchase-order', 'receipt', + 'rt-id', 'statement', ]) diff --git a/conservancy_beancount/plugin/meta_repo_links.py b/conservancy_beancount/plugin/meta_repo_links.py index f9f281b084a1032eca811892eed84a5acdf90cb5..658bd9dbe4f6270286ec85d44dcea8053b884fd3 100644 --- a/conservancy_beancount/plugin/meta_repo_links.py +++ b/conservancy_beancount/plugin/meta_repo_links.py @@ -34,6 +34,7 @@ from typing import ( class MetaRepoLinks(core.TransactionHook): HOOK_GROUPS = frozenset(['linkcheck']) + LINK_METADATA = data.LINK_METADATA.difference('rt-id') PATH_PUNCT_RE = re.compile(r'[:/]') def __init__(self, config: configmod.Config) -> None: @@ -48,7 +49,7 @@ class MetaRepoLinks(core.TransactionHook): post: Optional[Posting]=None, ) -> errormod.Iter: metadata = data.Metadata(meta) - for key in data.LINK_METADATA: + for key in self.LINK_METADATA: try: links = metadata.get_links(key) except TypeError: diff --git a/conservancy_beancount/plugin/meta_rt_links.py b/conservancy_beancount/plugin/meta_rt_links.py index b91f4ec45a4a70d18fa149c08fc4a9044dd9cc57..2d14e86b8bb172c4532f6810c609f6e17c7af029 100644 --- a/conservancy_beancount/plugin/meta_rt_links.py +++ b/conservancy_beancount/plugin/meta_rt_links.py @@ -32,7 +32,6 @@ from typing import ( class MetaRTLinks(core.TransactionHook): HOOK_GROUPS = frozenset(['linkcheck', 'network', 'rt']) - LINK_METADATA = data.LINK_METADATA.union(['rt-id']) def __init__(self, config: configmod.Config) -> None: rt_wrapper = config.rt_wrapper() @@ -46,7 +45,7 @@ class MetaRTLinks(core.TransactionHook): post: Optional[Posting]=None, ) -> errormod.Iter: metadata = data.Metadata(meta) - for key in self.LINK_METADATA: + for key in data.LINK_METADATA: try: links = metadata.get_links(key) except TypeError: