From 83a6b8a66a4f7ed5b3ba546a02ff4a109a851782 Mon Sep 17 00:00:00 2001 From: Dario Meloni Date: Thu, 26 Jul 2018 17:42:24 +0100 Subject: [PATCH] Open pattern files using UTF-8 encoding Closes #33 --- pygrok/pygrok.py | 3 ++- setup.py | 0 2 files changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 setup.py diff --git a/pygrok/pygrok.py b/pygrok/pygrok.py index e2c22bc..142d122 100644 --- a/pygrok/pygrok.py +++ b/pygrok/pygrok.py @@ -3,6 +3,7 @@ except ImportError as e: # If you import re, grok_match can't handle regular expression containing atomic group(?>) import re +import codecs import os import pkg_resources @@ -105,7 +106,7 @@ def _load_patterns_from_file(file): """ """ patterns = {} - with open(file, 'r') as f: + with codecs.open(file, 'r', encoding='utf-8') as f: for l in f: l = l.strip() if l == '' or l.startswith('#'): diff --git a/setup.py b/setup.py old mode 100644 new mode 100755