|
4 | 4 | """ |
5 | 5 | import fnmatch |
6 | 6 | import re |
7 | | -import os |
8 | 7 | import string |
9 | | -import types |
10 | | -import yaml.parser |
| 8 | +from six import string_types |
11 | 9 |
|
12 | 10 | from . import config |
13 | 11 |
|
@@ -77,12 +75,12 @@ def update(self, values): |
77 | 75 | for (key, value) in values.items(): |
78 | 76 | # Check type |
79 | 77 | if key == 'priority': |
80 | | - if type(value) != int: |
| 78 | + if not isinstance(value, int): |
81 | 79 | raise LanguageConfigError( |
82 | 80 | 'Language %s: priority must be integer but is %s.' |
83 | 81 | % (self.lang_id, type(value))) |
84 | 82 | else: |
85 | | - if type(value) != bytes: |
| 83 | + if not isinstance(value, string_types): |
86 | 84 | raise LanguageConfigError( |
87 | 85 | 'Language %s: %s must be string but is %s.' |
88 | 86 | % (self.lang_id, key, type(value))) |
@@ -209,18 +207,18 @@ def update(self, data): |
209 | 207 | for a language already in the set, the configuration |
210 | 208 | for that language will be overridden and updated. |
211 | 209 | """ |
212 | | - if type(data) is not dict: |
| 210 | + if not isinstance(data, dict): |
213 | 211 | raise LanguageConfigError( |
214 | 212 | 'Config file error: content must be a dictionary, but is %s.' |
215 | 213 | % (type(data))) |
216 | 214 |
|
217 | 215 | for (lang_id, lang_spec) in data.items(): |
218 | | - if type(lang_id) is not bytes: |
| 216 | + if not isinstance(lang_id, string_types): |
219 | 217 | raise LanguageConfigError( |
220 | 218 | 'Config file error: language IDs must be strings, but %s is %s.' |
221 | 219 | % (lang_id, type(lang_id))) |
222 | 220 |
|
223 | | - if type(lang_spec) is not dict: |
| 221 | + if not isinstance(lang_spec, dict): |
224 | 222 | raise LanguageConfigError( |
225 | 223 | 'Config file error: language spec must be a dictionary, but spec of language %s is %s.' |
226 | 224 | % (lang_id, type(lang_spec))) |
|
0 commit comments