<commit_before>"""Archaius functions for deployment."""
import logging

import boto3

from .utils import get_details

LOG = logging.getLogger(__name__)


def init_properties(env='dev', app='unnecessary'):
    """Make sure _application.properties_ file exists in S3.

    For Applications with Archaius support, there needs to be a file where the
    cloud environment variable points to.

    Args:
        env (str): Deployment environment, i.e. dev, stage, prod.
        app (str): GitLab Project name.

    Returns:
        True when application.properties was found.
        False when application.properties needed to be created.
    """
    aws_env = boto3.session.Session(profile_name=env)
    s3client = aws_env.resource('s3')
    generated = get_details(app=app, env=env)

    archaius_bucket, app, project = generated.archaius()['s3'].split('/')[:-1]
    archaius_bucket = 'archaius-{env}'.format(env=env)
    archaius_file = ('{project}/{app}/application.properties').format(
        project=project,
        app=app)

    try:
        s3client.Object(archaius_bucket, archaius_file).get()
        LOG.info('Found: %(bucket)s/%(file)s', {'bucket': archaius_bucket,
                                                'file': archaius_file})<commit_msg>fixed directory naming<commit_after>"""Archaius functions for deployment."""
import logging

import boto3

from .utils import get_details

LOG = logging.getLogger(__name__)


def init_properties(env='dev', app='unnecessary'):
    """Make sure _application.properties_ file exists in S3.

    For Applications with Archaius support, there needs to be a file where the
    cloud environment variable points to.

    Args:
        env (str): Deployment environment, i.e. dev, stage, prod.
        app (str): GitLab Project name.

    Returns:
        True when application.properties was found.
        False when application.properties needed to be created.
    """
    aws_env = boto3.session.Session(profile_name=env)
    s3client = aws_env.resource('s3')
    generated = get_details(app=app, env=env)

    archaius_bucket, project, app = generated.archaius()['s3'].split('/')[:-1]
    archaius_bucket = 'archaius-{env}'.format(env=env)
    archaius_file = ('{project}/{app}/application.properties').format(
        project=project,
        app=app)

    try:
        s3client.Object(archaius_bucket, archaius_file).get()
        LOG.info('Found: %(bucket)s/%(file)s', {'bucket': archaius_bucket,
                                                'file': archaius_file})
{'fraction_non_alphanumeric': 0.11950929956470123, 'fraction_numerical': 0.006331618519984171, 'mean_word_length': 3.0972447325769856, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4092676', 'n_tokens_mistral': 754, 'n_tokens_neox': 736, 'n_words': 191}