Python 属性错误:';名称空间';对象没有属性';报告路径';

Python 属性错误:';名称空间';对象没有属性';报告路径';,python,parsing,Python,Parsing,我不断得到:AttributeError:“Namespace”对象没有属性“reportPath” 我不明白为什么,我甚至不能按原样理解这段代码,因为我在一本取证书中使用了这段预先编写好的代码 def WalkPath(): processCount = 0 errorCount = 0 oCVS = _CSVWriter(gl_args.reportPath + 'fileSystemReport.csv', gl_hashType) # Create a loop that proce

我不断得到:AttributeError:“Namespace”对象没有属性“reportPath”

我不明白为什么,我甚至不能按原样理解这段代码,因为我在一本取证书中使用了这段预先编写好的代码

def WalkPath():
processCount = 0
errorCount = 0

oCVS = _CSVWriter(gl_args.reportPath + 'fileSystemReport.csv', gl_hashType)

# Create a loop that process all the files starting at the rootPath,
# all sub-directories will also be processed

log.info('Root Path: ' + gl_args.rootPath)

for root, dirs, files in os.walk(gl_args.rootPath):
        # for each file obtain the filename and call the HashFile Functionfor file in files:
    fname = os.path.join(root, file)
    result = HashFile(fname, file, oCVS)

    # if hashing was successful, then increment the ProcessCount
    if result is True:
        processCount += 1

    # if not successful, the increment the ErrorCount
    else:
        errorCount += 1

oCVS.writerClose()

return(processCount)
这里定义了reportPath:

def ParseCommandLine(): parser=argparse.ArgumentParser(“Python文件系统哈希…p-fish”) parser.add_参数('-v','-verbose',help='允许显示进度消息',action='store_true')

# setup a group where the selection is mutually exclusive and required

group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--md5', help='specifies MD5 algorithm', action='store_true')
group.add_argument('--sha256', help='specifies SHA256 algorithm', action='store_true')
group.add_argument('--sha512', help='specifies SHA512 algorithm', action='store_true')

parser.add_argument('--d', '--rootPath', type=ValidateDirectory, required=True, help='specify the root path for hashing')
parser.add_argument('--r', '--reportPath', type=ValidateDirectoryWritable, required=True, help='specify the path for reports and logs will be written')

# creates a global object to hold the validated arguments, these will be available
# to all the functions within the _pfish.py module

global gl_args
global gl_hashType

gl_args = parser.parse_args()

if gl_args.md5:
    gl_hashType = "MD5"
elif gl_args.sha256:
    gl_hashType = "SHA256"
elif gl_args.sha512:
    gl_hashType = "SHA512"
else:
    gl_hashType = "Unknown"
    logging.error("Unknown Hash Type Specified")


DisplayMessage("Command line processed: Successfully")

return