From 8ad6600746cb9b494cd2ef8d799ff136b9f7436b Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Wed, 19 Jun 2013 21:14:18 +0000 Subject: [PATCH] GEP 18: automatic update as you type for citation fields, fix in formatting, fix with indicators svn: r22526 --- data/evidencestyle/evidence_style.csv | 20 ++--- gramps/gen/lib/srcattrtype.py | 35 +++++---- gramps/gen/lib/srctemplate.py | 77 ++++++++----------- .../gui/editors/displaytabs/srctemplatetab.py | 4 +- gramps/gui/editors/editsource.py | 9 ++- 5 files changed, 70 insertions(+), 75 deletions(-) diff --git a/data/evidencestyle/evidence_style.csv b/data/evidencestyle/evidence_style.csv index b48192532..2b56c3b8f 100644 --- a/data/evidencestyle/evidence_style.csv +++ b/data/evidencestyle/evidence_style.csv @@ -2958,10 +2958,10 @@ ;;;;;;;;"[WEBSITE]";;;;;"Italics";;;; ;;;;;;;"(";"[URL (DIGITAL LOCATION)]";;":";;;;;;; ;;;;;;;"accessed";"[DATE ACCESSED]";;"),";;;;;;; -;;;;;;;;"[LOCATION]";"Location on Page";".";;;;;;; +;;;;;;;;"[POSITION]";"Location on Page";".";;;;;;; 160;"EE Publications: Periodicals, Broadcasts & Web Miscellanea";"Periodicals";"Journal articles";"Online archives of print journals";"S";"ESM780";;"[AUTHOR]";;",";;"S";;;;; ;;;;;;;;"[TITLE]";"Article Title";",";;;"Quoted";;;; -;;;;;;;;"[LOCATION]";"Location on Page";".";;;;;;; +;;;;;;;;"[POSITION]";"Location on Page";".";;;;;;; 161;"EE Publications: Periodicals, Broadcasts & Web Miscellanea";"Periodicals";"Journal articles";"Online journals";"L";"ESM781";;"[AUTHOR]";;".";"A";"SG";;;;; ;;;;;;;;"[TITLE]";"Article Title";":";"T";;"QuotedCont";;;; ;;;;;;;;"[SUBTITLE]";"Article Subtitle";".";"T";;"QuotedCont";;;; @@ -2980,10 +2980,10 @@ ;;;;;;;;"[FORMAT]";;;;;;;;; ;;;;;;;"(";"[URL (DIGITAL LOCATION)]";;":";;;;;;; ;;;;;;;"accessed";"[DATE ACCESSED]";;"),";;;;;;; -;;;;;;;;"[LOCATION]";"Location on Page";".";;;;;;; +;;;;;;;;"[POSITION]";"Location on Page";".";;;;;;; 161;"EE Publications: Periodicals, Broadcasts & Web Miscellanea";"Periodicals";"Journal articles";"Online journals";"S";"ESM781";;"[AUTHOR]";;",";;"S";;;;; ;;;;;;;;"[TITLE]";"Article Title";",";;;"Quoted";;;; -;;;;;;;;"[LOCATION]";"Location on Page";".";;;;;;; +;;;;;;;;"[POSITION]";"Location on Page";".";;;;;;; 162;"EE Publications: Periodicals, Broadcasts & Web Miscellanea";"Periodicals";"Magazine articles";"Print editions";"L";"ESM782";;"[AUTHOR]";;".";"A";"SG";;;;; ;;;;;;;;"[TITLE]";"Article Title";".";"T";;"Quoted";;;; ;;;;;;;;"[PUBLICATION TITLE]";"Magazine";;;"T";;"Italics";;; @@ -3011,11 +3011,11 @@ ;;;;;;;;"[WEBSITE]";;;;;"Italics";;;; ;;;;;;;"(";"[URL (DIGITAL LOCATION)]";;":";;;;;;; ;;;;;;;"accessed";"[DATE ACCESSED]";;"),";;;;;;; -;;;;;;;;"[LOCATION]";"Location on Page";";";;;;;;; +;;;;;;;;"[POSITION]";"Location on Page";";";;;;;;; ;;;;;;;;"[CREDIT LINE]";;".";;;;;;; 163;"EE Publications: Periodicals, Broadcasts & Web Miscellanea";"Periodicals";"Magazine articles";"Online reprints, random items";"S";"ESM783";;"[AUTHOR]";;",";;"S";;;;; ;;;;;;;;"[TITLE]";"Article Title";",";;;"Quoted";;;; -;;;;;;;;"[LOCATION]";"Location on Page";".";;;;;;; +;;;;;;;;"[POSITION]";"Location on Page";".";;;;;;; 164;"EE Publications: Periodicals, Broadcasts & Web Miscellanea";"Periodicals";"Newsletter articles";"Print editions";"L";"ESM784";;"[AUTHOR]";;".";"A";"SG";;;;; ;;;;;;;;"[TITLE]";"Article Title";".";"T";;"Quoted";;;; ;;;;;;;;"[PUBLICATION TITLE]";"Newsletter";;"T";;"Italics";;;; @@ -3056,11 +3056,11 @@ ;;;;;;;;"[EDITION]";;;;;;;;; ;;;;;;;"(";"[URL (DIGITAL LOCATION)]";;":";;;;;;; ;;;;;;;"accessed";"[DATE ACCESSED]";;"),";;;;;;; -;;;;;;;;"[LOCATION]";"Location on Page";";";;;;;;; +;;;;;;;;"[POSITION]";"Location on Page";";";;;;;;; ;;;;;;;;"[CREDIT LINE]";;".";;;;;;; 166;"EE Publications: Periodicals, Broadcasts & Web Miscellanea";"Periodicals";"Newspaper articles";"Online archives ";"S";"ESM786";;"[AUTHOR]";;",";;"S";;;;; ;;;;;;;;"[TITLE]";"Article Title";",";;;"Quoted";;;; -;;;;;;;;"[LOCATION]";"Location on Page";".";;;;;;; +;;;;;;;;"[POSITION]";"Location on Page";".";;;;;;; 167;"EE Publications: Periodicals, Broadcasts & Web Miscellanea";"Broadcasts & Web Miscellanea";"Blogs";;"L";"ESM787";;"[AUTHOR]";;".";"A";"SG";;;;; ;;;;;;;;"[TITLE]";"Article Title";".";"T";;"Quoted";;;; ;;;;;;;;"[CREATOR]";"Creator of Blog";".";"P";;;;;; @@ -3075,10 +3075,10 @@ ;;;;;;;;"[ISSUE DATE]";"Posting Date";;;;;;;; ;;;;;;;"(";"[URL (DIGITAL LOCATION)]";;":";;;;;;; ;;;;;;;"accessed";"[DATE ACCESSED]";;"),";;;;;;; -;;;;;;;;"[LOCATION]";"Location on Page";".";;;;;;; +;;;;;;;;"[POSITION]";"Location on Page";".";;;;;;; 167;"EE Publications: Periodicals, Broadcasts & Web Miscellanea";"Broadcasts & Web Miscellanea";"Blogs";;"S";"ESM787";;"[AUTHOR]";;",";;"S";;;;; ;;;;;;;;"[TITLE]";"Article Title";",";;;"Quoted";;;; -;;;;;;;;"[LOCATION]";"Location on Page";".";;;;;;; +;;;;;;;;"[POSITION]";"Location on Page";".";;;;;;; 168;"EE Publications: Periodicals, Broadcasts & Web Miscellanea";"Broadcasts & Web Miscellanea";"Discussion forums & lists";;"L";"ESM788";;"[PUBLICATION TITLE]";"Name of Forum";",";"T";;"Italics";;;; ;;;;;;;;"[TYPE]";"Type of Forum";",";"T";;;;;; ;;;;;;;;"[DATE RANGE]";"Date-span Read";".";"T";;;;;; diff --git a/gramps/gen/lib/srcattrtype.py b/gramps/gen/lib/srcattrtype.py index 8c9c99c17..30ebaaf15 100644 --- a/gramps/gen/lib/srcattrtype.py +++ b/gramps/gen/lib/srcattrtype.py @@ -129,8 +129,8 @@ class SrcAttributeType(GrampsType): CHAPTER_PAGES = 223 COLLECTION = 104 COLLECTION_SHORT_VERSION = 111 - COLUMN = 240 - COLUMN_SHORT_VERSION = 241 + COLUMN = 241 + COLUMN_SHORT_VERSION = 242 COMPILER = 166 COMPILER_SHORT_VERSION = 200 CREATION_DATE = 103 @@ -175,8 +175,8 @@ class SrcAttributeType(GrampsType): INSTITUTION_SHORT_VERSION = 178 INTERVIEWER = 161 ISSUE_DATE = 237 - ISSUE_DATE_SHORT_VERSION = 243 - ISSUE_RANGE = 239 + ISSUE_DATE_SHORT_VERSION = 244 + ISSUE_RANGE = 240 ITEM_OF_INTEREST = 122 ITEM_OF_INTEREST_SHORT_VERSION = 153 JURISDICTION = 183 @@ -195,7 +195,8 @@ class SrcAttributeType(GrampsType): PART = 231 PLACE_CREATED = 157 POSITION = 180 - POSTING_DATE = 242 + POSITION_SHORT_VERSION = 239 + POSTING_DATE = 243 PROFESSIONAL_CREDENTIALS = 145 PROVENANCE = 167 PUBLICATION_FORMAT = 215 @@ -205,7 +206,7 @@ class SrcAttributeType(GrampsType): PUBLICATION_YEAR = 139 PUBLICATION_YEAR_SHORT_VERSION = 203 PUBLISHER = 138 - PUB_INFO = 244 + PUB_INFO = 245 RECIPIENT = 129 RECIPIENT_SHORT_VERSION = 133 RELATIONSHIP = 168 @@ -308,6 +309,7 @@ class SrcAttributeType(GrampsType): EDITOR_SHORT_VERSION, ACT_SHORT_VERSION, SESSION_SHORT_VERSION, + POSITION_SHORT_VERSION, COLUMN_SHORT_VERSION, ISSUE_DATE_SHORT_VERSION, ] @@ -397,6 +399,7 @@ class SrcAttributeType(GrampsType): (PART, _("Part"), "Part"), (PLACE_CREATED, _("Place created"), "Place created"), (POSITION, _("Position"), "Position"), + (POSITION_SHORT_VERSION, _("Position (Short)"), "Position (Short)"), (POSTING_DATE, _("Posting date"), "Posting date"), (PROFESSIONAL_CREDENTIALS, _("Professional credentials"), "Professional credentials"), (PROVENANCE, _("Provenance"), "Provenance"), @@ -7847,7 +7850,7 @@ class SrcAttributeType(GrampsType): None, None), ('accessed', DATE_ACCESSED, _(''), '),', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', LOCATION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, + ('', POSITION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), ], REF_TYPE_S: [ @@ -7855,7 +7858,7 @@ class SrcAttributeType(GrampsType): None, None), ('', TITLE, _('Article Title'), ',', STYLE_QUOTE, False, False, EMPTY, EMPTY, None, None), - ('', LOCATION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, + ('', POSITION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), ], }, @@ -7899,7 +7902,7 @@ class SrcAttributeType(GrampsType): None, None), ('accessed', DATE_ACCESSED, _(''), '),', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', LOCATION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, + ('', POSITION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), ], REF_TYPE_S: [ @@ -7907,7 +7910,7 @@ class SrcAttributeType(GrampsType): None, None), ('', TITLE, _('Article Title'), ',', STYLE_QUOTE, False, False, EMPTY, EMPTY, None, None), - ('', LOCATION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, + ('', POSITION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), ], }, @@ -7977,7 +7980,7 @@ class SrcAttributeType(GrampsType): None, None), ('accessed', DATE_ACCESSED, _(''), '),', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', LOCATION, _('Location on Page'), ';', EMPTY, False, False, EMPTY, EMPTY, + ('', POSITION, _('Location on Page'), ';', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', CREDIT_LINE, _(''), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -7987,7 +7990,7 @@ class SrcAttributeType(GrampsType): None, None), ('', TITLE, _('Article Title'), ',', STYLE_QUOTE, False, False, EMPTY, EMPTY, None, None), - ('', LOCATION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, + ('', POSITION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), ], }, @@ -8091,7 +8094,7 @@ class SrcAttributeType(GrampsType): None, None), ('accessed', DATE_ACCESSED, _(''), '),', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', LOCATION, _('Location on Page'), ';', EMPTY, False, False, EMPTY, EMPTY, + ('', POSITION, _('Location on Page'), ';', EMPTY, False, False, EMPTY, EMPTY, None, None), ('', CREDIT_LINE, _(''), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), @@ -8101,7 +8104,7 @@ class SrcAttributeType(GrampsType): None, None), ('', TITLE, _('Article Title'), ',', STYLE_QUOTE, False, False, EMPTY, EMPTY, None, None), - ('', LOCATION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, + ('', POSITION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), ], }, @@ -8137,7 +8140,7 @@ class SrcAttributeType(GrampsType): None, None), ('accessed', DATE_ACCESSED, _(''), '),', EMPTY, False, False, EMPTY, EMPTY, None, None), - ('', LOCATION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, + ('', POSITION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), ], REF_TYPE_S: [ @@ -8145,7 +8148,7 @@ class SrcAttributeType(GrampsType): None, None), ('', TITLE, _('Article Title'), ',', STYLE_QUOTE, False, False, EMPTY, EMPTY, None, None), - ('', LOCATION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, + ('', POSITION, _('Location on Page'), '.', EMPTY, False, False, EMPTY, EMPTY, None, None), ], }, diff --git a/gramps/gen/lib/srctemplate.py b/gramps/gen/lib/srctemplate.py index fa1cc4571..0387815b8 100644 --- a/gramps/gen/lib/srctemplate.py +++ b/gramps/gen/lib/srctemplate.py @@ -299,52 +299,37 @@ class SrcTemplate(object): ref[-1] += ' ' + field[0].capitalize() + field[1:] elif len(ref[-1]) and ref[-1][-1] in [',', ':', '-']: ref[-1] += ' ' + field + elif len(ref[-1]) and ref[-1] != ' ': + ref[-1] += ' ' + field else: ref[-1] += field #right delimiter - if ')' in rdel: - if len(ref[-1] [ref[-1].find('('):]) > 0 : - newval = ref[-1] + rdel - ref = ref[:-1] - fieldadded = fieldadded[:-1] - fieldadded[-1] = True - ref[-1] += newval - else: - #no data inside of delimiter, we remove it entirely - ref = ref[:-1] - fieldadded = fieldadded[:-1] - #if . at end of rdel, add it - if rdel[-1] == '.': - ref[-1] = ref[-1] + '.' - elif ']' in rdel: - if len(ref[-1] [ref[-1].find('['):]) > 0 : - newval = ref[-1] + rdel - ref = ref[:-1] - fieldadded = fieldadded[:-1] - fieldadded[-1] = True - ref[-1] += newval - else: - #no data inside of delimiter, we remove it entirely - ref = ref[:-1] - fieldadded = fieldadded[:-1] - #if . at end of rdel, add it - if rdel[-1] == '.': - ref[-1] = ref[-1] + '.' - elif '}' in rdel: - if len(ref[-1] [ref[-1].find('{'):]) > 0 : - newval = ref[-1] + rdel - ref = ref[:-1] - fieldadded = fieldadded[:-1] - fieldadded[-1] = True - ref[-1] += newval - else: - #no data inside of delimiter, we remove it entirely - ref = ref[:-1] - fieldadded = fieldadded[:-1] - #if . at end of rdel, add it - if rdel[-1] == '.': - ref[-1] = ref[-1] + '.' - else: + nobracket = True + for bracketl, bracketr in [('(', ')'), ('[',']'), ('{','}')]: + if bracketr in rdel: + nobracket = False + if len(ref[-1] [ref[-1].find(bracketl)+1:]) > 0 : + newval = ref[-1] + rdel + ref = ref[:-1] + fieldadded = fieldadded[:-1] + fieldadded[-1] = True + ref[-1] += newval + else: + #no data inside of delimiter, we remove it entirely + ref = ref[:-1] + fieldadded = fieldadded[:-1] + #if . at end of rdel, add it + if rdel[-1] == '.': + if ref[-1] and ref[-1][-1] in [',', '.']: + ref[-1] = ref[-1][:-1] + if ref[-1]: + ref[-1] = ref[-1] + '.' + elif rdel[-1] == ',': + if ref[-1] and ref[-1][-1] in [',', '.']: + pass + elif ref[-1]: + ref[-1] = ref[-1] + ',' + if nobracket: # we add rdel if not ref[-1]: #nothing there, don't add delimiter @@ -375,9 +360,11 @@ class SrcTemplate(object): #we only add delimiters after this if new fields are added fieldadded[-1] = False - ref = ''.join(ref) + ref = ' '.join(ref) if ref: - return ref[0].capitalize() + ref[1:] + ref = ref[0].capitalize() + ref[1:] + ref.replace(' ', ' ') + return ref else: return ref diff --git a/gramps/gui/editors/displaytabs/srctemplatetab.py b/gramps/gui/editors/displaytabs/srctemplatetab.py index cd40e6ff1..3f38fc65e 100644 --- a/gramps/gui/editors/displaytabs/srctemplatetab.py +++ b/gramps/gui/editors/displaytabs/srctemplatetab.py @@ -328,10 +328,10 @@ class TemplateFields(object): parameter=srcattrtype) def get_src_field(self, srcattrtype): - self.__get_field(srcattrtype, self.src) + return self.__get_field(srcattrtype, self.src) def get_cite_field(self, srcattrtype): - self.__get_field(srcattrtype, self.cite) + return self.__get_field(srcattrtype, self.cite) def __get_field(self, srcattrtype, obj): """ diff --git a/gramps/gui/editors/editsource.py b/gramps/gui/editors/editsource.py index 0f0c80ca6..51d33203e 100644 --- a/gramps/gui/editors/editsource.py +++ b/gramps/gui/editors/editsource.py @@ -359,7 +359,12 @@ class EditSource(EditPrimary): if self.obj.get_source_template()[0] != self.srctemp.get_template_key(): self.srctemp.set_template_key(self.obj.get_source_template()[0]) #set new attrlist in template - self.srctemp.set_attr_list(self.obj.get_attribute_list()) + if self.citation_loaded: + citeattr = self.citation.get_attribute_list() + else: + citeattr = None + self.srctemp.set_attr_list(self.obj.get_attribute_list(), citeattr) + #set fields with the template self.refL.set_text(self.srctemp.reference_L()) @@ -395,7 +400,7 @@ class EditSource(EditPrimary): Change in the citation part might lead to changes needed in the src GUI section """ - pass + self.update_template_data(False) def update_notes(self, *par): """