parameters: (options)
docstring: Implements the 'split' action of this tool.
docstring_summary: Implements the 'split' action of this tool.
docstring_tokens: Implements the split action of this tool .
function: def split(options):
    """Implements the 'split' action of this tool."""
    # Load existing json data file for splitting.
    with open(options.json_input, 'r') as f:
      data = json.load(f)
  
    logging.info('Splitting off %d coverage files from %s',
                 len(data['files']), options.json_input)
  
    for file_name, coverage in data['files'].iteritems():
      # Preserve relative directories that are part of the file name.
      file_path = os.path.join(options.output_dir, file_name + '.json')
      try:
        os.makedirs(os.path.dirname(file_path))
      except OSError:
        # Ignore existing directories.
        pass
  
      with open(file_path, 'w') as f:
        # Flat-copy the old dict.
        new_data = dict(data)
  
        # Update current file.
        new_data['files'] = {file_name: coverage}
  
        # Write json data.
        json.dump(new_data, f, sort_keys=True)
function_tokens: def split ( options ) : # Load existing json data file for splitting. with open ( options . json_input , 'r' ) as f : data = json . load ( f ) logging . info ( 'Splitting off %d coverage files from %s' , len ( data [ 'files' ] ) , options . json_input ) for file_name , coverage in data [ 'files' ] . iteritems ( ) : # Preserve relative directories that are part of the file name. file_path = os . path . join ( options . output_dir , file_name + '.json' ) try : os . makedirs ( os . path . dirname ( file_path ) ) except OSError : # Ignore existing directories. pass with open ( file_path , 'w' ) as f : # Flat-copy the old dict. new_data = dict ( data ) # Update current file. new_data [ 'files' ] = { file_name : coverage } # Write json data. json . dump ( new_data , f , sort_keys = True )