Add versioning to socks.py

Also mark variable as private in novaprinter.py.

PR #22578.
This commit is contained in:
Chocobo1 2025-04-20 16:47:45 +08:00 committed by GitHub
commit 8fc5d0914d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 11 deletions

View file

@ -523,23 +523,23 @@ void SearchPluginManager::updateNova()
packageFile2.close();
// Copy search plugin files (if necessary)
const auto updateFile = [&enginePath](const Path &filename, const bool compareVersion)
const auto updateFile = [&enginePath](const Path &filename)
{
const Path filePathBundled = Path(u":/searchengine/nova3"_s) / filename;
const Path filePathDisk = enginePath / filename;
if (compareVersion && (getPluginVersion(filePathBundled) <= getPluginVersion(filePathDisk)))
if (getPluginVersion(filePathBundled) <= getPluginVersion(filePathDisk))
return;
Utils::Fs::removeFile(filePathDisk);
Utils::Fs::copyFile(filePathBundled, filePathDisk);
};
updateFile(Path(u"helpers.py"_s), true);
updateFile(Path(u"nova2.py"_s), true);
updateFile(Path(u"nova2dl.py"_s), true);
updateFile(Path(u"novaprinter.py"_s), true);
updateFile(Path(u"socks.py"_s), false);
updateFile(Path(u"helpers.py"_s));
updateFile(Path(u"nova2.py"_s));
updateFile(Path(u"nova2dl.py"_s));
updateFile(Path(u"novaprinter.py"_s));
updateFile(Path(u"socks.py"_s));
}
void SearchPluginManager::update()
@ -680,7 +680,8 @@ PluginVersion SearchPluginManager::getPluginVersion(const Path &filePath)
while (!pluginFile.atEnd())
{
const auto line = QString::fromUtf8(pluginFile.readLine(lineMaxLength)).remove(u' ');
if (!line.startsWith(u"#VERSION:", Qt::CaseInsensitive)) continue;
if (!line.startsWith(u"#VERSION:", Qt::CaseInsensitive))
continue;
const QString versionStr = line.sliced(9);
const auto version = PluginVersion::fromString(versionStr);

View file

@ -1,4 +1,4 @@
#VERSION: 1.52
# VERSION: 1.53
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@ -56,7 +56,7 @@ def prettyPrinter(dictionary: SearchResults) -> None:
print(outtext, file=utf8stdout)
sizeUnitRegex: re.Pattern[str] = re.compile(r"^(?P<size>\d*\.?\d+) *(?P<unit>[a-z]+)?", re.IGNORECASE)
_sizeUnitRegex: re.Pattern[str] = re.compile(r"^(?P<size>\d*\.?\d+) *(?P<unit>[a-z]+)?", re.IGNORECASE)
# TODO: use `float | int | str` when using Python >= 3.10
@ -73,7 +73,7 @@ def anySizeToBytes(size_string: Union[float, int, str]) -> int:
if isinstance(size_string, float):
return round(size_string)
match = sizeUnitRegex.match(size_string.strip())
match = _sizeUnitRegex.match(size_string.strip())
if match is None:
return -1

View file

@ -1,3 +1,5 @@
# VERSION: 1.00
"""PySocks - A SOCKS proxy client and wrapper for Python.
Version 1.7.1