parameters: ()
docstring: Main program entry
docstring_summary: Main program entry
docstring_tokens: Main program entry
function: def main():
      """ Main program entry """
      if len(sys.argv) < 2 or not os.path.isdir(sys.argv[1]):
          print("[ERROR] Must supply a directory to correct", file=sys.stderr)
          sys.exit(1)
      directory = sys.argv[1]
      all_files = os.listdir(directory)
      # Detect broken files
      defunct_files = [potential for potential in all_files if potential[0] == "_"]
      corrected = [old[1:] for old in defunct_files]
      # Move broken files
      for mover, movie in zip(defunct_files, corrected):
          shutil.move(os.path.join(directory, mover), os.path.join(directory, movie))
      # Rewrite updates for above files
      corrections_in = ['"{}'.format(correction) for correction in defunct_files] + \
                       ['/{}'.format(correction) for correction in defunct_files]
      corrections_out = ['"{}'.format(correction) for correction in corrected] + \
                        ['/{}'.format(correction) for correction in corrected]
      full_files = [os.path.join(path, file) for path, _, files in os.walk(directory) for file in files]
      mappings = list(zip(corrections_out, corrections_in))
      #for inin, outout in mappings:
      #    print("{} -> {}".format(inin, outout))
      absolution(full_files, mappings)
function_tokens: def main ( ) : if len ( sys . argv ) < 2 or not os . path . isdir ( sys . argv [ 1 ] ) : print ( "[ERROR] Must supply a directory to correct" , file = sys . stderr ) sys . exit ( 1 ) directory = sys . argv [ 1 ] all_files = os . listdir ( directory ) # Detect broken files defunct_files = [ potential for potential in all_files if potential [ 0 ] == "_" ] corrected = [ old [ 1 : ] for old in defunct_files ] # Move broken files for mover , movie in zip ( defunct_files , corrected ) : shutil . move ( os . path . join ( directory , mover ) , os . path . join ( directory , movie ) ) # Rewrite updates for above files corrections_in = [ '"{}' . format ( correction ) for correction in defunct_files ] + [ '/{}' . format ( correction ) for correction in defunct_files ] corrections_out = [ '"{}' . format ( correction ) for correction in corrected ] + [ '/{}' . format ( correction ) for correction in corrected ] full_files = [ os . path . join ( path , file ) for path , _ , files in os . walk ( directory ) for file in files ] mappings = list ( zip ( corrections_out , corrections_in ) ) #for inin, outout in mappings: #    print("{} -> {}".format(inin, outout)) absolution ( full_files , mappings )