feisty meow concerns codebase  2.140
fix_project_references.fix_project_references Class Reference

Public Member Functions

def __init__ (self, argv)
 
def print_instructions (self)
 
def validate_and_consume_command_line (self)
 
def read_file_data (self, filename)
 
def write_file_data (self, filename)
 
def is_alphanumeric (self, check_char)
 
def replace_within_string (self, fix_string)
 
def process_file_data (self)
 
def replace_all_occurrences (self)
 
def repair_project_references (self)
 
def extract_xml_tag (self, file_line, tag_name)
 
def extract_xml_attribute (self, file_line, tag_name, attribute_name)
 
def extract_xml_tag_from_file (self, filename, tag_name)
 
def extract_guid_from_project_file (self, filename)
 
def extract_filename_from_project_reference (self, file_line)
 
def find_all_project_references (self, filename)
 
def parse_dependency_line (self, line)
 
def extract_dependencies (self, filename)
 
def find_asset_created (self, filename)
 
def walk_directory_for_projects (self, dir)
 
def find_relative_path (self, our_path, project_file)
 
def locate_all_assets (self)
 
def locate_referenced_projects (self, project)
 
def remove_redundant_references (self, project)
 
def unit_test (self)
 

Public Attributes

 arguments
 
 file_buffer
 
 projects
 
 assets
 
 phrase_to_replace
 
 replacement_bit
 
 files
 
 file_lines
 
 state
 
 processed_buffer
 
 normal_accumulator
 
 comment_accumulator
 

Detailed Description

 This tool fixes visual studio 2010 projects to have the proper project references.

    Project files need to refer to other project files that they are dependent on if visual
    studio is to build them properly.  This is a painful task when done manually, but luckily
    this script automates the process for you.
    It requires an environment variable called BUILD_TOP that points at the top of all files
    included in a code base.  This is used to find the dependent projects.


hmmm: this tool is NOT finished.

Definition at line 6 of file fix_project_references.py.

Constructor & Destructor Documentation

◆ __init__()

def fix_project_references.fix_project_references.__init__ (   self,
  argv 
)
 Initializes the class with a set of arguments to work with.

    The arguments need to be in the form described by print_instructions().

Definition at line 21 of file fix_project_references.py.

Member Function Documentation

◆ extract_dependencies()

def fix_project_references.fix_project_references.extract_dependencies (   self,
  filename 
)
 reads in a visual studio project file and locates all dependencies.

This will produce a list of the lib files used by c++ projects.  These
are what we need to link up to their providing projects, if they're
actually things that we build.

Definition at line 367 of file fix_project_references.py.

References fix_project_references.fix_project_references.file_lines, phrase_replacer.phrase_replacer.file_lines, fix_project_references.fix_project_references.parse_dependency_line(), fix_project_references.fix_project_references.read_file_data(), and phrase_replacer.phrase_replacer.read_file_data().

Referenced by fix_project_references.fix_project_references.locate_referenced_projects().

◆ extract_filename_from_project_reference()

def fix_project_references.fix_project_references.extract_filename_from_project_reference (   self,
  file_line 
)
 given a ProjectReference line, this pulls out just the filename involved.

Definition at line 331 of file fix_project_references.py.

References fix_project_references.fix_project_references.extract_xml_attribute().

Referenced by fix_project_references.fix_project_references.find_all_project_references().

◆ extract_guid_from_project_file()

def fix_project_references.fix_project_references.extract_guid_from_project_file (   self,
  filename 
)
 reads in a visual studio project file and figures out that project's GUID.

note that this will fail horribly if the project has been messed with and is no
longer in microsoft's official format.

Definition at line 323 of file fix_project_references.py.

References fix_project_references.fix_project_references.extract_xml_tag_from_file().

Referenced by fix_project_references.fix_project_references.unit_test().

◆ extract_xml_attribute()

def fix_project_references.fix_project_references.extract_xml_attribute (   self,
  file_line,
  tag_name,
  attribute_name 
)
 locates an XML tag with "tag_name" and returns the value of the "attribute_name".

Definition at line 287 of file fix_project_references.py.

Referenced by fix_project_references.fix_project_references.extract_filename_from_project_reference().

◆ extract_xml_tag()

def fix_project_references.fix_project_references.extract_xml_tag (   self,
  file_line,
  tag_name 
)
 locates an XML tag with "tag_name" and returns the contents of the tag.

this currently assumes that the start tag, contents, and end tag are all on the same
line of text (which is not a very good assumption in general).

Definition at line 272 of file fix_project_references.py.

Referenced by fix_project_references.fix_project_references.extract_xml_tag_from_file(), fix_project_references.fix_project_references.find_asset_created(), and fix_project_references.fix_project_references.parse_dependency_line().

◆ extract_xml_tag_from_file()

def fix_project_references.fix_project_references.extract_xml_tag_from_file (   self,
  filename,
  tag_name 
)

