ó .Åt_c@s dZddlTddlmZddlZdefd„ƒYZdefd„ƒYZd efd „ƒYZd efd „ƒYZd efd„ƒYZ defd„ƒYZ defd„ƒYZ de fd„ƒYZ defd„ƒYZ defd„ƒYZdS(sŒ Field - base class for a field of a collection of statistics $Id: //eng/vdo-releases/magnesium/src/python/vdo/statistics/Field.py#1 $ iÿÿÿÿ(t*(t LabeledValueNtFieldcBsneZdZejdƒZejdƒZejdƒZed„ƒZ d„Z d„Z d„Z d„Z RS( sD Field is the base class for a field of a statistics structure. s ([A-Z][a-z])s([a-z])([A-Z])s\$([a-zA-Z0-9_]+)cCs.|jjd„|ƒ}|jjd„|ƒS(s Convert a camel-cased string to a set of space separated, lower case words. Preserves uppercase acronyms, so 'launchVDOErrorCount' becomes 'launch VDO error count'. :param string: The string to convert :return: The converted string cSsd|jƒjƒS(Nt (tgrouptlower(tmatch((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt1scSsdj|jƒƒS(NR(tjointgroups(R((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR3s(t decamelRE1tsubt decamelRE2(tclststringtlowered((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt_decamel%s  cs"|jjd|ƒ‰‡fd†S(s¡ Convert a string describing how to derive a field's value into a lambda. :param string The string to convert :return: An equivalent lambda s"parent.getSampleValue(stats, "\1")cs tˆƒS(N(teval(tstatstparent(t derivation(s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR?s(t fieldNamesR (tselfR((Rs8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt_generateLambda5s  cKs"||_|jddƒ|_|jdkr:||jn||_|jdtƒ|_|jr|jd|j|jƒƒnd |_|j |jddƒƒ|_ |jdd ƒ}|d k|_ dj d |jƒ}|j |rî|n|ƒ|_ |rtd j |jƒƒƒ‚nd S( sî Create a new field. :param name: The name of the field :param cType: The class representing the C representation for this field when sampled via an ioctl :param **kwargs: Keyword arguments which may be: available: Specifies python code to apply to other fields of the parent structure to decide whether this value is available. Defaults to True. derived: Specifies python code to apply to other fields of the parent structure to derive the value of this field. Defaults to None. display: If not True, this field will not be included in labeled output. Defaults to True. label: The label for this field. If unspecified, the label will be derived from the field name. length: if > 1, indicates this field is an array of the specified cType, otherwise is is a scalar. Defaults to 1. tlengthitdisplaytlabelt availabletTruetderivedsgetattr(stats, '{name}')tnamesunknown arguments to Field: {0}N(RtpopRtcTypeRRRtNoneRRRtinStructtformattgetValuet Exceptiontkeys(RRR tkwargsRt defaultValue((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__init__As %0cCs)|j||ƒstƒS|j||ƒS(sÙ Extract the value for this field from a sample. :param stats: The raw stats returned from an ioctl :param parent: The parent of this field :return: The value of this field in the current sample (Rt NotAvailableR$(RRR((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt extractSamplels cCstj||j|ƒS(sŸ Label a sampled value for this field. :param sample: The sampled field value :param prefix: The prefix for the label :return: A LabeledValue for a value of this field (RtmakeR(Rtsampletprefix((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pytlabeledzs (t__name__t __module__t__doc__tretcompileR R Rt classmethodRRR)R+R/(((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyRs + t IntegerFieldcBseZdZd„ZRS(s4 Base class for fields which are integer types. cCsttt|ƒj||ƒƒS(s :inherit: (tinttsuperR6R+(RRR((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR+Šs(R0R1R2R+(((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR6†st BoolFieldcBseZd„Zd„ZRS(cKs tt|ƒj|t|dS(N(R8R9R)tc_byte(RRR'((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR)’scCstt|ƒj||ƒdkS(Ni(R8R9R+(RRR((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR+•s(R0R1R)R+(((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR9‘s t Uint8FieldcBseZd„ZRS(cKs tt|ƒj|t|dS(N(R8R;R)R:(RRR'((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR)™s(R0R1R)(((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR;˜st Uint32FieldcBseZd„ZRS(cKs tt|ƒj|t|dS(N(R8R<R)tc_uint(RRR'((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR)s(R0R1R)(((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR<œst Uint64FieldcBseZd„ZRS(cKs tt|ƒj|t|dS(N(R8R>R)t c_ulonglong(RRR'((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR)¡s(R0R1R)(((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR> stFloatingPointFieldcBseZdZd„ZRS(s; Base class for fields which are floating point types. cCsttt|ƒj||ƒƒS(s :inherit: (tfloatR8R@R+(RRR((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR+©s(R0R1R2R+(((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR@¥st FloatFieldcBseZd„ZRS(cKs tt|ƒj|t|dS(N(R8RBR)tc_float(RRR'((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR)±s(R0R1R)(((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyRB°st StringFieldcBseZd„ZRS(cKs tt|ƒj|t|dS(N(R8RDR)tc_char(RRR'((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR)¶s(R0R1R)(((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyRDµsR*cBszeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „ZRS( sZ A value for numeric statistics which are currently not available; prints as 'N/A'. cCsdS(NsN/A((R((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__str__¿scCsdS(NR*((R((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__repr__ÂscCs|S(N((Rtother((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__add__ÅscCs|S(N((RRH((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__radd__ÈscCs|S(N((RRH((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__sub__ËscCs|S(N((RRH((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__rsub__ÎscCs|S(N((RRH((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__mul__ÑscCs|S(N((RRH((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__rmul__ÔscCs|S(N((RRH((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__div__×scCs|S(N((RRH((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__rdiv__ÚscCs|S(N((R((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt__int__ÝscCsd|djt|ƒƒS(Ns{0:t}(R#tstr(Rtspec((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyt __format__às(R0R1R2RFRGRIRJRKRLRMRNRORPRQRU(((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyR*ºs           (R2tctypesRR3tobjectRR6R9R;R<R>R@RBRDR7R*(((s8/usr/lib/python2.7/site-packages/vdo/statistics/Field.pyts  i