我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用pyparsing.__version__()。
def check(self): try: import dateutil except ImportError: # dateutil 2.1 has a file encoding bug that breaks installation on # python 3.3 # https://github.com/matplotlib/matplotlib/issues/2373 # hack around the problem by installing the (working) v2.0 #major, minor1, _, _, _ = sys.version_info #if self.version is None and (major, minor1) == (3, 3): #self.version = '!=2.1' raise CheckFailed ( "could not be found") major, minor1, _, _, _ = sys.version_info if dateutil.__version__ == '2.1' and (major, minor1) == (3, 3): raise CheckFailed ( "dateutil v. 2.1 has a bug that breaks installation" "on python 3.3.x, use another dateutil version") return "using dateutil version %s" % dateutil.__version__
def check(self): try: import pyparsing except ImportError: raise CheckFailed( "could not be found") required = [1, 5, 6] if [int(x) for x in pyparsing.__version__.split('.')] < required: raise CheckFailed( "matplotlib requires pyparsing >= {0}".format( '.'.join(str(x) for x in required))) if not self.is_ok(): return ( "Your pyparsing contains a bug that will be monkey-patched by " "matplotlib. For best results, upgrade to pyparsing 2.0.1 or " "later.") return "using pyparsing version %s" % pyparsing.__version__
def check(self): super(Tests, self).check() msgs = [] msg_template = ('{package} is required to run the matplotlib test ' 'suite. Please install it with pip or your preferred' ' tool to run the test suite') bad_nose = msg_template.format( package='nose %s or later' % self.nose_min_version ) try: import nose if is_min_version(nose.__version__, self.nose_min_version): msgs += ['using nose version %s' % nose.__version__] else: msgs += [bad_nose] except ImportError: msgs += [bad_nose] if sys.version_info >= (3, 3): msgs += ['using unittest.mock'] else: try: import mock msgs += ['using mock %s' % mock.__version__] except ImportError: msgs += [msg_template.format(package='mock')] return ' / '.join(msgs)
def check(self): min_version = extract_versions()['__version__numpy__'] try: import numpy except ImportError: raise CheckFailed( "could not be found" ) if not is_min_version(numpy.__version__, min_version): raise CheckFailed( "requires numpy %s or later to build. (Found %s)" % (min_version, numpy.__version__)) return 'version %s' % numpy.__version__
def check(self): try: import six except ImportError: raise CheckFailed("six was not found.") if not is_min_version(six.__version__, self.min_version): return ("The installed version of six is {inst_ver} but " "a the minimum required version is {min_ver}. " "pip/easy install will attempt to install a " "newer version." ).format(min_ver=self.min_version, inst_ver=six.__version__) return "using six version %s" % six.__version__
def parse_dot_data(data): global top_graphs top_graphs = list() if data.startswith(codecs.BOM_UTF8): data = data.decode( 'utf-8' ) try: graphparser = graph_definition() if pyparsing_version >= '1.2': graphparser.parseWithTabs() tokens = graphparser.parseString(data) if len(tokens) == 1: return tokens[0] else: return [g for g in tokens] except ParseException, err: print err.line print " "*(err.column-1) + "^" print err return None
def parse_dot_data(data): global top_graphs top_graphs = list() if PY3: if isinstance(data, bytes): # this is extremely hackish try: idx = data.index(b'charset') + 7 while data[idx] in b' \t\n\r=': idx += 1 fst = idx while data[idx] not in b' \t\n\r];,': idx += 1 charset = data[fst:idx].strip(b'"\'').decode('ascii') data = data.decode(charset) except Exception: data = data.decode('utf-8') else: if data.startswith(codecs.BOM_UTF8): data = data.decode('utf-8') try: graphparser = graph_definition() if pyparsing.__version__ >= '1.2': graphparser.parseWithTabs() tokens = graphparser.parseString(data) if len(tokens) == 1: return tokens[0] else: return [g for g in tokens] except pyparsing.ParseException: err = sys.exc_info()[1] print(err.line) print(" " * (err.column - 1) + "^") print(err) return None
def parse_dot_data(data): global top_graphs top_graphs = list() if PY3: if isinstance(data, bytes): # this is extremely hackish try: idx = data.index(b'charset') + 7 while data[idx] in b' \t\n\r=': idx += 1 fst = idx while data[idx] not in b' \t\n\r];,': idx += 1 charset = data[fst:idx].strip(b'"\'').decode('ascii') data = data.decode(charset) except: data = data.decode('utf-8') else: if data.startswith(codecs.BOM_UTF8): data = data.decode('utf-8') try: graphparser = graph_definition() if pyparsing_version >= '1.2': graphparser.parseWithTabs() tokens = graphparser.parseString(data) if len(tokens) == 1: return tokens[0] else: return [g for g in tokens] except ParseException: err = sys.exc_info()[1] print(err.line) print(" " * (err.column - 1) + "^") print(err) return None