Permalink
Browse files

Skip lines with only whitespace

  • Loading branch information...
1 parent 2a728f4 commit 61c08ec8aa4be0ce93adbcf9ca7d95f2894ae190 @martijnvermaat martijnvermaat committed Sep 23, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 vcf/parser.py
View
@@ -185,18 +185,20 @@ def __init__(self, fsock=None, filename=None, compressed=False, prepend_chr=Fals
raise Exception('You must provide at least fsock or filename')
if fsock:
- self.reader = fsock
+ self._reader = fsock
if filename is None and hasattr(fsock, 'name'):
filename = fsock.name
compressed = compressed or filename.endswith('.gz')
elif filename:
compressed = compressed or filename.endswith('.gz')
- self.reader = open(filename, 'rb' if compressed else 'rt')
+ self._reader = open(filename, 'rb' if compressed else 'rt')
self.filename = filename
if compressed:
- self.reader = gzip.GzipFile(fileobj=self.reader)
+ self._reader = gzip.GzipFile(fileobj=self._reader)
if sys.version > '3':
- self.reader = codecs.getreader('ascii')(self.reader)
+ self._reader = codecs.getreader('ascii')(self._reader)
+
+ self.reader = (line for line in self._reader if line.rstrip())
#: metadata fields from header (string or hash, depending)
self.metadata = None

0 comments on commit 61c08ec

Please sign in to comment.