summaryrefslogtreecommitdiff
path: root/FeatureExtractor/FeatureExtractor.py
blob: fab156e22dcba0e6656b12d884e5bfd3c5713d09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
Date: 2022-06-22
Author: [email protected]
Desc: Base class for all feature extractors
"""
from joblib import Parallel, delayed

class FeatureExtractor():
    """
    the base class for feature extractor
    """
    def __init__(self, extrator, jobs=-1):
        self.extractor = extrator
        self.jobs = jobs

    def extract(self, src:str, dst:str):
        """
        extract features
        :param src: pcap path or pacps dir path
        :param dst: csv file output path
        :return: None
        """
        raise "not implemented"

    def __extractOneFile(self, input_file:str, output_file:str):
        """
        extract one pcap to features
        :param input_file: pcap file path
        :param output_file: csv file path
        :return:
        """
        raise "not implemented"

    def multiProcess(self, extractOneFile, filenames:list, outputfiles:list):
        """
        :param extractOneFile:
        :param filenames:
        :param output:
        :return:
        """
        Parallel(n_jobs=self.jobs)(
            (delayed(extractOneFile)(input_file, output_file) for input_file, output_file in zip(filenames, outputfiles))
        )