Calls import_batch for the next filename in the queue
        and "archives" the file.

        The archive folder is typically the folder for the deserializer queue.
328656
def next_task(self, item, **kwargs):
        
        filename = os.path.basename(item)
        try:
            self.tx_importer.import_batch(filename=filename)
        except TransactionImporterError as e:
            raise TransactionsFileQueueError(e) from e
        else:
            self.archive(filename)
16918
def peek(self, deserialized_tx):
        
        self.batch_id = deserialized_tx.object.batch_id
        self.prev_batch_id = deserialized_tx.object.prev_batch_id
        self.producer = deserialized_tx.object.producer
        if self.batch_history.exists(batch_id=self.batch_id):
            raise BatchAlreadyProcessed(
                f"Batch {self.batch_id} has already been processed"
            )
        if self.prev_batch_id != self.batch_id:
            if not self.batch_history.exists(batch_id=self.prev_batch_id):
                raise InvalidBatchSequence(
                    f"Invalid import sequence. History does not exist for prev_batch_id. "
                    f"Got file='{self.filename}', prev_batch_id="
                    f"{self.prev_batch_id}, batch_id={self.batch_id}."
                )
467718
def archive_file(job_id, pathname)
      target_path = archive_pathname(pathname)
      target_path.mkpath
      target_file_name = target_path.join("#{job_id}_#{pathname.basename}")
      # In case the file is being moved across partitions
      FileUtils.move(pathname.to_s, target_file_name.to_s)
      target_file_name.to_s
    end
94866
def prep_folder(self, seq):
        """"""
        itasser_dir = op.join(self.root_dir, self.id)

        if not op.exists(itasser_dir):
            os.makedirs(itasser_dir)

        tmp = {self.id: seq}

        fasta.write_fasta_file_from_dict(indict=tmp,
                                         outname='seq',
                                         outext='.fasta',
                                         outdir=itasser_dir)
        return itasser_dir
160190
def _archive(self):
        
        archive, archive_file = _retrieve_archive()

        if self.backup:
            self.backup.add_archive(archive)

        if archive:
            from topydo.commands.ArchiveCommand import ArchiveCommand
            command = ArchiveCommand(self.todolist, archive)
            command.execute()

            if archive.dirty:
                archive_file.write(archive.print_todos())
1044564
def get_archive_cmdlist_func (program, command, format):
    """"""
    # get python module for given archive program
    key = util.stripext(os.path.basename(program).lower())
    modulename = ".programs." + ProgramModules.get(key, key)
    # import the module
    try:
        module = importlib.import_module(modulename, __name__)
    except ImportError as msg:
        raise util.PatoolError(msg)
    # get archive handler function (eg. patoolib.programs.star.extract_tar)
    try:
        return getattr(module, '%s_%s' % (command, format))
    except AttributeError as msg:
        raise util.PatoolError(msg)
569789
private void doBatchEnd(final JsonObject message) {
    if (currentBatch != null) {
      Object args = deserializer.deserialize(message);
      if (log.isDebugEnabled()) {
        log.debug(String.format("%s - Batch ended: Batch[batch=%s, args=%s]", this, currentBatch.id(), args));
      }
      currentBatch.handleEnd(args);
      currentBatch = null;
    }
  }
422268
def add_folder(self, folder):
        
        if folder in self.folders:
            return

        self.folders.add(folder)
        
        for subfolder, junk, filenames in os.walk(folder):
            for filename in filenames:
                name, ext = os.path.splitext(filename)
                if ext in self.exts:
                    self.images.append(
                        os.path.join(subfolder, filename))
908917
private void handleArchiveByFile(Predicate<String> filter, File archive, List<String> discoveredFiles)
    {
        try
        {
            try (ZipFile zip = new ZipFile(archive))
            {
                Enumeration<? extends ZipEntry> entries = zip.entries();
                
                while (entries.hasMoreElements())
                {
                    ZipEntry entry = entries.nextElement();
                    String name = entry.getName();
                    if (filter.accept(name))
                        discoveredFiles.add(name);
                }
            }
        }
        catch (IOException e)
        {
            throw new RuntimeException("Error handling file " + archive, e);
        }
    }
1343078
def get_from_archive(self, feed_id):
        
        file_path = self.feed_repository + '/' + str(feed_id) + '.xml'
        if not os.path.isfile(file_path):
            raise FeedArchiveNotFound()
        with open(file_path, 'r') as rec_file:
            return rec_file.read()
