Retrieves a format error location.

    Args:
      yaml_definition (dict[str, object]): current YAML definition.
      last_definition_object (DataTypeDefinition): previous data type
          definition.

    Returns:
      str: format error location.
544266
def _GetFormatErrorLocation(
      self, yaml_definition, last_definition_object):
    
    name = yaml_definition.get('name', None)
    if name:
      error_location = 'in: {0:s}'.format(name or '<NAMELESS>')
    elif last_definition_object:
      error_location = 'after: {0:s}'.format(last_definition_object.name)
    else:
      error_location = 'at start'

    return error_location
1045529
def get_yaml_parser_roundtrip_for_context():
    
    yaml_writer = get_yaml_parser_roundtrip()

    # Context is a dict data structure, so can just use a dict representer
    yaml_writer.Representer.add_representer(
        Context,
        yamler.representer.RoundTripRepresenter.represent_dict)

    return yaml_writer
763230
def get_format(self):
        
        url = self.build_url(self._endpoints.get('get_format'))
        response = self.session.get(url)
        if not response:
            return None
        return self.range_format_constructor(parent=self, **{self._cloud_data_key: response.json()})
930636
def resolve_format(format, path):
    
    if format is None:
        if (re.match(r'.+\.(yml|yaml)$', path)):
            return 'yaml'
        elif (re.match(r'.+\.tsv$', path)):
            return 'tsv'
    else:
        return format.lower()
487345
def describe_message(message_definition):
    
    message_descriptor = MessageDescriptor()
    message_descriptor.name = message_definition.definition_name().split(
        '.')[-1]

    fields = sorted(message_definition.all_fields(),
                    key=lambda v: v.number)
    if fields:
        message_descriptor.fields = [describe_field(field) for field in fields]

    try:
        nested_messages = message_definition.__messages__
    except AttributeError:
        pass
    else:
        message_descriptors = []
        for name in nested_messages:
            value = getattr(message_definition, name)
            message_descriptors.append(describe_message(value))

        message_descriptor.message_types = message_descriptors

    try:
        nested_enums = message_definition.__enums__
    except AttributeError:
        pass
    else:
        enum_descriptors = []
        for name in nested_enums:
            value = getattr(message_definition, name)
            enum_descriptors.append(describe_enum(value))

        message_descriptor.enum_types = enum_descriptors

    return message_descriptor
387607
def exception_format():
    
    return "".join(traceback.format_exception(
        sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]
    ))
1289832
def load_input(definition):
    
    if isinstance(definition, (str, io.TextIOWrapper)):
        try:
            definition = yaml.safe_load(definition)
        except Exception as exc:
            raise ParsingInputError("Unable to parse input: %s" % str(exc))

    return definition
987473
def formatted_description(self):
        
        desc = self.description

        if desc:
            return desc.replace("%s1", self.formatted_value)
        else:
            return None
371277
def _fetch_error_descriptions(self, error_dict):
        

        error_descriptions = []

        for error in error_dict[self._FIELD_ERROR]:
            description = error[self._FIELD_ERROR_DESCRIPTION]
            error_descriptions.append(description)

        return error_descriptions
1016714
private Definition getDefinition(final HttpServletRequest req) {
        final String definitionToken = req.getHeader(Headers.DEFINITION.getName());
        return StringUtils.isNotBlank(definitionToken)
                ? definitionService.parseDefinition(definitionToken)
                : MissingModelElement.DEFINITION;
    }
607837
def __type_to_tag(self, type_: Type) -> str:
        
        if type_ in scalar_type_to_tag:
            return scalar_type_to_tag[type_]

        if is_generic_list(type_):
            return 'tag:yaml.org,2002:seq'

        if is_generic_dict(type_):
            return 'tag:yaml.org,2002:map'

        if type_ in self._registered_classes.values():
            return '!{}'.format(type_.__name__)

        raise RuntimeError((
            'Unknown type {} in type_to_tag,'  # pragma: no cover
            ' please report a YAtiML bug.').format(type_))
975407
def parse(self, data, path=None):
        
        assert not self.exhausted, 'Must call get_parser() to reset state.'
        self.path = path
        parsed_data = self.yacc.parse(data, lexer=self.lexer, debug=self.debug)
        # It generally makes sense for lexer errors to come first, because
        # those can be the root of parser errors. Also, since we only show one
        # error max right now, it's best to show the lexing one.
        for err_msg, lineno in self.lexer.errors[::-1]:
            self.errors.insert(0, (err_msg, lineno, self.path))
        parsed_data.extend(self.anony_defs)
        self.exhausted = True
        return parsed_data
4419
def __format_error(self, error_list_tag):
    
    error = {'domain': self.domain(),
             'reason': self.reason(),
             'message': self.message()}
    error.update(self.extra_fields() or {})
    return {'error': {error_list_tag: [error],
                      'code': self.status_code(),
                      'message': self.message()}}
380439
def getPreprocessorDefinitions(self, engineRoot, delimiter=' '):
		
		return delimiter.join(self.resolveRoot(self.definitions, engineRoot))
62985
def CreateDataTypeMap(self, definition_name):
    
    data_type_definition = self._definitions_registry.GetDefinitionByName(
        definition_name)
    if not data_type_definition:
      return None

    return DataTypeMapFactory.CreateDataTypeMapByType(data_type_definition)
1200869
def _format_type_in_doc(self, namespace, data_type):
        
        if is_void_type(data_type):
            return 'None'
        elif is_user_defined_type(data_type):
            return ':class:`{}.{}.{}`'.format(
                self.args.types_package, namespace.name, fmt_type(data_type))
        else:
            return fmt_type(data_type)
874767
def Definition(self):
    """"""
    result = self._FormatDescriptionComment()

    result += "  enum %s {\n" % self.enum_name
    for k, v in sorted(iteritems(self.reverse_enum)):
      result += "    %s = %s;\n" % (v, k)

    result += "  }\n"

    result += self._FormatField()
    return result