f argument is file object; also renaming fin to f

fin was the argument and was a filelike object, but
it was pointless, now it is just a file object and called f;
also shrinking the length of two logging lines
This commit is contained in:
Martin A. Brown 2016-02-12 12:25:34 -08:00
parent f45f10913c
commit 7b97f221bf
1 changed files with 7 additions and 7 deletions

View File

@ -9,18 +9,18 @@ from ..utils import logger
class SignatureChecker(object):
@classmethod
def signatureLocation(cls, name, fin):
fin.seek(0)
buf = fin.read(1024)
def signatureLocation(cls, f):
f.seek(0)
buf = f.read(1024)
for sig in cls.signatures:
try:
sindex = string.index(buf.lower(), sig.lower())
logger.debug("In file %s, signature %s found at %s; doctype %s found",
name, sig, sindex, cls)
logger.debug("Found signature %s in %s at %s; doctype %s.",
sig, f.name, sindex, cls)
return sindex
except ValueError:
logger.debug("In file %s, signature %s not found for document type %s",
name, sig, cls.__name__)
logger.debug("Signature %s not found in %s for type %s",
sig, f.name, cls.__name__)
return None
#