Added events for edit command
also added comments to events functions to list what uses them
This commit is contained in:
parent
4862860a7e
commit
6b74683fb4
@ -7,6 +7,7 @@ from ..uis import get_ui
|
|||||||
from ..endecoder import EnDecoder
|
from ..endecoder import EnDecoder
|
||||||
from ..utils import resolve_citekey
|
from ..utils import resolve_citekey
|
||||||
from ..completion import CiteKeyCompletion
|
from ..completion import CiteKeyCompletion
|
||||||
|
from ..events import ModifyEvent
|
||||||
|
|
||||||
|
|
||||||
def parser(subparsers, conf):
|
def parser(subparsers, conf):
|
||||||
@ -88,4 +89,8 @@ def command(conf, args):
|
|||||||
# else edit again
|
# else edit again
|
||||||
# Also handle malformed bibtex and metadata
|
# Also handle malformed bibtex and metadata
|
||||||
|
|
||||||
|
if meta:
|
||||||
|
ModifyEvent(citekey, "metadata").send()
|
||||||
|
else:
|
||||||
|
ModifyEvent(citekey, "bibtex").send()
|
||||||
rp.close()
|
rp.close()
|
||||||
|
@ -35,27 +35,35 @@ class PaperEvent(Event):
|
|||||||
def description(self):
|
def description(self):
|
||||||
return self._format.format(citekey=self.citekey)
|
return self._format.format(citekey=self.citekey)
|
||||||
|
|
||||||
|
# Used by repo.push_paper()
|
||||||
class AddEvent(PaperEvent):
|
class AddEvent(PaperEvent):
|
||||||
_format = "Adds paper {citekey}."
|
_format = "Adds paper {citekey}."
|
||||||
|
|
||||||
|
# Used by repo.push_doc()
|
||||||
class DocAddEvent(PaperEvent):
|
class DocAddEvent(PaperEvent):
|
||||||
_format = "Adds document {citekey}."
|
_format = "Adds document for {citekey}."
|
||||||
|
|
||||||
|
|
||||||
|
# Used by repo.remove_paper()
|
||||||
class RemoveEvent(PaperEvent):
|
class RemoveEvent(PaperEvent):
|
||||||
_format = "Removes paper {citekey}."
|
_format = "Removes paper for {citekey}."
|
||||||
|
|
||||||
|
|
||||||
|
# Used by repo.remove_doc()
|
||||||
class DocRemoveEvent(PaperEvent):
|
class DocRemoveEvent(PaperEvent):
|
||||||
_format = "Removes document {citekey}."
|
_format = "Removes document for {citekey}."
|
||||||
|
|
||||||
|
|
||||||
|
# Used by commands.edit_cmd.command()
|
||||||
class ModifyEvent(PaperEvent):
|
class ModifyEvent(PaperEvent):
|
||||||
_format = "Modifies paper {citekey}."
|
_format = "Modifies {file_type} file of {citekey}."
|
||||||
|
|
||||||
|
def __init__(self, citekey, file_type):
|
||||||
|
super(ModifyEvent, self).__init__(citekey)
|
||||||
|
self.file_type = file_type
|
||||||
|
|
||||||
|
@property
|
||||||
|
def description(self):
|
||||||
|
return self._format.format(citekey=self.citekey, file_type=self.file_type)
|
||||||
|
|
||||||
|
# Used by repo.rename_paper()
|
||||||
class RenameEvent(PaperEvent):
|
class RenameEvent(PaperEvent):
|
||||||
_format = "Renames paper {old_citekey} to {citekey}."
|
_format = "Renames paper {old_citekey} to {citekey}."
|
||||||
|
|
||||||
@ -68,5 +76,6 @@ class RenameEvent(PaperEvent):
|
|||||||
def description(self):
|
def description(self):
|
||||||
return self._format.format(citekey=self.citekey, old_citekey=self.old_citekey)
|
return self._format.format(citekey=self.citekey, old_citekey=self.old_citekey)
|
||||||
|
|
||||||
|
# Used by commands.note_cmd.command()
|
||||||
class NoteEvent(PaperEvent):
|
class NoteEvent(PaperEvent):
|
||||||
_format = "Modifies note {citekey}"
|
_format = "Modifies note {citekey}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user