mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Python fixup after code review
This commit is contained in:
parent
c23e27eef0
commit
b77c057e7d
@ -206,20 +206,31 @@ QString PdmPythonGenerator::generate(PdmObjectFactory* factory) const
|
||||
QString commentDataType = field->xmlCapability()->isVectorField() ?
|
||||
QString("List of %1").arg(scriptDataType) : scriptDataType;
|
||||
|
||||
QString firstItemTag = pdmChildField ? QString("[0]") : QString("");
|
||||
QString fullComment =
|
||||
QString(" \"\"\"%1\n Returns:\n %2\n \"\"\"")
|
||||
.arg(comment)
|
||||
.arg(commentDataType);
|
||||
|
||||
QString fieldCode = QString(" def %1(self):\n%2\n return "
|
||||
"self.children(\"%3\", %4)%5\n")
|
||||
.arg(snake_field_name)
|
||||
.arg(fullComment)
|
||||
.arg(scriptability->scriptFieldName())
|
||||
.arg(scriptDataType)
|
||||
.arg(firstItemTag);
|
||||
classMethodsGenerated[field->ownerClass()][snake_field_name] = fieldCode;
|
||||
if (pdmChildField)
|
||||
{
|
||||
QString fieldCode = QString(" def %1(self):\n%2\n return "
|
||||
"self.children(\"%3\", %4)[0] if len(self.children) > 0 else None\n")
|
||||
.arg(snake_field_name)
|
||||
.arg(fullComment)
|
||||
.arg(scriptability->scriptFieldName())
|
||||
.arg(scriptDataType);
|
||||
classMethodsGenerated[field->ownerClass()][snake_field_name] = fieldCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString fieldCode = QString(" def %1(self):\n%2\n return "
|
||||
"self.children(\"%3\", %4)\n")
|
||||
.arg(snake_field_name)
|
||||
.arg(fullComment)
|
||||
.arg(scriptability->scriptFieldName())
|
||||
.arg(scriptDataType);
|
||||
classMethodsGenerated[field->ownerClass()][snake_field_name] = fieldCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,38 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//##################################################################################################
|
||||
//
|
||||
// Copyright (C) 2017 Statoil ASA
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// GNU General Public License Usage
|
||||
// This library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||
// for more details.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
#include "cafPdmScriptIOMessages.h"
|
||||
#include <QTextStream>
|
||||
|
||||
|
@ -1,20 +1,38 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//##################################################################################################
|
||||
//
|
||||
// Copyright (C) 2017 Statoil ASA
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// GNU General Public License Usage
|
||||
// This library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||
// for more details.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
@ -12,6 +12,10 @@ template < typename FieldType>
|
||||
class PdmFieldXmlCap : public PdmXmlFieldHandle
|
||||
{
|
||||
public:
|
||||
// Type traits magic to check if a template argument is a vector
|
||||
template<typename T> struct is_vector : public std::false_type {};
|
||||
template<typename T, typename A> struct is_vector<std::vector<T, A>> : public std::true_type {};
|
||||
|
||||
PdmFieldXmlCap(FieldType* field, bool giveOwnership) : PdmXmlFieldHandle(field, giveOwnership)
|
||||
{
|
||||
m_field = field;
|
||||
|
@ -54,7 +54,9 @@ void PdmXmlFieldHandle::disableIO()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Returns the classKeyword of the child class type, if this field is supposed to contain pointers
|
||||
/// to PdmObjectHandle derived objects.
|
||||
/// Returns typeid(DataType).name() if the field is not containing some PdmObjectHandle type
|
||||
/// Returns typeid(DataType).name() if the field is not containing some PdmObjectHandle type.
|
||||
/// Warning: typeid(DataType).name() is compiler implementation specific and thus you should not
|
||||
/// Compare this with a predefined literal, like "double" or "float". Instead compare with typeid(double).name().
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString PdmXmlFieldHandle::dataTypeName() const
|
||||
{
|
||||
|
@ -22,11 +22,6 @@ class PdmReferenceHelper;
|
||||
//==================================================================================================
|
||||
class PdmXmlFieldHandle : public PdmFieldCapability
|
||||
{
|
||||
public:
|
||||
// Type traits magic to check if a template argument is a vector
|
||||
template<typename T> struct is_vector : public std::false_type {};
|
||||
template<typename T, typename A> struct is_vector<std::vector<T, A>> : public std::true_type {};
|
||||
|
||||
public:
|
||||
PdmXmlFieldHandle(PdmFieldHandle* owner , bool giveOwnership);
|
||||
~PdmXmlFieldHandle() override { }
|
||||
|
Loading…
Reference in New Issue
Block a user