tools/json_schema_compiler/model.py
def UnixName(name):
  '''Returns the unix_style name for a given lowerCamelCase string.
  '''
  # Append an extra underscore to the |name|'s end if it's a reserved C++
  # keyword in order to avoid compilation errors in generated code.
  # Note: In some cases, this is overly greedy, because the unix name is
  # appended to another string (such as in choices, where it becomes
  # "as_double_"). We can fix this if this situation becomes common, but for now
  # it's only hit in tests, and not worth the complexity.
  if IsCPlusPlusKeyword(name):
    name = name + '_'

  # Prepend an extra underscore to the |name|'s start if it doesn't start with a
  # letter or underscore to ensure the generated unix name follows C++
  # identifier rules.
  assert(name)
  if name[0].isdigit():
    name = '_' + name

  unix_name = []
  for i, c in enumerate(name):
    if c.isupper() and i > 0 and name[i - 1] != '_':
      # Replace lowerUpper with lower_Upper.
      if name[i - 1].islower():
        unix_name.append('_')
      # Replace ACMEWidgets with ACME_Widgets
      elif i + 1 < len(name) and name[i + 1].islower():
        unix_name.append('_')
    if c == '.':
      # Replace hello.world with hello_world.
      unix_name.append('_')
    else:
      # Everything is lowercase.
      unix_name.append(c.lower())
  return ''.join(unix_name)
Returns the unix_style name for a given lowerCamelCase string.
  
Returns the unix_style name for a given lowerCamelCase string.
Returns the unix_style name for a given lowerCamelCase string .
def UnixName(name):
  if IsCPlusPlusKeyword(name):
    name = name + '_'
  assert(name)
  if name[0].isdigit():
    name = '_' + name
  unix_name = []
  for i, c in enumerate(name):
    if c.isupper() and i > 0 and name[i - 1] != '_':
      if name[i - 1].islower():
        unix_name.append('_')
      elif i + 1 < len(name) and name[i + 1].islower():
        unix_name.append('_')
    if c == '.':
      unix_name.append('_')
    else:
      unix_name.append(c.lower())
  return ''.join(unix_name)
def UnixName ( name ) : if IsCPlusPlusKeyword ( name ) : name = name + '_' assert ( name ) if name [ 0 ] . isdigit ( ) : name = '_' + name unix_name = [ ] for i , c in enumerate ( name ) : if c . isupper ( ) and i > 0 and name [ i - 1 ] != '_' : if name [ i - 1 ] . islower ( ) : unix_name . append ( '_' ) elif i + 1 < len ( name ) and name [ i + 1 ] . islower ( ) : unix_name . append ( '_' ) if c == '.' : unix_name . append ( '_' ) else : unix_name . append ( c . lower ( ) ) return '' . join ( unix_name )
Returns the unix_style name for a given lowerCamelCase string.
Returns the unix_style name for a given lowerCamelCase string .
'''Returns the unix_style name for a given lowerCamelCase string.
  ''' # Append an extra underscore to the |name|'s end if it's a reserved C++ # keyword in order to avoid compilation errors in generated code. # Note: In some cases, this is overly greedy, because the unix name is # appended to another string (such as in choices, where it becomes # "as_double_"). We can fix this if this situation becomes common, but for now # it's only hit in tests, and not worth the complexity. # Prepend an extra underscore to the |name|'s start if it doesn't start with a # letter or underscore to ensure the generated unix name follows C++ # identifier rules. # Replace lowerUpper with lower_Upper. # Replace ACMEWidgets with ACME_Widgets # Replace hello.world with hello_world. # Everything is lowercase.
name