Skip to content

unescape() not supported and not required as of python 3.9 onwards#191

Open
asafravid wants to merge 1 commit into
reingart:masterfrom
asafravid:master
Open

unescape() not supported and not required as of python 3.9 onwards#191
asafravid wants to merge 1 commit into
reingart:masterfrom
asafravid:master

Conversation

@asafravid
Copy link
Copy Markdown

unescape() not supported and not required as of python 3.9 onwards

unescape() not supported and not required as of python 3.9 onwards
@lambda-science
Copy link
Copy Markdown

Any update on merging this ?
Using python 3.9 code I had this specific issue:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/home/meyer/code-project/HistoQuant/zc_Unet.ipynb Cell 16' in <cell line: 66>()
     63 print('Number of validation steps: '+str(validation_steps))
     64 print('---------------------------- ------------------------ ----------------------------')
---> 66 pdf_export(augmentation = Use_Data_augmentation, pretrained_model = Use_pretrained_model)

/home/meyer/code-project/HistoQuant/zc_Unet.ipynb Cell 6' in pdf_export(trained, augmentation, pretrained_model)
     91 pdf.ln(1)
     92 html = """ 
     93 <table width=40% style="margin-left:0px;">
     94   <tr>
   (...)
    129 </table>
    130 """.format(number_of_epochs, str(patch_width)+'x'+str(patch_height), batch_size, number_of_steps, percentage_validation, initial_learning_rate, pooling_steps, min_fraction)
--> 131 pdf.write_html(html)
    133 #pdf.multi_cell(190, 5, txt = text_2, align='L')
    134 pdf.set_font("Arial", size = 11, style='B')

File ~/.cache/pypoetry/virtualenvs/histoquant-cknpwBRB-py3.9/lib/python3.9/site-packages/fpdf/html.py:400, in HTMLMixin.write_html(self, text, image_map)
    398 "Parse HTML and convert it to PDF"
    399 h2p = HTML2FPDF(self, image_map)
--> 400 text = h2p.unescape(text) # To deal with HTML entities
    401 h2p.feed(text)

AttributeError: 'HTML2FPDF' object has no attribute 'unescape'

@Lucas-C
Copy link
Copy Markdown

Lucas-C commented Sep 29, 2022

pyfpdf is not maintained anymore, have you tried using fpdf2?
https://pyfpdf.github.io/fpdf2/

@asafravid
Copy link
Copy Markdown
Author

pyfpdf is not maintained anymore, have you tried using fpdf2?
https://pyfpdf.github.io/fpdf2/

I haven’t
Any good?

@Lucas-C
Copy link
Copy Markdown

Lucas-C commented Sep 29, 2022

Any good?

Yes!
Disclaimer: I am its maintainer 😊

@asafravid
Copy link
Copy Markdown
Author

asafravid commented Sep 29, 2022

Cool
I see it was forked from this repo.
I'll try yours and see if I get the same issue there (to which the PR fix relates)

fpdf2 is a library for simple & fast PDF document generation in Python.
It is a fork and the successor of PyFPDF

(cf. history).

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

Successfully merging this pull request may close these issues.

3 participants