Example #1
0
class MongoIndex(Index):

    def __init__(self, mongoSaveUtils, mongoReadUtils):
        """
        Инициализация

        :param mongoSaveUtils:  параметры для записи данных в mongodb
        :param mongoReadUtils:  параметры для чтения данных из mongodb
        """
        if not mongoSaveUtils:
            raise ParamError("mongoUtils cannot be the None-object")
        if not isinstance(mongoSaveUtils, MongoSaveUtils):
            raise TypeError("mongoUtils can be the list MongoSaveUtils")
        if not ISaveRetrievalUtils.providedBy(mongoSaveUtils):
            raise TypeError("mongoUtils is not provided by ISaveRetrievalUtils")

        if not mongoReadUtils:
            raise ParamError("mongoReadUtils cannot be the None-object")
        if not isinstance(mongoReadUtils, MongoReadUtils):
            raise TypeError("mongoReadUtils can be the list MongoReadUtils")

        self.__mongoSaveUtils = mongoSaveUtils
        self.__mongoReadUtils = mongoReadUtils
        self.__ms = StatisticFactory().createStatistic(MONGO_TYPE, self.__mongoSaveUtils)

    def createStatistics(self, dataSourceWorker, readerSourceData, normalization, sourceCusCallback=None):
        if not dataSourceWorker:
            raise ParamError("dataSourceWorker cannot be the None-object")
        if not isinstance(dataSourceWorker, DataSourceWorker):
            raise TypeError("mongoUtils can be the list MongoSaveUtils")

        dataSourceWorker.createStatistics(self.__ms, readerSourceData, normalization, sourceCusCallback)

    def createTotalStatistics(self):
        self.__ms.makeTotalStatistic()

    def createSourceNameIndex(self, dataSourceWorker, parseCallback):
        """
        Создание индекса по полным именам файлов

        :param dataSourceWorker:  объект для работы с источниками (настроки для работы с источниками и тд)
        :param parseCallback:  колбэк для обработки имен источников
        """
        if not dataSourceWorker:
            raise ParamError("dataSourceWorker cannot be the None-object")
        if not isinstance(dataSourceWorker, DataSourceWorker):
            raise TypeError("mongoUtils can be the list MongoSaveUtils")

        if not parseCallback:
            raise ParamError("parseSourceNameCallback cannot be the None-object")
        if not isinstance(parseCallback, FileNameNormalization):
            raise TypeError("parseSourceNameCallback can be the list FileNameNormalization")

        dataSourceWorker.createSourceNameIndex(self.__ms, self.__mongoReadUtils, self.__mongoSaveUtils, parseCallback)

    def createSourceDataIndex(self, readSourceDataCallback):
        pass
 def setUp(self):
     self.__dirPath = os.path.abspath(os.curdir)
     firstPath = os.path.join(self.__dirPath, "resources/first")
     secondPath = os.path.join(self.__dirPath, "resources/second")
     self.__mongoSaveUtils = MongoSaveRetrievalUtils(
         HOST, PORT, USR, PWD, DB, FC_N, FC_DN, MDN)
     self.__mongoReadUtils = MongoReadUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                            FC_DN)
     self.__simN = SimpleNormalization()
     self.__simNamesN = FileNameNormalization()
     self.__ms = StatisticFactory().createStatistic(MONGO_TYPE,
                                                    self.__mongoSaveUtils)
     self.__scc = FSSourceCustomCallback()
     self.__rnFS = ReaderNameFS([firstPath, secondPath])
Example #3
0
    def __init__(self, mongoSaveUtils, mongoReadUtils):
        """
        Инициализация

        :param mongoSaveUtils:  параметры для записи данных в mongodb
        :param mongoReadUtils:  параметры для чтения данных из mongodb
        """
        if not mongoSaveUtils:
            raise ParamError("mongoUtils cannot be the None-object")
        if not isinstance(mongoSaveUtils, MongoSaveUtils):
            raise TypeError("mongoUtils can be the list MongoSaveUtils")
        if not ISaveRetrievalUtils.providedBy(mongoSaveUtils):
            raise TypeError(
                "mongoUtils is not provided by ISaveRetrievalUtils")

        if not mongoReadUtils:
            raise ParamError("mongoReadUtils cannot be the None-object")
        if not isinstance(mongoReadUtils, MongoReadUtils):
            raise TypeError("mongoReadUtils can be the list MongoReadUtils")

        self.__mongoSaveUtils = mongoSaveUtils
        self.__mongoReadUtils = mongoReadUtils
        self.__ms = StatisticFactory().createStatistic(MONGO_TYPE,
                                                       self.__mongoSaveUtils)
