# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2013  Benny Malengier
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

# $Id$

"""
Provide the different Source Attribute Types for Gramps.
"""

#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from .grampstype import GrampsType

#-------------------------------------------------------------------------
#
# Template constants
#
#-------------------------------------------------------------------------

REF_TYPE_F = 1 # Full footnote citation to a source
REF_TYPE_S = 2 # Short footnote citation to a source
REF_TYPE_L = 3 # Listed reference of the source (no citation info)

EMPTY = 0
# template to GEDCOM field mapping for L reference fields
GED_AUTHOR = 1
GED_TITLE  = 2
GED_PUBINF = 3
# template to GEDCOM field mapping for Date in F reference fields
GED_DATE   = 4
# template to a shortening algorithm mapping for predefined algorithms
SHORTERALG_LOC  = 1   # reduce a location to a shorter format (typically city level)
SHORTERALG_YEAR = 2   # reduce a date to only the year part
SHORTERALG_ETAL = 3   # reduce an author list to "first author et al."
SHORTERALG_REVERT_TO_DOT = 4  # change a list of first, second, third to 
                              # a list third. second. first.
# template to a style mapping
STYLE_QUOTE      = 1  # add quotes around the field
STYLE_QUOTECONT  = 2  # add quotes around this field combined with other
                      # QUOTECONT fields around it
STYLE_EMPH       = 3  # emphasize field
STYLE_BOLD       = 4  # make field bold

#-------------------------------------------------------------------------
#
# Classes
#
#-------------------------------------------------------------------------

