Addon Manager: Cleanup

This commit is contained in:
Chris Hennes
2022-09-08 22:19:30 -05:00
parent b3dd3b6d00
commit 53a642db40
11 changed files with 77 additions and 169 deletions

View File

@@ -655,7 +655,9 @@ void Metadata::appendToElement(DOMElement* root) const
{
appendSimpleXMLNode(root, "name", _name);
appendSimpleXMLNode(root, "description", _description);
appendSimpleXMLNode(root, "version", _version.str());
if (_version != Meta::Version())
// Only append version if it's not 0.0.0
appendSimpleXMLNode(root, "version", _version.str());
for (const auto& maintainer : _maintainer) {
auto element = appendSimpleXMLNode(root, "maintainer", maintainer.name);
@@ -977,6 +979,8 @@ Meta::Version::Version(const std::string& versionString) :
std::string Meta::Version::str() const
{
if (*this == Meta::Version())
return "";
std::ostringstream stream;
stream << major << "." << minor << "." << patch << suffix;
return stream.str();

View File

@@ -365,6 +365,13 @@ Add a new File. </UserDocu>
Remove the File. </UserDocu>
</Documentation>
</Methode>
<Methode Name="write">
<Documentation>
<UserDocu>write(filename)\n
Write the metadata to the given file as XML data.</UserDocu>
</Documentation>
</Methode>
<ClassDeclarations>
public:

View File

@@ -139,7 +139,7 @@ void MetadataPy::setVersion(Py::Object args)
const char *name = nullptr;
if (!PyArg_Parse(args.ptr(), "z", &name))
throw Py::Exception();
if (name)
if (name && name[0] != '\0')
getMetadataPtr()->setVersion(App::Meta::Version(std::string(name)));
else
getMetadataPtr()->setVersion(App::Meta::Version());
@@ -934,6 +934,18 @@ PyObject *MetadataPy::removeContentItem(PyObject *arg)
return Py_None;
}
PyObject* MetadataPy::write(PyObject* args)
{
char *filename = nullptr;
if (!PyArg_ParseTuple(args, "s", &filename))
return nullptr;
getMetadataPtr()->write(filename);
Py_INCREF(Py_None);
return Py_None;
}
PyObject *MetadataPy::getCustomAttributes(const char * /*attr*/) const
{
return nullptr;