-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a 'o' modifier to the ~x sigil allowing a path to not exist #10
Conversation
bd01953
to
4ffd3d8
Compare
|
||
def xmap(nil, _, %{is_optional: true}), do: nil | ||
|
||
def xmap(parent, [], atom) when is_atom(atom), do: xmap(parent, [], %{is_keyword: atom}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this clause here ensures that the changes to xmap are not breaking. All current uses will pass without trouble.
Are there any outstanding questions or concerns? |
Hi, @benwilson512. A modifier for optional paths is a nice feature. Could you updated the README, too, describing this feature? I'm not a maintainer, I'm just trying to help. |
…nfig passed through
Done. |
Hey, any possibility for movement on this? |
I'm not a maintainer, but 👍 What do you thing, @awetzel ? |
Yes it is perfect sorry for the late answer, I had already reviewed your commit and thought that it was already merged... Thank you very much for the contribution, I will publish to hex next week maybe with other improvements. |
Add a 'o' modifier to the ~x sigil allowing a path to not exist
Motivation:
I'm the author if ExAws, a set of elixir clients for interacting with AWS, and have been using sweet_xml to parse the resulting xml. This has been an extremely helpful library for handling xml results returned by AWS.
However, as it turns out, AWS will often leave out portions of xml depending on permissions, request parameters, and so on. Presently this will return the following error:
What this PR does is add an 'o' modifier
~x"//some/bad/path"o
such that it will return nil if the path does not exist instead of exploding.