<commit_before>"""Process a list of repository arguments."""
# =============================================================================
# CONTENTS
# -----------------------------------------------------------------------------
# abdi_processrepolist
#
# Public Functions:
#   do
#
# -----------------------------------------------------------------------------
# (this contents block is generated, edits will be lost)
# =============================================================================

from __future__ import absolute_import

import argparse
import functools
import os
import sys

import phlsys_scheduleunreliables
import phlsys_strtotime
import phlurl_watcher

import abdt_exhandlers

import abdi_operation
import abdi_processrepoargs
import abdi_repoargs


def do(args, reporter):

    repos = _repos_from_configs(args.repo_configs)

    # TODO: test write access to repos here

    operations = []
    conduits = {}
    url_watcher = phlurl_watcher.Watcher()

    urlwatcher_cache_path = os.path.abspath('.arcyd.urlwatcher.cache')

    # load the url watcher cache (if any)
    if os.path.isfile(urlwatcher_cache_path):
        with open(urlwatcher_cache_path) as f:
            url_watcher.load(f)

    _append_operations_for_repos(
        operations,
        reporter,
        conduits,
        url_watcher,
        urlwatcher_cache_path,
        args.sys_admin_emails,
        repos)

    _append_interrupt_operations(
        operations,
        args.sys_admin_emails,
        args.kill_file,
        args.reset_file,
        args.pause_file,
        args.sleep_secs,
        reporter)

    operations.append(
        abdi_operation.RefreshCaches(
            conduits, url_watcher, reporter))

    on_exception_delay = abdt_exhandlers.make_exception_delay_handler(
        args.sys_admin_emails, reporter, None)

    if args.no_loop:
        def process_once():
            return phlsys_scheduleunreliables.process_once(list(operations))

        new_ops = _try_handle_reset_file(process_once, on_exception_delay)<commit_msg>Arcyd: refactor, extract fn to process list of ops<commit_after>"""Process a list of repository arguments."""
# =============================================================================
# CONTENTS
# -----------------------------------------------------------------------------
# abdi_processrepolist
#
# Public Functions:
#   do
#
# -----------------------------------------------------------------------------
# (this contents block is generated, edits will be lost)
# =============================================================================

from __future__ import absolute_import

import argparse
import functools
import os
import sys

import phlsys_scheduleunreliables
import phlsys_strtotime
import phlurl_watcher

import abdt_exhandlers

import abdi_operation
import abdi_processrepoargs
import abdi_repoargs


def do(args, reporter):

    repos = _repos_from_configs(args.repo_configs)

    # TODO: test write access to repos here

    operations = []
    conduits = {}
    url_watcher = phlurl_watcher.Watcher()

    urlwatcher_cache_path = os.path.abspath('.arcyd.urlwatcher.cache')

    # load the url watcher cache (if any)
    if os.path.isfile(urlwatcher_cache_path):
        with open(urlwatcher_cache_path) as f:
            url_watcher.load(f)

    _append_operations_for_repos(
        operations,
        reporter,
        conduits,
        url_watcher,
        urlwatcher_cache_path,
        args.sys_admin_emails,
        repos)

    _append_interrupt_operations(
        operations,
        args.sys_admin_emails,
        args.kill_file,
        args.reset_file,
        args.pause_file,
        args.sleep_secs,
        reporter)

    operations.append(
        abdi_operation.RefreshCaches(
            conduits, url_watcher, reporter))

    _process_operations(
        args.no_loop, operations, args.sys_admin_emails, reporter)


def _process_operations(is_no_loop, operations, sys_admin_emails, reporter):

    on_exception_delay = abdt_exhandlers.make_exception_delay_handler(
        sys_admin_emails, reporter, None)

    if is_no_loop:
        def process_once():
            return phlsys_scheduleunreliables.process_once(list(operations))

        new_ops = _try_handle_reset_file(process_once, on_exception_delay)
{'fraction_non_alphanumeric': 0.20171773444753946, 'fraction_numerical': 0.0, 'mean_word_length': 2.639358108108108, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5977408', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1181, 'n_words': 243}