<commit_before>"""
Main click group for CLI
"""


import logging
from pkg_resources import iter_entry_points
import sys

import click
from click_plugins import with_plugins
import cligj

from . import options
import rasterio
from rasterio import aws


def configure_logging(verbosity):
    log_level = max(10, 30 - 10*verbosity)
    logging.basicConfig(stream=sys.stderr, level=log_level)


class FakeSession(object):
    """Fake AWS Session."""

    def __enter__(self):
        pass

    def __exit__(self):
        pass

    def open(self, path, mode='r'):
        return rasterio.open(path, mode)


def get_aws_session(profile_name):
    try:
        import rasterio.aws
        return rasterio.aws.Session(profile_name=profile_name)
    except ImportError:
        return FakeSession()


@with_plugins(ep for ep in list(iter_entry_points('rasterio.rio_commands')) +
              list(iter_entry_points('rasterio.rio_plugins')))
@click.group()
@cligj.verbose_opt
@cligj.quiet_opt
@click.option('--aws-profile', help="AWS credentials profile name")
@click.version_option(version=rasterio.__version__, message='%(version)s')
@click.pass_context
def main_group(ctx, verbose, quiet, aws_profile):

    """<commit_msg>Remove extra import, fix __exit__<commit_after>"""
Main click group for CLI
"""


import logging
from pkg_resources import iter_entry_points
import sys

import click
from click_plugins import with_plugins
import cligj

from . import options
import rasterio


def configure_logging(verbosity):
    log_level = max(10, 30 - 10*verbosity)
    logging.basicConfig(stream=sys.stderr, level=log_level)


class FakeSession(object):
    """Fake AWS Session."""

    def __enter__(self):
        pass

    def __exit__(self, *args):
        pass

    def open(self, path, mode='r'):
        return rasterio.open(path, mode)


def get_aws_session(profile_name):
    try:
        import rasterio.aws
        return rasterio.aws.Session(profile_name=profile_name)
    except ImportError:
        return FakeSession()


@with_plugins(ep for ep in list(iter_entry_points('rasterio.rio_commands')) +
              list(iter_entry_points('rasterio.rio_plugins')))
@click.group()
@cligj.verbose_opt
@cligj.quiet_opt
@click.option('--aws-profile', help="AWS credentials profile name")
@click.version_option(version=rasterio.__version__, message='%(version)s')
@click.pass_context
def main_group(ctx, verbose, quiet, aws_profile):

    """
{'fraction_non_alphanumeric': 0.10787530762920426, 'fraction_numerical': 0.004922067268252666, 'mean_word_length': 4.279220779220779, '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': '5070252', 'n_tokens_mistral': 796, 'n_tokens_neox': 760, 'n_words': 181}