Exemplo n.º 1
0
 public CPythonInterpreter(PythonInterpreterFactoryWithDatabase factory)
 {
     _langVersion = factory.Configuration.Version;
     _factory     = factory;
     _typeDb      = _factory.GetCurrentDatabase();
     _factory.NewDatabaseAvailable += OnNewDatabaseAvailable;
 }
Exemplo n.º 2
0
        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 ?? new Version());
            }

            if (databaseDirectories != null)
            {
                foreach (var d in databaseDirectories)
                {
                    LoadDatabase(d);
                }
            }

            _sharedState.ListenForCorruptDatabase(this);
        }
 public static PythonInterpreterFactoryWithDatabase CreateFromDatabase(Version version, params string[] dbPath) {
     var defPath = dbPath.ElementAtOrDefault(0) ?? PythonTypeDatabase.BaselineDatabasePath;
     var fact = new PythonInterpreterFactoryWithDatabase(
         new InterpreterConfiguration($"AnalysisOnly|{version}", $"Analysis Only {version}", version: version, uiMode: InterpreterUIMode.SupportsDatabase),
         new InterpreterFactoryCreationOptions { DatabasePath = defPath, WatchFileSystem = false }
     );
     foreach (var p in dbPath.Skip(1)) {
         fact.GetCurrentDatabase().LoadDatabase(p);
     }
     return fact;
 }
Exemplo n.º 4
0
 private PythonTypeDatabase(
     PythonInterpreterFactoryWithDatabase factory,
     string databaseDirectory,
     bool isDefaultDatabase,
     Version version = null
     )
 {
     _factory     = factory;
     _sharedState = new SharedDatabaseState(
         version ?? factory?.Configuration.Version ?? new Version(),
         databaseDirectory,
         defaultDatabase: isDefaultDatabase
         );
 }
Exemplo n.º 5
0
        public void Dispose()
        {
            lock (_searchPathDbLock) {
                _searchPathDb = null;
            }
            _zipPackageCache = null;
            _typeDb          = null;

            var factory = _factory;

            _factory = null;
            if (factory != null)
            {
                factory.NewDatabaseAvailable -= OnNewDatabaseAvailable;
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Returns a new interpreter created with the specified factory.
 /// </summary>
 /// <remarks>
 /// This is intended for use by derived classes only. To get an
 /// interpreter instance, use <see cref="CreateInterpreter"/>.
 /// </remarks>
 public virtual IPythonInterpreter MakeInterpreter(PythonInterpreterFactoryWithDatabase factory)
 {
     return(new CPythonInterpreter(factory));
 }
Exemplo n.º 7
0
 public static PythonTypeDatabase CreateDefaultTypeDatabase(PythonInterpreterFactoryWithDatabase factory)
 {
     return(new PythonTypeDatabase(factory, BaselineDatabasePath, isDefaultDatabase: true));
 }
Exemplo n.º 8
0
 public PythonTypeDatabase CloneWithNewFactory(PythonInterpreterFactoryWithDatabase newFactory)
 {
     return(new PythonTypeDatabase(newFactory, null, this));
 }