public PythonTypeDatabase( PythonInterpreterFactoryWithDatabase factory, IEnumerable <string> databaseDirectories = null, PythonTypeDatabase innerDatabase = null ) { if (innerDatabase != null && factory.Configuration.Version != innerDatabase.LanguageVersion) { throw new InvalidOperationException("Language versions do not match"); } _factory = factory; if (innerDatabase != null) { _sharedState = new SharedDatabaseState(innerDatabase._sharedState); } else { _sharedState = new SharedDatabaseState(_factory.Configuration.Version); } if (databaseDirectories != null) { foreach (var d in databaseDirectories) { LoadDatabase(d); } } _sharedState.ListenForCorruptDatabase(this); }
internal SharedDatabaseState(SharedDatabaseState inner) { _inner = inner; _langVersion = _inner.LanguageVersion; if (_inner.BuiltinModule != null) { _builtinName = _inner.BuiltinModule.Name; } else { _builtinName = (_langVersion.Major == 3) ? BuiltinName3x : BuiltinName2x; } }
private PythonTypeDatabase( PythonInterpreterFactoryWithDatabase factory, string databaseDirectory, bool isDefaultDatabase ) { _factory = factory; _sharedState = new SharedDatabaseState( factory.Configuration.Version, databaseDirectory, defaultDatabase: isDefaultDatabase ); }
public IPythonType GetBuiltinType(BuiltinTypeId id) { if (id == BuiltinTypeId.Unknown || _database.BuiltinModule == null) { return(null); } var name = SharedDatabaseState.GetBuiltinTypeName(id, _database.LanguageVersion); var res = _database.BuiltinModule.GetAnyMember(name) as IPythonType; if (res == null) { throw new KeyNotFoundException(string.Format("{0} ({1})", id, (int)id)); } return(res); }
public PythonTypeDatabase( PythonInterpreterFactoryWithDatabase factory, IEnumerable<string> databaseDirectories = null, PythonTypeDatabase innerDatabase = null ) { if (innerDatabase != null && factory.Configuration.Version != innerDatabase.LanguageVersion) { throw new InvalidOperationException("Language versions do not match"); } _factory = factory; if (innerDatabase != null) { _sharedState = new SharedDatabaseState(innerDatabase._sharedState); } else { _sharedState = new SharedDatabaseState(_factory.Configuration.Version); } if (databaseDirectories != null) { foreach (var d in databaseDirectories) { LoadDatabase(d); } } _sharedState.ListenForCorruptDatabase(this); }