asrtoolkit/clean_formatting.py
def main():
  """
    Either run tests or clean formatting for files, depending on # of arguments
  """
  if len(sys.argv) == 1:
    import doctest
    doctest.testmod()

  for file_name in sys.argv[1:]:
    extension = file_name.split(".")[-1]
    if extension != 'txt':
      print("File does not end in .txt - please only use this for cleaning txt files")
      continue

    with open(file_name, 'r', encoding='utf-8') as f:
      lines = f.readlines()

    cleaned = []
    for line in lines:
      cleaned.append(clean_up(line))

    with open(file_name.replace('.txt', '') + '_cleaned.txt', 'w', encoding='utf-8') as f:
      f.writelines(cleaned)

    print('File output: ' + file_name.replace('.txt', '') + '_cleaned.txt')

    Either run tests or clean formatting for files, depending on # of arguments
  
Either run tests or clean formatting for files, depending on # of arguments
Either run tests or clean formatting for files depending on # of arguments
def main():
  if len(sys.argv) == 1:
    import doctest
    doctest.testmod()
  for file_name in sys.argv[1:]:
    extension = file_name.split(".")[-1]
    if extension != 'txt':
      print("File does not end in .txt - please only use this for cleaning txt files")
      continue
    with open(file_name, 'r', encoding='utf-8') as f:
      lines = f.readlines()
    cleaned = []
    for line in lines:
      cleaned.append(clean_up(line))
    with open(file_name.replace('.txt', '') + '_cleaned.txt', 'w', encoding='utf-8') as f:
      f.writelines(cleaned)
    print('File output: ' + file_name.replace('.txt', '') + '_cleaned.txt')
def main ( ) : if len ( sys . argv ) == 1 : import doctest doctest . testmod ( ) for file_name in sys . argv [ 1 : ] : extension = file_name . split ( "." ) [ - 1 ] if extension != 'txt' : print ( "File does not end in .txt - please only use this for cleaning txt files" ) continue with open ( file_name , 'r' , encoding = 'utf-8' ) as f : lines = f . readlines ( ) cleaned = [ ] for line in lines : cleaned . append ( clean_up ( line ) ) with open ( file_name . replace ( '.txt' , '' ) + '_cleaned.txt' , 'w' , encoding = 'utf-8' ) as f : f . writelines ( cleaned ) print ( 'File output: ' + file_name . replace ( '.txt' , '' ) + '_cleaned.txt' )
Either run tests or clean formatting for files, depending on # of arguments
Either run tests or clean formatting for files depending on # of arguments
"""
    Either run tests or clean formatting for files, depending on # of arguments
  """