mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-07 05:31:11 -07:00
Update vendored beets to 1.6.0
Updates colorama to 0.4.6 Adds confuse version 1.7.0 Updates jellyfish to 0.9.0 Adds mediafile 0.10.1 Updates munkres to 1.1.4 Updates musicbrainzngs to 0.7.1 Updates mutagen to 1.46.0 Updates pyyaml to 6.0 Updates unidecode to 1.3.6
This commit is contained in:
parent
5073ec0c6f
commit
56c6773c6b
385 changed files with 25143 additions and 18080 deletions
|
@ -1,15 +1,12 @@
|
|||
# vim:ts=4 sw=4 expandtab softtabstop=4
|
||||
from __future__ import print_function
|
||||
import optparse
|
||||
import argparse
|
||||
import io
|
||||
import locale
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from unidecode import unidecode
|
||||
|
||||
PY3 = sys.version_info[0] >= 3
|
||||
|
||||
def fatal(msg):
|
||||
sys.stderr.write(msg + "\n")
|
||||
sys.exit(1)
|
||||
|
@ -17,42 +14,38 @@ def fatal(msg):
|
|||
def main():
|
||||
default_encoding = locale.getpreferredencoding()
|
||||
|
||||
parser = optparse.OptionParser('%prog [options] [FILE]',
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Transliterate Unicode text into ASCII. FILE is path to file to transliterate. "
|
||||
"Standard input is used if FILE is omitted and -c is not specified.")
|
||||
parser.add_option('-e', '--encoding', metavar='ENCODING', default=default_encoding,
|
||||
parser.add_argument('-e', '--encoding', metavar='ENCODING', default=default_encoding,
|
||||
help='Specify an encoding (default is %s)' % (default_encoding,))
|
||||
parser.add_option('-c', metavar='TEXT', dest='text',
|
||||
parser.add_argument('-c', metavar='TEXT', dest='text',
|
||||
help='Transliterate TEXT instead of FILE')
|
||||
parser.add_argument('path', nargs='?', metavar='FILE')
|
||||
|
||||
options, args = parser.parse_args()
|
||||
args = parser.parse_args()
|
||||
|
||||
encoding = options.encoding
|
||||
encoding = args.encoding
|
||||
|
||||
if args:
|
||||
if options.text:
|
||||
if args.path:
|
||||
if args.text:
|
||||
fatal("Can't use both FILE and -c option")
|
||||
else:
|
||||
with open(args[0], 'rb') as f:
|
||||
stream = f.read()
|
||||
elif options.text:
|
||||
if PY3:
|
||||
stream = os.fsencode(options.text)
|
||||
else:
|
||||
stream = options.text
|
||||
stream = open(args.path, 'rb')
|
||||
elif args.text:
|
||||
text = os.fsencode(args.text)
|
||||
# add a newline to the string if it comes from the
|
||||
# command line so that the result is printed nicely
|
||||
# on the console.
|
||||
stream += '\n'.encode('ascii')
|
||||
stream = io.BytesIO(text + b'\n')
|
||||
else:
|
||||
if PY3:
|
||||
stream = sys.stdin.buffer.read()
|
||||
else:
|
||||
stream = sys.stdin.read()
|
||||
stream = sys.stdin.buffer
|
||||
|
||||
try:
|
||||
stream = stream.decode(encoding)
|
||||
except UnicodeDecodeError as e:
|
||||
fatal('Unable to decode input: %s, start: %d, end: %d' % (e.reason, e.start, e.end))
|
||||
for line_nr, line in enumerate(stream):
|
||||
try:
|
||||
line = line.decode(encoding)
|
||||
except UnicodeDecodeError as e:
|
||||
fatal('Unable to decode input line %s: %s, start: %d, end: %d' % (line_nr, e.reason, e.start, e.end))
|
||||
|
||||
sys.stdout.write(unidecode(stream))
|
||||
sys.stdout.write(unidecode(line))
|
||||
stream.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue