<commit_before># -*- coding: utf-8 -*-
# ###
# Copyright (c) 2015, Rice University
# This software is subject to the provisions of the GNU Affero General
# Public License version 3 (AGPLv3).
# See LICENCE.txt for details.
# ###

import os

from ..utils import timestamp


__all__ = ('cli_loader',)


def cli_command(migration_name='', **kwargs):
    filename = '{}_{}.py'.format(timestamp(), migration_name)
    directory = kwargs['migrations_directory']
    if not directory:
        raise Exception('migrations directory undefined')
    if len(directory) > 1:
        raise Exception('more than one migrations directory specified')
    directory = directory[0]
    path = os.path.join(directory, filename)
    if not os.path.isdir(directory):
        os.makedirs(directory)
    with open(path, 'w') as f:
        f.write("""\
# -*- coding: utf-8 -*-

def up(cursor):<commit_msg>Make `dbmigrator generate` generate pep8 compliant code<commit_after># -*- coding: utf-8 -*-
# ###
# Copyright (c) 2015, Rice University
# This software is subject to the provisions of the GNU Affero General
# Public License version 3 (AGPLv3).
# See LICENCE.txt for details.
# ###

import os

from ..utils import timestamp


__all__ = ('cli_loader',)


def cli_command(migration_name='', **kwargs):
    filename = '{}_{}.py'.format(timestamp(), migration_name)
    directory = kwargs['migrations_directory']
    if not directory:
        raise Exception('migrations directory undefined')
    if len(directory) > 1:
        raise Exception('more than one migrations directory specified')
    directory = directory[0]
    path = os.path.join(directory, filename)
    if not os.path.isdir(directory):
        os.makedirs(directory)
    with open(path, 'w') as f:
        f.write("""\
# -*- coding: utf-8 -*-


def up(cursor):
{'fraction_non_alphanumeric': 0.13643926788685523, 'fraction_numerical': 0.011647254575707155, 'mean_word_length': 3.5555555555555554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4915154', 'n_tokens_mistral': 547, 'n_tokens_neox': 541, 'n_words': 167}