MCPcopy
hub / github.com/codemayq/chinese-chatbot-corpus / run

Function run

language/langconv.py:246–278  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

244
245
246def run():
247 import sys
248 from optparse import OptionParser
249 parser = OptionParser()
250 parser.add_option('-e', type='string', dest='encoding',
251 help='encoding')
252 parser.add_option('-f', type='string', dest='file_in',
253 help='input file (- for stdin)')
254 parser.add_option('-t', type='string', dest='file_out',
255 help='output file')
256 (options, args) = parser.parse_args()
257 if not options.encoding:
258 parser.error('encoding must be set')
259 if options.file_in:
260 if options.file_in == '-':
261 file_in = sys.stdin
262 else:
263 file_in = open(options.file_in)
264 else:
265 file_in = sys.stdin
266 if options.file_out:
267 if options.file_out == '-':
268 file_out = sys.stdout
269 else:
270 file_out = open(options.file_out, 'wb')
271 else:
272 file_out = sys.stdout
273
274 c = Converter(options.encoding)
275 for line in file_in:
276 # print >> file_out, c.convert(line.rstrip('\n').decode(
277 file_out.write(c.convert(line.rstrip('\n').decode(
278 'utf8')).encode('utf8'))
279
280
281def simple2tradition(line):

Callers 1

langconv.pyFile · 0.85

Calls 2

convertMethod · 0.95
ConverterClass · 0.85

Tested by

no test coverage detected