U af @sZddlZddlZddlZddlZddlmZmZmZmZe e Z Gdddej dZ dS)N)AnyDictOptionalTuplec@seZdZdZdZdZdeejddddZ dee e ddd Z e e e fd d d Ze d d dZe e e dddZe e dddZejddddZdS)LogDataz Logging dataN)recordreturncCs<i|_t|dsdn|j|_d|_t|tjr8||dS)N freefieldsF)datahasattrr r isinstancelogging LogRecordloadselfrrrD/opt/nydus/tmp/pip-target-53d1vnqk/lib/python/primordial/log/data.py__init__s  zLogData.__init__)fieldr cCs&|dkr|jS||jkr"|j|SdS)zRGet the data from a single field. :param field: The field to get N)r )rrrrrgets   z LogData.get)r cCs>i}|D](\}}t|tr0|||<q|||<q|S)zGet a dictionary of the data.)ritemsr rgetDict)rZdatadictkeyvalrrrr&s   zLogData.getDictcCst|S)N)jsondumpsr)rrrrgetJSON1szLogData.getJSON)rvaluer cCsdt|tr0|D]\}}|||||<q|S||jksX|dksX|dksXt|ttfr\|St|S)zParse a value and coerce it into appropriate datatypes. :param field: The name of the field to be parsed :param value: The value of the field. N process_time)r dictrparseVal RAW_FIELDSrboolstr)rrrkvrrrr!4s   zLogData.parseVal)rrcCs8||jks|jr$||||j|<ntd|d|S)zSet a value in the data dictionary. :param field: The field to be set :param value: The value of the field :raises ValueError: If the field name is invalid zNo such field '')FIELDSr r!r ValueError)rrrrrrsetHsz LogData.setcCs ||_dS)zKLoad a log record. :param record: The record to be loaded N)rrrrrrVsz LogData.load)N)N)__name__ __module__ __qualname____doc__r(r"rrrrr$rrrrrr!r*rrrrrr s  r) metaclass)abcrrlogging.configtypingrrrr getLoggerr+LOGABCMetarrrrrs