From 8f8c6320e436b631d8ed21dcc8026f9ae131b630 Mon Sep 17 00:00:00 2001
From: Christian Heimes <cheimes@redhat.com>
Date: Mon, 20 Jul 2015 10:22:50 +0200
Subject: [PATCH 15/18] Don't use the types module for builtin types

Since Python 2.2 most types in the types module refer to builtin type
objects, e.g. types.ListType is list.
---
 base/common/python/pki/cert.py    | 15 +++++++--------
 base/common/python/pki/key.py     |  5 ++---
 base/common/python/pki/profile.py | 27 +++++++++++++--------------
 3 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/base/common/python/pki/cert.py b/base/common/python/pki/cert.py
index 61b04377eeef119b6a256410d5f4530d563a6547..7df9acfd93f26b291a4aa21716c9c84135fe2d5c 100644
--- a/base/common/python/pki/cert.py
+++ b/base/common/python/pki/cert.py
@@ -22,7 +22,6 @@
 
 import copy
 import json
-import types
 
 import pki
 import pki.client as client
@@ -164,7 +163,7 @@ class CertDataInfoCollection(object):
         """ Populate object from JSON input """
         ret = cls()
         cert_infos = json_value['entries']
-        if not isinstance(cert_infos, types.ListType):
+        if not isinstance(cert_infos, list):
             ret.cert_data_info_list.append(CertDataInfo.from_json(cert_infos))
         else:
             for cert_info in cert_infos:
@@ -172,7 +171,7 @@ class CertDataInfoCollection(object):
                     CertDataInfo.from_json(cert_info))
 
         links = json_value['Link']
-        if not isinstance(links, types.ListType):
+        if not isinstance(links, list):
             ret.links.append(pki.Link.from_json(links))
         else:
             for link in links:
@@ -281,7 +280,7 @@ class CertRequestInfoCollection(object):
         """ Populate object from JSON input """
         ret = cls()
         cert_req_infos = json_value['entries']
-        if not isinstance(cert_req_infos, types.ListType):
+        if not isinstance(cert_req_infos, list):
             ret.cert_request_info_list.append(
                 CertRequestInfo.from_json(cert_req_infos))
         else:
@@ -290,7 +289,7 @@ class CertRequestInfoCollection(object):
                     CertRequestInfo.from_json(cert_info))
 
         links = json_value['Link']
-        if not isinstance(links, types.ListType):
+        if not isinstance(links, list):
             ret.links.append(pki.Link.from_json(links))
         else:
             for link in links:
@@ -506,7 +505,7 @@ class CertEnrollmentRequest(object):
                     setattr(enroll_request, k, v)
 
         inputs = attr_list['Input']
-        if not isinstance(inputs, types.ListType):
+        if not isinstance(inputs, list):
             enroll_request.inputs.append(profile.ProfileInput.from_json(inputs))
         else:
             for profile_input in inputs:
@@ -514,7 +513,7 @@ class CertEnrollmentRequest(object):
                     profile.ProfileInput.from_json(profile_input))
 
         outputs = attr_list['Output']
-        if not isinstance(outputs, types.ListType):
+        if not isinstance(outputs, list):
             enroll_request.outputs.append(
                 profile.ProfileOutput.from_json(outputs))
         else:
@@ -599,7 +598,7 @@ class CertReviewResponse(CertEnrollmentRequest):
                     setattr(review_response, k, v)
 
         profile_policy_sets = attr_list['ProfilePolicySet']
-        if not isinstance(profile_policy_sets, types.ListType):
+        if not isinstance(profile_policy_sets, list):
             review_response.policy_sets.append(
                 profile.ProfilePolicySet.from_json(profile_policy_sets))
         else:
diff --git a/base/common/python/pki/key.py b/base/common/python/pki/key.py
index 5d6a79c245126c8ca7ae43fdf7f4ae00754f0a5d..f428481f09e2a9346919c2730c248f72c722af88 100644
--- a/base/common/python/pki/key.py
+++ b/base/common/python/pki/key.py
@@ -26,7 +26,6 @@ KeyRequestClient REST API on a DRM
 """
 import base64
 import json
-import types
 import urllib
 
 import pki
@@ -157,7 +156,7 @@ class KeyInfoCollection(object):
         """ Return a KeyInfoCollection object from its JSON representation """
         ret = cls()
         infos = json_value['entries']
-        if not isinstance(infos, types.ListType):
+        if not isinstance(infos, list):
             ret.key_infos.append(KeyInfo.from_json(infos))
         else:
             for info in infos:
@@ -232,7 +231,7 @@ class KeyRequestInfoCollection(object):
         """
         ret = cls()
         infos = json_value['entries']
-        if not isinstance(infos, types.ListType):
+        if not isinstance(infos, list):
             ret.key_requests.append(KeyRequestInfo.from_json(infos))
         else:
             for info in infos:
