Ejemplo n.º 1
0
__author__ = 'sms2056'
import os
import sys
import struct
import hashlib

from module.syslog import syslog,GetCurrentLine
logger = syslog(module_name="base")

from module.constant import FileFormat

def GetFilePath(filespath):
    if filespath[0] == '\'' or filespath[-1] == '\'':
        print(" include (\'),(\'\') at str[0],str[-1] Error")
        return False

    __object = filespath
    __files = []
    if os.path.isdir(__object):
        for root, dirs, filenames in os.walk(__object):
            for name in filenames:
                __files.append(os.path.join(root, name))
    elif os.path.isfile(__object):
        __files.append(__object)
    else:
        print("not find file or directory!")
        return False
    return __files

def GetFileFormat(infile):
    buf = infile.read(4)