|
|
@ -5,18 +5,20 @@ import collections
|
|
|
|
|
|
|
|
|
|
|
|
from ... import repo
|
|
|
|
from ... import repo
|
|
|
|
from ... import files
|
|
|
|
from ... import files
|
|
|
|
from ...configs import config
|
|
|
|
|
|
|
|
from ...uis import get_ui
|
|
|
|
from ...uis import get_ui
|
|
|
|
|
|
|
|
from ...configs import config
|
|
|
|
from ...plugins import PapersPlugin
|
|
|
|
from ...plugins import PapersPlugin
|
|
|
|
|
|
|
|
from ...events import RemoveEvent, RenameEvent, AddEvent
|
|
|
|
from ...commands.helpers import add_references_argument, parse_reference
|
|
|
|
from ...commands.helpers import add_references_argument, parse_reference
|
|
|
|
|
|
|
|
|
|
|
|
from ...events import RemoveEvent, RenameEvent, AddEvent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SECTION = 'texnote'
|
|
|
|
SECTION = 'texnote'
|
|
|
|
DIR = os.path.join(config().papers_dir, 'texnote')
|
|
|
|
DIR = os.path.join(config().papers_dir, 'texnote')
|
|
|
|
TPL_DIR = os.path.join(DIR, 'template')
|
|
|
|
TPL_DIR = os.path.join(DIR, 'template')
|
|
|
|
TPL_BODY = os.path.join(TPL_DIR, 'body.tex')
|
|
|
|
TPL_BODY = os.path.join(TPL_DIR, 'body.tex')
|
|
|
|
TPL_STYLE = os.path.join(TPL_DIR, 'style.sty')
|
|
|
|
TPL_STYLE = os.path.join(TPL_DIR, 'style.sty')
|
|
|
|
|
|
|
|
TPL_BIB = os.path.join(TPL_DIR, 'bib.bib')
|
|
|
|
|
|
|
|
|
|
|
|
DFT_BODY = os.path.join(os.path.dirname(__file__), 'default_body.tex')
|
|
|
|
DFT_BODY = os.path.join(os.path.dirname(__file__), 'default_body.tex')
|
|
|
|
DFT_STYLE = os.path.join(os.path.dirname(__file__), 'default_style.sty')
|
|
|
|
DFT_STYLE = os.path.join(os.path.dirname(__file__), 'default_style.sty')
|
|
|
@ -31,6 +33,7 @@ class TexnotePlugin(PapersPlugin):
|
|
|
|
('remove', self.remove),
|
|
|
|
('remove', self.remove),
|
|
|
|
('edit', self.edit),
|
|
|
|
('edit', self.edit),
|
|
|
|
('edit_template', self.edit_template),
|
|
|
|
('edit_template', self.edit_template),
|
|
|
|
|
|
|
|
('generate_bib', self.generate_bib),
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
def _ensure_init(self):
|
|
|
|
def _ensure_init(self):
|
|
|
@ -64,6 +67,8 @@ class TexnotePlugin(PapersPlugin):
|
|
|
|
help='edit the main body', default=None)
|
|
|
|
help='edit the main body', default=None)
|
|
|
|
p.add_argument('-S', '--style', action='store_true',
|
|
|
|
p.add_argument('-S', '--style', action='store_true',
|
|
|
|
help='open the style', default=None)
|
|
|
|
help='open the style', default=None)
|
|
|
|
|
|
|
|
# generate_bib
|
|
|
|
|
|
|
|
p = sub.add_parser('generate_bib', help='generate the latex bib used by texnote')
|
|
|
|
return parser
|
|
|
|
return parser
|
|
|
|
|
|
|
|
|
|
|
|
def command(self, args):
|
|
|
|
def command(self, args):
|
|
|
@ -151,6 +156,10 @@ class TexnotePlugin(PapersPlugin):
|
|
|
|
def rename(self, old_citekey, new_citekey, overwrite=False):
|
|
|
|
def rename(self, old_citekey, new_citekey, overwrite=False):
|
|
|
|
shutil.move(self.get_texfile(old_citekey), self.get_texfile(new_citekey))
|
|
|
|
shutil.move(self.get_texfile(old_citekey), self.get_texfile(new_citekey))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_bib(self):
|
|
|
|
|
|
|
|
cmd = 'papers list -k |xargs papers export >> {}'.format(TPL_BIB)
|
|
|
|
|
|
|
|
os.system(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@AddEvent.listen()
|
|
|
|
@AddEvent.listen()
|
|
|
|
def create(addevent):
|
|
|
|
def create(addevent):
|
|
|
|