def getIndigoExceptionText(e): if isJython(): return e.message elif isIronPython(): return e.Message.replace("\\'", "'") else: value = str(e) if value[0] == '\'' and value[-1] == '\'': value = value[1:-1] if value[0] == '"' and value[-1] == '"': value = value[1:-1] return value.replace("\\'", "'")
def open_file_utf8(filename): import codecs if isJython(): return open(filename, 'wt') elif isIronPython(): # TODO: FIXME (maybe on C# site?) return codecs.open(filename, 'wb', encoding='utf-8') # FAILED: wrong symbols # return open(filename, 'wt') # ERROR: UnicodeEncodeError: 'ascii' codec can't encode character '\uFFFD' in position 814: ordinal not in range(128) # return open(filename, 'wb') # ERROR: UnicodeEncodeError: 'ascii' codec can't encode character '\uFFFD' in position 724: ordinal not in range(128) # return codecs.open(filename, 'wb') # # ERROR: UnicodeEncodeError: 'ascii' codec can't encode character '\uFFFD' in position 724: ordinal not in range(128) else: if sys.version_info.major < 3: return open(filename, 'wt') else: return codecs.open(filename, 'wb', encoding='utf-8')
def __init__(self, path=None): Indigo.__init__(self, path) if isJython() or isIronPython(): IndigoObject = IndigoObjectCoverageWrapper # TODO: Change standard IndigoObject to IndigoObjectCoverageWrapper else: self.IndigoObject = IndigoObjectCoverageWrapper self._indigoObjectCoverageDict = dict() self._indigoObjectCoverageByTypeDict = dict() m = self.createMolecule() for item in getmembers(m): if type(item[1]) in (BuiltinFunctionType, BuiltinMethodType, MethodType, FunctionType) and not item[0].startswith('_'): self._indigoObjectCoverageDict[item[0]] = 0 self._indigoCoverageDict = dict() for item in getmembers(self): if type(item[1]) in (BuiltinFunctionType, BuiltinMethodType, MethodType, FunctionType) and not item[0].startswith('_'): self._indigoCoverageDict[item[0]] = 0
if 'INDIGO_COVERAGE' in os.environ: from indigo_coverage import IndigoCoverageWrapper as Indigo, IndigoObjectCoverageWrapper as IndigoObject, IndigoException, IndigoRenderer, IndigoInchi Indigo.IndigoObject = IndigoObject else: cur_path = os.path.abspath(os.path.dirname(__file__)) distPaths = [ os.path.normpath(os.path.join(cur_path, '../../../../dist')), ] success = False indigo_root = os.path.dirname( os.path.dirname( os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) if isIronPython(): if not 'INDIGO_PATH' in os.environ: import clr target_framework = 'netstandard2.0' dll_full_path = os.path.normpath( os.path.abspath( os.path.join( indigo_root, "api/dotnet/bin/Release/{}/Indigo.Net.dll".format( target_framework)))) if not os.path.exists(dll_full_path): for distPath in distPaths: if not dir_exists(distPath): continue dll_full_path_base = None for item in os.listdir(distPath):