cantera/interfaces/cython/cantera/utils.pyx
Ray Speth 7065076320 [Cython] Changed variable names to be consistent with PEP8
Instance methods and instance variables all follow the words_with_underscores
convention, rather than using mixedCaseNames.
2013-01-30 22:05:30 +00:00

26 lines
668 B
Cython

import sys
cdef int _pythonMajorVersion = sys.version_info[0]
cdef string stringify(x):
""" Converts Python strings to std::string. """
# This method works with both Python 2.x and 3.x.
tmp = bytes(x.encode())
return string(tmp)
cdef pystr(string x):
cdef bytes s = x.c_str()
if _pythonMajorVersion == 2:
# Python 2.x
return s
else:
# Python 3.x
return s.decode()
def add_directory(directory):
""" Add a directory to search for Cantera data files. """
CxxAddDirectory(stringify(directory))
def _have_sundials():
return bool(get_sundials_version())
__version__ = pystr(get_cantera_version())