◆ find_all_project_references()

◆ find_asset_created()

def fix_project_references.fix_project_references.find_asset_created (   self,
  filename 
)

◆ find_relative_path()

def fix_project_references.fix_project_references.find_relative_path (   self,
  our_path,
  project_file 
)
 calculates path between directory at "our_path" to the location of "project_file".

this assumes that the locations are actually rooted at the same place; otherwise there is
no path between the locations.  the location at "our_path" is considered to be the source,
or where we start out.  the location for "project_file" is the target location.

Definition at line 481 of file fix_project_references.py.

Referenced by fix_project_references.fix_project_references.unit_test().

◆ is_alphanumeric()

def fix_project_references.fix_project_references.is_alphanumeric (   self,
  check_char 
)
 given a character, this returns true if it's between a-z, A-Z or 0-9. 

Definition at line 115 of file fix_project_references.py.

Referenced by fix_project_references.fix_project_references.replace_within_string(), and phrase_replacer.phrase_replacer.replace_within_string().

◆ locate_all_assets()

def fix_project_references.fix_project_references.locate_all_assets (   self)
 locates every project file in our list and determines the asset created by it.

this returns a dictionary of {asset=project} items.  we index by asset way more frequently
than by project, so the asset name is used as our key.

Definition at line 514 of file fix_project_references.py.

References fix_project_references.fix_project_references.find_asset_created(), and fix_project_references.fix_project_references.projects.

◆ locate_referenced_projects()

def fix_project_references.fix_project_references.locate_referenced_projects (   self,
  project 
)
 finds all the libraries needed by the "project" file and returns their project files.

Definition at line 533 of file fix_project_references.py.

References fix_project_references.fix_project_references.assets, and fix_project_references.fix_project_references.extract_dependencies().

Referenced by fix_project_references.fix_project_references.unit_test().

◆ parse_dependency_line()

def fix_project_references.fix_project_references.parse_dependency_line (   self,
  line 
)
 given an AdditionalDependencies line, this finds the libs listed.

Definition at line 353 of file fix_project_references.py.

References fix_project_references.fix_project_references.extract_xml_tag().

Referenced by fix_project_references.fix_project_references.extract_dependencies().

◆ print_instructions()

def fix_project_references.fix_project_references.print_instructions (   self)

◆ process_file_data()

def fix_project_references.fix_project_references.process_file_data (   self)
 iterates through the stored version of the file and replaces the phrase. 

Definition at line 156 of file fix_project_references.py.

Referenced by fix_project_references.fix_project_references.replace_all_occurrences(), and phrase_replacer.phrase_replacer.replace_all_occurrences().

◆ read_file_data()

◆ remove_redundant_references()

def fix_project_references.fix_project_references.remove_redundant_references (   self,
  project 
)
 cleans out any references in "project" to assets that we intend to update.

this actually modifies the file.  it had better be right.

Definition at line 565 of file fix_project_references.py.

Referenced by fix_project_references.fix_project_references.unit_test().

◆ repair_project_references()

def fix_project_references.fix_project_references.repair_project_references (   self)
 the main entry point to the project fixing process.

Operates on one project file at a time by:
  1) finding all libraries (lib files) used by the project A,
  2) locating the external project that creates each lib file,
  3) adding a reference to the external projects to our project A.

We rely on some important assumptions to get this done:
  1) project names and project file names are unique across the codebase,
  2) the structure of the source code hierarchies uses a compatible architecture,
(which is?)

Definition at line 254 of file fix_project_references.py.

◆ replace_all_occurrences()

◆ replace_within_string()

◆ unit_test()

◆ validate_and_consume_command_line()

def fix_project_references.fix_project_references.validate_and_consume_command_line (   self)

◆ walk_directory_for_projects()

def fix_project_references.fix_project_references.walk_directory_for_projects (   self,
  dir 
)
 traverses the directory in "dir" and finds all the project files.

the project files are returned as a massive list.

Definition at line 450 of file fix_project_references.py.

◆ write_file_data()

def fix_project_references.fix_project_references.write_file_data (   self,
  filename 
)

Member Data Documentation

◆ arguments

◆ assets

fix_project_references.fix_project_references.assets

◆ comment_accumulator

fix_project_references.fix_project_references.comment_accumulator

◆ file_buffer

fix_project_references.fix_project_references.file_buffer

◆ file_lines

◆ files

fix_project_references.fix_project_references.files

◆ normal_accumulator

fix_project_references.fix_project_references.normal_accumulator

Definition at line 161 of file fix_project_references.py.

◆ phrase_to_replace

fix_project_references.fix_project_references.phrase_to_replace

◆ processed_buffer

◆ projects

fix_project_references.fix_project_references.projects

◆ replacement_bit

fix_project_references.fix_project_references.replacement_bit

◆ state

fix_project_references.fix_project_references.state

Definition at line 158 of file fix_project_references.py.


The documentation for this class was generated from the following file: