def rename_in_module(occurrences_finder, new_name, resource=None, pymodule=None, replace_primary=False, region=None, reads=True, writes=True):
 if (resource is not None):
  source_code = resource.read()
 else:
  source_code = pymodule.source_code
 change_collector = codeanalyze.ChangeCollector(source_code)
 for occurrence in occurrences_finder.find_occurrences(resource, pymodule):
  if (replace_primary and occurrence.is_a_fixed_primary()):
   continue
  if replace_primary:
   (start, end) = occurrence.get_primary_range()
  else:
   (start, end) = occurrence.get_word_range()
  if (((not reads) and (not occurrence.is_written())) or ((not writes) and occurrence.is_written())):
   continue
  if ((region is None) or (region[0] <= start < region[1])):
   change_collector.add_change(start, end, new_name)
 return change_collector.get_changed()

def rename_in_module ( occurrences_finder , new_name , resource = None , pymodule = None , replace_primary = False , region = None , reads = True , writes = True ) : if ( resource is not None ) : source_code = resource . read ( ) else : source_code = pymodule . source_code change_collector = codeanalyze . ChangeCollector ( source_code ) for occurrence in occurrences_finder . find_occurrences ( resource , pymodule ) : if ( replace_primary and occurrence . is_a_fixed_primary ( ) ) : continue if replace_primary : ( start , end ) = occurrence . get_primary_range ( ) else : ( start , end ) = occurrence . get_word_range ( ) if ( ( ( not reads ) and ( not occurrence . is_written ( ) ) ) or ( ( not writes ) and occurrence . is_written ( ) ) ) : continue if ( ( region is None ) or ( region [ 0 ] <= start < region [ 1 ] ) ) : change_collector . add_change ( start , end , new_name ) return change_collector . get_changed ( )
returns the changed source or none if there is no changes .