534401
def next_task(self, item, raise_exceptions=None, **kwargs):
        
        filename = os.path.basename(item)
        batch = self.get_batch(filename)
        tx_deserializer = self.tx_deserializer_cls(
            allow_self=self.allow_self, override_role=self.override_role
        )
        try:
            tx_deserializer.deserialize_transactions(
                transactions=batch.saved_transactions
            )
        except (DeserializationError, TransactionDeserializerError) as e:
            raise TransactionsFileQueueError(e) from e
        else:
            batch.close()
            self.archive(filename)
902527
def _load_folder(folder_entry, corpus):
        
        for wav_path in glob.glob(os.path.join(folder_entry.path, '*.wav')):
            wav_name = os.path.basename(wav_path)
            basename, __ = os.path.splitext(wav_name)

            command = folder_entry.name
            file_idx = '{}_{}'.format(basename, command)
            issuer_idx = str(basename).split('_', maxsplit=1)[0]

            corpus.new_file(wav_path, file_idx)

            if issuer_idx not in corpus.issuers.keys():
                corpus.import_issuers(issuers.Speaker(
                    issuer_idx
                ))

            utt = corpus.new_utterance(file_idx, file_idx, issuer_idx)

            labels = annotations.LabelList.create_single(command, idx=audiomate.corpus.LL_WORD_TRANSCRIPT)
            utt.set_label_list(labels)
531342
def _read_data_legacy(prefix, batch_size):
    
    prefix = prefix.replace("\\", "/")
    folder = "/".join(prefix.split("/")[:-1])
    phase = prefix.split("/")[-1]
    config = json.load(open(prefix + '_config.json'))
    num_threads = config["num_threads"]

    filenames = [folder + "/" + f for f in listdir(folder) if isfile(join(folder, f)) and phase in f and not "config.json" in f]

    # Create a tf object for the filename list and the readers.
    filename_queue = tf.train.string_input_producer(filenames)
    readers = [_read_tf_record(filename_queue, config) for _ in range(num_threads)]

    batch_dict = tf.train.shuffle_batch_join(
        readers,
        batch_size=batch_size,
        capacity=10 * batch_size,
        min_after_dequeue=5 * batch_size
    )

    # Add batch dimension to feature and label shape

    feature_batch = {}
    label_batch = {}
    for k in batch_dict.keys():
        shape = tuple([batch_size] + list(config[k]["shape"]))
        tensor = tf.reshape(batch_dict[k], shape, name="input/"+phase+"/" + k + "_reshape")
        if "feature_" in k:
            feature_batch["_".join(k.split("_")[1:])] = tensor
        if "label_" in k:
            label_batch["_".join(k.split("_")[1:])] = tensor

    return feature_batch, label_batch
334051
def archive_filenames(self):
        """"""
        try:
            return _bfd.archive_list_filenames(self._ptr)
        except TypeError, err:
            raise BfdException(err)
791973
def update_batches() -> None:
    ""
    batches_data  = requests.get(BATCHES_API_URL).json()
    batches_url   = {i["name"]: i["download_url"] for i in batches_data
                     if i["type"] == "file"}
    order_batches = sorted(batches_url, key=int)

    try:
        existing = set(os.listdir(BATCHES_DIR))
    except FileNotFoundError:
        BATCHES_DIR.mkdir(parents=True)
        existing = set()

    def get_batch(name: str) -> None:
        if name in existing and name != order_batches[-1]:
            return

        answer = requests.get(batches_url[name])
        try:
            answer.raise_for_status()
        except requests.RequestException:
            return

        with AtomicFile(BATCHES_DIR / name, "w") as file:
            file.write(answer.text)

    ThreadPool(8).map(get_batch, order_batches)
457422
private void executeArchive() {
        for (AbstractArchiveJob archiveJob : jobs) {
            archiveJob.setArchiveDateDiff(extractArchiveDateCount(archiveEnv.getDatePattern()));
            archiveJob.setPath(archiveEnv.getDirPath());
            archiveJob.setCompressionExtention(archiveEnv.getCompression().getExtention());
            archiveJob.archive();
        }
    }
761045
def archive_if_exists(filename):
    
    if os.path.exists(filename):
        current_time = datetime.datetime.now()
        dt_format = '%Y-%m-%dT%H:%M:%S%z'
        timestamp = current_time.strftime(dt_format)
        dst = filename + '_' + timestamp
        shutil.move(filename, dst)