Changed init of texnote to pass tests.
This commit is contained in:
parent
ebff1bb4e4
commit
1f91712b31
@ -24,12 +24,6 @@ class TexnotePlugin(PapersPlugin):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.name = TEXNOTE_SECTION
|
self.name = TEXNOTE_SECTION
|
||||||
if not files.check_directory(TEXNOTE_DIR):
|
|
||||||
os.mkdir(TEXNOTE_DIR)
|
|
||||||
if not files.check_file(TEXNOTE_TEMPLATE):
|
|
||||||
shutil.copy(TEXNOTE_DEFAULT_TEMPLATE, TEXNOTE_TEMPLATE)
|
|
||||||
if not files.check_file(TEXNOTE_STYLE):
|
|
||||||
shutil.copy(TEXNOTE_DEFAULT_STYLE, TEXNOTE_STYLE)
|
|
||||||
|
|
||||||
self.texcmds = collections.OrderedDict([
|
self.texcmds = collections.OrderedDict([
|
||||||
('remove', self.remove),
|
('remove', self.remove),
|
||||||
@ -38,6 +32,14 @@ class TexnotePlugin(PapersPlugin):
|
|||||||
('edit_template', self.edit_template),
|
('edit_template', self.edit_template),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def ensure_init(self):
|
||||||
|
if not files.check_directory(TEXNOTE_DIR):
|
||||||
|
os.mkdir(TEXNOTE_DIR)
|
||||||
|
if not files.check_file(TEXNOTE_TEMPLATE):
|
||||||
|
shutil.copy(TEXNOTE_DEFAULT_TEMPLATE, TEXNOTE_TEMPLATE)
|
||||||
|
if not files.check_file(TEXNOTE_STYLE):
|
||||||
|
shutil.copy(TEXNOTE_DEFAULT_STYLE, TEXNOTE_STYLE)
|
||||||
|
|
||||||
def parser(self, subparsers):
|
def parser(self, subparsers):
|
||||||
parser = subparsers.add_parser(self.name, help='edit advance note in latex')
|
parser = subparsers.add_parser(self.name, help='edit advance note in latex')
|
||||||
sub = parser.add_subparsers(title='valid texnote commands', dest='texcmd')
|
sub = parser.add_subparsers(title='valid texnote commands', dest='texcmd')
|
||||||
@ -56,6 +58,8 @@ class TexnotePlugin(PapersPlugin):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def command(self, args):
|
def command(self, args):
|
||||||
|
self.ensure_init()
|
||||||
|
|
||||||
texcmd = args.texcmd
|
texcmd = args.texcmd
|
||||||
del args.texcmd
|
del args.texcmd
|
||||||
self.texcmds[texcmd](**vars(args))
|
self.texcmds[texcmd](**vars(args))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user