GEDitCOM II Module for Python Scripting

GEDitCOM II is installed with a GEDitCOMII.py Python module to help in writing Python scripts. Two remarks on the GEDitCOMII.py module are:

  1. See the script template for creating a script that uses the module methods.
  2. The default module is installed in the /Users/(your name)/Library/Application Support/GEDitCOM II/System/Modules folder. If you download a new version, it can replace the module at this location or can be saved in to the user section in a /Users/(your name)/Library/Application Support/GEDitCOM II//Modules folder. Either folder can hold Python modules (the user section is checked first)

The following topics explain the GEDitCOMII module classes and functions. They are grouped by subject.

Some of the methods take optional parameters and they are surrounded by square brackets ([...]). If a method as more then one optional parameter, you can provide any number, but must start from the beginning and include all up to the last one needed.

Initialization Tools

These methods are used when a script starts for fetching basic information needed for the script.

CheckVersionAndDocument(sName,vNeed[,bNeed])
Python scripts cannot perform many useful tasks unless a document is open. This subroutine will verify that a document is open. It should normally be called at the beginning of every script.
    This subroutine also checks that the current version is adequate for the needs of the script. If you use scripting methods that only became available in a certain version, you should specify that version number to this subroutine. The build number argument checks for build number too. Scripts that use this Python module, for example, require version 1.6, build 2. Note that when running scripts in an extension (GEDitCOM II, version 2.0 or newer), you can specify a minimum version number in the extension settings and can skip the check in this method (by either omitting vNeed and bNeed or providing low numbers).
    If all checks are passed, this function returns a reference to the current application object. If no document is open or if the version number is not adequate, a message is printed to the GEDitCOM II scripting panel and the function returns None.
FrontDocument()
Returns a reference to the current front document in GEDitCOM II or returns None if no document is open. To find a document other than the front document, you can look at gedit.documents()[i], where i is document number (the front document is number 0) and gedit is reference to the application.

ScriptOutput Class

This class and its methods help formatting script output for reports or to save to files. In brief, you create one instance of the class for your script and then use the ScriptOutput methods to help preparing the script output. It it very helpful to any scripts that create reports and/or save results to a file. A template for its use in a script is:

# create a ScriptOutput object
rpt = ScriptOutput(GetScriptName(),"html",None)
	
# the script adds content to the rpt object using its methods
rpt.out("Text for the script output")
	
# generate script out
rpt.write()

When you create the ScriptOutput instance, the second parameter defines the style of the output. The most common output style for scripts is to use html content. This output can either be displayed in a GEDitCOM II window or saved to a standard .html file that can be opened in any browser. If a file name is provided in the third parameter when creating the ScriptOutput object is created, the output will be saved to an .html file. If the third parameter is None (or omitted), the output will be displayed in a GEDitCOM II window. In either case, your script only provides the internal html content. The ScriptOutput class will take care of all other elements needed for an .html file or a report. In fact, the exact same script can provide output to a window or to a file simply by changing the file name parameter; no other changes are needed.

The other style is monospace. This style is used for a plain text report (or file) with no options for formatting (except to select the font). It is used for quick or simple output. It is called "monospace" because the default font is a fixed-width font (Courier) which provides the option of aligning output in columns by counting the number of characters in each row. The font can, however, be changed. When done, the plain text can be sent to a GEDitCOM II window or written to a text file (if a file name is provided).

ScriptOutput Class Initialization

ScriptOutput(name,style[,file])
When the ScriptOutput object is created, you provide the script name, the style of the report, and a file name if you want file output (otherwise use None or omit the last parameter). Scripts then prepare output using this object and various methods (most commonly the out() method). When done, finish the output with the write() method.

ScriptOutput Class Methods

out(text)
For html output, embed html elements in the text such as
rpt.out("<h1>Section Title</h1>\n")
Build a complete report by adding any html content. There are several html helper functions to help create output for tables, lists, record links, etc..
    For monospace output, simply build the report by adding text. You can add "\n" to include line feeds because out() does not insert them.
