The Wayback Machine - https://web.archive.org/web/20220903121848/https://github.com/atcoder/ac-library/issues/111
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

generate_document.py breaking in python version 3.9 #111

Closed
rocka0 opened this issue Mar 4, 2021 · 2 comments
Closed

generate_document.py breaking in python version 3.9 #111

rocka0 opened this issue Mar 4, 2021 · 2 comments

Comments

@rocka0
Copy link

rocka0 commented Mar 4, 2021

I had cloned the ACL repository and I tried to convert all the markdown files into HTML files using the generate_document.py script which is given in the /tools directory when I ran into this error:

❯ ./generate_document.py
12:45:37 [INFO] start converting, lang=en
12:45:37 [INFO] convert ../document_en/twosat.md
Traceback (most recent call last):
File "/home/tusky/Tushar/ac-library/tools/./generate_document.py", line 89, in
statement = convert(open(md_file).read(), base_dir, opts.tag)
File "/home/tusky/Tushar/ac-library/tools/./generate_document.py", line 50, in convert
if tag == 'production' or re.match(r'v[0-9].[0-9]', tag):
File "/usr/lib/python3.9/re.py", line 191, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object

After a little bit of googling, I was brought to an answer on Stack Overflow which urged me to wrap the variable tag with the str function which seemed to do the trick.

Thus changing line 50 of generate_document.py to

if tag == 'production' or re.match(r'v[0-9]\.[0-9]', str(tag)):

seems to do the trick and I can now see the desired output:

❯ ./generate_document.py
12:50:49 [INFO] start converting, lang=en
12:50:49 [INFO] convert ../document_en/twosat.md
12:50:49 [INFO] read example: twosat_practice
12:50:49 [INFO] convert ../document_en/dsu.md
12:50:49 [INFO] read example: dsu_practice
12:50:49 [INFO] convert ../document_en/maxflow.md
12:50:49 [INFO] read example: maxflow_practice
12:50:49 [INFO] convert ../document_en/appendix.md
12:50:49 [INFO] convert ../document_en/scc.md
12:50:49 [INFO] read example: scc_practice
12:50:49 [INFO] convert ../document_en/index.md
12:50:49 [INFO] convert ../document_en/convolution.md
12:50:49 [INFO] read example: convolution_int_practice
12:50:49 [INFO] read example: convolution_practice
12:50:49 [INFO] convert ../document_en/lazysegtree.md
12:50:49 [INFO] read example: lazyseg_practice1
12:50:49 [INFO] read example: lazyseg_practice2
12:50:49 [INFO] convert ../document_en/modint.md
12:50:49 [INFO] read example: modint_usage
12:50:49 [INFO] convert ../document_en/fenwicktree.md
12:50:49 [INFO] read example: fenwick_practice
12:50:49 [INFO] convert ../document_en/string.md
12:50:49 [INFO] read example: sa_usage
12:50:49 [INFO] read example: sa_practice
12:50:49 [INFO] convert ../document_en/segtree.md
12:50:49 [INFO] read example: segtree_practice
12:50:49 [INFO] convert ../document_en/mincostflow.md
12:50:49 [INFO] read example: mincostflow_practice
12:50:49 [INFO] convert ../document_en/math.md
12:50:49 [INFO] read example: floor_sum_practice
12:50:49 [INFO] start converting, lang=ja
12:50:49 [INFO] convert ../document_ja/twosat.md
12:50:49 [INFO] read example: twosat_practice
12:50:49 [INFO] convert ../document_ja/dsu.md
12:50:49 [INFO] read example: dsu_practice
12:50:49 [INFO] convert ../document_ja/maxflow.md
12:50:49 [INFO] read example: maxflow_practice
12:50:49 [INFO] convert ../document_ja/appendix.md
12:50:49 [INFO] convert ../document_ja/scc.md
12:50:49 [INFO] read example: scc_practice
12:50:49 [INFO] convert ../document_ja/index.md
12:50:49 [INFO] convert ../document_ja/convolution.md
12:50:49 [INFO] read example: convolution_int_practice
12:50:49 [INFO] read example: convolution_practice
12:50:49 [INFO] convert ../document_ja/lazysegtree.md
12:50:49 [INFO] read example: lazyseg_practice1
12:50:49 [INFO] read example: lazyseg_practice2
12:50:49 [INFO] convert ../document_ja/modint.md
12:50:49 [INFO] read example: modint_usage
12:50:49 [INFO] convert ../document_ja/fenwicktree.md
12:50:49 [INFO] read example: fenwick_practice
12:50:49 [INFO] convert ../document_ja/string.md
12:50:49 [INFO] read example: sa_usage
12:50:49 [INFO] read example: sa_practice
12:50:49 [INFO] convert ../document_ja/segtree.md
12:50:49 [INFO] read example: segtree_practice
12:50:49 [INFO] convert ../document_ja/mincostflow.md
12:50:49 [INFO] read example: mincostflow_practice
12:50:49 [INFO] convert ../document_ja/math.md
12:50:49 [INFO] read example: floor_sum_practice

@yosupo06
Copy link
Collaborator

yosupo06 commented Mar 5, 2021

Please try

./generate_document.py --tag your_ac_library

We use --tag for specify the version of the library (e.g. master, v1.4, production, ..) and this script fails without this argument.

yosupo06 added a commit that referenced this issue Mar 5, 2021
@rocka0
Copy link
Author

rocka0 commented Mar 5, 2021

Thanks a lot @yosupo06 , adding --tag master onto the ./generate_document.py seems to fix the issue, the script now runs as expected without any errors. I think making --tag mandatory as you have in 83c14d0 should do the trick.

@rocka0 rocka0 closed this as completed Mar 5, 2021
yosupo06 added a commit that referenced this issue Mar 5, 2021
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