单班。 TypeError:'module'对象不可调用

时间:2015-03-05 05:44:07

标签: python

    def ProcessFailureSignatures(self, directory, report_dir):
        for element in os.listdir(directory):
        full_path = os.path.join(directory, element)
        m = re.match('(\d+)_FAILED_Pass(\d+)_(.+)', element)
        ......

def GatherTestResults(self):
    earliest =  time.time() - TEST_RESULTS_MAX_AGE_SECONDS

    for element in os.listdir(RESULTS_DIR_PATH):
        time_struct = time.strptime(element, "%Y-%m-%d_%H-%M-%S")
        time_sse    = time.mktime(time_struct)

        outdir       = os.path.join(REPORT_DIR_PATH, self.accurev_info['Basis'], self.rtl, element)
        summary_file = os.path.join(RESULTS_DIR_PATH, element, "summary.txt")
        perf_file    = os.path.join(RESULTS_DIR_PATH, element, "performance_data.xml")

        if os.path.isfile(perf_file) and not self.IsTestComplete(perf_file, element):
           continue
        if(time_sse > earliest):
            if os.path.isfile(perf_file):
                self.ProcessTestPerformance(perf_file, element)

            if os.path.isfile(summary_file):
                self.ProcessTestSummary(summary_file, element)

            self.ProcessFailureSignatures(os.path(RESULTS_DIR_PATH, element), outdir)
        ...........

我收到以下错误,当我在Python窗口中键入self.ProcessFailureSignatures时,函数名称也不会出现。我不明白为什么这不属于班级的范围。因为它是在调用函数上面的类下面编写的。

File "fbe_test_analyze.py", line 621, in GatherTestResults
    self.ProcessFailureSignatures(os.path(RESULTS_DIR_PATH, element), outdir)
TypeError: 'module' object is not callable

2 个答案:

答案 0 :(得分:0)

os.path是一个模块。你不能称之为。可能你想从模块中获得一些功能。功能列表是here

答案 1 :(得分:0)

使用 os.path.join

我将举例说明返回csv文件的文件路径

def symbol_to_path(symbol,base_dir =“../”):

''' Reuturn csv path for a given ticker symbol'''

return os.path.join(base_dir,"{}.csv".format(str(symbol)))

symbol_to_path(符号)