Exemplo n.º 1
0
 def introspect(self):
     return strip_none({
         'type':
         self.introspect_type,
         'description':
         self.description,
         'options': [option.introspect() for option in self.options],
     })
Exemplo n.º 2
0
 def introspect(self):
     return strip_none({
         'type':
         self.introspect_type,
         'contents': [value.introspect() for value in self.contents],
         'description':
         self.description,
     })
Exemplo n.º 3
0
 def introspect(self):
     return strip_none({
         'type': self.introspect_type,
         'description': self.description,
         # Unfortunately, this is the one sort of thing we can't represent
         # super well. Maybe add some dotted path stuff in here.
         'valid_type': repr(self.valid_type),
     })
Exemplo n.º 4
0
 def introspect(self):
     return strip_none({
         'type': self.introspect_type,
         'contents': self.contents.introspect(),
         'max_length': self.max_length,
         'min_length': self.min_length,
         'description': self.description,
     })
Exemplo n.º 5
0
 def introspect(self):  # type: () -> Introspection
     return strip_none({
         'type': self.introspect_type,
         'description': self.description,
         'gt': six.text_type(self.gt) if self.gt else None,
         'gte': six.text_type(self.gte) if self.gte else None,
         'lt': six.text_type(self.lt) if self.lt else None,
         'lte': six.text_type(self.lte) if self.lte else None,
     })
Exemplo n.º 6
0
 def introspect(self):  # type: () -> Introspection
     return strip_none({
         'type':
         self.introspect_type,
         'description':
         self.description,
         'value_schema':
         self.value_schema.introspect() if self.value_schema else None,
     })
Exemplo n.º 7
0
 def introspect(self):  # type: () -> Dict[six.text_type, AnyType]
     return strip_none({
         'type':
         self.introspect_type,
         'description':
         self.description,
         'value_schema':
         self.value_schema.introspect() if self.value_schema else None,
     })
Exemplo n.º 8
0
 def introspect(self):
     return strip_none({
         'type':
         self.introspect_type,
         'description':
         self.description,
         'requirements':
         [requirement.introspect() for requirement in self.requirements],
     })
Exemplo n.º 9
0
 def introspect(self):
     return strip_none({
         'type': self.introspect_type,
         'description': self.description,
         'min_length': self.min_length,
         'max_length': self.max_length,
         'allow_blank': self.allow_blank
         and None,  # if the default True, hide it from introspection
     })
Exemplo n.º 10
0
 def introspect(self):
     return strip_none({
         'type': self.introspect_type,
         'description': self.description,
         'gt': self.gt,
         'gte': self.gte,
         'lt': self.lt,
         'lte': self.lte,
     })
Exemplo n.º 11
0
 def introspect(self):
     return strip_none({
         'type': self.introspect_type,
         'description': self.description,
         'switch_field': self.switch_field,
         'contents_map': {
             key: value.introspect()
             for key, value in self.contents_map.items()
         },
     })
Exemplo n.º 12
0
 def introspect(self):
     return strip_none({
         'type': self.introspect_type,
         'description': self.description,
         'domain_whitelist': (
             sorted(self.domain_whitelist)
             if self.domain_whitelist and self.domain_whitelist is not self.__class__.domain_whitelist
             else None
         ),
     })
Exemplo n.º 13
0
 def introspect(self):  # type: () -> Introspection
     return strip_none({
         'type':
         self.introspect_type,
         'contents': [value.introspect() for value in self.contents],
         'description':
         self.description,
         'additional_validation':
         (self.additional_validator.__class__.__name__
          if self.additional_validator else None),
     })
Exemplo n.º 14
0
 def introspect(self):
     result = {
         'type': self.introspect_type,
         'description': self.description,
     }
     # We avoid using isinstance() here as that would also match subclass instances
     if not self.key_type.__class__ == Hashable:
         result['key_type'] = self.key_type.introspect()
     if not self.value_type.__class__ == Anything:
         result['value_type'] = self.value_type.introspect()
     return strip_none(result)
Exemplo n.º 15
0
 def introspect(self):  # type: () -> Introspection
     return strip_none({
         'type':
         self.introspect_type,
         'values': [
             s if isinstance(s, (six.text_type, bool, int, float,
                                 type(None))) else six.text_type(s)
             for s in sorted(self.values, key=six.text_type)
         ],
         'description':
         self.description,
     })
