Example #1
0
 /// <summary>
 /// <para>Constructs a new interpreter configuration based on the
 /// provided values.</para>
 /// <para>No validation is performed on the parameters.</para>
 /// <para>If winPath is null or empty,
 /// <see cref="WindowsInterpreterPath"/> will be set to path.</para>
 /// <para>If libraryPath is null or empty and prefixPath is a valid
 /// file system path, <see cref="LibraryPath"/> will be set to
 /// prefixPath plus "Lib".</para>
 /// </summary>
 public InterpreterConfiguration(
     string id,
     string description,
     string prefixPath          = null,
     string path                = null,
     string winPath             = "",
     string libraryPath         = "",
     string pathVar             = "",
     ProcessorArchitecture arch = ProcessorArchitecture.None,
     Version version            = null,
     InterpreterUIMode uiMode   = InterpreterUIMode.Normal,
     string descriptionSuffix   = ""
     )
 {
     _id                     = id;
     _description            = description;
     _prefixPath             = prefixPath;
     _interpreterPath        = path;
     _windowsInterpreterPath = string.IsNullOrEmpty(winPath) ? path : winPath;
     _libraryPath            = libraryPath;
     if (string.IsNullOrEmpty(_libraryPath) && !string.IsNullOrEmpty(_prefixPath))
     {
         try {
             _libraryPath = Path.Combine(_prefixPath, "Lib");
         } catch (ArgumentException) {
         }
     }
     _pathEnvironmentVariable = pathVar;
     _architecture            = arch;
     _version           = version;
     _uiMode            = uiMode;
     _descriptionSuffix = descriptionSuffix;
 }
Example #2
0
 /// <summary>
 /// <para>Constructs a new interpreter configuration based on the
 /// provided values.</para>
 /// <para>No validation is performed on the parameters.</para>
 /// <para>If winPath is null or empty,
 /// <see cref="WindowsInterpreterPath"/> will be set to path.</para>
 /// <para>If libraryPath is null or empty and prefixPath is a valid
 /// file system path, <see cref="LibraryPath"/> will be set to
 /// prefixPath plus "Lib".</para>
 /// </summary>
 public InterpreterConfiguration(
     string prefixPath,
     string path,
     string winPath,
     string libraryPath,
     string pathVar,
     ProcessorArchitecture arch,
     Version version,
     InterpreterUIMode uiMode
 ) {
     _prefixPath = prefixPath;
     _interpreterPath = path;
     _windowsInterpreterPath = string.IsNullOrEmpty(winPath) ? path : winPath;
     _libraryPath = libraryPath;
     if (string.IsNullOrEmpty(_libraryPath) && !string.IsNullOrEmpty(_prefixPath)) {
         try {
             _libraryPath = Path.Combine(_prefixPath, "Lib");
         } catch (ArgumentException) {
         }
     }
     _pathEnvironmentVariable = pathVar;
     _architecture = arch;
     _version = version;
     Debug.Assert(string.IsNullOrEmpty(_interpreterPath) || !string.IsNullOrEmpty(_prefixPath),
         "Anyone providing an interpreter should also specify the prefix path");
     _uiMode = uiMode;
 }
