From acaad08ab21889877c15760589533c1aed41964d Mon Sep 17 00:00:00 2001 From: rltest Date: Sat, 28 Oct 2017 18:28:58 +0200 Subject: [PATCH] print_gedcom can write in any output stream --- gedcom/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gedcom/__init__.py b/gedcom/__init__.py index c652829..1b20dd7 100644 --- a/gedcom/__init__.py +++ b/gedcom/__init__.py @@ -28,6 +28,7 @@ # Global imports import re +import sys class Gedcom: """Parses and manipulates GEDCOM 5.5 format data @@ -292,11 +293,12 @@ def get_family_members(self, family, mem_type="ALL"): # Other methods - def print_gedcom(self): - """Write GEDCOM data to stdout.""" + def print_gedcom(self, file=sys.stdout, flush=False): + """Write GEDCOM data to stream (default is sys.stdout). + argument (default is False) as the same semantics than + in the print function. """ for element in self.element_list(): - print(element) - + print(element, file=file, flush=flush) class GedcomParseError(Exception): """ Exception raised when a Gedcom parsing error occurs