本文整理汇总了Python中gramps.gen.lib.Note类的典型用法代码示例。如果您正苦于以下问题:Python Note类的具体用法?Python Note怎么用?Python Note使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Note类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_struct
def from_struct(struct):
"""
Given a struct with metadata, create a Gramps object.
"""
from gramps.gen.lib import (Person, Family, Event, Source, Place, Citation,
Repository, MediaObject, Note, Tag)
if isinstance(struct, dict):
if "_class" in struct.keys():
if struct["_class"] == "Person":
return Person.create(Person.from_struct(struct))
elif struct["_class"] == "Family":
return Family.create(Family.from_struct(struct))
elif struct["_class"] == "Event":
return Event.create(Event.from_struct(struct))
elif struct["_class"] == "Source":
return Source.create(Source.from_struct(struct))
elif struct["_class"] == "Place":
return Place.create(Place.from_struct(struct))
elif struct["_class"] == "Citation":
return Citation.create(Citation.from_struct(struct))
elif struct["_class"] == "Repository":
return Repository.create(Repository.from_struct(struct))
elif struct["_class"] == "MediaObject":
return MediaObject.create(MediaObject.from_struct(struct))
elif struct["_class"] == "Note":
return Note.create(Note.from_struct(struct))
elif struct["_class"] == "Tag":
return Tag.create(Tag.from_struct(struct))
raise AttributeError("invalid struct: %s" % struct)
示例2: instance_from_struct
def instance_from_struct(cls, struct):
"""
Given a struct with metadata, create a Gramps object.
self is class when called as a classmethod.
"""
from gramps.gen.lib import (Person, Family, Event, Source, Place, Citation,
Repository, Media, Note, Tag, Date)
if isinstance(struct, dict):
if "_class" in struct.keys():
if struct["_class"] == "Person":
return Person.create(Person.from_struct(struct))
elif struct["_class"] == "Family":
return Family.create(Family.from_struct(struct))
elif struct["_class"] == "Event":
return Event.create(Event.from_struct(struct))
elif struct["_class"] == "Source":
return Source.create(Source.from_struct(struct))
elif struct["_class"] == "Place":
return Place.create(Place.from_struct(struct))
elif struct["_class"] == "Citation":
return Citation.create(Citation.from_struct(struct))
elif struct["_class"] == "Repository":
return Repository.create(Repository.from_struct(struct))
elif struct["_class"] == "Media":
return Media.create(Media.from_struct(struct))
elif struct["_class"] == "Note":
return Note.create(Note.from_struct(struct))
elif struct["_class"] == "Tag":
return Tag.create(Tag.from_struct(struct))
elif struct["_class"] == "Date":
return Date().unserialize(Date.from_struct(struct, full=True))
raise AttributeError("invalid struct: %s" % struct)
示例3: create_event
def create_event(self, description=_("Estimated date"),
type=None, date=None, source=None,
note_text="", modifier=None):
event = Event()
event.set_description(description)
note = Note()
note.handle = create_id()
note.type.set(NoteType.EVENT)
note.set(note_text)
self.db.add_note(note, self.trans)
event.add_note(note.handle)
if type:
event.set_type(EventType(type))
if date:
if modifier:
date.set_modifier(modifier)
date.set_quality(Date.QUAL_ESTIMATED)
date.set_yr_mon_day(date.get_year(), 0, 0)
event.set_date_object(date)
if source:
citation = Citation()
citation.set_reference_handle(source.get_handle())
self.db.add_citation(citation, self.trans)
event.add_citation(citation.get_handle())
self.db.commit_source(source, self.trans)
self.db.add_event(event, self.trans)
return event
示例4: read_family_comment
def read_family_comment(self,line,fields):
if not self.current_family:
LOG.warning("Unknown family of child in line %d!" % self.lineno)
return None
n = Note()
n.set(line)
self.db.add_note(n,self.trans)
self.current_family.add_note(n.handle)
self.db.commit_family(self.current_family,self.trans)
return None
示例5: empty_object
def empty_object(self):
"""Return an empty Note object for comparison for changes.
It is used by the base class L{EditPrimary}.
"""
empty_note = Note();
if self.extratype:
empty_note.set_type(self.extratype[0])
return empty_note
示例6: new_clicked
def new_clicked(self, obj):
"""
Create a new To Do note.
"""
from gramps.gui.editors import EditNote
note = Note()
note.set_type(NoteType.TODO)
try:
EditNote(self.gui.dbstate, self.gui.uistate, [], note)
except AttributeError:
pass
示例7: create_note
def create_note(self, place, data, trans):
new_note = Note()
tag = StyledTextTag(StyledTextTagType.FONTFACE, 'Monospace',
[(0, len(data))])
text = StyledText(data, [tag])
new_note.set_styledtext(text)
note_type = NoteType()
note_type.set((NoteType.CUSTOM, _("Place titles")))
new_note.set_type(note_type)
handle = self.db.add_note(new_note, trans)
place.add_note(handle)
示例8: add_note
def add_note(self, gid, text, trans):
new_note = self.db.get_note_from_gramps_id(gid)
if new_note:
new_note.set(text)
self.db.commit_note(new_note, trans)
msg = _("Add Test Note")
else:
new_note = Note(text)
new_note.set_gramps_id(gid)
self.db.add_note(new_note, trans)
msg = _("Add Test Note")
trans.set_description(msg)
示例9: call_editor
def call_editor(self, obj=None):
if obj is None:
note = Note()
note.set_type(self.get_notetype())
func = self.obj_added
else:
note = obj
func = self.after_edit
try:
EditNote(self.dbstate, self.uistate, self.track,
note, func)
except WindowActiveError:
pass
示例10: read_pevent_line
def read_pevent_line(self, event, fields):
name = fields[2] + fields[1]
try:
self.person = self.ikeys[name]
# check key on {ikey}
except:
self.person = "(TO_CHECK: %s)" % fields[1:]
#GrampsImportError()
lastname = fields[1]
firstname = fields[2]
self.current_person = self.get_or_create_person(firstname, lastname)
#name = Name()
#name.set_type(NameType(NameType.BIRTH))
#name.set_first_name(firstname)
#surname_obj = name.get_primary_surname()
#surname_obj.set_surname(surname)
#self.current_person.set_primary_name(name)
if pevents_map.get(event[0:5]) == None:
return #need to fix custom event types not in the map
self.current_event = None
# get events for the current person
for evr in self.current_person.get_event_ref_list():
ev = self.db.get_event_from_handle(evr.get_reference_handle())
if ev.get_type() == pevents_map.get(event[0:5]):
self.current_event = ev # found. Need to also check EventRef role
if not self.current_event: # No event found create a new one
self.current_event = self.new_gwplus_pevent(event)
while True:
line = self.get_next_line()
if line and line[0:5] in pevents_map:
self.current_mode = "person_event"
self.current_event = self.new_gwplus_pevent(line)
elif line and line[0:4] == "note":
n = Note()
n.set(line[5:])
self.db.add_note(n, self.trans)
if self.current_event:
self.current_event.add_note(n.handle)
self.db.commit_event(self.current_event, self.trans)
else:
print('note', n.handle)
else:
self.current_mode = None
#self.db.commit_person(self.current_person,self.trans)
break
示例11: __init__
def __init__(self, dbstate, uistate, clicked):
self.clicked_func = clicked
self.filter_id = widgets.BasicEntry()
self.filter_text = widgets.BasicEntry()
self.note = Note()
self.note.set_type((NoteType.CUSTOM,''))
self.ntype = Gtk.ComboBox(has_entry=True)
if dbstate.is_open():
self.custom_types = dbstate.db.get_note_types()
else:
self.custom_types = []
self.event_menu = widgets.MonitoredDataType(
self.ntype,
self.note.set_type,
self.note.get_type,
False, # read-only?
self.custom_types)
self.filter_regex = Gtk.CheckButton(label=_('Use regular expressions'))
self.tag = Gtk.ComboBox()
self.generic = Gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Note")
示例12: importData
def importData(db, filename, user):
"""Function called by Gramps to import data on persons in CSV format."""
db.disable_signals()
try:
with DbTxn(_("JSON import"), db, batch=True) as trans:
with OpenFileOrStdin(filename, encoding="utf-8") as fp:
line = fp.readline()
while line:
data = json.loads(line)
if data["_class"] == "Person":
obj = Person.create(Person.from_struct(data))
db.add_person(obj, trans)
elif data["_class"] == "Family":
obj = Family.create(Family.from_struct(data))
db.add_family(obj, trans)
elif data["_class"] == "Event":
obj = Event.create(Event.from_struct(data))
db.add_event(obj, trans)
elif data["_class"] == "Media":
obj = Media.create(Media.from_struct(data))
db.add_media(obj, trans)
elif data["_class"] == "Repository":
obj = Repository.create(Repository.from_struct(data))
db.add_repository(obj, trans)
elif data["_class"] == "Tag":
obj = Tag.create(Tag.from_struct(data))
db.add_tag(obj, trans)
elif data["_class"] == "Source":
obj = Source.create(Source.from_struct(data))
db.add_source(obj, trans)
elif data["_class"] == "Citation":
obj = Citation.create(Citation.from_struct(data))
db.add_citation(obj, trans)
elif data["_class"] == "Note":
obj = Note.create(Note.from_struct(data))
db.add_note(obj, trans)
elif data["_class"] == "Place":
obj = Place.create(Place.from_struct(data))
db.add_place(obj, trans)
else:
LOG.warn("ignored: " + data)
line = fp.readline()
except EnvironmentError as err:
user.notify_error(_("%s could not be opened\n") % filename, str(err))
db.enable_signals()
db.request_rebuild()
示例13: new_clicked
def new_clicked(self, obj):
"""
Create a new To Do note.
"""
nav_type = self.uistate.viewmanager.active_page.navigation_type()
active_handle = self.get_active(nav_type)
if active_handle:
from gramps.gui.editors import EditNote
note = Note()
note.set_type(NoteType.TODO)
try:
EditNote(self.gui.dbstate, self.gui.uistate, [], note, self.created)
except WindowActiveError:
pass
else:
WarningDialog(_("No active object"),
_("First select the object to which you want to attach a note")
+ _(":") + _(nav_type),
parent=self.uistate.window)
示例14: add_button_clicked
def add_button_clicked(self, obj):
"""
Create a new Note instance and call the EditNote editor with the new
note.
Called when the Add button is clicked.
If the window already exists (WindowActiveError), we ignore it.
This prevents the dialog from coming up twice on the same object.
"""
note = Note()
if self.notetype :
note.set_type(self.notetype)
try:
from .. import EditNote
EditNote(self.dbstate, self.uistate, self.track,
note, self.add_callback,
self.callertitle, extratype = [self.notetype])
except WindowActiveError:
pass
示例15: _read_notes_lines
def _read_notes_lines(self, note_tag):
note_txt = ""
while True:
line = self.get_next_line()
if line is None:
break
fields = line.split(" ")
if fields[0] == "end" and fields[1] == note_tag:
break
elif fields[0] == "beg":
continue
else:
if note_txt:
note_txt = note_txt + "\n" + line
else:
note_txt = note_txt + line
if note_txt:
n = Note()
n.set(note_txt)
self.db.add_note(n,self.trans)
return n.handle
return None