/// <summary>
        /// Returns the database for this factory. This database may be shared
        /// between callers and should be cloned before making modifications.
        ///
        /// This function never returns null.
        /// </summary>
        public PythonTypeDatabase GetCurrentDatabase()
        {
            if (_typeDb == null || _typeDb.DatabaseDirectory != DatabasePath)
            {
                _typeDb = MakeTypeDatabase(DatabasePath) ??
                          PythonTypeDatabase.CreateDefaultTypeDatabase(this);
            }

            return(_typeDb);
        }
        /// <summary>
        /// Returns the database for this factory, optionally excluding package
        /// analysis. This database may be shared between callers and should be
        /// cloned before making modifications.
        ///
        /// This function never returns null.
        /// </summary>
        public PythonTypeDatabase GetCurrentDatabase(bool includeSitePackages)
        {
            if (includeSitePackages)
            {
                return(GetCurrentDatabase());
            }

            if (_typeDbWithoutPackages == null || _typeDbWithoutPackages.DatabaseDirectory != DatabasePath)
            {
                _typeDbWithoutPackages = MakeTypeDatabase(DatabasePath, false) ??
                                         PythonTypeDatabase.CreateDefaultTypeDatabase(this);
            }

            return(_typeDbWithoutPackages);
        }
        /// <summary>
        /// Returns a new database loaded from the specified path. If null is
        /// returned, <see cref="GetCurrentDatabase"/> will assume the default
        /// completion DB is intended.
        /// </summary>
        /// <remarks>
        /// This is intended for overriding in derived classes. To get a
        /// queryable database instance, use <see cref="GetCurrentDatabase"/> or
        /// <see cref="CreateInterpreter"/>.
        /// </remarks>
        public virtual PythonTypeDatabase MakeTypeDatabase(string databasePath, bool includeSitePackages = true)
        {
            if (!_generating && PythonTypeDatabase.IsDatabaseVersionCurrent(databasePath))
            {
                var paths = new List <string>();
                paths.Add(databasePath);
                if (includeSitePackages)
                {
                    paths.AddRange(Directory.EnumerateDirectories(databasePath));
                }

                try {
                    return(new PythonTypeDatabase(this, paths));
                } catch (IOException) {
                } catch (UnauthorizedAccessException) {
                }
            }

            return(PythonTypeDatabase.CreateDefaultTypeDatabase(this));
        }
Exemplo n.º 4
0
 public IPythonInterpreter CreateInterpreter()
 {
     return(new NoInterpretersInterpreter(PythonTypeDatabase.CreateDefaultTypeDatabase()));
 }