utilities.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:civet 作者: TheJacksonLaboratory 项目源码 文件源码
def cleanup_command_line():

    if not sys.stdin.encoding or sys.stdin.encoding == 'ascii':
        return

    conversion_pairs = {
        'EN DASH': '-',
        'EM DASH': '--',
        'LEFT DOUBLE QUOTATION MARK': '"',
        'RIGHT DOUBLE QUOTATION MARK': '"',
        'LEFT SINGLE QUOTATION MARK': "'",
        'RIGHT SINGLE QUOTATION MARK': "'",
    }

    for i in range(len(sys.argv)):
        # create a unicode string with the decoded contents of the corresponding
        # sys.argv string
        decoded = unicode(sys.argv[i], sys.stdin.encoding)
        for key, val in conversion_pairs.iteritems():
            decoded = unicode.replace(decoded, unicodedata.lookup(key), val)
        # Should we be doing 'strict' here instead of 'replace'?
        sys.argv[i] = decoded.encode(sys.stdin.encoding, 'replace')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号