|
55 | 55 |
|
56 | 56 | import os
|
57 | 57 | import re
|
| 58 | +from configparser import ConfigParser |
| 59 | + |
58 | 60 | from yapsy import log
|
59 |
| -from yapsy.compat import ConfigParser, is_py2, basestring |
60 | 61 |
|
61 | 62 | from yapsy.PluginInfo import PluginInfo
|
62 | 63 | from yapsy import PLUGIN_NAME_FORBIDEN_STRING
|
63 | 64 | from yapsy.IPluginLocator import IPluginLocator
|
64 | 65 |
|
65 | 66 |
|
| 67 | +_BASIC_STRING_CLASSES = (str, bytes) |
66 | 68 |
|
67 | 69 |
|
68 | 70 | class IPluginFileAnalyzer(object):
|
@@ -180,10 +182,7 @@ def getPluginNameAndModuleFromStream(self, infoFileObject, candidate_infofile=No
|
180 | 182 | # parse the information buffer to get info about the plugin
|
181 | 183 | config_parser = ConfigParser()
|
182 | 184 | try:
|
183 |
| - if is_py2: |
184 |
| - config_parser.readfp(infoFileObject) |
185 |
| - else: |
186 |
| - config_parser.read_file(infoFileObject) |
| 185 | + config_parser.read_file(infoFileObject) |
187 | 186 | except Exception as e:
|
188 | 187 | log.debug("Could not parse the plugin file '%s' (exception raised was '%s')" % (candidate_infofile,e))
|
189 | 188 | return (None, None, None)
|
@@ -216,7 +215,7 @@ def _extractCorePluginInfo(self,directory, filename):
|
216 | 215 | and decorators.
|
217 | 216 | """
|
218 | 217 | # now we can consider the file as a serious candidate
|
219 |
| - if not isinstance(filename, basestring): |
| 218 | + if not isinstance(filename, _BASIC_STRING_CLASSES): |
220 | 219 | # filename is a file object: use it
|
221 | 220 | name, moduleName, config_parser = self.getPluginNameAndModuleFromStream(filename)
|
222 | 221 | else:
|
@@ -514,7 +513,7 @@ def setPluginPlaces(self, directories_list):
|
514 | 513 | """
|
515 | 514 | Set the list of directories where to look for plugin places.
|
516 | 515 | """
|
517 |
| - if isinstance(directories_list, basestring): |
| 516 | + if isinstance(directories_list, _BASIC_STRING_CLASSES): |
518 | 517 | raise ValueError("'directories_list' given as a string, but expected to be a list or enumeration of strings")
|
519 | 518 | if directories_list is None:
|
520 | 519 | directories_list = [os.path.dirname(__file__)]
|
|
0 commit comments