Update GEDCOM Header in getmyancestors.py for 5.5.1 compliance. (#11)
authorchangeling <cklarson@gmail.com>
Mon, 11 Mar 2019 06:28:54 +0000 (01:28 -0500)
committerLinekio <benoitfontaine.ba@gmail.com>
Mon, 11 Mar 2019 06:28:54 +0000 (07:28 +0100)
* Update GEDCOM Header in getmyancestors.py for 5.5.1 compliance.

getmyancestors.py: Add SOUR, SUBM ref and SUBM entry. Update VERS to 5.5.1.
(UTF-8 is only in GEDCOM 5.5.1 and not 5.5, but getmyancestors creates header with VERS 5.5 and encoding UTF-8.)

* Fix Notes: set the text attribute before adding to Tree

* Updated to render correct ordinals in Download progress counts.

fstogedcom.py:
Lines 34-45: Implemented ordinal() function.
Line 441: Yield correct ordinal for ancestor generations.
Line 450: Yield correct ordinal for descendant generations.

getmyancestors.py
Lines 107-118: Implemented ordinal() function.
Line: 960: Yield correct ordinal for ancestor generations.
Line 970: Yield correct ordinal for descendant generations.

translation.py
Lines 104-115: Translate ordinal suffixes.
Lines 116-120: Translate updated ancestor and descendant generation strings.

Fixed string slice in ordinal() to correctly handle 11, 12, 13.

Fixed string slice in ordinal() to correctly handle 11, 12, 13 in fstogedcom.py and getmyancestors.py.

* Replaced ordinal() function and calls with num2word module and calls.

Replaced ordinal() function and calls with num2word module and calls in fstogedcom.py and getmyancestors.py.

Removed ordinal suffixes from translation.py.

* Update README.md to reference num2words and github repository.

Added num2words requirement to README.md.
Add references for github repository to README.md.

* Update getmyancestors.py to add more 5.5.1 HEAD entries.

Add display_name to Session().
Assign display_name from current.json ['users'][0]['displayName'].
Add 'getmyancestors' value for HEAD.SOUR, HEAD.SOUR.NAME, HEAD.DEST. See:
https://www.tamurajones.net/GEDCOMSOURandDEST.xhtml for discussion.
Add HEAD.SOUR.VERS with placeholder value for version.
Add HEAD.DATE and HEAD.TIME.
Add SUBM.NAME from Family Search displayName for current user.
Add SUBM.LANG from Family Search displayName for current user. NOTE: This value is invalid.
TODO: Fix 2-char lang value to full language name for legal GEDCOM.

* Update getmyancestors.py to correct SUBM.LANG format.

Added import of babelfish to handle language formats.
Added babelfish conversion to SUBM.LANG to convert alpha2 language code (i.e. `en`) from Family Search to legal GEDCOM language code (i.e. `ENGLISH`).
Updated README.md to include reference to babelfish module.

* Revert "Merge pull request #9 from changeling/handle_ordinals"

This reverts commit 88e724d1b6d590af7dd4f7d91dbe4997bfd6a0a6, reversing
changes made to 0a0a1035f9f4c4a985069f2a914851e630e84b50.

* Change information text about downloading generations

* Update GEDCOM Header in getmyancestors.py for 5.5.1 compliance.

getmyancestors.py: Add SOUR, SUBM ref and SUBM entry. Update VERS to 5.5.1.
(UTF-8 is only in GEDCOM 5.5.1 and not 5.5, but getmyancestors creates header with VERS 5.5 and encoding UTF-8.)

* Update getmyancestors.py to add more 5.5.1 HEAD entries.

Add display_name to Session().
Assign display_name from current.json ['users'][0]['displayName'].
Add 'getmyancestors' value for HEAD.SOUR, HEAD.SOUR.NAME, HEAD.DEST. See:
https://www.tamurajones.net/GEDCOMSOURandDEST.xhtml for discussion.
Add HEAD.SOUR.VERS with placeholder value for version.
Add HEAD.DATE and HEAD.TIME.
Add SUBM.NAME from Family Search displayName for current user.
Add SUBM.LANG from Family Search displayName for current user. NOTE: This value is invalid.
TODO: Fix 2-char lang value to full language name for legal GEDCOM.

* Update getmyancestors.py to correct SUBM.LANG format.

Added import of babelfish to handle language formats.
Added babelfish conversion to SUBM.LANG to convert alpha2 language code (i.e. `en`) from Family Search to legal GEDCOM language code (i.e. `ENGLISH`).
Updated README.md to include reference to babelfish module.

* Updated `README.md` and `getmyancestors.py` re  5.5.1.

`getmyancestors.py`:
Remove `DEST` tag.
Set `SOUR.VERS` to 1.0.
Implement `babelfish` module to correct FamilySearch `LANG` to match iso639 full language for 5.5.1 compliance.
`README.md`.:
Add babelfish.
Modify requirement install instruction for readability and line length re PEP 8.
Add github Issues link.

* Revert "Merge branch '551_compliance' of https://github.com/changeling/getmyancestors into 551_compliance"

This reverts commit 94b9fda218fdb316e1479c1661a1956f9ef4f2fb, reversing
changes made to ec42301fcbbef74d60a3c79f6e13885215ac47c8.

README.md
getmyancestors.py

index 84e3894a8e509a6e5da1a3a702fcf4ff68d52869..1778c93e49a5780b5f9f081948502be76d89263e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -5,7 +5,17 @@ getmyancestors.py is a python3 script that downloads family trees in GEDCOM form
 
 This program is now in production phase, but bugs might still be present. Features will be added on request. It is provided as is.
 
-This script requires python3 and the requests module to work. To install this module on Linux, run in your terminal: "python3 -m pip install requests" (or "python3 -m pip install --user requests" if you don't have admin rights on your machine).
+The project is maintained at https://github.com/Linekio/getmyancestors. Visit here for the latest version and more information.
+
+This script requires python3, the requests module, and the babelfish module to work. To install the modules, run in your terminal:
+
+For requests:
+
+"python3 -m pip install requests" (or "python3 -m pip install --user requests" if you don't have admin rights on your machine).
+
+For babelfish:
+
+"python3 -m pip install babelfish" (or "python3 -m pip install --user babelfish" if you don't have admin rights on your machine).
 
 This script requires python 3.4 (or higher) to run due to some novel features in the argparse and asyncio modules (https://docs.python.org/3/whatsnew/3.4.html)
 
@@ -71,7 +81,7 @@ python3 getmyancestors.py -c -u username -p password -i LF7T-Y4C -o out.ged
 Support
 =======
 
-Send questions, suggestions, or feature requests to benoitfontaine.ba@gmail.com or giulio.genovese@gmail.com
+Send questions, suggestions, or feature requests to benoitfontaine.ba@gmail.com or giulio.genovese@gmail.com, or open an Issue at https://github.com/Linekio/getmyancestors/issues
 
 Donation
 ========
index 6c94bfd81913d5ef01f6eae5904d78e44cf4b3fc..4553a82cecf7478f90b5287e02919305e937698b 100755 (executable)
@@ -40,6 +40,13 @@ except ImportError:
     sys.stderr.write('(run this in your terminal: "python3 -m pip install requests" or "python3 -m pip install --user requests")\n')
     exit(2)
 
+try:
+    import babelfish
+except ImportError:
+    sys.stderr.write('You need to install the babelfish module first\n')
+    sys.stderr.write('(run this in your terminal: "python3 -m pip install babelfish" or "python3 -m pip install --user babelfish")\n')
+    exit(2)
+
 MAX_PERSONS = 200  # is subject to change: see https://www.familysearch.org/developers/docs/api/tree/Persons_resource
 
 FACT_TAGS = {
@@ -112,7 +119,7 @@ class Session:
         self.verbose = verbose
         self.logfile = logfile
         self.timeout = timeout
-        self.fid = self.lang = None
+        self.fid = self.lang = self.display_name = None
         self.counter = 0
         self.logged = self.login()
 
@@ -225,6 +232,7 @@ class Session:
         if data:
             self.fid = data['users'][0]['personId']
             self.lang = data['users'][0]['preferredLanguage']
+            self.display_name = data['users'][0]['displayName']
 
     def get_userid(self):
         if not self.fid:
@@ -865,8 +873,18 @@ class Tree:
         file.write('0 HEAD\n')
         file.write('1 CHAR UTF-8\n')
         file.write('1 GEDC\n')
-        file.write('2 VERS 5.5\n')
+        file.write('2 VERS 5.5.1\n')
         file.write('2 FORM LINEAGE-LINKED\n')
+        file.write('1 SOUR getmyancestors\n')
+        file.write('2 VERS 1.0\n')
+        file.write('2 NAME getmyancestors\n')
+        file.write('1 DATE ' + time.strftime('%d %b %Y') + '\n')
+        file.write('2 TIME ' + time.strftime('%H:%M:%S') + '\n')
+        file.write('1 SUBM @SUBM@\n')
+        file.write('0 @SUBM@ SUBM\n')
+        file.write('1 NAME ' + self.fs.display_name + '\n')
+        file.write('1 LANG ' + babelfish.Language.fromalpha2(self.fs.lang).name + '\n')
+
         for fid in sorted(self.indi, key=lambda x: self.indi.__getitem__(x).num):
             self.indi[fid].print(file)
         for husb, wife in sorted(self.fam, key=lambda x: self.fam.__getitem__(x).num):