class SrcAttributeType(GrampsType):
    """
    Sources/citations have many predefined attribute types. We follow here 
    Elizabeth Shown Mills fields. 
    
    For several of the types, predefined values are possible, which are
    localized. The English version will be stored.
    """

    # PREDEFINED TYPES
    UNKNOWN     = -1
    CUSTOM      = 0
    SRCTEMPLATE = 1
    # GEDCOM support
    EVEN_REC    = 2
    EVEN_CITED  = 3
    EVEN_ROLE   = 4
    GEN_BY      = 5
    
    # Special fields which double existing database
    # 1. repository fields
    REPOSITORY = 10
    REPOSITORY_ADDRESS = 11
    REPOSITORY_SHORT_VERSION = 12
    REPOSITORY_CALL_NUMBER = 13
    # 2. existing class attributes
    DATE = 14
    
    _CUSTOM = CUSTOM
    _DEFAULT = SRCTEMPLATE
    
    _DATAMAP = [
        (UNKNOWN     , _("Unknown"), "Unknown"),
        (CUSTOM      , _("Custom"), "Custom"),
        # required attribute to use for Elizabeth Shown Mills citation defs
        (SRCTEMPLATE , _("Source Template"), "Source Template"),
        # GEDCOM support
        (EVEN_REC    , _("Events Recorded in Source"), "Events Recorded in Source"),  # GEDCOM EVENTS_RECORDED
        (EVEN_CITED  , _("Event Type Used for Citation"), "Event Type Used for Citation"), # GEDCOM EVENT_TYPE_CITED_FROM
        (EVEN_ROLE  , _("Role in Event Cited from"), "Role in Event Cited from"), # GEDCOM ROLE_IN_EVENT
        (GEN_BY    , _("Generated by"), "Generated by"), # Generated sources on import
        (REPOSITORY, _("Repository"), "Repository"),
        (REPOSITORY_ADDRESS, _("Repository address"), "Repository address"),
        (REPOSITORY_SHORT_VERSION, _("Repository (Short)"), "Repository (Short)"),
        (REPOSITORY_CALL_NUMBER, _("Repository call number"), "Repository call number"),
        (DATE, _("Date"), "Date"),
        # possible fields for evidence styles need to be added next
        ]

    #following fields are generated with evidencefieldgenerator.py
    #the index starts at 100!
    ACT = 226
    ACT_SHORT_VERSION = 227
    ADDRESS = 155
    AFFILIATION = 160
    AUTHOR = 100
    AUTHOR_LOCATION = 170
    AUTHOR_SHORT_VERSION = 107
    BOOK = 203
    BOOK_SHORT_VERSION = 204
    CASE = 198
    CASE_SHORT_VERSION = 200
    CEMETERY = 176
    CEMETERY_SHORT_VERSION = 178
    CHAPTER = 228
    CHAPTER_PAGES = 217
    COLLECTION = 104
    COLLECTION_SHORT_VERSION = 109
    COLUMN = 235
    COLUMN_SHORT_VERSION = 236
    COMPILER = 163
    COMPILER_SHORT_VERSION = 194
    CREATION_DATE = 103
    CREATION_DATE_SHORT_VERSION = 141
    CREATOR = 190
    CREATOR_SHORT_VERSION = 213
    CREDIT_LINE = 116
    DATE_ACCESSED = 114
    DATE_RANGE = 133
    DATE_SHORT_VERSION = 156
    DESCRIPTION = 139
    DISTRICT = 188
    DISTRICT_SHORT_VERSION = 189
    DIVISION = 182
    DIVISION_SHORT_VERSION = 186
    EDITION = 221
    EDITOR = 216
    EDITOR_SHORT_VERSION = 218
    FILE = 129
    FILE_DATE = 206
    FILE_DATE_SHORT_VERSION = 207
    FILE_LOCATION = 166
    FILE_NO = 128
    FILE_NO_SHORT_VERSION = 199
    FILE_SHORT_VERSION = 152
    FILE_UNIT = 143
    FILE_UNIT_SHORT_VERSION = 179
    FILM_ID = 191
    FILM_PUBLICATION_PLACE = 223
    FILM_PUBLISHER = 224
    FILM_TYPE = 147
    FORMAT = 159
    FRAME = 205
    GROUP = 167
    GROUP_SHORT_VERSION = 174
    HOUSEHOLD = 183
    HOUSEHOLD_SHORT_VERSION = 187
    ID = 127
    ID_SHORT_VERSION = 131
    INSTITUTION = 173
    INSTITUTION_SHORT_VERSION = 175
    INTERVIEWER = 158
    ISSUE_DATE = 231
    ISSUE_DATE_SHORT_VERSION = 238
    ISSUE_RANGE = 234
    ITEM_OF_INTEREST = 119
    ITEM_OF_INTEREST_SHORT_VERSION = 150
    JURISDICTION = 180
    JURISDICTION_SHORT_VERSION = 184
    LOCATION = 157
    LOCATION_SHORT_VERSION = 195
    NUMBER = 105
    NUMBER_6TOTAL9 = 144
    NUMBER_SHORT_VERSION = 120
    ORIGINAL_REPOSITORY = 145
    ORIGINAL_REPOSITORY_LOCATION = 146
    ORIGINAL_YEAR = 220
    PAGE = 115
    PAGE_RANGE = 232
    PAGE_SHORT_VERSION = 118
    PART = 225
    PLACE_CREATED = 154
    POSITION = 177
    POSITION_SHORT_VERSION = 233
    POSTING_DATE = 237
    PROFESSIONAL_CREDENTIALS = 142
    PROVENANCE = 164
    PUBLICATION_FORMAT = 209
    PUBLICATION_PLACE = 134
    PUBLICATION_TITLE = 208
    PUBLICATION_TITLE_SHORT_VERSION = 214
    PUBLICATION_YEAR = 136
    PUBLICATION_YEAR_SHORT_VERSION = 197
    PUBLISHER = 135
    PUB_INFO = 239
    RECIPIENT = 126
    RECIPIENT_SHORT_VERSION = 130
    RELATIONSHIP = 165
    REPORT_DATE = 162
    REPORT_DATE_SHORT_VERSION = 171
    RESEARCH_COMMENT = 106
    RESEARCH_COMMENT_SHORT_VERSION = 137
    RESEARCH_PROJECT = 161
    ROLL = 151
    ROLL_SHORT_VERSION = 196
    SCHEDULE = 181
    SCHEDULE_SHORT_VERSION = 185
    SECTION = 148
    SECTION_SHORT_VERSION = 149
    SERIES = 122
    SERIES_NO = 121
    SERIES_NO_SHORT_VERSION = 124
    SERIES_SHORT_VERSION = 132
    SESSION = 229
    SESSION_SHORT_VERSION = 230
    SHEET_NO = 192
    SHEET_NO_SHORT_VERSION = 193
    SUBJECT = 138
    SUBJECT_SHORT_VERSION = 140
    SUBSERIES = 168
    SUBSERIES_SHORT_VERSION = 169
    SUBTITLE = 215
    TERM = 201
    TERM_SHORT_VERSION = 202
    TIMESTAMP = 210
    TIMESTAMP_SHORT_VERSION = 211
    TITLE = 101
    TITLE_SHORT_VERSION = 108
    TRANSLATION = 222
    TYPE = 102
    TYPE_SHORT_VERSION = 153
    URL_6DIGITAL_LOCATION9 = 112
    VOLUME = 123
    VOLUME_INFO = 219
    VOLUME_SHORT_VERSION = 125
    WEBSITE = 111
    WEBSITE_CREATOR_OR_OWNER = 110
    WEBSITE_SHORT_VERSION = 117
    YEAR = 113
    YEAR_ACCESSED = 172
    YEAR_SHORT_VERSION = 212

    _DATAMAPIGNORE = [
        AUTHOR_SHORT_VERSION,
        TITLE_SHORT_VERSION,
        COLLECTION_SHORT_VERSION,
        WEBSITE_SHORT_VERSION,
        PAGE_SHORT_VERSION,
        NUMBER_SHORT_VERSION,
        SERIES_NO_SHORT_VERSION,
        VOLUME_SHORT_VERSION,
        RECIPIENT_SHORT_VERSION,
        ID_SHORT_VERSION,
        SERIES_SHORT_VERSION,
        RESEARCH_COMMENT_SHORT_VERSION,
        SUBJECT_SHORT_VERSION,
        CREATION_DATE_SHORT_VERSION,
        SECTION_SHORT_VERSION,
        ITEM_OF_INTEREST_SHORT_VERSION,
        FILE_SHORT_VERSION,
        TYPE_SHORT_VERSION,
        DATE_SHORT_VERSION,
        SUBSERIES_SHORT_VERSION,
        REPORT_DATE_SHORT_VERSION,
        GROUP_SHORT_VERSION,
        INSTITUTION_SHORT_VERSION,
        CEMETERY_SHORT_VERSION,
        FILE_UNIT_SHORT_VERSION,
        JURISDICTION_SHORT_VERSION,
        SCHEDULE_SHORT_VERSION,
        DIVISION_SHORT_VERSION,
        HOUSEHOLD_SHORT_VERSION,
        DISTRICT_SHORT_VERSION,
        SHEET_NO_SHORT_VERSION,
        COMPILER_SHORT_VERSION,
        LOCATION_SHORT_VERSION,
        ROLL_SHORT_VERSION,
        PUBLICATION_YEAR_SHORT_VERSION,
        FILE_NO_SHORT_VERSION,
        CASE_SHORT_VERSION,
        TERM_SHORT_VERSION,
        BOOK_SHORT_VERSION,
        FILE_DATE_SHORT_VERSION,
        TIMESTAMP_SHORT_VERSION,
        YEAR_SHORT_VERSION,
        CREATOR_SHORT_VERSION,
        PUBLICATION_TITLE_SHORT_VERSION,
        EDITOR_SHORT_VERSION,
        ACT_SHORT_VERSION,
        SESSION_SHORT_VERSION,
        POSITION_SHORT_VERSION,
        COLUMN_SHORT_VERSION,
        ISSUE_DATE_SHORT_VERSION,
    ]


    _DATAMAP += [
        (ACT, _("Act"), "Act"),
        (ACT_SHORT_VERSION, _("Act (Short)"), "Act (Short)"),
        (ADDRESS, _("Address"), "Address"),
        (AFFILIATION, _("Affiliation"), "Affiliation"),
        (AUTHOR, _("Author"), "Author"),
        (AUTHOR_LOCATION, _("Author location"), "Author location"),
        (AUTHOR_SHORT_VERSION, _("Author (Short)"), "Author (Short)"),
        (BOOK, _("Book"), "Book"),
        (BOOK_SHORT_VERSION, _("Book (Short)"), "Book (Short)"),
        (CASE, _("Case"), "Case"),
        (CASE_SHORT_VERSION, _("Case (Short)"), "Case (Short)"),
        (CEMETERY, _("Cemetery"), "Cemetery"),
        (CEMETERY_SHORT_VERSION, _("Cemetery (Short)"), "Cemetery (Short)"),
        (CHAPTER, _("Chapter"), "Chapter"),
        (CHAPTER_PAGES, _("Chapter pages"), "Chapter pages"),
        (COLLECTION, _("Collection"), "Collection"),
        (COLLECTION_SHORT_VERSION, _("Collection (Short)"), "Collection (Short)"),
        (COLUMN, _("Column"), "Column"),
        (COLUMN_SHORT_VERSION, _("Column (Short)"), "Column (Short)"),
        (COMPILER, _("Compiler"), "Compiler"),
        (COMPILER_SHORT_VERSION, _("Compiler (Short)"), "Compiler (Short)"),
        (CREATION_DATE, _("Creation date"), "Creation date"),
        (CREATION_DATE_SHORT_VERSION, _("Creation date (Short)"), "Creation date (Short)"),
        (CREATOR, _("Creator"), "Creator"),
        (CREATOR_SHORT_VERSION, _("Creator (Short)"), "Creator (Short)"),
        (CREDIT_LINE, _("Credit line"), "Credit line"),
        (DATE_ACCESSED, _("Date accessed"), "Date accessed"),
        (DATE_RANGE, _("Date range"), "Date range"),
        (DATE_SHORT_VERSION, _("Date (Short)"), "Date (Short)"),
        (DESCRIPTION, _("Description"), "Description"),
        (DISTRICT, _("District"), "District"),
        (DISTRICT_SHORT_VERSION, _("District (Short)"), "District (Short)"),
        (DIVISION, _("Division"), "Division"),
        (DIVISION_SHORT_VERSION, _("Division (Short)"), "Division (Short)"),
        (EDITION, _("Edition"), "Edition"),
        (EDITOR, _("Editor"), "Editor"),
        (EDITOR_SHORT_VERSION, _("Editor (Short)"), "Editor (Short)"),
        (FILE, _("File"), "File"),
        (FILE_DATE, _("File date"), "File date"),
        (FILE_DATE_SHORT_VERSION, _("File date (Short)"), "File date (Short)"),
        (FILE_LOCATION, _("File location"), "File location"),
        (FILE_NO, _("File no."), "File no."),
        (FILE_NO_SHORT_VERSION, _("File no. (Short)"), "File no. (Short)"),
        (FILE_SHORT_VERSION, _("File (Short)"), "File (Short)"),
        (FILE_UNIT, _("File unit"), "File unit"),
        (FILE_UNIT_SHORT_VERSION, _("File unit (Short)"), "File unit (Short)"),
        (FILM_ID, _("Film id"), "Film id"),
        (FILM_PUBLICATION_PLACE, _("Film publication place"), "Film publication place"),
        (FILM_PUBLISHER, _("Film publisher"), "Film publisher"),
        (FILM_TYPE, _("Film type"), "Film type"),
        (FORMAT, _("Format"), "Format"),
        (FRAME, _("Frame"), "Frame"),
        (GROUP, _("Group"), "Group"),
        (GROUP_SHORT_VERSION, _("Group (Short)"), "Group (Short)"),
        (HOUSEHOLD, _("Household"), "Household"),
        (HOUSEHOLD_SHORT_VERSION, _("Household (Short)"), "Household (Short)"),
        (ID, _("Id"), "Id"),
        (ID_SHORT_VERSION, _("Id (Short)"), "Id (Short)"),
        (INSTITUTION, _("Institution"), "Institution"),
        (INSTITUTION_SHORT_VERSION, _("Institution (Short)"), "Institution (Short)"),
        (INTERVIEWER, _("Interviewer"), "Interviewer"),
        (ISSUE_DATE, _("Issue date"), "Issue date"),
        (ISSUE_DATE_SHORT_VERSION, _("Issue date (Short)"), "Issue date (Short)"),
        (ISSUE_RANGE, _("Issue range"), "Issue range"),
        (ITEM_OF_INTEREST, _("Item of interest"), "Item of interest"),
        (ITEM_OF_INTEREST_SHORT_VERSION, _("Item of interest (Short)"), "Item of interest (Short)"),
        (JURISDICTION, _("Jurisdiction"), "Jurisdiction"),
        (JURISDICTION_SHORT_VERSION, _("Jurisdiction (Short)"), "Jurisdiction (Short)"),
        (LOCATION, _("Location"), "Location"),
        (LOCATION_SHORT_VERSION, _("Location (Short)"), "Location (Short)"),
        (NUMBER, _("Number"), "Number"),
        (NUMBER_6TOTAL9, _("Number (total)"), "Number (total)"),
        (NUMBER_SHORT_VERSION, _("Number (Short)"), "Number (Short)"),
        (ORIGINAL_REPOSITORY, _("Original repository"), "Original repository"),
        (ORIGINAL_REPOSITORY_LOCATION, _("Original repository location"), "Original repository location"),
        (ORIGINAL_YEAR, _("Original year"), "Original year"),
        (PAGE, _("Page"), "Page"),
        (PAGE_RANGE, _("Page range"), "Page range"),
        (PAGE_SHORT_VERSION, _("Page (Short)"), "Page (Short)"),
        (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"),
        (PUBLICATION_FORMAT, _("Publication format"), "Publication format"),
        (PUBLICATION_PLACE, _("Publication place"), "Publication place"),
        (PUBLICATION_TITLE, _("Publication title"), "Publication title"),
        (PUBLICATION_TITLE_SHORT_VERSION, _("Publication title (Short)"), "Publication title (Short)"),
        (PUBLICATION_YEAR, _("Publication year"), "Publication year"),
        (PUBLICATION_YEAR_SHORT_VERSION, _("Publication year (Short)"), "Publication year (Short)"),
        (PUBLISHER, _("Publisher"), "Publisher"),
        (PUB_INFO, _("Pub_info"), "Pub_info"),
        (RECIPIENT, _("Recipient"), "Recipient"),
        (RECIPIENT_SHORT_VERSION, _("Recipient (Short)"), "Recipient (Short)"),
        (RELATIONSHIP, _("Relationship"), "Relationship"),
        (REPORT_DATE, _("Report date"), "Report date"),
        (REPORT_DATE_SHORT_VERSION, _("Report date (Short)"), "Report date (Short)"),
        (RESEARCH_COMMENT, _("Research comment"), "Research comment"),
        (RESEARCH_COMMENT_SHORT_VERSION, _("Research comment (Short)"), "Research comment (Short)"),
        (RESEARCH_PROJECT, _("Research project"), "Research project"),
        (ROLL, _("Roll"), "Roll"),
        (ROLL_SHORT_VERSION, _("Roll (Short)"), "Roll (Short)"),
        (SCHEDULE, _("Schedule"), "Schedule"),
        (SCHEDULE_SHORT_VERSION, _("Schedule (Short)"), "Schedule (Short)"),
        (SECTION, _("Section"), "Section"),
        (SECTION_SHORT_VERSION, _("Section (Short)"), "Section (Short)"),
        (SERIES, _("Series"), "Series"),
        (SERIES_NO, _("Series no."), "Series no."),
        (SERIES_NO_SHORT_VERSION, _("Series no. (Short)"), "Series no. (Short)"),
        (SERIES_SHORT_VERSION, _("Series (Short)"), "Series (Short)"),
        (SESSION, _("Session"), "Session"),
        (SESSION_SHORT_VERSION, _("Session (Short)"), "Session (Short)"),
        (SHEET_NO, _("Sheet no."), "Sheet no."),
        (SHEET_NO_SHORT_VERSION, _("Sheet no. (Short)"), "Sheet no. (Short)"),
        (SUBJECT, _("Subject"), "Subject"),
        (SUBJECT_SHORT_VERSION, _("Subject (Short)"), "Subject (Short)"),
        (SUBSERIES, _("Subseries"), "Subseries"),
        (SUBSERIES_SHORT_VERSION, _("Subseries (Short)"), "Subseries (Short)"),
        (SUBTITLE, _("Subtitle"), "Subtitle"),
        (TERM, _("Term"), "Term"),
        (TERM_SHORT_VERSION, _("Term (Short)"), "Term (Short)"),
        (TIMESTAMP, _("Timestamp"), "Timestamp"),
        (TIMESTAMP_SHORT_VERSION, _("Timestamp (Short)"), "Timestamp (Short)"),
        (TITLE, _("Title"), "Title"),
        (TITLE_SHORT_VERSION, _("Title (Short)"), "Title (Short)"),
        (TRANSLATION, _("Translation"), "Translation"),
        (TYPE, _("Type"), "Type"),
        (TYPE_SHORT_VERSION, _("Type (Short)"), "Type (Short)"),
        (URL_6DIGITAL_LOCATION9, _("Url (digital location)"), "Url (digital location)"),
        (VOLUME, _("Volume"), "Volume"),
        (VOLUME_INFO, _("Volume info"), "Volume info"),
        (VOLUME_SHORT_VERSION, _("Volume (Short)"), "Volume (Short)"),
        (WEBSITE, _("Website"), "Website"),
        (WEBSITE_CREATOR_OR_OWNER, _("Website creator/owner"), "Website creator/owner"),
        (WEBSITE_SHORT_VERSION, _("Website (Short)"), "Website (Short)"),
        (YEAR, _("Year"), "Year"),
        (YEAR_ACCESSED, _("Year accessed"), "Year accessed"),
        (YEAR_SHORT_VERSION, _("Year (Short)"), "Year (Short)"),
        ]

    _DEFAULT_HINTS = {
        ACT: _("Public Law 12-98"),
        ADDRESS: _("Broadway Avenue, New York"),
        AFFILIATION: _("Agent of Gramps Software"),
        AUTHOR: _("Doe, D.P. & Cameron, E."),
        AUTHOR_LOCATION: _("Chicago"),
        BOOK: _("The big example Gramps manual"),
        CASE: _("B. Malengier versus N. Hall"),
        CEMETERY: _("Greenwich Cemetery Office"),
        CHAPTER: _("The first office of T. Rooseveld"),
        CHAPTER_PAGES: _("24-55"),
        COLLECTION: _("Bruges Lace Collection"),
        COLUMN: _("col. 3"),
        COMPILER: _("T. Da Silva"),
        CREATION_DATE: _("13 Aug 1965"),
        CREATOR: _("P. Picasso"),
        CREDIT_LINE: _("Based on unnamed document lost in fire"),
        DATE: _("17 Sep 1745"),
        DATE_ACCESSED: _("18 Jun 2013"),
        DATE_RANGE: _("2003-6"),
        DESCRIPTION: _("The lace has inscriptions with names of nobility"),
        DISTRICT: _("Enumeration district (ED) 14"),
        DIVISION: _("Peterburg Post Office, or Portland, ward 4"),
        EDITION: _("Second Edition"),
        EDITOR: _("Hoover, J.E."),
        FILE: _("Membership application J. Rapinat"),
        FILE_DATE: _("15 Jan 1870"),
        FILE_LOCATION: _("Accession 7, Box 3"),
        FILE_NO: _("1243-EB-98"),
        FILE_UNIT: _("Letters to George Washington"),
        FILM_ID: _("T345"),
        FILM_PUBLICATION_PLACE: _("Kansas City"),
        FILM_PUBLISHER: _("NY Genealogy Association"),
        FILM_TYPE: _("FHL microfilm"),
        FORMAT: _("Digital Images, or Database, or Cards, ..."),
        FRAME: _("frames 387-432"),
        GROUP: _("Miami Patent Office"),
        HOUSEHOLD: _("dwelling 345, family 654"),
        ID: _("I50-68, or 1910 U.S. census, or ..."),
        INSTITUTION: _("Sorbonne University"),
        INTERVIEWER: _("Materley, B."),
        ISSUE_DATE: _("Jun 2004"),
        ISSUE_RANGE: _("145-394, scattered issues"),
        ITEM_OF_INTEREST: _("entry for G. Galileo, or Doe Household, or A. Einstein Grave ..."),
        JURISDICTION: _("Jackson County, Alabama"),
        LOCATION: _("Istanbul"),
        NUMBER: _("2, or Record Group 34, or ..."),
        NUMBER_6TOTAL9: _("5"),
        ORIGINAL_REPOSITORY: _("National Archives"),
        ORIGINAL_REPOSITORY_LOCATION: _("Washington, D.C."),
        ORIGINAL_YEAR: _("1966"),
        PAGE: _("5; or 4,6-8, ..."),
        PAGE_RANGE: _("1-13"),
        PART: _("Part 3"),
        PLACE_CREATED: _("London"),
        POSITION: _("written in the left margin, or second row, 3th line"),
        POSTING_DATE: _("5 Jul 1799"),
        PROFESSIONAL_CREDENTIALS: _("Prof.; or Dr. ..."),
        PROVENANCE: _("add provenance of the material"),
        PUBLICATION_FORMAT: _("CD-ROM or eprint or ..."),
        PUBLICATION_PLACE: _("Berlin"),
        PUBLICATION_TITLE: _("Title of Blog, Newsletter, DVD, ..."),
        PUBLICATION_YEAR: _("2014"),
        PUBLISHER: _("Springer"),
        PUB_INFO: _("Springer, Berlin, 2014"),
        RECIPIENT: _("J. Ralls"),
        RELATIONSHIP: _("Paul's uncle and brother of Erik"),
        REPORT_DATE: _("3 May 1999"),
        RESEARCH_COMMENT: _("Descriptive detail or provenance or research analysis conclusion, ..."),
        RESEARCH_PROJECT: _("Tahiti Natives"),
        ROLL: _("176, or rolls 145-160"),
        SCHEDULE: _("population schedule or slave schedule or ..."),
        SECTION: _("1890 section or ER patients or ..."),
        SERIES: _("Carnival County Records"),
        SERIES_NO: _("series 34-38"),
        SESSION: _("2nd session"),
        SHEET_NO: _("sheet 13-C"),
        SUBJECT: _("D. Copernicus and close family"),
        SUBTITLE: _("Subtitle of article or magazine ..."),
        TERM: _("June Term 1934 or 13th Congress or Reagan Office or ..."),
        TIMESTAMP: _("min. 34-36"),
        TITLE: _("Diary Title, Message Title, Bible Name, Article Title, ..."),
        TRANSLATION: _("A translated version, typically of the title"),
        TYPE: _("Letter"),
        URL_6DIGITAL_LOCATION9: _("http://gramps-project.org/blog"),
        VOLUME: _("4"),
        VOLUME_INFO: _("5 volumes"),
        WEBSITE: _("gramps-project.org"),
        WEBSITE_CREATOR_OR_OWNER: _("Family Historians Inc"),
        YEAR: _("1888"),
        YEAR_ACCESSED: _("2013"),
    }

    _DEFAULT_TOOLTIPS = {
        ACT: _("A statute or law name passed by a legislature"),
        ADDRESS: _("Store address information. Set Private if needed! Give information from lowest to highest level separated by comma's"),
        AFFILIATION: _("A relevant affiliation that might influence data in the source"),
        AUTHOR: _("Give names in following form: 'FirstAuthorSurname, Given Names & SecondAuthorSurname, Given Names'. Like this Gramps can parse the name and shorten as needed."),
        AUTHOR_LOCATION: _("City where author resides or wrote."),
        BOOK: _("Title of the Book"),
        CASE: _("Dispute between opposing parties in a court of law."),
        CEMETERY: _("Name of cemetery or cemetery office with sources."),
        CHAPTER_PAGES: _("The pages in the chapter."),
        COMPILER: _("The name of the person who compiled the source."),
        CREATOR: _("The name of the creator of the artifact."),
        CREDIT_LINE: _("Acknowledgement of writers and contributors"),
        DATE_RANGE: _("The range of years which are present in the source."),
        DESCRIPTION: _("Some important detail of the source."),
        DISTRICT: _("District as handled by Census"),
        DIVISION: _("The subdivision of a larger group that is handled in the source."),
        EDITOR: _("The Editor of a multi-author book."),
        FILE: _("The title of a specific file in a source."),
        FILE_DATE: _("Date of submitting the document to a clerk or court."),
        FILE_LOCATION: _("Accession method to the file"),
        FILE_NO: _("Number to indicate a file"),
        FILE_UNIT: _("A grouping unit for a number of files in a source."),
        FILM_ID: _("ID of a Microfilm."),
        FILM_TYPE: _("The type of the microfilm."),
        FORMAT: _("The format of the source."),
        FRAME: _("What frames in the source are relevant."),
        GROUP: _("A larger grouping to which the source belongs."),
        HOUSEHOLD: _("Household of interest on a census."),
        ID: _("ID to identify the source or citation part"),
        INSTITUTION: _("Institution that issued the source."),
        ISSUE_DATE: _("Date the source was issued."),
        ISSUE_RANGE: _("A range of magazine, journal, ... issues covered in the source"),
        ITEM_OF_INTEREST: _("Specific part, item, or person of interest in the source"),
        JURISDICTION: _("Area with a set of laws under the control of a system of courts or government entity. Enter this from lowest to highest relevant jurisdiction, separated by comma's."),
        LOCATION: _("City that is relevant."),
        NUMBER: _("A number."),
        NUMBER_6TOTAL9: _("The maximum of entities available."),
        ORIGINAL_REPOSITORY: _("Name of the repository where the original is stored."),
        ORIGINAL_REPOSITORY_LOCATION: _("Address or only city of the repository where the original is stored."),
        ORIGINAL_YEAR: _("Year the original source was published/created"),
        PAGE: _("The page or page(s) relevant for the citation"),
        PAGE_RANGE: _("The range of the pages in the source. The page given for a citation must be in this range."),
        POSITION: _("Where in or on the source the citation piece can be found."),
        PROVENANCE: _("Where the material originated from."),
        PUB_INFO: _("Publication Information, such as city and year of publication, name of publisher, ..."),
        RECIPIENT: _("The person to who the letter is addressed."),
        RELATIONSHIP: _("The relationship of the author to the person of interest that is the subject."),
        REPORT_DATE: _("Date the report was written/submitted."),
        RESEARCH_COMMENT: _("Descriptive detail or provenance or research analysis conclusion, ..."),
        RESEARCH_PROJECT: _("The genealogical or scientific research project."),
        ROLL: _("The Microfilm role."),
        SCHEDULE: _("The census schedule (the type of census table) used, eg population schedule or slave schedule. or ..."),
        SECTION: _("The section or subgroup under which filed, eg 'Diplomatic correspondance, 1798-1810'"),
        SESSION: _("The number of the meeting or series of connected meetings devoted by a legislature to a single order of business, program, agenda, or announced purpose."),
        SHEET_NO: _("Number of a census sheet."),
        TERM: _("Reference to the time a person/group/parliament is in office or session."),
        TIMESTAMP: _("Indication of the time in audio or video where the relevant fragment can be found."),
        TRANSLATION: _("A translated version, typically of the title"),
        URL_6DIGITAL_LOCATION9: _("Detailed internet address of the content"),
        VOLUME_INFO: _("Information about the volumes, eg the amount of volumes."),
        WEBSITE: _("The main internet address."),
        WEBSITE_CREATOR_OR_OWNER: _("Organization or person behind a website."),
    }

    def __init__(self, value=None):
        GrampsType.__init__(self, value)
 
    def short_version(self, sattrtype):
        """
        Method that returns the type which is the short version type of the given type
        """
        sattrt = SrcAttributeType(sattrtype)
        if sattrt.xml_str().lower().endswith(' (short)'):
            return sattrtype
        return SrcAttributeType(sattrt.xml_str() +' (Short)')

    @staticmethod
    def get_default_hint(sattrtype):
        index = int(SrcAttributeType(sattrtype))
        return SrcAttributeType._DEFAULT_HINTS.get(index) or ""

    @staticmethod
    def get_default_tooltip(sattrtype):
        index = int(SrcAttributeType(sattrtype))
        return SrcAttributeType._DEFAULT_TOOLTIPS.get(index) or ""

    def get_ignore_list(self, exception=None):
        """
        Return a list of the types to ignore and not include in default lists.
        
        Exception is a sublist of types that may not be ignored
        
        :param exception: list of integer values corresponding with types that
            have to be excluded from the ignore list
        :type exception: list
        :returns: list of integers corresponding with the types to ignore when 
            showing a list of different NoteType's
        :rtype: list
        
        """
        ignlist = [x for x in self._DATAMAPIGNORE]
        if exception:
            for type_ in exception:
                try: 
                    del ignlist[ignlist.index(type_)]
                except ValueError:
                    pass
        return ignlist
