<commit_before>#!/usr/bin/python
"""The script searches ixirc.com and parases
the simple json output"""

import sys
import json
import requests
import argparse


class termcolors:
    """Asign some cheap color output for the shell."""
    HEADER = '\033[95m'
    BLUE = '\033[94m'
    GREEN = '\033[92m'
    RED = '\033[31m'
    YELLOW = '\033[33m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'


def get_args():
    """get all args"""
    parser = argparse.ArgumentParser(
        description='Simple cli search for ixirc',
        epilog="Made by shaggy")
    parser.add_argument(
        '-V', '-v', '--version', action='version',
        version='%(prog)s ' + "0.1")
    parser.add_argument(
        '-s', '--searchterm', type=str, help='search string',
        required=False, default=None)
    parser.add_argument(
        '-c', '--chanid', type=str, help='channel id, see list:',
        required=False, default=None)
    parser.add_argument(
        '-r', '--reverse', action='store_true', help='reverse order',
        required=False)
    parser.add_argument(
        '-p', '--page', type=str, help='page number',
        required=False)
    args = parser.parse_args()
    searchterm = args.searchterm
    chanid = args.chanid
    page = args.page
    reverse = args.reverse
    conflictdate = args.chanid, args.page
    if all(conflictdate):
        sys.exit('Conflict in options: can not use \
                page option with chanid.')
    return searchterm, chanid, page, reverse

searchterm, chanid, page, reverse = get_args()


def print_search():
    searches = requests.get("http://ixirc.com/api/?q=%s&cid=%s&pn=%s" % (
        searchterm, chanid, page)).json()
    jsondata = json.loads(str(searches).replace("'", '"'))
    jsons = jsondata['results']
    for item in reversed(jsons):
        title = item['name']
        packn = item['n']
        botn = item['uname']
        chan = item['cname']
        netw = item['naddr']
        size = item['szf']
        print(termcolors.RED + title + termcolors.GREEN + " from", chan,
              termcolors.BLUE + "on", netw + termcolors.ENDC)
        print(termcolors.RED + size + termcolors.YELLOW + " /msg",
              botn, "xdcc send", packn, termcolors.ENDC)
        print("---------------------------------------------")


def main():
    try:
        print_search()
    except KeyError:
        print("No Result Found")

if __name__ == '__main__':<commit_msg>no need for conflicts<commit_after>#!/usr/bin/python
"""The script searches ixirc.com and parases
the simple json output"""

import sys
import json
import requests
import argparse


class termcolors:
    """Asign some cheap color output for the shell."""
    HEADER = '\033[95m'
    BLUE = '\033[94m'
    GREEN = '\033[92m'
    RED = '\033[31m'
    YELLOW = '\033[33m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'


def get_args():
    """get all args"""
    parser = argparse.ArgumentParser(
        description='Simple cli search for ixirc',
        epilog="Made by shaggy")
    parser.add_argument(
        '-V', '-v', '--version', action='version',
        version='%(prog)s ' + "0.1")
    parser.add_argument(
        '-s', '--searchterm', type=str, help='search string',
        required=False, default=None)
    parser.add_argument(
        '-c', '--chanid', type=str, help='channel id, see list:',
        required=False, default=None)
    parser.add_argument(
        '-r', '--reverse', action='store_true', help='reverse order',
        required=False)
    parser.add_argument(
        '-p', '--page', type=str, help='page number',
        required=False)
    args = parser.parse_args()
    searchterm = args.searchterm
    chanid = args.chanid
    page = args.page
    reverse = args.reverse
    #conflictdate = args.chanid, args.page
    #if all(conflictdate):
    #    sys.exit('Conflict in options: can not use \
    #            page option with chanid.')
    return searchterm, chanid, page, reverse

searchterm, chanid, page, reverse = get_args()


def print_search():
    searches = requests.get("http://ixirc.com/api/?q=%s&cid=%s&pn=%s" % (
        searchterm, chanid, page)).json()
    jsondata = json.loads(str(searches).replace("'", '"'))
    jsons = jsondata['results']
    for item in reversed(jsons):
        title = item['name']
        packn = item['n']
        botn = item['uname']
        chan = item['cname']
        netw = item['naddr']
        size = item['szf']
        print(termcolors.RED + title + termcolors.GREEN + " from", chan,
              termcolors.BLUE + "on", netw + termcolors.ENDC)
        print(termcolors.RED + size + termcolors.YELLOW + " /msg",
              botn, "xdcc send", packn, termcolors.ENDC)
        print("---------------------------------------------")


def main():
    try:
        print_search()
    except KeyError:
        print("No Result Found")

if __name__ == '__main__':
{'fraction_non_alphanumeric': 0.17156665324204592, 'fraction_numerical': 0.017720499395892066, 'mean_word_length': 2.4207988980716255, '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': '543941', 'n_tokens_mistral': 1686, 'n_tokens_neox': 1591, 'n_words': 390}