Skip to content

Commit

Permalink
replace descriptionAsPythonString
Browse files Browse the repository at this point in the history
  • Loading branch information
Koyaani authored and nyalldawson committed Sep 24, 2021
1 parent caad9f2 commit 68f003c
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 76 deletions.
Expand Up @@ -387,8 +387,6 @@ Returns the description for the parameter. This is the user-visible string
used to identify this parameter.

.. seealso:: :py:func:`setDescription`

.. seealso:: :py:func:`descriptionAsPythonString`
%End

void setDescription( const QString &description );
Expand Down Expand Up @@ -509,17 +507,6 @@ parameter. Returns ``True`` if the value can be accepted.
The optional ``context`` parameter can be specified to allow a more stringent
check to be performed, capable of checking for the presence of required
layers and other factors within the context.
%End

QString descriptionAsPythonString() const;
%Docstring
Returns the description of the parameter with quotes around.
If there are quotes in the description, they are escaped if necessary.
The around quote could be single or double.

.. seealso:: :py:func:`description`

.. versionadded:: 3.24
%End

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;
Expand Down
3 changes: 2 additions & 1 deletion src/core/processing/qgsprocessingparameteraggregate.cpp
Expand Up @@ -74,7 +74,8 @@ QString QgsProcessingParameterAggregate::asPythonString( QgsProcessing::PythonOu
{
case QgsProcessing::PythonQgsProcessingAlgorithmSubclass:
{
QString code = QStringLiteral( "QgsProcessingParameterAggregate('%1', %2" ).arg( name(), descriptionAsPythonString() );
QString code = QStringLiteral( "QgsProcessingParameterAggregate('%1', %2" )
.arg( name(), QgsProcessingUtils::stringToPythonLiteral( description() ) );
if ( !mParentLayerParameterName.isEmpty() )
code += QStringLiteral( ", parentLayerParameterName=%1" ).arg( QgsProcessingUtils::stringToPythonLiteral( mParentLayerParameterName ) );

Expand Down
3 changes: 2 additions & 1 deletion src/core/processing/qgsprocessingparameterdxflayers.cpp
Expand Up @@ -145,7 +145,8 @@ QString QgsProcessingParameterDxfLayers::asPythonString( QgsProcessing::PythonOu
{
case QgsProcessing::PythonQgsProcessingAlgorithmSubclass:
{
QString code = QStringLiteral( "QgsProcessingParameterDxfLayers('%1', %2)" ).arg( name(), descriptionAsPythonString() );
QString code = QStringLiteral( "QgsProcessingParameterDxfLayers('%1', %2)" )
.arg( name(), QgsProcessingUtils::stringToPythonLiteral( description() ) );
return code;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/processing/qgsprocessingparameterfieldmap.cpp
Expand Up @@ -72,7 +72,8 @@ QString QgsProcessingParameterFieldMapping::asPythonString( QgsProcessing::Pytho
{
case QgsProcessing::PythonQgsProcessingAlgorithmSubclass:
{
QString code = QStringLiteral( "QgsProcessingParameterFieldMapping('%1', %2" ).arg( name(), descriptionAsPythonString() );
QString code = QStringLiteral( "QgsProcessingParameterFieldMapping('%1', %2" )
.arg( name(), QgsProcessingUtils::stringToPythonLiteral( description() ) );
if ( !mParentLayerParameterName.isEmpty() )
code += QStringLiteral( ", parentLayerParameterName=%1" ).arg( QgsProcessingUtils::stringToPythonLiteral( mParentLayerParameterName ) );

Expand Down
2 changes: 1 addition & 1 deletion src/core/processing/qgsprocessingparametermeshdataset.cpp
Expand Up @@ -62,7 +62,7 @@ QString QgsProcessingParameterMeshDatasetGroups::asPythonString( QgsProcessing::
case QgsProcessing::PythonQgsProcessingAlgorithmSubclass:
{
QString code = QStringLiteral( "QgsProcessingParameterMeshDatasetGroups('%1', %2" )
.arg( name(), descriptionAsPythonString() );
.arg( name(), QgsProcessingUtils::stringToPythonLiteral( description() ) );
if ( !mMeshLayerParameterName.isEmpty() )
code += QStringLiteral( ", meshLayerParameterName=%1" ).arg( QgsProcessingUtils::stringToPythonLiteral( mMeshLayerParameterName ) );

Expand Down
108 changes: 62 additions & 46 deletions src/core/processing/qgsprocessingparameters.cpp

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions src/core/processing/qgsprocessingparameters.h
Expand Up @@ -496,7 +496,6 @@ class CORE_EXPORT QgsProcessingParameterDefinition
* Returns the description for the parameter. This is the user-visible string
* used to identify this parameter.
* \see setDescription()
* \see descriptionAsPythonString()
*/
QString description() const { return mDescription; }

Expand Down Expand Up @@ -607,16 +606,6 @@ class CORE_EXPORT QgsProcessingParameterDefinition
*/
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const;

/**
* Returns the description of the parameter with quotes around.
* If there are quotes in the description, they are escaped if necessary.
* The around quote could be single or double.
* \see description()
*
* \since QGIS 3.24
*/
QString descriptionAsPythonString() const;

/**
* Returns a string version of the parameter input \a value, which is suitable for use as an input
* parameter value when running an algorithm directly from a Python command.
Expand Down
3 changes: 2 additions & 1 deletion src/core/processing/qgsprocessingparametertininputlayers.cpp
Expand Up @@ -91,7 +91,8 @@ QString QgsProcessingParameterTinInputLayers::asPythonString( QgsProcessing::Pyt
{
case QgsProcessing::PythonQgsProcessingAlgorithmSubclass:
{
QString code = QStringLiteral( "QgsProcessingParameterTinInputLayers('%1', %2)" ).arg( name(), descriptionAsPythonString() );
QString code = QStringLiteral( "QgsProcessingParameterTinInputLayers('%1', %2)" )
.arg( name(), QgsProcessingUtils::stringToPythonLiteral( description() ) );
return code;
}
}
Expand Down
Expand Up @@ -96,7 +96,8 @@ QString QgsProcessingParameterVectorTileWriterLayers::asPythonString( QgsProcess
{
case QgsProcessing::PythonQgsProcessingAlgorithmSubclass:
{
QString code = QStringLiteral( "QgsProcessingParameterVectorTileWriterLayers('%1', %2)" ).arg( name(), descriptionAsPythonString() );
QString code = QStringLiteral( "QgsProcessingParameterVectorTileWriterLayers('%1', %2)" )
.arg( name(), QgsProcessingUtils::stringToPythonLiteral( description() ) );
return code;
}
}
Expand Down

0 comments on commit 68f003c

Please sign in to comment.