Skip to content

Commit

Permalink
clean up usage of quoted ",!offsets"
Browse files Browse the repository at this point in the history
  • Loading branch information
lgray authored Oct 17, 2023
1 parent faff41e commit 864f709
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/coffea/nanoevents/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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}"


Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -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}"


Expand Down

0 comments on commit 864f709

Please sign in to comment.