#coding: utf-8 import sys from common import sort_items if len(sys.argv) != 3: print "Usage: ", sys.argv[0], "[input] [output]" exit(1) sort_items(sys.argv[1], sys.argv[2])
#coding: utf-8 import sys from common import sort_items if len(sys.argv) < 4: print "Usage: ", sys.argv[0], "[input1] [input2] … [inputN] [output]" exit(1) all_lines = [] for i in range(1, len(sys.argv) - 1): input_file = open(sys.argv[i], "r") for line in input_file: all_lines += line input_file.close() all_lines += '\n' output_filename = sys.argv[-1] output_file = open(output_filename, "w") for line in all_lines: output_file.write(line) output_file.close() sort_items(output_filename, output_filename)
#!/usr/bin/env python #coding: utf-8 import glob import sys from common import sort_items if len(sys.argv) < 2: print "Sort the dictionary" print "Usage: ", sys.argv[0], "[directory]" exit(1) dirtectory = sys.argv[1] files = glob.glob(dirtectory + "/*") for filename in files: print filename sort_items(filename, filename)
#!/usr/bin/env python # -*- coding: utf-8 -*- import codecs import sys from common import sort_items if len(sys.argv) < 4: print("Merge and sort all text dictionaries") print(("Usage: ", sys.argv[0], "[input1] [input2] ... [inputN] [output]")) exit(1) all_lines = [] for i in range(1, len(sys.argv) - 1): input_file = codecs.open(sys.argv[i], "r", encoding="utf-8") for line in input_file: all_lines += line input_file.close() all_lines += '\n' output_filename = sys.argv[-1] output_file = open(output_filename, "wb") for line in all_lines: output_file.write(line.encode('utf-8')) output_file.close() sort_items(output_filename, output_filename)
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from common import sort_items if len(sys.argv) < 2: print("Sort the dictionary") print(("Usage: ", sys.argv[0], "[input] ([output])")) exit(1) input = sys.argv[1] if len(sys.argv) < 3: output = input else: output = sys.argv[2] sort_items(input, output)
#!/usr/bin/env python #coding: utf-8 import sys from common import sort_items if len(sys.argv) != 3: print "Sort the dictionary" print "Usage: ", sys.argv[0], "[input] [output]" exit(1) sort_items(sys.argv[1], sys.argv[2])
#!/usr/bin/env python #coding: utf-8 import sys from common import sort_items if len(sys.argv) < 2: print "Sort the dictionary" print "Usage: ", sys.argv[0], "[input] ([output])" exit(1) input = sys.argv[1] if len(sys.argv) < 3: output = input else: output = sys.argv[2] sort_items(input, output)