Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print_gedcom can write in any output stream #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions gedcom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

# Global imports
import re
import sys

class Gedcom:
"""Parses and manipulates GEDCOM 5.5 format data
Expand Down Expand Up @@ -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 <file> (default is sys.stdout).
<flush> 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
Expand Down