File: utolf.py

package info (click to toggle)
handbrake 1.9.2%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 17,008 kB
  • sloc: ansic: 117,103; sh: 3,350; python: 2,397; ruby: 1,635; objc: 333; makefile: 92; xml: 63; csh: 15
file content (22 lines) | stat: -rwxr-xr-x 499 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#/usr/bin/env python3

import os
import sys

def main():
    filenames = sys.argv[1:]
    if filenames:
        convert(filenames)
    else:
        print("Usage: <command> filename [filename ...]")

def convert(files):
    for file in files:
        print(file)
        with open(file, 'r') as infile, \
             open(file + '.tmp', 'w', newline='\n') as outfile:
            outfile.writelines(infile.readlines())
        os.replace(file + '.tmp', file)

if __name__ == "__main__":
    main()