Improves documentation and formatting.

This commit is contained in:
Robert Smallshire
2015-05-07 15:57:42 +02:00
parent 1ba97f75ce
commit 2a22e8588f
+8 -2
View File
@@ -1,3 +1,10 @@
"""Support for the text encodings used in SEG Y.
SEG Y data can contain textual data encoded in either ASCII
or EBCDIC format. This module contains tools for detecting those
encodings.
"""
ASCII = 'ascii'
EBCDIC = 'cp037'
@@ -29,6 +36,7 @@ COMMON_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:_
COMMON_EBCDIC_CHARS = set(COMMON_CHARS.encode(EBCDIC))
COMMON_ASCII_CHARS = set(COMMON_CHARS.encode(ASCII))
def guess_encoding(bs, threshold=0.5):
"""Try to determine whether the encoding of byte stream b is an ASCII string or an EBCDIC string.
@@ -73,6 +81,4 @@ def guess_encoding(bs, threshold=0.5):
if ebcdic_freq < threshold and ascii_freq < threshold:
return None
return None