diff --git a/base/common/python/pki/profile.py b/base/common/python/pki/profile.py
index 57ff831b4276db14e38d2983044d09d9c662f1e3..81e2a6c900dc5456815263116092961694f06efb 100644
--- a/base/common/python/pki/profile.py
+++ b/base/common/python/pki/profile.py
@@ -19,7 +19,6 @@
 
 import json
 import os
-import types
 
 
 import pki
@@ -86,7 +85,7 @@ class ProfileDataInfoCollection(object):
     def from_json(cls, attr_list):
         ret = cls()
         profile_data_infos = attr_list['entries']
-        if not isinstance(profile_data_infos, types.ListType):
+        if not isinstance(profile_data_infos, list):
             ret.profile_data_list.append(
                 ProfileDataInfo.from_json(profile_data_infos))
         else:
@@ -95,7 +94,7 @@ class ProfileDataInfoCollection(object):
                     ProfileDataInfo.from_json(profile_info))
 
         links = attr_list['Link']
-        if not isinstance(links, types.ListType):
+        if not isinstance(links, list):
             ret.links.append(pki.Link.from_json(links))
         else:
             for link in links:
@@ -269,7 +268,7 @@ class ProfileInput(object):
                     setattr(profile_input, k, v)
 
         attributes = attr_list['Attribute']
-        if not isinstance(attributes, types.ListType):
+        if not isinstance(attributes, list):
             profile_input.attributes.append(
                 ProfileAttribute.from_json(attributes))
         else:
@@ -278,7 +277,7 @@ class ProfileInput(object):
                     ProfileAttribute.from_json(profile_info))
 
         config_attributes = attr_list['ConfigAttribute']
-        if not isinstance(config_attributes, types.ListType):
+        if not isinstance(config_attributes, list):
             profile_input.config_attributes.append(
                 ProfileAttribute.from_json(config_attributes))
         else:
@@ -354,7 +353,7 @@ class ProfileOutput(object):
                     setattr(profile_output, k, v)
 
         attributes = attr_list['attributes']
-        if not isinstance(attributes, types.ListType):
+        if not isinstance(attributes, list):
             profile_output.attributes.append(
                 ProfileAttribute.from_json(attributes))
         else:
@@ -477,7 +476,7 @@ class PolicyDefault(object):
 
         if 'policyAttribute' in attr_list:
             attributes = attr_list['policyAttribute']
-            if not isinstance(attributes, types.ListType):
+            if not isinstance(attributes, list):
                 policy_def.policy_attributes.append(
                     ProfileAttribute.from_json(attributes))
             else:
@@ -487,7 +486,7 @@ class PolicyDefault(object):
 
         if 'params' in attr_list:
             params = attr_list['params']
-            if not isinstance(params, types.ListType):
+            if not isinstance(params, list):
                 policy_def.policy_params.append(
                     ProfileParameter.from_json(params))
             else:
@@ -595,7 +594,7 @@ class PolicyConstraint(object):
 
         if 'constraint' in attr_list:
             constraints = attr_list['constraint']
-            if not isinstance(constraints, types.ListType):
+            if not isinstance(constraints, list):
                 policy_constraint.add_constraint_value(
                     PolicyConstraintValue.from_json(constraints))
             else:
@@ -657,7 +656,7 @@ class ProfilePolicySet(object):
         policy_set = cls()
 
         policies = attr_list['policies']
-        if not isinstance(policies, types.ListType):
+        if not isinstance(policies, list):
             policy_set.policies.append(ProfilePolicy.from_json(policies))
         else:
             for policy in policies:
@@ -718,7 +717,7 @@ class PolicySet(object):
 
         policy_set.name = attr_list['id']
         policies = attr_list['value']
-        if not isinstance(policies, types.ListType):
+        if not isinstance(policies, list):
             policy_set.policy_list.append(ProfilePolicy.from_json(policies))
         else:
             for policy in policies:
@@ -783,7 +782,7 @@ class PolicySetList(object):
 
         policy_set_list = cls()
         policy_sets = attr_list['PolicySet']
-        if not isinstance(policy_sets, types.ListType):
+        if not isinstance(policy_sets, list):
             policy_set_list.policy_sets.append(PolicySet.from_json(policy_sets))
         else:
             for policy_set in policy_sets:
@@ -926,7 +925,7 @@ class Profile(object):
                     setattr(profile_data, k, v)
 
         profile_inputs = attr_list['Input']
-        if not isinstance(profile_inputs, types.ListType):
+        if not isinstance(profile_inputs, list):
             profile_data.inputs.append(ProfileInput.from_json(profile_inputs))
         else:
             for profile_input in profile_inputs:
@@ -934,7 +933,7 @@ class Profile(object):
                     ProfileInput.from_json(profile_input))
 
         profile_outputs = attr_list['Output']
-        if not isinstance(profile_outputs, types.ListType):
+        if not isinstance(profile_outputs, list):
             profile_data.outputs.append(
                 ProfileOutput.from_json(profile_outputs))
         else:
-- 
2.4.3

