Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(18)  |  Call(15)  |  Derive(0)  |  Import(3)
Mapping field for constant values.

>>> class Record(Mapping):
...     type = ConstantField(default='S')
>>> rec = Record()
>>> rec.type
'S'
>>> rec.type = 'W'
Traceback (most recent call last):
    ...(more...)

src/a/s/astm-0.5.0/astm/omnilab/common.py   astm(Download)
 
from astm import __version__
from astm.mapping import (
    Component, ConstantField, ComponentField, DateField, DateTimeField,
    IntegerField, SetField, TextField
 
    sender = ComponentField(Sender)
    processing_id = ConstantField(default='P')
    version = ConstantField(default='E 1394-97')
 
class CommonComment(CommentRecord):
    ctype = ConstantField(default='G')
 
 
class Terminator(TerminatorRecord):

src/a/s/astm-0.5.0/astm/omnilab/client.py   astm(Download)
"""
 
from astm.mapping import (
    Component, ConstantField, ComponentField, IntegerField, DateTimeField,
    RepeatedComponentField, SetField, TextField, NotUsedField
    laboratory = TextField(length=20)
    laboratory_field_1 = TextField(length=20)
    report_type = ConstantField(default='O')
    sampled_at = DateTimeField()
    test = RepeatedComponentField(Test)
    :type ctype: str
    """
    source = ConstantField(default='L')
    data = ComponentField(CommentData)
 

src/a/s/astm-0.5.0/astm/omnilab/server.py   astm(Download)
 
from astm.server import BaseRecordsDispatcher
from astm.mapping import (
    Component, ConstantField, ComponentField, DateTimeField, IntegerField,
    SetField, TextField, NotUsedField, DateField
    action_code = SetField(values=(None, 'Q'))
    instrument = ComponentField(Instrument)
    report_type = ConstantField(default='F')
    test = ComponentField(Test)
 
    :type ctype: str
    """
    source = ConstantField(default='I')
    data = ComponentField(CommentData)
 

src/a/s/astm-0.5.0/astm/tests/test_mapping.py   astm(Download)
        class Dummy(mapping.Mapping):
            field = mapping.ConstantField(default=42)
        obj = Dummy()
        self.assertEqual(obj.field, 42)
 
    def test_set_value_if_none_default(self):
        class Dummy(mapping.Mapping):
            field = mapping.ConstantField(default='foo')
        class Dummy(mapping.Mapping):
            field = mapping.ConstantField(default='foo')
        obj = Dummy()
        obj.field = 'foo'
        self.assertEqual(obj.field, 'foo')
        self.assertRaises(ValueError, setattr, obj, 'field', 'bar')
 
    def test_restrict_new_values_by_default_one(self):
        class Dummy(mapping.Mapping):
            field = mapping.ConstantField(default='foo')
        class Dummy(mapping.Mapping):
            field = mapping.ConstantField(default='foo')
        obj = Dummy()
        obj.field = 'foo'
        self.assertEqual(obj._data['field'], 'foo')