ropensci / EML

Ecological Metadata Language interface for R: synthesis and integration of heterogenous data
https://docs.ropensci.org/EML
Other
97 stars 33 forks source link

Update get_attributes to handle attributeLists w single attribute #326

Open ianbrunjes opened 3 years ago

ianbrunjes commented 3 years ago

Under certain conditions (see reprex in #285), passing an attributeList with a single attribute into get_attributes will cause an error due to the use of lapply, which for multiple attributes (represented as a list of lists) will correctly apply the function to each attribute, but for a singular attribute (which can be just a flat list) would attempt to apply the function to each character element of the list and causes the error.

This fix attempts to prevent that error by identifying which case is being handled and applying the appropriate logic accordingly.

With that said, this fix feels a little hacky to me and if anyone has a better idea on how to handle it I very much welcome input.