MCPcopy Index your code
hub / github.com/ddserver/ddserver / FieldDeclaration

Class FieldDeclaration

ddserver/utils/txtprot.py:25–56  ·  view source on GitHub ↗

Declaration of a message field.

Source from the content-addressed store, hash-verified

23
24
25class FieldDeclaration(object):
26 ''' Declaration of a message field. '''
27
28 def __init__(self, name, conv):
29 ''' Declares a field.
30
31 @param name: the name of the field - this name is used as property name
32 of parsed messages
33 @param conv: the type converter function used to parse the field - the
34 function must accept a string and return a value
35 '''
36
37 self.__name = name
38 self.__conv = conv
39
40
41 @property
42 def name(self):
43 ''' Returns the name of the field. '''
44 return self.__name
45
46
47 def lex(self, value):
48 ''' Lex the field. '''
49
50 return self.__conv(value)
51
52
53 def format(self, value):
54 ''' Format the field. '''
55
56 return str(value)
57
58
59

Callers 1

__main__.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected