Check whether a requirement is a direct reference (VCS URL or PEP 508 "name @ url" form) rather than a regular PyPI specifier.
| 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 | |
| 109 | QmitkPipInstaller::QmitkPipInstaller(QObject* parent) |
no test coverage detected