Object.defineProperty(exports, "__esModule", { value: true });
const inversify_1 = require("inversify");
const os = require("os");
const path = require("path");
const types_1 = require("../../../common/types");
const types_2 = require("../../../ioc/types");
const contracts_1 = require("../../contracts");
const baseVirtualEnvService_1 = require("./baseVirtualEnvService");
let GlobalVirtualEnvService = class GlobalVirtualEnvService extends baseVirtualEnvService_1.BaseVirtualEnvService {
    constructor(globalVirtualEnvPathProvider, serviceContainer) {
        super(globalVirtualEnvPathProvider, serviceContainer, 'VirtualEnvService');
    }
};
GlobalVirtualEnvService = __decorate([
    inversify_1.injectable(),
    __param(0, inversify_1.inject(contracts_1.IVirtualEnvironmentsSearchPathProvider)), __param(0, inversify_1.named('global')),
    __param(1, inversify_1.inject(types_2.IServiceContainer))
], GlobalVirtualEnvService);
exports.GlobalVirtualEnvService = GlobalVirtualEnvService;
let GlobalVirtualEnvironmentsSearchPathProvider = class GlobalVirtualEnvironmentsSearchPathProvider {
    constructor(serviceContainer) {
        this.process = serviceContainer.get(types_1.ICurrentProcess);
        this.config = serviceContainer.get(types_1.IConfigurationService);
    }
    getSearchPaths(_resource) {
        const homedir = os.homedir();
        const venvFolders = this.config.getSettings(_resource).venvFolders;
        const folders = venvFolders.map(item => path.join(homedir, item));
        // tslint:disable-next-line:no-string-literal
        const pyenvRoot = this.process.env['PYENV_ROOT'];
        if (pyenvRoot) {
Esempio n. 2
0
            case ProductType.WorkspaceSymbols:
                return new CTagsInstaller(this.serviceContainer, this.outputChannel);
            case ProductType.TestFramework:
                return new TestFrameworkInstaller(this.serviceContainer, this.outputChannel);
            case ProductType.RefactoringLibrary:
                return new RefactoringLibraryInstaller(this.serviceContainer, this.outputChannel);
            default:
                break;
        }
        throw new Error(`Unknown product ${product}`);
    }
};
ProductInstaller = __decorate([
    inversify_1.injectable(),
    __param(0, inversify_1.inject(types_2.IServiceContainer)),
    __param(1, inversify_1.inject(types_9.IOutputChannel)), __param(1, inversify_1.named(constants_1.STANDARD_OUTPUT_CHANNEL))
], ProductInstaller);
exports.ProductInstaller = ProductInstaller;
function translateProductToModule(product, purpose) {
    switch (product) {
        case types_9.Product.mypy: return 'mypy';
        case types_9.Product.nosetest: {
            return purpose === types_9.ModuleNamePurpose.install ? 'nose' : 'nosetests';
        }
        case types_9.Product.pylama: return 'pylama';
        case types_9.Product.prospector: return 'prospector';
        case types_9.Product.pylint: return 'pylint';
        case types_9.Product.pytest: return 'pytest';
        case types_9.Product.autopep8: return 'autopep8';
        case types_9.Product.pep8: return 'pep8';
        case types_9.Product.pydocstyle: return 'pydocstyle';
    getWorkspace(resource) {
        if (!Array.isArray(vscode_1.workspace.workspaceFolders) || vscode_1.workspace.workspaceFolders.length === 0) {
            const noWkspaceMessage = 'Please open a workspace';
            this.outChannel.appendLine(noWkspaceMessage);
            throw new Error(noWkspaceMessage);
        }
        if (!resource || vscode_1.workspace.workspaceFolders.length === 1) {
            return vscode_1.workspace.workspaceFolders[0].uri;
        }
        const workspaceFolder = vscode_1.workspace.getWorkspaceFolder(resource);
        if (workspaceFolder) {
            return workspaceFolder.uri;
        }
        const message = `Resource '${resource.fsPath}' does not belong to any workspace`;
        this.outChannel.appendLine(message);
        throw new Error(message);
    }
    ensureTestManagerService(wkspace) {
        if (!this.workspaceTestManagers.has(wkspace.fsPath)) {
            this.workspaceTestManagers.set(wkspace.fsPath, this.testManagerServiceFactory(wkspace));
        }
    }
};
WorkspaceTestManagerService = __decorate([
    inversify_1.injectable(),
    __param(0, inversify_1.inject(types_1.IOutputChannel)), __param(0, inversify_1.named(constants_1.TEST_OUTPUT_CHANNEL)),
    __param(1, inversify_1.inject(types_2.ITestManagerServiceFactory)),
    __param(2, inversify_1.inject(types_1.IDisposableRegistry))
], WorkspaceTestManagerService);
exports.WorkspaceTestManagerService = WorkspaceTestManagerService;
//# sourceMappingURL=workspaceTestManagerService.js.map
Esempio n. 4
0
                }
            }
        }
        return startDirectory;
    }
    getTestPattern(options) {
        let pattern = 'test*.py';
        const indexOfPattern = options.args.findIndex(arg => arg.indexOf('-p') === 0);
        if (indexOfPattern >= 0) {
            const patternValue = options.args[indexOfPattern].trim();
            if (patternValue.trim() === '-p' && options.args.length >= indexOfPattern) {
                // Assume the next items is the directory
                pattern = options.args[indexOfPattern + 1];
            }
            else {
                pattern = patternValue.substring(2).trim();
                if (pattern.startsWith('=')) {
                    pattern = pattern.substring(1);
                }
            }
        }
        return pattern;
    }
};
TestDiscoveryService = __decorate([
    inversify_1.injectable(),
    __param(0, inversify_1.inject(types_1.IServiceContainer)),
    __param(1, inversify_1.inject(types_2.ITestsParser)), __param(1, inversify_1.named(constants_1.UNITTEST_PROVIDER))
], TestDiscoveryService);
exports.TestDiscoveryService = TestDiscoveryService;
//# sourceMappingURL=discoveryService.js.map