mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Merge pull request #379 from lahdjirayhan/fix-path-sep
Fix issue of path separators and UnicodeDecodeError on adoptGenerator.py
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@ import scipy
|
|||||||
|
|
||||||
genList = []
|
genList = []
|
||||||
|
|
||||||
|
SEP = os.sep
|
||||||
class Generator:
|
class Generator:
|
||||||
def __init__(self, title, id, func, kwargs):
|
def __init__(self, title, id, func, kwargs):
|
||||||
self.title = title
|
self.title = title
|
||||||
@@ -18,10 +19,10 @@ class Generator:
|
|||||||
|
|
||||||
(filename, line_number, function_name,
|
(filename, line_number, function_name,
|
||||||
text) = traceback.extract_stack()[-2]
|
text) = traceback.extract_stack()[-2]
|
||||||
funcname = filename[filename.rfind('/'):].strip()
|
funcname = filename[filename.rfind(SEP):].strip()
|
||||||
funcname = funcname[1:-3]
|
funcname = funcname[1:-3]
|
||||||
subjectname = filename[:filename.rfind('/')].strip()
|
subjectname = filename[:filename.rfind(SEP)].strip()
|
||||||
subjectname = subjectname[subjectname.rfind('/'):].strip()
|
subjectname = subjectname[subjectname.rfind(SEP):].strip()
|
||||||
subjectname = subjectname[1:]
|
subjectname = subjectname[1:]
|
||||||
genList.append([id, title, self, funcname, subjectname, kwargs])
|
genList.append([id, title, self, funcname, subjectname, kwargs])
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ def main():
|
|||||||
for write_line in write_list:
|
for write_line in write_list:
|
||||||
lines.append(write_line)
|
lines.append(write_line)
|
||||||
|
|
||||||
with open('../README.md', "w") as g:
|
with open('../README.md', "w", encoding = 'utf-8') as g:
|
||||||
g.writelines(lines)
|
g.writelines(lines)
|
||||||
|
|
||||||
print("New README.md table generated")
|
print("New README.md table generated")
|
||||||
|
|||||||
Reference in New Issue
Block a user