Skip to content
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

Issue translating regular expression (via XMLSchema) #75

Closed
RS-Credentive opened this issue Aug 11, 2024 · 6 comments
Closed

Issue translating regular expression (via XMLSchema) #75

RS-Credentive opened this issue Aug 11, 2024 · 6 comments

Comments

@RS-Credentive
Copy link
Contributor

RS-Credentive commented Aug 11, 2024

regex.append(ch if dot_all else '[^\r\n]')

Hi, I'm running into a problem in xmlschema, but I think it may be related to this library.

I am developing an application to generate code from a specific XML schema, and I need to extract patterns from an XSD into python regular expressions for injection into templates.

Generally, it works quite well! However, I have noticed an issue with the pattern \\S(.*\\S)?, intended to describe a string with no leading or trailing spaces. This pattern is translated into ^(?:\\S(?:[^\r\n]*\\S)?)$(?!\\n\\Z) - note that the [^\r\n] in the middle of the string does not have a double escape.

I believe the line I reference above is the culprit - it does not use a raw string, like the rest of the examples in this module. The result is that this sequence is translated into:

"^(?:\S(?:[^
]*\S)?)$(?!\n\Z)")

when I pass it to another library. Does this appear to be the issue? I can submit a pull request, but wanted to see if you agree with my troubleshooting.

Thanks!

@RS-Credentive
Copy link
Contributor Author

I have confirmed this fixes the issue. Submitting PR

@brunato
Copy link
Member

brunato commented Aug 14, 2024

Hi,
thank you for reporting the issue and for the PR.
If you can fix the failing tests with another commit in the PR (then i squash and merge the PR into a single commit anyway) I would appreciate.

@RS-Credentive
Copy link
Contributor Author

I have added what I believe will fix the failing tests, but I'm not sure how to trigger a re-test.

@brunato
Copy link
Member

brunato commented Aug 14, 2024

You cannot trigger CI tests on the origin repo, maybe you could set something in your fork project. But for this case running local tests in the usual mode for unittest or with tox is sufficient (the fix is not strictly related to the platform or the version of Python).

I'll keep this issue open until the next release of the package is published.

thank you

@RS-Credentive
Copy link
Contributor Author

It appears that the tests have run successfully for the updated PR! Let me know if you have any other concerns.

@brunato
Copy link
Member

brunato commented Sep 9, 2024

Hi, a new release of the package is available, so i close the issue.

@brunato brunato closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants