49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
|
import configparser
|
||
|
|
||
|
class Config:
|
||
|
|
||
|
|
||
|
def generate_config(self):
|
||
|
print('config: generating configuration file')
|
||
|
self.config = configparser.ConfigParser()
|
||
|
self.config['trigger'] = {
|
||
|
'active': '$rtex',
|
||
|
'raw': '$rawtex',
|
||
|
'equation': ';;',
|
||
|
'command': '$'
|
||
|
}
|
||
|
self.config['packages'] = [
|
||
|
'xcolor',
|
||
|
'amsmath'
|
||
|
]
|
||
|
self.config['package_code'] = '\\usepackage{@PKG_NAME}'
|
||
|
self.config['precode'] = [
|
||
|
'\\documentclass{article}',
|
||
|
'@INC_PKGS',
|
||
|
'\\begin{document}',
|
||
|
'\\color{gray}'
|
||
|
]
|
||
|
self.config['postcode'] = [
|
||
|
'\\pagenumbering{gobble}',
|
||
|
'\\end{document}'
|
||
|
]
|
||
|
self.config['login'] = {
|
||
|
'type': 'user',
|
||
|
'token': 'Token goes here'
|
||
|
}
|
||
|
self.write_config()
|
||
|
|
||
|
def write_config(self):
|
||
|
print('config: updating configuration file')
|
||
|
with open('config.ini', 'w') as cf:
|
||
|
self.config.write(cf)
|
||
|
print('config: written, syncing internal config representation')
|
||
|
self.read_config()
|
||
|
|
||
|
def read_config(self):
|
||
|
print('config: updating internal config from file')
|
||
|
self.config.read('config.ini')
|
||
|
|
||
|
def watch_config(self):
|
||
|
print('config: setting up file watcher')
|