Example #4
0
    def __init__(self, mongoSaveUtils, mongoReadUtils):
        """
        Инициализация

        :param mongoSaveUtils:  параметры для записи данных в mongodb
        :param mongoReadUtils:  параметры для чтения данных из mongodb
        """
        if not mongoSaveUtils:
            raise ParamError("mongoUtils cannot be the None-object")
        if not isinstance(mongoSaveUtils, MongoSaveUtils):
            raise TypeError("mongoUtils can be the list MongoSaveUtils")
        if not ISaveRetrievalUtils.providedBy(mongoSaveUtils):
            raise TypeError("mongoUtils is not provided by ISaveRetrievalUtils")

        if not mongoReadUtils:
            raise ParamError("mongoReadUtils cannot be the None-object")
        if not isinstance(mongoReadUtils, MongoReadUtils):
            raise TypeError("mongoReadUtils can be the list MongoReadUtils")

        self.__mongoSaveUtils = mongoSaveUtils
        self.__mongoReadUtils = mongoReadUtils
        self.__ms = StatisticFactory().createStatistic(MONGO_TYPE, self.__mongoSaveUtils)
Example #5
0
class MongoIndex(Index):
    def __init__(self, mongoSaveUtils, mongoReadUtils):
        """
        Инициализация

        :param mongoSaveUtils:  параметры для записи данных в mongodb
        :param mongoReadUtils:  параметры для чтения данных из mongodb
        """
        if not mongoSaveUtils:
            raise ParamError("mongoUtils cannot be the None-object")
        if not isinstance(mongoSaveUtils, MongoSaveUtils):
            raise TypeError("mongoUtils can be the list MongoSaveUtils")
        if not ISaveRetrievalUtils.providedBy(mongoSaveUtils):
            raise TypeError(
                "mongoUtils is not provided by ISaveRetrievalUtils")

        if not mongoReadUtils:
            raise ParamError("mongoReadUtils cannot be the None-object")
        if not isinstance(mongoReadUtils, MongoReadUtils):
            raise TypeError("mongoReadUtils can be the list MongoReadUtils")

        self.__mongoSaveUtils = mongoSaveUtils
        self.__mongoReadUtils = mongoReadUtils
        self.__ms = StatisticFactory().createStatistic(MONGO_TYPE,
                                                       self.__mongoSaveUtils)

    def createStatistics(self,
                         dataSourceWorker,
                         readerSourceData,
                         normalization,
                         sourceCusCallback=None):
        if not dataSourceWorker:
            raise ParamError("dataSourceWorker cannot be the None-object")
        if not isinstance(dataSourceWorker, DataSourceWorker):
            raise TypeError("mongoUtils can be the list MongoSaveUtils")

        dataSourceWorker.createStatistics(self.__ms, readerSourceData,
                                          normalization, sourceCusCallback)

    def createTotalStatistics(self):
        self.__ms.makeTotalStatistic()

    def createSourceNameIndex(self, dataSourceWorker, parseCallback):
        """
        Создание индекса по полным именам файлов

        :param dataSourceWorker:  объект для работы с источниками (настроки для работы с источниками и тд)
        :param parseCallback:  колбэк для обработки имен источников
        """
        if not dataSourceWorker:
            raise ParamError("dataSourceWorker cannot be the None-object")
        if not isinstance(dataSourceWorker, DataSourceWorker):
            raise TypeError("mongoUtils can be the list MongoSaveUtils")

        if not parseCallback:
            raise ParamError(
                "parseSourceNameCallback cannot be the None-object")
        if not isinstance(parseCallback, FileNameNormalization):
            raise TypeError(
                "parseSourceNameCallback can be the list FileNameNormalization"
            )

        dataSourceWorker.createSourceNameIndex(self.__ms,
                                               self.__mongoReadUtils,
                                               self.__mongoSaveUtils,
                                               parseCallback)

    def createSourceDataIndex(self, readSourceDataCallback):
        pass