From 864f7094e92fe11792dba736f093f8f3115b3ac0 Mon Sep 17 00:00:00 2001 From: Lindsey Gray Date: Tue, 17 Oct 2023 10:22:52 -0500 Subject: [PATCH] clean up usage of quoted ",!offsets" --- src/coffea/nanoevents/factory.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/coffea/nanoevents/factory.py b/src/coffea/nanoevents/factory.py index 123f6a131..e97f556f0 100644 --- a/src/coffea/nanoevents/factory.py +++ b/src/coffea/nanoevents/factory.py @@ -29,8 +29,9 @@ PHYSLITESchema, TreeMakerSchema, ) -from coffea.nanoevents.util import key_to_tuple, tuple_to_key +from coffea.nanoevents.util import quote, unquote, key_to_tuple, tuple_to_key +_offsets_label = quote(",!offsets") def _remove_not_interpretable(branch): if isinstance( @@ -63,7 +64,7 @@ def _remove_not_interpretable(branch): def _key_formatter(prefix, form_key, form, attribute): if attribute == "offsets": - form_key += "%2C%21offsets" + form_key += _offsets_label return prefix + f"/{attribute}/{form_key}" @@ -80,7 +81,7 @@ def keys_for_buffer_keys(self, buffer_keys): base_columns = set() for buffer_key in buffer_keys: form_key, attribute = self.parse_buffer_key(buffer_key) - operands = urllib.parse.unquote(form_key).split(",") + operands = unquote(form_key).split(",") it_operands = iter(operands) next(it_operands) @@ -97,7 +98,7 @@ def keys_for_buffer_keys(self, buffer_keys): def parse_buffer_key(self, buffer_key): prefix, attribute, form_key = buffer_key.rsplit("/", maxsplit=2) if attribute == "offsets": - return (form_key[: -len("%2C%21offsets")], attribute) + return (form_key[: -len(_offsets_label)], attribute) else: return (form_key, attribute) @@ -107,7 +108,7 @@ def buffer_key(self): def _key_formatter(self, prefix, form_key, form, attribute): if attribute == "offsets": - form_key += "%2C%21offsets" + form_key += _offsets_label return prefix + f"/{attribute}/{form_key}"