bulshit
This commit is contained in:
parent
70eec18c1d
commit
a880f5b677
@ -1,5 +1,6 @@
|
||||
from .. import repo
|
||||
from .. import color
|
||||
from .. import configs
|
||||
from .helpers import add_references_argument, parse_references
|
||||
|
||||
|
||||
@ -18,4 +19,12 @@ def command(config, ui, references):
|
||||
sure = ui.input_yn(question=are_you_sure, default='n')
|
||||
if sure:
|
||||
for c in citekeys:
|
||||
# Extend with plugin commands, think about how to create a smart registering system for plugins
|
||||
plugs = configs.get_plugins(config)
|
||||
for plugname in plugs:
|
||||
module_name = 'papers.plugins.' + plugname + '.' + plugname + '_cmd'
|
||||
plug = __import__(module_name, globals(), locals(), ['callback'], -1)
|
||||
plug.callback(config, ui, 'remove', c)
|
||||
|
||||
rp.remove(c)
|
||||
|
||||
|
@ -27,20 +27,29 @@ TEXNOTE_DIR = 'texnote'
|
||||
|
||||
def parser(subparsers, config):
|
||||
parser = subparsers.add_parser('texnote', help="edit advance note in latex")
|
||||
parser.add_argument('-v', '--view', action='store_true', help='open the paper in a pdf viewer', default=None)
|
||||
add_references_argument(parser, single=True)
|
||||
parser.add_argument('-v', '--view', action='store_true', help='open the paper in a pdf viewer', default=None)
|
||||
return parser
|
||||
|
||||
|
||||
def command(config, ui, ref, view):
|
||||
ui.print_('texnote test')
|
||||
def command(config, ui, reference, view):
|
||||
if view is not None:
|
||||
subprocess.Popen(['papers', 'open', ref])
|
||||
|
||||
subprocess.Popen(['papers', 'open', reference])
|
||||
# check if citekey exist
|
||||
open_texnote(config, ui, ref)
|
||||
open_texnote(config, ui, reference)
|
||||
|
||||
|
||||
def callback(config, ui, name, ref):
|
||||
if name == 'remove':
|
||||
rp = repo.Repository.from_directory(config)
|
||||
paper = rp.get_paper(parse_reference(ui, rp, ref))
|
||||
|
||||
if paper.metadata.has_key('texnote'):
|
||||
os.remove(paper.metadata['texnote'])
|
||||
paper.metadata.pop('texnote')
|
||||
metapath = rp.path_to_paper_file(paper.citekey, 'meta')
|
||||
files.save_meta(paper.metadata, metapath)
|
||||
|
||||
|
||||
def open_texnote(config, ui, ref):
|
||||
rp = repo.Repository.from_directory(config)
|
||||
@ -48,7 +57,7 @@ def open_texnote(config, ui, ref):
|
||||
|
||||
if not paper.metadata.has_key('texnote'):
|
||||
texnote_dir = os.path.join(rp.papersdir, TEXNOTE_DIR)
|
||||
# if folder does not exist create it
|
||||
# if folder does not exist create it, this should be relative
|
||||
if not os.path.exists(texnote_dir):
|
||||
os.mkdir(texnote_dir)
|
||||
texnote_path = os.path.join(texnote_dir, paper.citekey + '.tex')
|
||||
|
4
setup.py
4
setup.py
@ -10,9 +10,9 @@ setup(name='papers',
|
||||
description='research papers manager',
|
||||
requires=['pybtex'],
|
||||
packages=find_packages(),
|
||||
#package_data={'': ['*.tex']},
|
||||
scripts=['papers/papers']
|
||||
)
|
||||
|
||||
# TODO include package data from plugins
|
||||
# Jonathan could not make it works (08/06/2013)
|
||||
# TODO include proper package data from plugins (08/06/2013)
|
||||
# should we use MANIFEST.in or package_data = ..., or both
|
||||
|
Loading…
x
Reference in New Issue
Block a user