# Path: src/apex/buffers.py
# class NonrepeatingBuffer(object):
#     def __init__(self, base_tnc, base_name, base_port=None, echo_packets=True, buffer_size=10000, buffer_time=30):
#         self.packet_cache = cachetools.TTLCache(buffer_size, buffer_time)
#         self.lock = threading.Lock()
#         self.base_tnc = base_tnc
#         self.base_port = base_port
#         self.base_name = base_name
#         self.echo_packets = echo_packets
# 
#     @property
#     def port(self):
#         return self.base_port
# 
#     @property
#     def name(self):
#         return self.base_name
# 
#     def connect(self, *args, **kwargs):
#         self.base_tnc.connect(*args, **kwargs)
# 
#     def close(self, *args, **kwargs):
#         self.base_tnc.close(*args, **kwargs)
# 
#     def write(self, frame, *args, **kwargs):
#         with self.lock:
#             frame_hash = str(aprs_util.hash_frame(frame))
#             if frame_hash not in self.packet_cache:
#                 self.packet_cache[frame_hash] = frame
#                 if self.base_port:
#                     self.base_tnc.write(frame, self.base_port)
#                 else:
#                     self.base_tnc.write(frame)
# 
#                 if self.echo_packets:
#                     echo_colorized_frame(frame, self.base_name, False)
# 
#     def read(self, *args, **kwargs):
#         with self.lock:
#             frame = self.base_tnc.read(*args, **kwargs)
#             if not frame:
#                 return frame
#             frame_hash = str(aprs_util.hash_frame(frame))
#             if frame_hash not in self.packet_cache:
#                 self.packet_cache[frame_hash] = frame
#                 if self.echo_packets:
#                     echo_colorized_frame(frame, self.base_name, True)
#                 return frame
#             else:
#                 return None
# 
# Path: src/apex/util.py
# def echo_colorized_error(text):
#     click.echo(click.style('Error: ', fg='red', bold=True, blink=True) + click.style(text, bold=True))
# 
# Path: src/apex/util.py
# def echo_colorized_warning(text):
#     click.echo(click.style('Warning: ', fg='yellow') + click.style(text))


import os
import signal
import sys
import threading
import time
import click
import six
import apex.aprs
import apex.buffers
    import ConfigParser  # noqa: F401
    import configparser
from apex.kiss import constants as kissConstants
from apex.plugin_loader import get_plugins
from apex.plugin_loader import load_plugin
from .buffers import NonrepeatingBuffer
from .util import echo_colorized_error
from .util import echo_colorized_warning
    home_path = os.path.join(os.path.expanduser('~'), rc_file)
    etc_path = os.path.sep + os.path.join('etc', config_file)
    if config_paths is None:
        if os.name == 'posix':
            config_paths = [cur_path, home_path, etc_path]
        else:
            config_paths = [cur_path, home_path]
    elif isinstance(config_paths, str):
        config_paths = [config_paths]
    elif not isinstance(config_paths, list):
        raise TypeError('config_paths argument was neither a string nor a list')

    if verbose:
        click.echo('Searching for configuration file in the following locations: %s' % repr(config_paths))

    config = configparser.ConfigParser()
    for config_path in config_paths:
        try:
            if len(config.read(config_path)) > 0:
                return config
        except IOError:
            pass

    return None


def configure(configfile, verbose=False):
    global config
    config = find_config(configfile, verbose)
    if config is None:

# Path: src/apex/buffers.py
# class NonrepeatingBuffer(object):
#     def __init__(self, base_tnc, base_name, base_port=None, echo_packets=True, buffer_size=10000, buffer_time=30):
#         self.packet_cache = cachetools.TTLCache(buffer_size, buffer_time)
#         self.lock = threading.Lock()
#         self.base_tnc = base_tnc
#         self.base_port = base_port
#         self.base_name = base_name
#         self.echo_packets = echo_packets
# 
#     @property
#     def port(self):
#         return self.base_port
# 
#     @property
#     def name(self):
#         return self.base_name
# 
#     def connect(self, *args, **kwargs):
#         self.base_tnc.connect(*args, **kwargs)
# 
#     def close(self, *args, **kwargs):
#         self.base_tnc.close(*args, **kwargs)
# 
#     def write(self, frame, *args, **kwargs):
#         with self.lock:
#             frame_hash = str(aprs_util.hash_frame(frame))
#             if frame_hash not in self.packet_cache:
#                 self.packet_cache[frame_hash] = frame
#                 if self.base_port:
#                     self.base_tnc.write(frame, self.base_port)
#                 else:
#                     self.base_tnc.write(frame)
# 
#                 if self.echo_packets:
#                     echo_colorized_frame(frame, self.base_name, False)
# 
#     def read(self, *args, **kwargs):
#         with self.lock:
#             frame = self.base_tnc.read(*args, **kwargs)
#             if not frame:
#                 return frame
#             frame_hash = str(aprs_util.hash_frame(frame))
#             if frame_hash not in self.packet_cache:
#                 self.packet_cache[frame_hash] = frame
#                 if self.echo_packets:
#                     echo_colorized_frame(frame, self.base_name, True)
#                 return frame
#             else:
#                 return None
# 
# Path: src/apex/util.py
# def echo_colorized_error(text):
#     click.echo(click.style('Error: ', fg='red', bold=True, blink=True) + click.style(text, bold=True))
# 
# Path: src/apex/util.py
# def echo_colorized_warning(text):
#     click.echo(click.style('Warning: ', fg='yellow') + click.style(text))


# Path: src/apex/cli.py
import os
import signal
import sys
import threading
import time
import click
import six
import apex.aprs
import apex.buffers
    import ConfigParser  # noqa: F401
    import configparser
from apex.kiss import constants as kissConstants
from apex.plugin_loader import get_plugins
from apex.plugin_loader import load_plugin
from .buffers import NonrepeatingBuffer
from .util import echo_colorized_error
from .util import echo_colorized_warning

    home_path = os.path.join(os.path.expanduser('~'), rc_file)
    etc_path = os.path.sep + os.path.join('etc', config_file)
    if config_paths is None:
        if os.name == 'posix':
            config_paths = [cur_path, home_path, etc_path]
        else:
            config_paths = [cur_path, home_path]
    elif isinstance(config_paths, str):
        config_paths = [config_paths]
    elif not isinstance(config_paths, list):
        raise TypeError('config_paths argument was neither a string nor a list')

    if verbose:
        click.echo('Searching for configuration file in the following locations: %s' % repr(config_paths))

    config = configparser.ConfigParser()
    for config_path in config_paths:
        try:
            if len(config.read(config_path)) > 0:
                return config
        except IOError:
            pass

    return None


def configure(configfile, verbose=False):
    global config
    config = find_config(configfile, verbose)
    if config is None:

        echo_colorized_error('No apex configuration found, can not continue.')