Browse Source

ignore comments properly

master
Pavel Šimerda 6 years ago
parent
commit
48033de191
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      lib/invoice/db/base.py

+ 3
- 0
lib/invoice/db/base.py View File

@@ -163,6 +163,7 @@ class Data(object):
_fields = []
_multivalue_fields = []
_line_regex = re.compile(r"^([A-Z][a-zA-Z-]*):\s+(.*?)\s+$")
_comment_regex = re.compile(r"^\s*#")

def __init__(self, item):
self._item = item
@@ -179,6 +180,8 @@ class Data(object):
for f in self._multivalue_fields:
self._data[f] = []
for n, line in enumerate(stream):
if self._comment_regex.match(line):
continue
match = self._line_regex.match(line)
if not match:
log.warning("Ignoring {0}:{1}: {2}".format(n, self._item._name, line))


Loading…
Cancel
Save