move regex for parsing lecture title into config file
This commit is contained in:
parent
a49f49a60b
commit
7c350fcb85
3 changed files with 8 additions and 7 deletions
|
@ -19,4 +19,5 @@ DEFAULT_MASTER_FILE_NAME = 'master.tex'
|
||||||
MAX_LEN = 40
|
MAX_LEN = 40
|
||||||
LECTURE_START_MARKER = 'start lectures'
|
LECTURE_START_MARKER = 'start lectures'
|
||||||
LECTURE_END_MARKER = 'end lectures'
|
LECTURE_END_MARKER = 'end lectures'
|
||||||
DEFAULT_NEW_LECTURE_HEADER = r'\lecture{{{number}}}{{{date}}}{{}}'
|
DEFAULT_NEW_LECTURE_HEADER = r'\lecture{{{number}}}{{{date}}}{{{title}}}'
|
||||||
|
DEFAULT_LECTURE_SEARCH_REGEX = r'lecture{(.*?)}{(.*?)}{(.*)}'
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
from pathlib import Path, PurePath
|
|
||||||
import os
|
|
||||||
import locale
|
import locale
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from config import DATE_FORMAT, LOCALE, DEFAULT_MASTER_FILE_NAME, DEFAULT_NEW_LECTURE_HEADER
|
from config import DATE_FORMAT, LOCALE, DEFAULT_NEW_LECTURE_HEADER, DEFAULT_LECTURE_SEARCH_REGEX
|
||||||
from utils import get_week
|
from utils import get_week
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
@ -25,7 +24,7 @@ class Lecture:
|
||||||
def __init__(self, file_path, course):
|
def __init__(self, file_path, course):
|
||||||
with file_path.open() as f:
|
with file_path.open() as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
lecture_match = re.search(r'lecture{(.*?)}{(.*?)}{(.*)}', line)
|
lecture_match = re.search(DEFAULT_LECTURE_SEARCH_REGEX, line)
|
||||||
if lecture_match:
|
if lecture_match:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -112,7 +111,7 @@ class Lectures(list):
|
||||||
date = today.strftime(DATE_FORMAT)
|
date = today.strftime(DATE_FORMAT)
|
||||||
|
|
||||||
vimtex_root_str = f"%! TEX root = {str(os.path.relpath(self.notes.master_file, self.root))}\n"
|
vimtex_root_str = f"%! TEX root = {str(os.path.relpath(self.notes.master_file, self.root))}\n"
|
||||||
header_str = DEFAULT_NEW_LECTURE_HEADER.format(number=new_lecture_number, date=date)
|
header_str = DEFAULT_NEW_LECTURE_HEADER.format(number=new_lecture_number, date=date, title='Untitled')
|
||||||
new_lecture_path.touch()
|
new_lecture_path.touch()
|
||||||
new_lecture_path.write_text(vimtex_root_str + header_str)
|
new_lecture_path.write_text(vimtex_root_str + header_str)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from lectures import Lectures, number2filename
|
from lectures import Lectures, number2filename
|
||||||
from config import *
|
from config import DEFAULT_MASTER_FILE_NAME, LECTURE_START_MARKER, LECTURE_END_MARKER
|
||||||
|
|
||||||
|
|
||||||
class Notes:
|
class Notes:
|
||||||
|
|
Loading…
Reference in a new issue