Example #3
0
 /// <summary>
 /// <para>Constructs a new interpreter configuration based on the
 /// provided values.</para>
 /// <para>No validation is performed on the parameters.</para>
 /// <para>If winPath is null or empty,
 /// <see cref="WindowsInterpreterPath"/> will be set to path.</para>
 /// <para>If libraryPath is null or empty and prefixPath is a valid
 /// file system path, <see cref="LibraryPath"/> will be set to
 /// prefixPath plus "Lib".</para>
 /// </summary>
 public InterpreterConfiguration(
     string prefixPath,
     string path,
     string winPath,
     string libraryPath,
     string pathVar,
     ProcessorArchitecture arch,
     Version version,
     InterpreterUIMode uiMode
     )
 {
     _prefixPath             = prefixPath;
     _interpreterPath        = path;
     _windowsInterpreterPath = string.IsNullOrEmpty(winPath) ? path : winPath;
     _libraryPath            = libraryPath;
     if (string.IsNullOrEmpty(_libraryPath) && !string.IsNullOrEmpty(_prefixPath))
     {
         try {
             _libraryPath = Path.Combine(_prefixPath, "Lib");
         } catch (ArgumentException) {
         }
     }
     _pathEnvironmentVariable = pathVar;
     _architecture            = arch;
     _version = version;
     Debug.Assert(string.IsNullOrEmpty(_interpreterPath) || !string.IsNullOrEmpty(_prefixPath),
                  "Anyone providing an interpreter should also specify the prefix path");
     _uiMode = uiMode;
 }
