<commit_before>import sys
import argparse
from slap.publisher import Publisher
from slap import git


def only_one(iterable):
    it = iter(iterable)
    return any(it) and not any(it)


def _create_parser():
    parser = argparse.ArgumentParser()
    parser.add_argument("-u", "--username",
                        required=True,
                        help="Portal or AGS username (ex: --username john)")
    parser.add_argument("-p", "--password",
                        required=True,
                        help="Portal or AGS password (ex: --password myPassword)")
    parser.add_argument("-c", "--config",
                        required=True,
                        help="full path to config file (ex: --config c:/configs/int_config.json)")
    parser.add_argument("-s", "--site",
                        action="store_true",
                        help="create a site before publishing")
    parser.add_argument("-n", "--name",
                        help="override the hostname in config")
    parser.add_argument("-i", "--inputs",
                        action="append",
                        help="one or more inputs to publish (ex: -i mxd/bar.mxd -i mxd/foo.mxd")
    parser.add_argument("-g", "--git",
                        help="publish all mxd files that have changed between HEAD and this commit "
                             "(ex: -g b45e095834af1bc8f4c348bb4aad66bddcadeab4")
    return parser


def get_args(raw_args):
    parser = _create_parser()
    args = parser.parse_args(raw_args)

    if not args.username:
        parser.error("username is required")

    if not args.password:
        parser.error("password is required")

    if not args.config:
        parser.error("Full path to config file is required")

    if args.git and args.inputs:
        parser.error("Specify only one of --git or --inputs")

    return args


def main(raw_args):
    args = get_args(raw_args)
    publisher = Publisher(args.username, args.password, args.config, args.name)

    if args.site:
        print "Creating site..."
        if "site" in publisher.config and "json" in publisher.config["site"]:
            publisher.api.create_site(args.username, args.password, publisher.config["site"]["json"])
        else:
            publisher.api.create_default_site()

    print "Registering data sources..."
    publisher.register_data_sources()<commit_msg>Removes 'json' element for creating site<commit_after>import sys
import argparse
from slap.publisher import Publisher
from slap import git


def only_one(iterable):
    it = iter(iterable)
    return any(it) and not any(it)


def _create_parser():
    parser = argparse.ArgumentParser()
    parser.add_argument("-u", "--username",
                        required=True,
                        help="Portal or AGS username (ex: --username john)")
    parser.add_argument("-p", "--password",
                        required=True,
                        help="Portal or AGS password (ex: --password <PASSWORD>)")
    parser.add_argument("-c", "--config",
                        required=True,
                        help="full path to config file (ex: --config c:/configs/int_config.json)")
    parser.add_argument("-s", "--site",
                        action="store_true",
                        help="create a site before publishing")
    parser.add_argument("-n", "--name",
                        help="override the hostname in config")
    parser.add_argument("-i", "--inputs",
                        action="append",
                        help="one or more inputs to publish (ex: -i mxd/bar.mxd -i mxd/foo.mxd")
    parser.add_argument("-g", "--git",
                        help="publish all mxd files that have changed between HEAD and this commit "
                             "(ex: -g b45e095834af1bc8f4c348bb4aad66bddcadeab4")
    return parser


def get_args(raw_args):
    parser = _create_parser()
    args = parser.parse_args(raw_args)

    if not args.username:
        parser.error("username is required")

    if not args.password:
        parser.error("password is required")

    if not args.config:
        parser.error("Full path to config file is required")

    if args.git and args.inputs:
        parser.error("Specify only one of --git or --inputs")

    return args


def main(raw_args):
    args = get_args(raw_args)
    publisher = Publisher(args.username, args.password, args.config, args.name)

    if args.site:
        print "Creating site..."
        if "site" in publisher.config:
            publisher.api.create_site(args.username, args.password, publisher.config["site"])
        else:
            publisher.api.create_default_site()

    print "Registering data sources..."
    publisher.register_data_sources()
{'fraction_non_alphanumeric': 0.11624472573839663, 'fraction_numerical': 0.007594936708860759, 'mean_word_length': 2.0845803513337673, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '445169', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1298, 'n_words': 354}