コード例 #1
0
 def __new__(klass, context):
     adapter = super(UniquelyIdentified, klass).__new__(klass)
     meta_context = IMetaDataProvider(context)
     uuid = meta_context.setdefault_meta('identifier', UUID())
     identifier_registry.setdefault(uuid, context)
     adapter.initialize(meta_context)
     return adapter
コード例 #2
0
ファイル: adapters.py プロジェクト: mcruse/monotone
 def __new__(klass, context):
     adapter = super(UniquelyIdentified, klass).__new__(klass)
     meta_context = IMetaDataProvider(context)
     uuid = meta_context.setdefault_meta('identifier', UUID())
     identifier_registry.setdefault(uuid, context)
     adapter.initialize(meta_context)
     return adapter
コード例 #3
0
 def configuration(self):
     config = super(MetaDataNode, self).configuration()
     metaprovider = IMetaDataProvider(self)
     metadata = []
     for name,value in metaprovider.get_items():
         metadata.append({'name':name,'definition':value})
     config['metadata'] = metadata
     return config
コード例 #4
0
 def configure(self, config):
     metadata = config.get('metadata', [])
     metaprovider = IMetaDataProvider(self)
     for datum in metadata:
         name, value = datum['name'], datum['definition']
         metaprovider[name] = value
     super(MetaDataNode, self).configure(config)
コード例 #5
0
from mpx.lib.metadata.adapters import MetaDataProvider

class C(object):
    implements(Interface)
    def __init__(self, name='test', value='test value',
                 nstest='Namespace conflict test'):
        self.name = name
        self.value = value
        self.__predicate = nstest

objects = []
for i in range(0, 100):
    objects.append(C('Test %s' % i, 'Value %s' % i, 'Conflict Test %s' % i))

first = objects[0]
meta1 = IMetaDataProvider(first)

assert meta1.context is first, "Incorrect context"
items = meta1.get_items()
meta_dict = meta1.get_meta_dictionary()
predicates = meta1.get_predicates()
triples = meta1.get_triples()
values = meta1.get_values()
assert type(items) is list, 'Incorrect datatype'
assert type(meta_dict) is dict, 'Incorrect datatype'
assert type(predicates) is list, 'Incorrect datatype'
assert type(triples) is list, 'Incorrect datatype'
assert type(values) is list, 'Incorrect datatype'

assert not (items or meta_dict or predicates or triples or values), 'Non-empty'
コード例 #6
0
 def start_simulation(self):
     metadataprovider = IMetaDataProvider(self)
     point_type = metadataprovider.get_meta('point_type', 'scalar')
     point_value = metadataprovider.get_meta('value', 0)
     if point_type == 'scalar':
         self.parent.scalarcount += 1
         try: 
             minvalue = int(point_value)
         except ValueError: 
             minvalue = float(point_value)
         maxvalue = 100
         stepvalue = 1
         upmagnitude = not (self.parent.scalarcount % 5)
         if upmagnitude:
             minvalue += 500
             maxvalue *= 10
         oddscalar = self.parent.scalarcount % 2
         if oddscalar:
             step = 0.5
         minvalue = metadataprovider.get_meta('min', str(minvalue))
         maxvalue = metadataprovider.get_meta('max', str(maxvalue))
         stepvalue = metadataprovider.get_meta('step', str(stepvalue))
         scalartype = simulators.SequentialInteger
         conversion = int
         try: 
             minvalue = int(minvalue)
         except ValueError: 
             conversion = float
             minvalue = float(minvalue)
             scalartype = simulators.SequentialNumber
         try:
             maxvalue = int(maxvalue)
         except ValueError:
             conversion = float
             maxvalue = float(maxvalue)
             scalartype = simulators.SequentialNumber
         try:
             stepvalue = int(stepvalue)
         except ValueError:
             conversion = float
             stepvalue = float(stepvalue)
             scalartype = simulators.SequentialNumber
         #self.scalarconversion = conversion
         # Overriding for demonstration which uses all floats.
         self.scalarconversion = float
         self._simulator = scalartype(minvalue, maxvalue, stepvalue)
     elif point_type == 'enumeration':
         values = point_value.keys()
         values.sort()
         names = map(point_value.get, values)
         enumerations = map(EnumeratedValue, values, names)
         self._simulator = simulators.SequentialEnumeration(enumerations)
     self.pointtype = point_type
     periodvalue = 15
     periodvalue = metadataprovider.get_meta('period', str(periodvalue))
     try:
         periodvalue = int(periodvalue)
     except ValueError:
         periodvalue = float(periodvalue)
     self._simulator = simulators.PeriodicModifier(self._simulator, periodvalue)
     self.mode = 'simulation'
コード例 #7
0
ファイル: test_adapters.py プロジェクト: ed-aicradle/monotone
    def __init__(self,
                 name='test',
                 value='test value',
                 nstest='Namespace conflict test'):
        self.name = name
        self.value = value
        self.__predicate = nstest


objects = []
for i in range(0, 100):
    objects.append(C('Test %s' % i, 'Value %s' % i, 'Conflict Test %s' % i))

first = objects[0]
meta1 = IMetaDataProvider(first)

assert meta1.context is first, "Incorrect context"
items = meta1.get_items()
meta_dict = meta1.get_meta_dictionary()
predicates = meta1.get_predicates()
triples = meta1.get_triples()
values = meta1.get_values()
assert type(items) is list, 'Incorrect datatype'
assert type(meta_dict) is dict, 'Incorrect datatype'
assert type(predicates) is list, 'Incorrect datatype'
assert type(triples) is list, 'Incorrect datatype'
assert type(values) is list, 'Incorrect datatype'

assert not (items or meta_dict or predicates or triples or values), 'Non-empty'