MCPcopy Create free account
hub / github.com/MITK/MITK / IsDirectReference

Function IsDirectReference

Modules/PythonInstaller/src/QmitkPipInstaller.cpp:91–106  ·  view source on GitHub ↗

Check whether a requirement is a direct reference (VCS URL or PEP 508 "name @ url" form) rather than a regular PyPI specifier.

Source from the content-addressed store, hash-verified

89 // Check whether a requirement is a direct reference (VCS URL or PEP 508
90 // "name @ url" form) rather than a regular PyPI specifier.
91 bool IsDirectReference(const std::string& req)
92 {
93 // Bare VCS URL: git+https://..., hg+https://..., etc.
94 if (req.size() > 4 &&
95 (req.compare(0, 4, "git+") == 0 || req.compare(0, 3, "hg+") == 0 ||
96 req.compare(0, 4, "svn+") == 0 || req.compare(0, 4, "bzr+") == 0))
97 return true;
98
99 // PEP 508 direct reference: name and URL separated by an '@' with arbitrary
100 // whitespace on either side (e.g. "name @ https://...", "name@url",
101 // "name\t@ git+https://..."). Require at least one alphanumeric character
102 // before the '@' and something after it to avoid false positives on stray
103 // '@' characters.
104 static const QRegularExpression directRef(R"(^\s*[A-Za-z0-9][\w\-.]*\s*@\s*\S)");
105 return directRef.match(QString::fromStdString(req)).hasMatch();
106 }
107}
108
109QmitkPipInstaller::QmitkPipInstaller(QObject* parent)

Callers 2

StartInstallPackageMethod · 0.85
ParseResolveReportMethod · 0.85

Calls 2

matchMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected