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

Undefined variable 'utils' in html_decapsulator.py #42

Open
doerrf opened this issue Nov 6, 2024 · 3 comments
Open

Undefined variable 'utils' in html_decapsulator.py #42

doerrf opened this issue Nov 6, 2024 · 3 comments

Comments

@doerrf
Copy link

doerrf commented Nov 6, 2024

  File "C:\Users\User\Documents\parser.py", line 14, in <module>
    renderer.render(parsed, f)
  File "C:\Users\User\Documents\venv\Lib\site-packages\rtfparse\renderers\html_decapsulator.py", line 98, in render
    self.render(item, file)
  File "C:\Users\User\Documents\venv\Lib\site-packages\rtfparse\renderers\html_decapsulator.py", line 105, in render
    self.render_symbol(item, file)
  File "C:\Users\User\Documents\venv\Lib\site-packages\rtfparse\renderers\html_decapsulator.py", line 88, in render_symbol
    utils.warn(f"Found an IGNORABLE control symbol which is not a group start!")
    ^^^^^
NameError: name 'utils' is not defined

I'm not sure what "utils" is meant to be, but I resolved this issue by adding the following to html_decapsulator.py:

class utils:
    @staticmethod
    def warn(message: str) -> str:
        return f"WARNING: {message}"
    
    @staticmethod
    def error(message: str) -> str:
        return f"ERROR: {message}"
@fleetingbytes
Copy link
Owner

Thanks for this issue. Error is caused by a missing import. utils refer to this module. The function warn was just prepending a symbol before the message line, similar to your f"WARNING: {message}". I will fix this. I am just considering whether to drop this extra warning decoration alltogether.

@fleetingbytes
Copy link
Owner

@doerrf This is now fixed in the current rtfparse version. I wonder how you came about this error. If you don't mind, please share the rtf producing the error. I suspect that there is a deeper problem in rtfparse than just this missing import had been. To me it looks like rtfparse may be ignoring certain control words which it isn't supposed to ignore.

@fleetingbytes fleetingbytes reopened this Nov 11, 2024
@doerrf
Copy link
Author

doerrf commented Nov 12, 2024 via email

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