newline()
Start a newline in the report (it is equivalent to out("\n")
css(text)
For html output, you can define styles for elements by adding a style element to the head element of type 'text/css'. The ScriptOutput class does all the work. All you need do is add style definitions for element types using the css() method. For example, one definition could be:
rpt.css("table { border-bottom: 1px solid #ccc;}\n")
You can add as many css definitions you want for the html output. Each one uses standard methods for cascading style sheets.
    This method is not useful for monospace output.
addhead(text)
For html output, this method can add content to the document's head element. A common use is to add javascript for the report document.
    This method is not useful for monospace output.
cols(text1,col1,text2,col2,...)
This method helps you align text in columns when using monospace output and a fixed-width font. It is used as follows:
rpt.cols("John Smith",30,"14 Oct 1754",-45,"NY")
This method adds a series of text blocks aligned in columns. The first text starts in column 1. The subsequent text strings (in odd-numbered arguments of which there can be any number) starts in the column number preceding that text. If the number is negative, the previous text is right justified up to that column otherwise the previous text is padded with blank characters up to that column (note: to start with leading blanks, make the first text argument an empty string). This command can be used in the middle of the line, but then the column numbers are relative to the current position and not to the start of the current line. This command does not end the line; you still need line feed characters (in last argument or a subsequent out() command) to move to the next line.
    This method is not useful for html output.
SetFont(name)
This method sets the font for monospace output only. The default font for monospace output is Courier. This font is a fixed-width font, which is essential if you intend to use cols() or character spacings to align output in columns. If you don't need aligned columns, you can select a proportional font instead. You cannot mix fonts. If more than on SetFont() command is used, only the last will will be used.
    This method is not useful for html output.
SetFontSize(size)
This method sets the font size for monospace output only. The default font size is 9 points. You cannot mix font sizes. If more than on SetFontSize() command is used, only the last will will be used.
    This method is not useful for html output.
write()
When the report is done and ready to for output, call this method with:
rpt.write()
If no file name was provided, the report will be displayed in a GEDitCOM II report window. If the style was html, it will display as html content. If the style was monospace, it will display as plain text. If a file name is given, the output will be written to a file. For html style, it will be written to an html file that can be opened with a browser. For monospace output, it will be written to a plain text file that can be opened with a text editor.
    If you need to access the new window in MacOS Ventura or latter, you should follow with a call to WaitForWindow().

Work with Generic Records

The methods in this section and several following sections are convenience methods for looking up records or other common tasks with records.

GetSelectedType(rtype[,gdoc])
This function finds all the currently selected records in a document and returns a list having only records of one type (as specified in the rtype) parameter. If no such records are select, it will return an empty list. This method is faster then looping your self and picking out the records.

Work with Individual Records

These methods help access information about individual records.

GetIndividual([gdoc,prompt])
Returns a reference to the first selected individual record in the current front document, or in gdoc if provided. If no records are selected or if none of the selected records are individual records, this function looks at the prompt argument. If it is omitted (or None) the function returns None. If prompt is provided, the user is shown a list of all individuals and can select one. The selected one is returned (or None if that selection is canceled).
EveryIndividual([gdoc])
This function returns an iterator for looping over all individuals in the front document (or in gdoc if provided). A template for its use is:
for (n,indi) in EveryIndividual() :
    (loop statements)
In the loop, n is the individual number (with the first one being number zero) and indi is a reference to each individual record.
GetFather(person)
Returns a reference to a person's father's record. If the person does not have a father, it returns None. If the person has more than one father, the reference is to the first father.
GetMother(person)
Returns a reference to a person's mother's record. If the person does not have a mother, it returns None. If the person has more than one mother, the reference is to the first mother.
GetAncestors(indi[,gdoc,maxgen])
This function generates an ancestor tree and then returns a list of all ancestors in that tree. The format for the list is described in listedRecords() for "Ancestor Family Tree window". By default the list will have all ancestors in the file. The optional maxgen can limit the list to any number of generations (parents are generation number 1).
GetDescendants(indi[,gdoc,maxgen])
This function generates a descendant tree and then returns a list of all descendants in that tree. The format for the list is described in for listedRecords() for "Descendant Family Tree window". By default the list will have all descendants in the file. The optional maxgen can limit the list to any number of generations (children are generation number 1).

Work with Family Records

These methods help access information about family records.

GetFamily([gdoc,prompt])
Returns a reference to the first selected family record in the current front document (or in gdoc if provided). If no records are selected or if none of the selected records are family records, this function looks at the prompt argument. If it is omitted (or None) the function returns None. If prompt is provided, the user is shown a list of all families and can select one. The selected one is returned (or None if that selection is canceled).
EveryFamily([gdoc])
This function returns an iterator for looping over all families in the front document (or in gdoc if provided). A template for its use is:
for (n,fam) in EveryFamily() :
    (loop statements)
In the loop, n is the family number (with the first one being number zero) and fam is a reference to each family record.
SpouseNames(famrec)
This function returns the names of the spouse in the family with first name first, such as "Joseph Smith and Emma Hale". If either spouse is missing, it will be say "Unknown Spouse".

Work with Note Records

These methods help create and access information about note records.

AddNoteRecord([gdoc,noteText])
Create a new notes record in the provided document and then returns a reference to that new record. You can provide text content for the notes in noteText or set its text later using properties of the returned record.
GetHTMLComment(ntext,comments)
This will search html content (any string beginning in <div> element, usually from a notes record with web content) for comments. A comment is defined as <!--name Text of the comment--> where name is the comment label and "Text of the comment" is the comment text. You provide the notes text (as a string) and a list of labels to be searched. The returned result will be the text of the first comment that matches a label in the comments list. The returned result will be a list:
[label,Text of the comment]
If no comment is found, the returned result is [None,None]. For example, GEDitCOM II uses a "name" comment to allow users to specify the name for notes with html content. You can fetch this name with:
GetHTMLComment(ntext,["name"])
Your scripts can define custom comments. The comments will not show up in GEDitCOM II when viewing the html content (because they are comments), but can be read by your script. For example the "Create Generations Book" etension defines "TeX" and "alt" comments to allow alternate versions of notes to be included in the book (because notes only with html content are not compatible with that book). It prefers the "TeX" version, but will accept an "alt" version. The one to use is found with:
GetHTMLComment(ntext,["TeX","alt"])

Work with Place Records

These methods help create and access information about place records.

GetPlace([gdoc,prompt])
Returns a reference to the first selected place record in the current front document (or in gdoc if provided). If no records are selected or if none of the selected records are place records, this function looks at the prompt argument. If it is omitted (or None) the function returns None. If prompt is provided, the user is shown a list of all places and can select one. The selected one is returned (or None if that selection is canceled).
FirstMapCentroid(plc)
Returns the centroid for the bounding box of the first map in the place record. The returned centroid will be [lat, lon] in a two element list. If the place has no map or its bounding box is not valid, the returned result will a list with one element having a string that describes the error.

Work with Structures

The methods in this section are convenience methods for working with structures.

AddStructure(grec,p)
Adds a structure subordinate to the record or structure in grec. It is added to the end of other subordinate structures. The structure properties are specified in the p argument as a dictionary. For example, to add an occupation to an individual, you could use:
AddStructure(indi,{"name":"OCCU","contents":"Electrician"})
The dictionary can use properties defined in GEDitCOM II's Apple Scripting dictionary. You do not need to set the structure level number because that is set automatically depending on where you add the structure.

Event Class

This class is a wrapper class for GEDCOM event data (individual or family events). It provides options for describing the event in a sentence for use in reports. It also caches the event data, which can speed up scripts if you need to access the event data more than once. For example, the methods calculate and return event data the first time they are called and store that result. If you call the method again, it returns a previously calculated result rather the having the re-read the data from GEDitCOM II. Similarly, the variables are read once when the instance is created and stored for later use.

Event Class Initialization

Event(e)
You create an instance of an Event class from any GEDCOM structure for an event.
evnt = Event(e)
The initialization reads the date and place. Other methods get output for the event only when needed and do it efficiently.

Event Class Variables

evnt.event
A reference to the original GEDCOM structure used to create the instance of the Event class.
evnt.date
The date for the event.
evnt.place
The place for the event and the place name is cleaned up when it is read. It removes extra commas, makes sure commas are followed by one space, and removes other leading and trailing spaces.

Event Class Methods

describe(verb[,atAge])
This method returns a phrase to describe the event in following style:
verb [at age (age)] (date) in (place)
    e.g., died at age 84 on 12 OCT 1856 in Boston, MA, USA
The phrase starts with the verb (e.g., "died"), optionally includes the age (if atAge is true), and ends with date and place.
randomDescribe(noun,verb[,atAge,freq])
This method returns one of three possible complete sentences to describe the event. The possibilities are
noun verb [at age (age)] (date) in (place)
    e.g. Sam Adams died at age 84 on 12 OCT 1856 in Boston, MA, USA
(date) [at age (age)], noun verb in (place)
    e.g. On 12 Oct 1856 at age 84, Sam Adams died in Boston, MA, USA
noun verb in (place) (date) [at age (age)]
    e.g. Sam Adams died in Boston, MA USA on 12 Oct 1856 at age 84
The noun is usually a person's name or a pronoun ("he" or "she", which will be capitalized if needed). The verb should be appropriate for the above phrases and the event type. The phrase optionally includes the age if atAge is true. The optional freq parameter determines the probability of each phrase. It should be a list with two numbers less than one, freq = [n1, n2]. Phrase 1 is picked with probability n1; phrase 2 with probability n2-n1; phrase 3 with probability 1-n2. The default setting is freq = [1./3., 2./3.], which makes each phrase equally likely with probability of 1/3.
describeDate()
This methods formats the date for better inclusion in reports. For single dates it will be "on 4 Jul 1776" for exact dates or "in 1979" for vague dates. For dates with GEDCOM words, it will replace the abbreviations with full lower-case English words. For example "BET 1920 AND 1930" would be changed to "between 1920 and 1930". Note: the replacements for GEDCOM date words or the words "on" and "in" can be changed using SetGedWords().
SDNRange()
Returns the serial day number range for the event's date in a two-number list. If there is no date or an invalid date, the returned list will be [0, 0].

Attribute Class

This class is a wrapper class for GEDCOM attribute data. It is a subclass of the Event class with the only change being that the phrases that are produced include the attribute value in their output.

According to the GEDCOM standard, residence structures are attributes, but unlike all other attributes, they have no value on the first line of the structure. In formatting residences for output, they work better be treating them as an event and wrapping them in an Event class instead of an Attribute class.

Attribute Class Initialization

Attribute(a)
You create an instance of an Attribute class from any GEDCOM structure for an attribute.
attr = Attribute(a)
The initialization reads the date and place. Other methods get output for the attribute only when needed and do it efficiently.

Attribute Class Variables

These variables are same as for the super Event class except that attr.event is a reference to the attribute.

Attribute Class Methods

The methods are the same as for the super Event class except that the description outputs are slightly altered:

describe(verb[,atAge])
The output will be a phrase formatted as follows:
verb (attribute value) [at age (age)] (date) in (place)
    e.g. occupation was brewer at age 84 on 12 OCT 1856 in Boston, MA, USA
where "occupation was" is the verb passed to this method and "brewer" is the value of the attribute inserted into the phrase. See this method in the Event class for more details.
randomDescribe(noun,verb[,atAge,freq])
The output will be one of three randomly chosen phrases:
noun verb (attribute value) [at age (age)] (date) in (place)
    e.g. Sam's occupation was brewer at age 84 on 12 OCT 1856 in Boston, MA, USA
(date) [at age (age)], noun verb (attribute value) in (place)
    e.g. On 12 Oct 1856 at age 84, Sam's occupation was brewer in Boston, MA, USA
noun verb (attribute value) in (place) (date) [at age (age)]
    e.g. Sam's occupation was brewer in Boston, MA USA on 12 Oct 1856 at age 84
Here noun should be a possessive noun. See this method in the Event class for more details.

User Interaction Functions

These methods make it easier to get input from the user.

Alert(mainText[,message)
Displays an alert window to the user with the main text in bold and the optional message in a smaller font. The window has a single "OK" button to close the window.
GetInteger(prompt,title[,istart,imin,imax])
Displays a window with a single editing field for the user to enter an integer. The first two parameters provide a prompt to the user above the editing field and a title for the window. The istart parameter is the initial integer in the editing field (defaults to 0 if omitted). The optional imin and imax specify the range of valid integers. If the user enters a number outside this range, and error message is provided and they are asked to try again. One or both limits can be specified. Finally, the function returns the entered integer or None if the user cancels the process.
GetOption(prompt,msg,options)
Displays a window with the prompt and one to three buttons. The text of the buttons are provided in options, which much be a list with one to three strings. The buttons are arranged right to left. The first button in the list is the default button (highlighted in blue and can be selected by typing return or enter). The msg parameter is an extra prompt for the user, which is displayed under the prompt in a smaller font. It can be None if not needed. The returned value is the text of the button the user clicks.
GetString(prompt[,initial,title])
Display a window with a single editing field and the prompt to the user above the field. The user can enter a single line of text and click "OK" or "Cancel". The initial parameter can provide initial text to be in the editing field. The optional title will be title of the window. When done, the function will return the text entered by the user or None if the process was canceled.
GetOneItem(items[,prompt,title])
Displays a window with a list of any number of items and a prompt to the user above that list. The window can have an optional title. The user can select one item and click "OK" or "Cancel" (or double click the one item). The function returns the text of the clicked item and the number for the clicked item in a two-element tuple - (item text, item number). The item numbers start at 1. It returns (None, None) if the selection is cancelled by the user. To select multiple items, you have to use the lower-level command list choice command rather than this convenience method in the module.

HTML Helper Functions

These method help formatting results to output into a report that is formatted using html elements. Their use is optional; you can always directly insert html elements into strings.

MakeTable(args)
This function builds part of an html table and returns the html code. You can uses a series of MakeTable() calls to build any size table. A template for its use (when using ScriptOutput class, but that is optional) is:
# start table then add optional add caption and header
rpt.out(MakeTable("begin","caption","Sample Table"))
rpt.out(MakeTable("head",headCols))
  
# body of the table
rpt.out(MakeTable("body"))
for i in range(numRows) :
    rpt.out(MakeTable("row c r",colData[i]))
    
# end the body and the table
rpt.out(MakeTable("endbody","end"))
The arguments to MakeTable() are keywords followed by zero or one parameter. Each call can have any number of keywords with parameters. A series of calls fill out the table. The table keywords, which are usually in this order, are:
  1. "begin" — Each table sequence must start with a begin keyword and it takes no parameters. It is like a <table> element in html content.
  2. "caption","Text for the caption" — Provides an optional table caption. It must be followed by one parameter that has the text of the caption.
  3. "head l c r mystyle",headCols — Provides an optional row of header cells. The text for the columns are in the list variable headCols. The head key word can optionally include alignment codes l, c, or r (separated by whitespace) to have the columns left justified, centered, or right justified. If any other alignment code is used (e.g., mystyle above), that header cell uses that class from the report's CSS options. If no alignment settings are used, the header row cells are centered.
  4. "body" — The body of the table data should begin with a body keyword. This keywords makes tables work better with the default cascading style sheet for reports.
  5. "row l c r mystyle",colData — Provides a row of data for the table. The text for the columns are in the list variable colData. The row key word can optionally be followed by alignment codes as explain for the head keyword, except that for columns, if no alignment settings are used, the columns are left justified.
  6. "endbody" — The body of the table data should end with an endbody keyword. This keyword makes tables work better with the default cascading style sheet for reports.
  7. "end" — Each table sequence must finish with an end keyword and it takes no parameters. It is like a </table> element in html content.
MakeList(alist[,ordered])
Converts any list of strings into an html list for inclusion in a report. The list can be numbered or unordered.
RecordLink(ref[,alternate])
Reports created in html can include internal links to records by using an <a> with its href set to the record's ID. This function helps insert those links. The text of the link can be the name() property of the record or its alternameName() property (depending on the optional alternate parameter).
Centered(ctext)
Returns html code to center the block of text in the passed string variable.

Date Functions

This methods help processing of date information.

GetAgeSpan(beginDate, endDate)
This function converts the time between two serial day numbers into the number of years. The time span is from the beginDate to the endDate.
SetGedWords(newWords)
This method sets new replacement strings when some other methods reformat dates for inclusion in reports (e.g., Event and Attribute classes). The default words are lower-case English versions:
{"ABT":"about","EST":"about","BEF":"before","AFT":"after",\
        "FROM":"from","TO":"to","BET":"between","AND":"and",\
        "CAL":"calculated","INT":"interpreted",\
        "ON":"on","IN":"in"}
The new dictionary must specify new strings for all these key words. One use could be to format dates in a different language. A script can fetch these string using GetGedWord().
GetGedWord(key)
Returns a defined replacement string for a GEDCOM key word. These are usually key words used in GEDCOM dates and all the standard keys are defined in the SetGedWords() method (although a script could add additional keys, if needed, by using SetGedWords()).

Latitude and Longitude Functions

These functions are for help working with latitude and longitude coordinates in various editing fields.

GetBoundingBox(gpsStr)
This method will decode any format supported by bounding boxes in place records and return a rectangle of signed latitude and longitude values. The returned rectangle will be [south, west, north, east] in a four element list. If the input data are not valid, the returned result will be a list with one element having a string that describes the error.
GetLatLonCentroid(gpsStr)
This method will decode any format supported by bounding boxes in place records and return latitude and longitude for its centroid. The returned centroid will be [lat, lon] in a two element list. If the input data are not valid, the returned result will be a list with one element having a string that describes the error.
kmDistanceBetween(pt1,pt2)
This method will find the distance between any two latitude and longitude locations on earth. The latitude and longitude must be signed numbers.
kmPerLatitudeDegree()
Returns the number of kilometers per latitude degree on surface of the earth. It is always 111.195
kmPerLongitudeDegree(atLat)
Returns the number of kilometers per longitude degree on surface of the earth when moving east or west at a constant latitude value. The latitude value is provided in the parameter.

Utility Functions

These methods provide various utility functions for scripts.

GetScriptName()
Returns the name of the current script. The name is the name provided to CheckVersionAndDocument() method when the script starts. Thus, this method assumes that method was used, but all Python scripts should start with that method to check the current version and to verify a document is open.
ProgressMessage(fraction[,msg])
Scripting of GEDitCOM II is a great tool, but it can get slow for large calculations in large files. For this reason, all good GEDitCOM II scripts should inform the user of the progress of the calculations. Here is sample code:
# set progress variables
fractionStepSize = nextFraction = 0.01
  
# main script loop
for i in range(1, numTasks)
    # the script code
      
    # time for progress
    fractionDone = float(i) / float(numTasks)
    if fractionDone > nextFraction:
        ProgressFraction(fractionDone)
        nextFraction = nextFraction + fractionStepSize
At the beginning of the script you define two variables. The fractionStepSize defines how often to inform the user of progress. There is no point in sending too many notifications since the progress is rounded to the nearest percent. A good choice is usually to notify the user after each percent is completed and thus fractionStepSize is set to 0.01. The nextFraction variable defines the next time the notification should be sent to GEDitCOM II. It is initialized to the same value as fractionStepSize to define the point for the first notification.
    Periodically during the script, you should then calculate the fraction of the script that has finished. This sample code shows a script with a repeat loop that will execute numTasks times. At the end the each pass through the loop, the fractionDone is easily calculated to be i/numTasks (converted to floating point). If this fraction has passed a predetermined notification point (stored in nextFraction), the fraction is sent to GEDitCOM II using ProgressMessage() and nextFraction is advanced by the fractionStepSize defined at the start of the script.
    For other scripts, it may be harder to determine the fraction completed (such as a script searching for ancestors when you do not know how many ancestors will be found). For these scripts, you have three options. First, you can periodically guess the fraction. Second, you can post a message to the user with the optional msg argument; it can be any string. Third, you can do nothing; GEDitCOM II will provide a spinning indicator to tell the user the script is running.
WaitForWindow(prevID[,maxTime])
MacOS Ventura introduced a bug into python scripting. Whenever a script opens a new window, MacOS Ventura (and likely newer) does not report the correct front-most window for a short amount of time. A work around to this problem is to call this method whenever a new window is created. A template example for its use is:
# save the previous window's id
prevId=gedit.windows()[0].id()
  ...
# a command that creates a new window (such as report output)
rpt.write()
# after that command, wait for new window to be noticed
WaitForWindow(prevId)
  ...
# now can access the front-most window in other commands
This call fixes scripts running in MacOS Ventura and works in prior MacOS's as well. The required parameter is id of the window that was opened prior to opening the new window. By default, this method will wait a maximum of 1 second. You can change the maximum wait time if needed with the optional maxTime parameter in seconds. The required wait is typically less than 10 ms (or 0.01 seconds)
Cardinal(anum)
For numbers 0 to 10, it returns the number as a word, such as "zero", "one", "two", etc.; for all other numbers it converts the number to a string and returns the result. The words and the range of words can be customized with SetCardinal().
SetCardinal(newCards)
You can pass a list of words to replace the default English words for cardinal numbers. The list must start with the word for 0 and continue as high as you want for 1, 2, 3, etc..
RomanNumeral(number)
For integers 1 to 4999, it returns Roman number (using upper case letters) for the number; for all other numbers it converts the number to a string and returns the result.
CapitalOne(target)
Capitalize the string by converting the first character only to upper case. The rest of the string is unaltered.
OpenWebSite(website)
Open a web site in the default browser application.
GetMainScreenSize()
This function gets the size of the visible area on the main screen. For computers with multiple monitors, it is the screen with the menu bar. The result is returned as [x, y, width, height] where x and y are coordinates of lower-left corner and width and height are the size of the visible area. The visible area will leave room for the dock (if visible) and the menu bar.
SayText(utext)
This method will read the provided text using built-in MacOS speech synthesis methods.
GCConstant(constantName)
Some commands take arguments that select among two or more defined constants in the Apple Scripting dictionary for GEDitCOM II. Similarly, the restriction property of individual records returns a defined constant. These constants are used in AppleScript by their name, but in Python scripts, you have to use the underlying numeric codes instead. The GCConstant() function converts a named constant into its numeric value. The constant's name is passed as the subroutine's single argument as a string variable.
    The current named constants are: "chart", "outline", "the children", "the events", "the spouses", "charMacOS", "charANSEL", "charUTF8", "charUTF16", "charWindows", "linesLF", "linesCR", "linesCRLF", "mmGEDitCOM", "mmEmbed", "mmPhpGedView", "logsInclude", "logsOmit", "locked", "privacy", and "unlocked".
DoCommand(command_line)
The function executes a shell command, waits for the output, and then returns the result as a string. For example, the following commands will list the files in the working directory:
sc = DoCommand("ls -la")
print sc
The shell command is a generic command (i.e., not under your user name) and thus this example returns the directory of the computer's root folder.
WriteUTF8File(saveFile,text[,silent])
Write the text (in a possibly unicode string) to a file using UTF8 encoding. The file name must be the full POSIX path (folders delimited by slashes) to the file. If the save is successful, this method returns None after saving. If an error occurs, this method returns a description of the error. If silent is False, the user is also alerted of the error using a standard alert window. If silent is True, the description is returned without showing an alert (the default for silent is False).