add encoding parameter to all file open() calls in code samples, example files, and text

This commit is contained in:
Mark Pilgrim
2009-07-16 12:36:37 -04:00
parent 49fae282ec
commit e35d9d1bda
8 changed files with 24 additions and 23 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ def build_match_and_apply_functions(pattern, search, replace):
return [matches_rule, apply_rule]
rules = []
with open('plural4-rules.txt') as pattern_file:
with open('plural4-rules.txt', encoding='utf-8') as pattern_file:
for line in pattern_file:
pattern, search, replace = line.split(None, 3)
rules.append(build_match_and_apply_functions(
+1 -1
View File
@@ -15,7 +15,7 @@ def build_match_and_apply_functions(pattern, search, replace):
return [matches_rule, apply_rule]
def rules(rules_filename):
with open(rules_filename) as pattern_file:
with open(rules_filename, encoding='utf-8') as pattern_file:
for line in pattern_file:
pattern, search, replace = line.split(None, 3)
yield build_match_and_apply_functions(pattern, search, replace)
+1 -1
View File
@@ -18,7 +18,7 @@ class LazyRules:
rules_filename = 'plural6-rules.txt'
def __iter__(self):
self.pattern_file = open(self.rules_filename)
self.pattern_file = open(self.rules_filename, encoding='utf-8')
self.cache = []
self.cache_index = 0
return self