A math problem generator, created for the purpose of giving self-studying students and teaching organizations the means to easily get access to high-quality, generated math problems to suit their needs.
In summary: makeReadme creates empty table of generators in README. I believe this is because my OS is Windows.
OS: Windows 7
IDE: Visual Studio Code
Virtual environment?: Yes
Python: 3.8.5
The problem: I tried to add a new generator, placed inside geometry folder. I then ran the scripts. adoptGenerator.py creates a README file, but its table of available generators are empty. Just the headers exist. However, the __init__ file in mathgenerator/funcs/geometry/ is updated correctly. Thus I suspect that the makeReadme.py script is the culprit.
I tracked down that the problem lies in Generator.__init__:
Notice that the path separator is backslash \ and not forward-slash /. Consequently, the method .rfind('/') does not work as intended in finding funcname and subjectname within this filename.
I believe that A simple, minimal fix for this is to use import os; os.sep.
Another way is to use pathlib library for path-like string manipulation instead of manipulating it directly. It is supported on Python 3.4+.
In summary:
makeReadme
creates empty table of generators in README. I believe this is because my OS is Windows.OS: Windows 7 IDE: Visual Studio Code Virtual environment?: Yes Python: 3.8.5
The problem: I tried to add a new generator, placed inside
geometry
folder. I then ran the scripts.adoptGenerator.py
creates a README file, but its table of available generators are empty. Just the headers exist. However, the__init__
file inmathgenerator/funcs/geometry/
is updated correctly. Thus I suspect that themakeReadme.py
script is the culprit.I tracked down that the problem lies in
Generator.__init__
:https://github.com/lukew3/mathgenerator/blob/f3f74afc4ae5780768622eebd7837c58a6cff4be/mathgenerator/__init__.py#L19-L26
When I run the script inside using a debugger, I find that the variable
filename
has the following value:e:\\git-line\\lukew3-mathgenerator\\mathgenerator\\mathgenerator\\funcs\\algebra\\combine_like_terms.py
Notice that the path separator is backslash
\
and not forward-slash/
. Consequently, the method.rfind('/')
does not work as intended in findingfuncname
andsubjectname
within thisfilename
.I believe that A simple, minimal fix for this is to use
import os; os.sep
.Another way is to use
pathlib
library for path-like string manipulation instead of manipulating it directly. It is supported on Python 3.4+.