def should_raises_error_if_no_match_in_filename(self):
        # Given
        filename = None
        date_regexp = re.compile(r"Resume(\d{6}).zip")

        # When / Then
        with pytest.raises(ValueError):
            get_date_from_filename(filename, date_regexp)
    def open_next_file(self):
        if self.products_file:
            file_date = get_date_from_filename(self.products_file, DATE_REGEXP)
            self.log_provider_event(LocalProviderEventType.SyncPartEnd,
                                    file_date)
        self.products_file = next(self.thing_files)
        file_date = get_date_from_filename(self.products_file, DATE_REGEXP)
        self.log_provider_event(LocalProviderEventType.SyncPartStart,
                                file_date)

        self.data_lines = get_lines_from_thing_file(str(self.products_file))
Beispiel #3
0
    def get_remaining_files_to_check(self, all_zips):
        latest_sync_part_end_event = local_provider_event_queries.find_latest_sync_part_end_event(self.provider)

        if latest_sync_part_end_event is None:
            return iter(all_zips)
        payload = int(latest_sync_part_end_event.payload)
        return iter(filter(lambda z: get_date_from_filename(z, DATE_REGEXP) > payload, all_zips))
Beispiel #4
0
    def open_next_file(self):
        if self.zip:
            file_date = get_date_from_filename(self.zip, DATE_REGEXP)
            self.log_provider_event(LocalProviderEventType.SyncPartEnd, file_date)

        next_zip_file_name = str(next(self.zips))
        file_date = get_date_from_filename(next_zip_file_name, DATE_REGEXP)

        self.zip = get_zip_file_from_ftp(next_zip_file_name, THUMB_FOLDER_NAME_TITELIVE)
        self.log_provider_event(LocalProviderEventType.SyncPartStart, file_date)

        self.thumb_zipinfos = iter(
            filter(
                lambda f: f.filename.lower().endswith(SYNCHONISABLE_FILE_EXTENSION),
                sorted(self.zip.infolist(), key=lambda f: f.filename),
            )
        )
    def open_next_file(self):
        if self.zip_file:
            current_file_date = get_date_from_filename(self.zip_file,
                                                       DATE_REGEXP)
            self.log_provider_event(LocalProviderEventType.SyncPartEnd,
                                    current_file_date)
        next_zip_file_name = str(next(self.zips))
        self.zip_file = get_zip_file_from_ftp(
            next_zip_file_name, DESCRIPTION_FOLDER_NAME_TITELIVE)
        new_file_date = get_date_from_filename(self.zip_file, DATE_REGEXP)

        self.log_provider_event(LocalProviderEventType.SyncPartStart,
                                new_file_date)

        self.description_zip_infos = self.get_description_files_from_zip_info()

        self.date_modified = read_description_date(str(new_file_date))
 def get_remaining_files_to_check(self, ordered_thing_files: list) -> iter:
     latest_sync_part_end_event = local_provider_event_queries.find_latest_sync_part_end_event(
         self.provider)
     if latest_sync_part_end_event is None:
         return iter(ordered_thing_files)
     for index, filename in enumerate(ordered_thing_files):
         if get_date_from_filename(filename, DATE_REGEXP) == int(
                 latest_sync_part_end_event.payload):
             return iter(ordered_thing_files[index + 1:])
     return iter([])
    def should_return_matching_pattern_in_filename(self):
        # Given
        filename = "Resume191012.zip"
        date_regexp = re.compile(r"Resume(\d{6}).zip")

        # When
        extracted_date = get_date_from_filename(filename, date_regexp)

        # Then
        assert extracted_date == 191012