def validateJson(newJsonObj): ''' Validate input json against defined schema ''' try: theSchema = getPlanSchema(newJsonObj['platform']['name']) loadDocumentFromDict(convertToDotDictRecurse(newJsonObj), theSchema.schema) return True except Exception, e: return "Invalid JSON: " + str(e)
def toXpjson(self): platform = self.jsonPlan['platform'] if platform: planSchema = getPlanSchema(platform[u'name']) return xpjson.loadDocumentFromDict(self.jsonPlan, schema=planSchema.getSchema()) logging.warning('toXpjson: could not convert to xpjson, probably no schema %s', self.uuid) raise # FIX
def toXpjson(self): platform = self.jsonPlan['platform'] if platform: planSchema = getPlanSchema(platform[u'name']) return xpjson.loadDocumentFromDict(self.jsonPlan, schema=planSchema.getSchema()) logging.warning( 'toXpjson: could not convert to xpjson, probably no schema %s', self.uuid) raise # FIX
def planDocFromPlanDict(planDict, schema): # downstream processing tools assume plan is a DotDict planDict = convertToDotDictRecurse(planDict) planDoc = (xpjson.loadDocumentFromDict( planDict, schema=schema, parseOpts=xpjson.ParseOpts(fillInDefaults=True))) # fill in ids fillIds = FillIdsPlanExporter() return fillIds.exportPlan(planDoc, schema)
def planDocFromPlanDict(planDict, schema): # downstream processing tools assume plan is a DotDict planDict = convertToDotDictRecurse(planDict) planDoc = (xpjson.loadDocumentFromDict (planDict, schema=schema, parseOpts=xpjson.ParseOpts(fillInDefaults=True))) # fill in ids fillIds = FillIdsPlanExporter() return fillIds.exportPlan(planDoc, schema)