Get an example from a property specification linked to a definition.

        Args:
            prop_spec: specification of the property you want an example of.

        Returns:
            An example.
508148
def _example_from_definition(self, prop_spec):
        
        # Get value from definition
        definition_name = self.get_definition_name_from_ref(prop_spec['$ref'])

        if self.build_one_definition_example(definition_name):
            example_dict = self.definitions_example[definition_name]
            if not isinstance(example_dict, dict):
                return example_dict
            example = dict((example_name, example_value) for example_name, example_value in example_dict.items())
            return example
978240
def get_matching_property_names(self, regex):
        
        log = logging.getLogger(self.cls_logger + '.get_matching_property_names')
        prop_list_matched = []
        if not isinstance(regex, basestring):
            log.warn('regex arg is not a string, found type: {t}'.format(t=regex.__class__.__name__))
            return prop_list_matched
        log.debug('Finding properties matching regex: {r}'.format(r=regex))
        for prop_name in self.properties.keys():
            match = re.search(regex, prop_name)
            if match:
                prop_list_matched.append(prop_name)
        return prop_list_matched
890150
def get_prop(self, key, default_val=None):
        
        if self.props.has_key(key):
            return self.props[key]
        else:
            return default_val
836024
function def (params, spec, errs) {
  for (var key in params) {
    if (!spec.hasOwnProperty(key)) defError(key, errs)
  }
}
431658
def fetch(self, spec=None, *args, **kwargs):
        
        if spec is None:
            spec = {}
        for key in self.structure:
            if key in spec:
                if isinstance(spec[key], dict):
                    spec[key].update({'$exists': True})
            else:
                spec[key] = {'$exists': True}
        return self.find(spec, *args, **kwargs)
85232
def get_prop_value(name, props, default=None):
    # type: (str, Dict[str, Any], Any) -> Any
    
    if not props:
        return default

    try:
        return props[name]
    except KeyError:
        return default
211932
def find_prop_item(self, prop_name, prop_key, prop_value):
        
        # Image props are a sequence of dicts. We often need one of them.
        # Where one of the items has a dict key matching a value, and if
        # nothing matches, return None

        prop = getattr(self.props, prop_name, None)
        if prop:
            return next(
                (p for p in prop
                 if getattr(p, prop_key) == prop_value),
                None
            )

        return None
505638
def open_spec(f):
    
    import ruamel.yaml as yaml

    keys = ['modules', 'pths', 'test_import', 'install_hints', 'extra_paths']
    data = yaml.safe_load(f)
    parsed = dict()
    ## pattern = re.compile("^\s+|\s*,\s*|\s+$")
    for k in keys:
        v = data.get(k, [])
        # Items are always lists
        if isinstance(v, basestring):
            parsed[k] = [m for m in re.split(r",| ", v)]
            # parsed[k] = re.split(pattern, v)
        else:
            parsed[k] = v

    return parsed
484176
def parse_spec(self, spec):
    

    if spec.endswith('::'):
      spec_path = spec[:-len('::')]
      return DescendantAddresses(self._normalize_spec_path(spec_path))
    elif spec.endswith(':'):
      spec_path = spec[:-len(':')]
      return SiblingAddresses(self._normalize_spec_path(spec_path))
    else:
      spec_parts = spec.rsplit(':', 1)
      spec_path = self._normalize_spec_path(spec_parts[0]) 
      name = spec_parts[1] if len(spec_parts) > 1 else os.path.basename(spec_path)
      return SingleAddress(spec_path, name)
1013977
def get_example(cls) -> dict:
        
        if cls.example is not None:
            return cls.example
        return {k: v.get_example() for k, v in cls.properties.items()}
1363723
def GetProperties(cls, path_spec):
    
    properties = {}

    for property_name in cls.PROPERTY_NAMES:
      # Note that we do not want to set the properties when not used.
      if hasattr(path_spec, property_name):
        properties[property_name] = getattr(path_spec, property_name)

    return properties
1289680
def get_property_description(self, name):
        
        if not isinstance(name, basestring):
            raise TypeError("name can only be an instance of type basestring")
        description = self._call("getPropertyDescription",
                     in_p=[name])
        return description
60686
def expects(self, prop):
        
        expectation = SinonExpectation(self.obj, prop)
        self.exp_list.append(expectation)
        return expectation
320020
def get_target_from_spec(self, spec, relative_to=''):
    
    return self.get_target(Address.parse(spec, relative_to=relative_to))
195154
def get_object_example(self, def_name):
        '''
        
        '''
        def_model = self.definitions[def_name]
        example = dict()
        for opt_name, opt_value in def_model.get('properties', dict()).items():
            var_type = opt_value.get('format', None) or opt_value.get('type', None)
            example[opt_name] = self.get_response_example(opt_name, var_type, opt_value)
            if var_type == 'string':
                example[opt_name] = example[opt_name].format(opt_name)
        return example
532868
def property_key(prop)
      prop_key = prop.name.join
      prop_value = value_as_string(prop.value.first)

      # Differentiate between values for different vendor prefixes
      prop_value.to_s.scan(/^(-[^-]+-.+)/) do |vendor_keyword|
        prop_key << vendor_keyword.first
      end

      prop_key
    end
1055664
def get_properties(cls_def):
    
    # pdb.set_trace()
    prop_list = {prop: value for prop, value in cls_def.items() \
                 if 'rdf_Property' in value.get('rdf_type', "") or \
                 value.get('rdfs_domain')}

    return prop_list