Commit 4f89d514 by Craig Heffner

Removed codecs encoding

parent 26e2c4d6
......@@ -4,7 +4,6 @@
__all__ = ['Magic']
import codecs
import re
import struct
import datetime
......@@ -790,9 +789,8 @@ class Magic(object):
Returns None.
'''
# Open file as UTF-8 to prevent decoding issues for non-ASCII bytes
# that may inadvertantly be in the signature file.
fp = codecs.open(fname, "r", encoding='utf-8')
# Magic files must be ASCII, else encoding issues can arise.
fp = open(fname, "r")
lines = fp.readlines()
self.parse(lines)
fp.close()
......@@ -808,8 +806,6 @@ class Magic(object):
signature = None
for line in lines:
# The signature lines were read in as UTF-8 unicode; be sure to treat them as strings.
line = str(line)
# Split at the first comment delimiter (if any) and strip the result
line = line.split('#')[0].strip()
# Ignore blank lines and lines that are nothing but comments.
......
......@@ -2,7 +2,6 @@
# This is automatically invoked by core.module code if extraction has been
# enabled by the user; other modules need not reference this module directly.
import codecs
import os
import re
import sys
......@@ -318,7 +317,7 @@ class Extractor(Module):
'''
try:
# Process each line from the extract file, ignoring comments
with codecs.open(fname, 'r', encoding='utf-8') as f:
with open(fname, 'r') as f:
for rule in f.readlines():
self.add_rule(rule.split(self.COMMENT_DELIM, 1)[0])
except KeyboardInterrupt as e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment