Как исправить неисправимый TypeError тип: 'rqm__Cell' -> (автоматически сгенерированный класс) - PullRequest
0 голосов
/ 04 июня 2019

Я использую python-json-schema-objects для автоматического создания классов из схемы. Я пытаюсь заполнить массив уже созданными объектами.

Но я получаю эту ошибку -

TypeError: тип сообщения: «rqm__Cell»

Мой вопрос и ошибка очень похожи на опубликованный здесь https://github.com/cwacek/python-jsonschema-objects/issues/126

Это схема

"rqm__RatType": {
  "type": "string",
  "enum": [
    "GSM",
    "CDMA"
  ]
},
"rqm__ChannelBandwidth": {
  "type": "string",
  "enum": [
    "BW_1_4_MHZ",
    "BW_3_MHZ",
  ]
},
"rqm__Cell": {
  "type": "object",
  "properties": {
    "rat": {
      "$ref": "#/definitions/rqm__RatType"
    },
    "bandwidth": {
      "$ref": "#/definitions/rqm__ChannelBandwidth"
    }
  }
},
"rqm__CellSet": {
  "type": "object",
  "properties": {
    "cellsToDeploy": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/rqm__Cell"
      },
      "minItems": 0,
      "uniqueItems": true
    }
  }
},

Я использую код

import python_jsonschema_objects as pjs
schema = {}
schema['Rqm'] = 'rqm.json'
builder = pjs.ObjectBuilder(schema['Rqm'])
ns = builder.build_classes()
Cell = ns.RqmCell
CellSet = ns.RqmCellset
cellSet = None
GSMCell = Cell(rat='GSM', bandwidth='BW_1_4_MHZ')
cellSet = CellSet(cellsToDeploy=[GSMCell])

В последней строке я получаю эту ошибку

TypeError: тип сообщения: «rqm__Cell»

Большое спасибо за любой тип поводка

...