Skip to content

feat(pipeline): IE errors translation #6709

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

Merged
merged 2 commits into from
Dec 21, 2017
Merged

feat(pipeline): IE errors translation #6709

merged 2 commits into from
Dec 21, 2017

Conversation

kamilogorek
Copy link
Contributor

@kamilogorek kamilogorek commented Dec 7, 2017

@ghost
Copy link

ghost commented Dec 7, 2017

1 Warning
⚠️ You should update CHANGES due to the size of this PR

Generated by 🚫 danger

@kamilogorek
Copy link
Contributor Author

@mitsuhiko @mattrobenolt all tests are passing locally, but I have some encoding issues when running pre-commit hook. Could you help me figure it out?

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 31: ordinal not in range(128)    

I also need a review of my last commit, as I'm not 100% sure if I handled encoding correctly.

@mattrobenolt
Copy link
Contributor

but I have some encoding issues when running pre-commit hook. Could you help me figure it out?

I’m not sure which tool, but one of the tools we use can’t handle utf-8 source code. So the test_errorlocale file is causing a problem. Just use the ascii escape sequences. I don’t have a better suggestion. :/

@kamilogorek
Copy link
Contributor Author

Ready for a review. All tests and linters are passing now.

screen shot 2017-12-12 at 13 41 09

import io
import re

LOCALES_DIR = 'src/sentry/data/error-locale'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do os.path.join(os.path.dirname(__file__), '../../data/error-locale' instead? Current working directory is unrealiable. You can see with other code how we do it.

# exact match
translation_regexp = '^' + \
translation_regexp.replace(
'\%s', '(?P<format_string_data>[a-zA-Z0-9-_\$]+)') + '$'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this from '' to r''? Right now this mostly works by accident.


# Handle both cases. Just a message and message preceeded with error type
# eg. `ReferenceError: foo`, `TypeError: bar`
match = re.match('^(?P<type>[a-zA-Z]*Error): (?P<message>.*)', message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please precompile this regex with re.compile and stash it away instead of using re.match. The regex cache on 2.7 is really bad. Also use regex.search instead of regex.match. The latter anchors.

@kamilogorek kamilogorek force-pushed the ie-errors-translation branch from 37712d3 to ab197e0 Compare December 21, 2017 21:57
@dcramer
Copy link
Member

dcramer commented Dec 21, 2017

hero

@dcramer dcramer merged commit 6cc5a95 into master Dec 21, 2017
@dcramer
Copy link
Member

dcramer commented Dec 21, 2017

Merging this per @kamilogorek's request

@dcramer dcramer deleted the ie-errors-translation branch December 21, 2017 22:46
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants