Changeset 21b5434


Ignore:
Timestamp:
May 26, 2010 3:35:49 AM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
4e00f7c
Parents:
cf00ddd
Message:

The string coercion was turning perfectly valid None types into 'None" strings. Modified the string coercion to respect None.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/topdl.py

    rcf00ddd r21b5434  
    2626        else: return [ a ]
    2727
     28    @staticmethod
     29    def init_string(s):
     30        """
     31        Force a string coercion for everything but a None.
     32        """
     33        if s is not None: return "%s" % s
     34        else: return None
     35
    2836    def remove_attribute(self, key):
    2937        to_del = None
     
    6270class Attribute(base):
    6371    def __init__(self, attribute, value):
    64         self.attribute = "%s" % attribute
    65         self.value = "%s" % value
     72        self.attribute = self.init_string(attribute)
     73        self.value = self.init_string(value)
    6674
    6775    def clone(self):
     
    7482    def __init__(self, rate, kind):
    7583        self.rate = float(rate)
    76         self.kind = "%s" % kind
     84        self.kind = self.init_string(kind)
    7785
    7886    def clone(self):
     
    8593    def __init__(self, time, kind):
    8694        self.time = float(time)
    87         self.kind = "%s" % kind
     95        self.kind = self.init_string(kind)
    8896
    8997    def clone(self):
     
    95103class Substrate(base):
    96104    def __init__(self, name, capacity=None, latency=None, attribute=[]):
    97         self.name = "%s" % name
     105        self.name = self.init_string(name)
    98106        self.capacity = self.init_class(Capacity, capacity)
    99107        self.latency = self.init_class(Latency, latency)
     
    126134class CPU(base):
    127135    def __init__(self, type, attribute=[]):
    128         self.type = "%s" % type
     136        self.type = self.init_string(type)
    129137        self.attribute = [ self.init_class(Attribute, a) for a in \
    130138                self.make_list(attribute) ]
     
    143151    def __init__(self, amount, persistence, attribute=[]):
    144152        self.amount = float(amount)
    145         self.presistence = "%s" % persistence
     153        self.presistence = self.init_string(persistence)
    146154        self.attribute = [ self.init_class(Attribute, a) \
    147155                for a in self.make_list(attribute) ]
     
    160168    def __init__(self, name=None, version=None, distribution=None,
    161169            distributionversion=None, attribute=[]):
    162         self.name = "%s" % name
    163         self.version = "%s" % version
    164         self.distribution = "%s" % distribution
    165         self.distributionversion = "%s" % distributionversion
     170        self.name = self.init_string(name)
     171        self.version = self.init_string(version)
     172        self.distribution = self.init_string(distribution)
     173        self.distributionversion = self.init_string(distributionversion)
    166174        self.attribute = [ self.init_class(Attribute, a) \
    167175                for a in self.make_list(attribute) ]
     
    186194class Software(base):
    187195    def __init__(self, location, install=None, attribute=[]):
    188         self.location = "%s" % location
    189         self.install = "%s" % install
     196        self.location = self.init_string(location)
     197        self.install = self.init_string(install)
    190198        self.attribute = [ self.init_class(Attribute, a)\
    191199                for a in self.make_list(attribute) ]
     
    205213    def __init__(self, substrate, name=None, capacity=None, latency=None,
    206214            attribute=[], element=None):
    207         self.name = "%s" % name
     215        self.name = self.init_string(name)
     216
    208217        self.substrate = self.make_list(substrate)
    209218        self.capacity = self.init_class(Capacity, capacity)
     
    239248            kerberosUsername=None):
    240249        self.fedid=fedid_class(hexstr="%s" % fedid)
    241         self.uuid = "%s" % uuid
    242         self.uri = "%s" % uri
    243         self.localname ="%s" %  localname
    244         self.kerberosUsername = "%s" % kerberosUsername
     250        self.uuid = self.init_string(uuid)
     251        self.uri = self.init_string(uri)
     252        self.localname =self.init_string( localname)
     253        self.kerberosUsername = self.init_string(kerberosUsername)
    245254
    246255    def clone(self):
     
    263272            i.element = self
    264273
    265         self.name = "%s" % name
     274        self.name = self.init_string(name)
    266275        self.cpu = [ self.init_class(CPU, c)  for c in self.make_list(cpu) ]
    267276        self.os = [ self.init_class(OperatingSystem, c) \
     
    308317class Testbed(base):
    309318    def __init__(self, uri, type, interface=[], attribute=[]):
    310         self.uri = "%s" % uri
    311         self.type = "%s" % type
     319        self.uri = self.init_string(uri)
     320        self.type = self.init_string(type)
    312321        self.interface = [ self.init_class(Interface, c) \
    313322                for c in self.make_list(interface) ]
     
    333342    def __init__(self, id, type, uri, interface=[], attribute=[]):
    334343        self.id = self.init_class(ID, id)
    335         self.type = "%s" % type
    336         self.uri = "%s" % uri
     344        self.type = self.init_string(type)
     345        self.uri = self.init_string(uri)
    337346        self.interface = [ self.init_class(Interface, c) \
    338347                for c in self.make_list(interface) ]
Note: See TracChangeset for help on using the changeset viewer.