@@ -33,6 +33,69 @@ namespace mo2::python {
3333
3434 void add_versioninfo_classes (py::module_ m)
3535 {
36+ // Version
37+ py::class_<Version> pyVersion (m, " Version" );
38+
39+ py::enum_<Version::ReleaseType>(pyVersion, " ReleaseType" )
40+ .value (" DEVELOPMENT" , Version::Development)
41+ .value (" ALPHA" , Version::Alpha)
42+ .value (" BETA" , Version::Beta)
43+ .value (" RELEASE_CANDIDATE" , Version::ReleaseCandidate)
44+ .export_values ();
45+
46+ py::enum_<Version::ParseMode>(pyVersion, " ParseMode" )
47+ .value (" SEMVER" , Version::ParseMode::SemVer)
48+ .value (" MO2" , Version::ParseMode::MO2);
49+
50+ py::enum_<Version::FormatMode>(pyVersion, " FormatMode" , py::arithmetic{})
51+ .value (" FORCE_SUBPATCH" , Version::FormatMode::ForceSubPatch)
52+ .value (" NO_SEPARATOR" , Version::FormatMode::NoSeparator)
53+ .value (" SHORT_ALPHA_BETA" , Version::FormatMode::ShortAlphaBeta)
54+ .value (" NO_METADATA" , Version::FormatMode::NoMetadata)
55+ .value (" CONDENSED" ,
56+ static_cast <Version::FormatMode>(Version::FormatCondensed.toInt ()))
57+ .export_values ();
58+
59+ pyVersion
60+ .def_static (" parse" , &Version::parse, " value" _a,
61+ " mode" _a = Version::ParseMode::SemVer)
62+ .def (py::init<int , int , int , QString>(), " major" _a, " minor" _a, " patch" _a,
63+ " metadata" _a = " " )
64+ .def (py::init<int , int , int , int , QString>(), " major" _a, " minor" _a,
65+ " patch" _a, " subpatch" _a, " metadata" _a = " " )
66+ .def (py::init<int , int , int , Version::ReleaseType, QString>(), " major" _a,
67+ " minor" _a, " patch" _a, " type" _a, " metadata" _a = " " )
68+ .def (py::init<int , int , int , int , Version::ReleaseType, QString>(),
69+ " major" _a, " minor" _a, " patch" _a, " subpatch" _a, " type" _a,
70+ " metadata" _a = " " )
71+ .def (py::init<int , int , int , Version::ReleaseType, int , QString>(),
72+ " major" _a, " minor" _a, " patch" _a, " type" _a, " prerelease" _a,
73+ " metadata" _a = " " )
74+ .def (py::init<int , int , int , int , Version::ReleaseType, int , QString>(),
75+ " major" _a, " minor" _a, " patch" _a, " subpatch" _a, " type" _a,
76+ " prerelease" _a, " metadata" _a = " " )
77+ .def (py::init<int , int , int , int ,
78+ std::vector<std::variant<int , Version::ReleaseType>>,
79+ QString>(),
80+ " major" _a, " minor" _a, " patch" _a, " subpatch" _a, " prereleases" _a,
81+ " metadata" _a = " " )
82+ .def (" isPreRelease" , &Version::isPreRelease)
83+ .def_property_readonly (" major" , &Version::major)
84+ .def_property_readonly (" minor" , &Version::minor)
85+ .def_property_readonly (" patch" , &Version::patch)
86+ .def_property_readonly (" subpatch" , &Version::subpatch)
87+ .def_property_readonly (" prereleases" , &Version::preReleases)
88+ .def_property_readonly (" build_metadata" , &Version::buildMetadata)
89+ .def (" string" , &Version::string, " mode" _a = Version::FormatCondensed)
90+ .def (" __str__" , &Version::string)
91+ .def (py::self < py::self)
92+ .def (py::self > py::self)
93+ .def (py::self <= py::self)
94+ .def (py::self >= py::self)
95+ .def (py::self != py::self)
96+ .def (py::self == py::self);
97+
98+ // VersionInfo
3699 py::enum_<MOBase::VersionInfo::ReleaseType>(m, " ReleaseType" )
37100 .value (" final" , MOBase::VersionInfo::RELEASE_FINAL)
38101 .value (" candidate" , MOBase::VersionInfo::RELEASE_CANDIDATE)
@@ -451,7 +514,17 @@ namespace mo2::python {
451514 .def (" overwritePath" , &IOrganizer::overwritePath)
452515 .def (" basePath" , &IOrganizer::basePath)
453516 .def (" modsPath" , &IOrganizer::modsPath)
454- .def (" appVersion" , &IOrganizer::appVersion)
517+ .def (" appVersion" ,
518+ [](IOrganizer& o) {
519+ mo2::python::show_deprecation_warning (
520+ " appVersion" , " IOrganizer::appVersion() is deprecated, use "
521+ " IOrganizer::version() instead." );
522+ #pragma warning(push)
523+ #pragma warning(disable : 4996)
524+ return o.appVersion ();
525+ #pragma warning(pop)
526+ })
527+ .def (" version" , &IOrganizer::version)
455528 .def (" createMod" , &IOrganizer::createMod,
456529 py::return_value_policy::reference, " name" _a)
457530 .def (" getGame" , &IOrganizer::getGame, py::return_value_policy::reference,
0 commit comments