Extract the package-name prefix of a requirement specifier. Stops at the first character that is not part of a PEP 508 distribution name.
| 73 | // Extract the package-name prefix of a requirement specifier. |
| 74 | // Stops at the first character that is not part of a PEP 508 distribution name. |
| 75 | std::string ExtractPackageName(const std::string& requirement) |
| 76 | { |
| 77 | std::size_t end = 0; |
| 78 | while (end < requirement.size()) |
| 79 | { |
| 80 | char c = requirement[end]; |
| 81 | if (std::isalnum(static_cast<unsigned char>(c)) || c == '_' || c == '.' || c == '-') |
| 82 | ++end; |
| 83 | else |
| 84 | break; |
| 85 | } |
| 86 | return requirement.substr(0, end); |
| 87 | } |
| 88 | |
| 89 | // Check whether a requirement is a direct reference (VCS URL or PEP 508 |
| 90 | // "name @ url" form) rather than a regular PyPI specifier. |
no test coverage detected