threefoldtecharchive / jumpscale9_core

Apache License 2.0
0 stars 2 forks source link

Can't get schema object for list of schema's type (with more than 2 char symbol) #172

Closed AhmedHanafy725 closed 5 years ago

AhmedHanafy725 commented 5 years ago

Installation information

Detailed description

Steps to reproduce

schema = """
         @url = test.schema
         mobile_list = (Ltel)
         """
schema_test = j.data.schema.get(schema_text_path=schema)

Actual Result

can't get schema object for list of schema's type (with more than 2 char symbol)

Traceback (most recent call last)
~/opt/var/CODEGEN/_8e0e54a2f7e82350a7822b312db19edb.py in <module>()
----> 1 schema_test = j.data.schema.get(schema_text_path=schema)

/opt/code/github/threefoldtech/jumpscale_core/Jumpscale/data/schema/SchemaFactory.py in get(self, schema_text_path, url, die)
     49         if schema_text_path != "":
     50             if j.data.types.string.check(schema_text_path):
---> 51                 return self._add(schema_text_path)
     52             else:
     53                 raise RuntimeError("need to be text ")

/opt/code/github/threefoldtech/jumpscale_core/Jumpscale/data/schema/SchemaFactory.py in _add(self, schema_text_path)
    112                 res.append(self._md5_schema[md5])
    113             else:
--> 114                 s = Schema(text=block)
    115                 if s.md5 in self._md5_schema:
    116                     raise RuntimeError("should not be there")

/opt/code/github/threefoldtech/jumpscale_core/Jumpscale/data/schema/Schema.py in __init__(self, text)
     18         self._index_list = None
     19         self.url = ""
---> 20         self._schema_from_text(text)
     21         self.key = j.core.text.strip_to_ascii_dense(self.url).replace(".", "_")
     22 

/opt/code/github/threefoldtech/jumpscale_core/Jumpscale/data/schema/Schema.py in _schema_from_text(self, text)
    176                 self.error_raise("did not find =, need to be there to define field", schema=text)
    177 
--> 178             propname, alias, jumpscaletype, defvalue, comment, pointer_type = process(line)
    179 
    180             p = SchemaProperty()

/opt/code/github/threefoldtech/jumpscale_core/Jumpscale/data/schema/Schema.py in process(line)
    135                     defvalue = ""
    136                 else:
--> 137                     jumpscaletype = j.data.types.get(line_proptype)
    138                     try:
    139                         if line_wo_proptype == "" or line_wo_proptype == None:

/opt/code/github/threefoldtech/jumpscale_core/Jumpscale/data/types/Types.py in get(self, ttype, return_class)
    155                 return tt
    156             else:
--> 157                 raise RuntimeError("list type len needs to be 1 or 2")
    158         elif ttype == "dict":
    159             res = self._dict

RuntimeError: list type len needs to be 1 or 2