From 869e396eb573af36eb3986742d8ee729c55dbd16 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 18 May 2022 10:50:37 +0900 Subject: [PATCH] Remove handling of 'u' prefix ... because the prefix is no longer printed in Python 3. In python 2 >>> print({u'foo': u'baa'}) {u'foo': u'baa'} >>> print([u'foo', 'baa']) [u'foo', 'baa'] In python 3 >>> print({u'foo': u'baa'}) {'foo': 'baa'} >>> print([u'foo', 'baa']) ['foo', 'baa'] Change-Id: I8f4adab5d7c6c8730d08f9311c55783ea719527f --- lib/puppet/provider/cinder_type/openstack.rb | 2 +- spec/unit/provider/cinder_type/openstack_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/cinder_type/openstack.rb b/lib/puppet/provider/cinder_type/openstack.rb index 72cf7f46..7504e36e 100644 --- a/lib/puppet/provider/cinder_type/openstack.rb +++ b/lib/puppet/provider/cinder_type/openstack.rb @@ -114,7 +114,7 @@ Puppet::Type.type(:cinder_type).provide( end def self.pythondict2array(input) - json_input = JSON.parse(input.gsub(/u'([^']*)'/, '"\1"').gsub(/'/, '"')) + json_input = JSON.parse(input.gsub(/'/, '"')) output = [] json_input.each do | k, v | output = output + ["#{k}=#{v}"] diff --git a/spec/unit/provider/cinder_type/openstack_spec.rb b/spec/unit/provider/cinder_type/openstack_spec.rb index 5a0a6fe9..85c6677b 100644 --- a/spec/unit/provider/cinder_type/openstack_spec.rb +++ b/spec/unit/provider/cinder_type/openstack_spec.rb @@ -122,7 +122,7 @@ access_project_ids="54f4d231201b4944a5fa4587a09bda23, 54f4d231201b4944a5fa4587a0 describe '#pythondict2array' do it 'should return an array with key-value when provided with a unicode python dict' do - s = "{u'key': 'value', u'key2': 'value2'}" + s = "{'key': 'value', 'key2': 'value2'}" expect(provider_class.pythondict2array(s)).to eq(['key=value', 'key2=value2']) end @@ -139,7 +139,7 @@ access_project_ids="54f4d231201b4944a5fa4587a09bda23, 54f4d231201b4944a5fa4587a0 end it 'should call pythondict2array when provided with a hash' do - s = "{u'key': 'value', u'key2': 'value2'}" + s = "{'key': 'value', 'key2': 'value2'}" expect(provider_class.parsestring(s)).to eq(['key=value', 'key2=value2']) end end