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

Fail gracefully for files that cant be opened using utf-8 #6

Open
jayvdb opened this issue Sep 18, 2021 · 0 comments
Open

Fail gracefully for files that cant be opened using utf-8 #6

jayvdb opened this issue Sep 18, 2021 · 0 comments

Comments

@jayvdb
Copy link

jayvdb commented Sep 18, 2021

It would be great if enmerkar could skip files which can not be opened as text, with a warning.

I have three docx/xlsx files causing errors like below, encountered if I use mapping [django: */templates/**.*]. To avoid this it seems I need to specify lots of sections in my babel.cfg mapping file for all the other filetypes I want processed.

extracting messages from common\templates\common\docx\WIN_TEMPLATE.docx
Traceback (most recent call last):
  File "C:\Users\vandjohn\Downloads\WPy64-3771\python-3.7.7.amd64\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\vandjohn\Downloads\WPy64-3771\python-3.7.7.amd64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\vandjohn\Downloads\WPy64-3771\python-3.7.7.amd64\Scripts\pybabel.exe\__main__.py", line 7, in <module>
  File "C:\Users\vandjohn\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\babel\messages\frontend.py", line 929, in main
    return CommandLineInterface().run(sys.argv)
  File "C:\Users\vandjohn\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\babel\messages\frontend.py", line 853, in run
    return cmdinst.run()
  File "C:\Users\vandjohn\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\babel\messages\frontend.py", line 481, in run
    for filename, lineno, message, comments, context in extracted:
  File "C:\Users\vandjohn\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\babel\messages\extract.py", line 157, in extract_from_dir
    dirpath=absname,
  File "C:\Users\vandjohn\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\babel\messages\extract.py", line 212, in check_and_call_extract_file
    strip_comment_tags=strip_comment_tags
  File "C:\Users\vandjohn\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\babel\messages\extract.py", line 244, in extract_from_file
    options, strip_comment_tags))
  File "C:\Users\vandjohn\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\babel\messages\extract.py", line 325, in extract
    for lineno, funcname, messages, comments in results:
  File "C:\Users\vandjohn\Downloads\WPy64-3771\python-3.7.7.amd64\lib\site-packages\enmerkar\extract.py", line 52, in extract_django
    text = fileobj.read().decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 14: invalid start byte
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

1 participant