Example #4
0
 /// <summary>
 /// <para>Constructs a new interpreter configuration based on the
 /// provided values.</para>
 /// <para>No validation is performed on the parameters.</para>
 /// <para>If winPath is null or empty,
 /// <see cref="WindowsInterpreterPath"/> will be set to path.</para>
 /// <para>If libraryPath is null or empty and prefixPath is a valid
 /// file system path, <see cref="LibraryPath"/> will be set to
 /// prefixPath plus "Lib".</para>
 /// </summary>
 public InterpreterConfiguration(
     string id,
     string description,
     string prefixPath = null,
     string path = null,
     string winPath = "",
     string libraryPath = "",
     string pathVar = "",
     ProcessorArchitecture arch = ProcessorArchitecture.None,
     Version version = null,
     InterpreterUIMode uiMode = InterpreterUIMode.Normal,
     string descriptionSuffix = ""
     )
 {
     _id = id;
     _description = description;
     _prefixPath = prefixPath;
     _interpreterPath = path;
     _windowsInterpreterPath = string.IsNullOrEmpty(winPath) ? path : winPath;
     _libraryPath = libraryPath;
     if (string.IsNullOrEmpty(_libraryPath) && !string.IsNullOrEmpty(_prefixPath)) {
         try {
             _libraryPath = Path.Combine(_prefixPath, "Lib");
         } catch (ArgumentException) {
         }
     }
     _pathEnvironmentVariable = pathVar;
     _architecture = arch;
     _version = version;
     _uiMode = uiMode;
     _descriptionSuffix = descriptionSuffix;
 }
        /// <summary>
        /// Reconstructs an interpreter configuration from a dictionary.
        /// </summary>
        public static VisualStudioInterpreterConfiguration CreateFromDictionary(Dictionary <string, object> properties)
        {
            var id                      = Read(properties, nameof(InterpreterConfiguration.Id));
            var description             = Read(properties, nameof(InterpreterConfiguration.Description)) ?? "";
            var prefixPath              = Read(properties, nameof(PrefixPath));
            var interpreterPath         = Read(properties, nameof(InterpreterConfiguration.InterpreterPath));
            var windowsInterpreterPath  = Read(properties, nameof(WindowsInterpreterPath));
            var pathEnvironmentVariable = Read(properties, nameof(InterpreterConfiguration.PathEnvironmentVariable));
            var architecture            = InterpreterArchitecture.TryParse(Read(properties, nameof(InterpreterConfiguration.Architecture)));

            var version = default(Version);

            try
            {
                version = Version.Parse(Read(properties, nameof(Version)));
            }
            catch (Exception ex) when(ex is ArgumentException || ex is FormatException)
            {
                version = new Version();
            }

            InterpreterUIMode uiMode = 0;

            foreach (var bit in (Read(properties, nameof(UIMode)) ?? "").Split('|'))
            {
                if (Enum.TryParse(bit, out InterpreterUIMode m))
                {
                    uiMode |= m;
                }
            }

            VisualStudioInterpreterConfiguration configuration = new VisualStudioInterpreterConfiguration(id, description, prefixPath, interpreterPath, windowsInterpreterPath, pathEnvironmentVariable, architecture, version, uiMode);

            if (properties.TryGetValue(nameof(InterpreterConfiguration.SearchPaths), out object o))
            {
                configuration.SearchPaths.Clear();
                switch (o)
                {
                case string s:
                    configuration.SearchPaths.AddRange(s.Split(';'));
                    break;

                case IEnumerable <string> ss:
                    configuration.SearchPaths.AddRange(ss);
                    break;
                }
            }

            return(configuration);
        }
 public VisualStudioInterpreterConfiguration(
     string id,
     string description,
     string prefixPath    = null,
     string pythonExePath = null,
     string winPath       = "",
     string pathVar       = "",
     InterpreterArchitecture architecture = default(InterpreterArchitecture),
     Version version          = null,
     InterpreterUIMode uiMode = InterpreterUIMode.Normal
     ) : base(id, description, pythonExePath, pathVar, string.Empty, string.Empty, architecture, version)
 {
     PrefixPath             = prefixPath;
     WindowsInterpreterPath = string.IsNullOrEmpty(winPath) ? pythonExePath : winPath;
     UIMode = uiMode;
 }
 /// <summary>
 /// <para>Constructs a new interpreter configuration based on the
 /// provided values.</para>
 /// <para>No validation is performed on the parameters.</para>
 /// <para>If winPath is null or empty,
 /// <see cref="WindowsInterpreterPath"/> will be set to path.</para>
 /// </summary>
 public InterpreterConfiguration(
     string id,
     string description,
     string prefixPath = null,
     string path = null,
     string winPath = "",
     string pathVar = "",
     InterpreterArchitecture arch = default(InterpreterArchitecture),
     Version version = null,
     InterpreterUIMode uiMode = InterpreterUIMode.Normal
 ) {
     Id = id;
     Description = description;
     PrefixPath = prefixPath;
     InterpreterPath = path;
     WindowsInterpreterPath = string.IsNullOrEmpty(winPath) ? path : winPath;
     PathEnvironmentVariable = pathVar;
     Architecture = arch ?? InterpreterArchitecture.Unknown;
     Version = version ?? new Version();
     UIMode = uiMode;
 }
 /// <summary>
 /// <para>Constructs a new interpreter configuration based on the
 /// provided values.</para>
 /// <para>No validation is performed on the parameters.</para>
 /// <para>If winPath is null or empty,
 /// <see cref="WindowsInterpreterPath"/> will be set to path.</para>
 /// </summary>
 public InterpreterConfiguration(
     string id,
     string description,
     string prefixPath            = null,
     string path                  = null,
     string winPath               = "",
     string pathVar               = "",
     InterpreterArchitecture arch = default(InterpreterArchitecture),
     Version version              = null,
     InterpreterUIMode uiMode     = InterpreterUIMode.Normal
     )
 {
     Id                      = id;
     Description             = description;
     PrefixPath              = prefixPath;
     InterpreterPath         = path;
     WindowsInterpreterPath  = string.IsNullOrEmpty(winPath) ? path : winPath;
     PathEnvironmentVariable = pathVar;
     Architecture            = arch ?? InterpreterArchitecture.Unknown;
     Version                 = version ?? new Version();
     UIMode                  = uiMode;
 }
Example #9
0
 private static InterpreterConfiguration MockInterpreterConfiguration(string description, Version version, InterpreterUIMode uiMode)
 {
     return(new InterpreterConfiguration(Guid.NewGuid().ToString(), description, null, null, null, null, null, ProcessorArchitecture.None, version, uiMode));
 }
Example #10
0
 private static InterpreterConfiguration MockInterpreterConfiguration(Version version, InterpreterUIMode uiMode)
 {
     return(new InterpreterConfiguration(null, null, null, null, null, ProcessorArchitecture.None, version, uiMode));
 }