diff --git a/src/App/Metadata.cpp b/src/App/Metadata.cpp index 10106d9006..05c61b35b8 100644 --- a/src/App/Metadata.cpp +++ b/src/App/Metadata.cpp @@ -228,7 +228,11 @@ Meta::Version Metadata::freecadmin() const Meta::Version Metadata::freecadmax() const { - return _freecadmax; + return _freecadmax; } + +Meta::Version Metadata::pythonmin() const +{ + return _pythonmin; } std::multimap Metadata::content() const @@ -343,6 +347,11 @@ void Metadata::setFreeCADMin(const Meta::Version& version) _freecadmin = version; } +void Metadata::setPythonMin(const Meta::Version &version) +{ + _pythonmin = version; +} + void Metadata::setFreeCADMax(const Meta::Version& version) { _freecadmax = version; @@ -687,8 +696,11 @@ void Metadata::appendToElement(DOMElement* root) const if (_freecadmin != Meta::Version()) appendSimpleXMLNode(root, "freecadmin", _freecadmin.str()); - if (_freecadmax != Meta::Version()) - appendSimpleXMLNode(root, "freecadmax", _freecadmin.str()); + if (_freecadmax != Meta::Version()) + appendSimpleXMLNode(root, "freecadmax", _freecadmax.str()); + + if (_pythonmin != Meta::Version()) + appendSimpleXMLNode(root, "pythonmin", _pythonmin.str()); for (const auto& url : _url) { auto element = appendSimpleXMLNode(root, "url", url.location); @@ -784,6 +796,8 @@ void Metadata::parseVersion1(const DOMNode* startNode) _freecadmin = Meta::Version(StrXUTF8(element->getTextContent()).str); else if (tagString == "freecadmax") _freecadmax = Meta::Version(StrXUTF8(element->getTextContent()).str); + else if (tagString == "pythonmin") + _pythonmin = Meta::Version(StrXUTF8(element->getTextContent()).str); else if (tagString == "url") _url.emplace_back(element); else if (tagString == "author") diff --git a/src/App/Metadata.h b/src/App/Metadata.h index 4b338941dc..dc3828b53f 100644 --- a/src/App/Metadata.h +++ b/src/App/Metadata.h @@ -220,6 +220,7 @@ namespace App { std::vector file() const; //< Arbitrary files associated with this package or content item. Meta::Version freecadmin() const; //< The minimum FreeCAD version. Meta::Version freecadmax() const; //< The maximum FreeCAD version. + Meta::Version pythonmin() const; //< The minimum Python version. /** * Access the metadata for the content elements of this package @@ -274,7 +275,8 @@ namespace App { void addFile(const boost::filesystem::path &path); void addContentItem(const std::string &tag, const Metadata &item); void setFreeCADMin(const Meta::Version& version); - void setFreeCADMax(const Meta::Version& version); + void setFreeCADMax(const Meta::Version &version); + void setPythonMin(const Meta::Version &version); void addGenericMetadata(const std::string &tag, const Meta::GenericMetadata &genericMetadata); // Deleters @@ -337,6 +339,7 @@ namespace App { std::vector _file; Meta::Version _freecadmin; Meta::Version _freecadmax; + Meta::Version _pythonmin; std::multimap _content; diff --git a/src/App/MetadataPy.xml b/src/App/MetadataPy.xml index 23f3197089..e4a35530b2 100644 --- a/src/App/MetadataPy.xml +++ b/src/App/MetadataPy.xml @@ -184,6 +184,14 @@ If unset it will be 0.0.0. + + + String representing the minimum version of Python needed for this item. +If unset it will be 0.0.0. + + + + getLastSupportedFreeCADVersion() -> str or None\n diff --git a/src/App/MetadataPyImp.cpp b/src/App/MetadataPyImp.cpp index b0330a9097..fd701d1e4c 100644 --- a/src/App/MetadataPyImp.cpp +++ b/src/App/MetadataPyImp.cpp @@ -864,6 +864,21 @@ void MetadataPy::setFreeCADMax(Py::Object args) getMetadataPtr()->setFreeCADMax(App::Meta::Version()); } +Py::Object MetadataPy::getPythonMin() const +{ + return Py::String(getMetadataPtr()->pythonmin().str()); +} + +void MetadataPy::setPythonMin(Py::Object args) +{ + char *version = nullptr; + PyObject *p = args.ptr(); + if (!PyArg_Parse(p, "z", &version)) throw Py::Exception(); + if (version) getMetadataPtr()->setPythonMin(App::Meta::Version(version)); + else + getMetadataPtr()->setPythonMin(App::Meta::Version()); +} + PyObject *MetadataPy::getFirstSupportedFreeCADVersion(PyObject *p) { if (!PyArg_ParseTuple(p, ""))