Exemplo n.º 16
0
    def introspect(self):
        base_classes = None
        if self.base_classes:
            if isinstance(self.base_classes, type):
                base_classes = [six.text_type(self.base_classes)]
            else:
                base_classes = [six.text_type(c) for c in self.base_classes]

        return strip_none({
            'type': self.introspect_type,
            'description': self.description,
            'base_classes': base_classes,
        })
Exemplo n.º 17
0
    def introspect(self):
        display_order = None
        if isinstance(self.contents, OrderedDict):
            display_order = list(self.contents.keys())

        return strip_none({
            'type': self.introspect_type,
            'contents':
            {key: value.introspect()
             for key, value in self.contents.items()},
            'optional_keys': sorted(self.optional_keys),
            'allow_extra_keys': self.allow_extra_keys,
            'description': self.description,
            'display_order': display_order,
        })
Exemplo n.º 18
0
 def introspect(self):  # type: () -> Introspection
     return strip_none({
         'type':
         self.introspect_type,
         'contents':
         self.contents.introspect(),
         'max_length':
         self.max_length,
         'min_length':
         self.min_length,
         'description':
         self.description,
         'additional_validation':
         (self.additional_validator.__class__.__name__
          if self.additional_validator else None),
     })
Exemplo n.º 19
0
 def introspect(self):  # type: () -> Introspection
     return strip_none({
         'type':
         self.introspect_type,
         'description':
         self.description,
         'valid_currencies':
         ('(all currencies)'
          if self.valid_currencies is DEFAULT_CURRENCY_CODES else sorted(
              self.valid_currencies)),
         'gt':
         self.gt,
         'gte':
         self.gte,
         'lt':
         self.lt,
         'lte':
         self.lte,
     })
Exemplo n.º 20
0
 def introspect(self):
     return strip_none({
         'type':
         self.introspect_type,
         'description':
         self.description,
         'base_class':
         six.text_type(self.base_class.__name__),
         'default_path':
         self.default_path,
         'switch_field':
         'path',
         'switch_field_schema':
         self.switch_field_schema.introspect(),
         'kwargs_field':
         'kwargs',
         'kwargs_contents_map':
         {k: v.introspect()
          for k, v in six.iteritems(self._schema_cache)},
     })
Exemplo n.º 21
0
 def introspect(self):  # type: () -> Introspection
     result = {
         'type':
         self.introspect_type,
         'max_length':
         self.max_length,
         'min_length':
         self.min_length,
         'description':
         self.description,
         'additional_validation':
         (self.additional_validator.__class__.__name__
          if self.additional_validator else None),
     }  # type: Introspection
     # We avoid using isinstance() here as that would also match subclass instances
     if not self.key_type.__class__ == Hashable:
         result['key_type'] = self.key_type.introspect()
     if not self.value_type.__class__ == Anything:
         result['value_type'] = self.value_type.introspect()
     return strip_none(result)
Exemplo n.º 22
0
    def introspect(self):  # type: () -> Introspection
        display_order = None  # type: Optional[ListType[AnyType]]
        if isinstance(self.contents, OrderedDict):
            display_order = list(self.contents.keys())

        return strip_none({
            'type':
            self.introspect_type,
            'contents':
            {key: value.introspect()
             for key, value in self.contents.items()},
            'optional_keys':
            sorted(self.optional_keys),
            'allow_extra_keys':
            self.allow_extra_keys,
            'description':
            self.description,
            'display_order':
            display_order,
            'additional_validation':
            (self.additional_validator.__class__.__name__
             if self.additional_validator else None),
        })
Exemplo n.º 23
0
 def introspect(self):
     return strip_none({
         'type': self.introspect_type,
         'description': self.description,
     })
Exemplo n.º 24
0
 def introspect(self):  # type: () -> Introspection
     return strip_none({
         'type': self.introspect_type,
         'description': self.description,
         'validator': self.validator_description,
     })
Exemplo n.º 25
0
 def introspect(self):
     return strip_none({
         'type': self.introspect_type,
         'values': sorted(self.values),
         'description': self.description,
     })