def transform_old_to_new(line, old_module, new_module, ignore_import_from=False):
 if (not ignore_import_from):
  import_from_statement = (IMPORT_FROM_TEMPLATE % (old_module,))
  if line.startswith(import_from_statement):
   new_import_from_statement = (IMPORT_FROM_TEMPLATE % (new_module,))
   return line.replace(import_from_statement, new_import_from_statement, 1)
 import_statement = (IMPORT_TEMPLATE % (old_module,))
 if (import_statement in line):
  new_import_statement = (IMPORT_TEMPLATE % (new_module,))
  return line.replace(import_statement, new_import_statement, 1)
 if line.lstrip().startswith(old_module):
  return line.replace(old_module, new_module, 1)
 if ((': ' + old_module) in line):
  return line.replace((': ' + old_module), (': ' + new_module), 1)

def transform_old_to_new ( line , old_module , new_module , ignore_import_from = False ) : if ( not ignore_import_from ) : import_from_statement = ( IMPORT_FROM_TEMPLATE % ( old_module , ) ) if line . startswith ( import_from_statement ) : new_import_from_statement = ( IMPORT_FROM_TEMPLATE % ( new_module , ) ) return line . replace ( import_from_statement , new_import_from_statement , 1 ) import_statement = ( IMPORT_TEMPLATE % ( old_module , ) ) if ( import_statement in line ) : new_import_statement = ( IMPORT_TEMPLATE % ( new_module , ) ) return line . replace ( import_statement , new_import_statement , 1 ) if line . lstrip ( ) . startswith ( old_module ) : return line . replace ( old_module , new_module , 1 ) if ( ( ': ' + old_module ) in line ) : return line . replace ( ( ': ' + old_module ) , ( ': ' + new_module ) , 1 )
transforms from an old module to a new one .