<commit_before>import os
import aiohttp
import asyncio
import re
import traceback
from functools import partial
from jinja2 import Environment, FileSystemLoader
from datetime import datetime
import click
from tqdm import tqdm
import logging
from . import version as __version__
logging.basicConfig(level=logging.INFO, format='{asctime}: {message}', style='{')


##########constant#########

_island_info = {
    'nimingban': {
        'CDNHOST': 'http://img1.nimingban.com',
        'headers': {
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate, sdch',
            'Accept-Language': 'en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Dnt': '1',
            'Host': 'img1.nimingban.com',
            'Pragma': 'no-cache',
            'Referer': 'http://h.nimingban.com/t/117617?page=10',
            'Upgrade-Insecure-Requests': '1',
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36'
            }
        },
    'kukuku': {
        'CDNHOST': 'http://static.koukuko.com/h',
        'headers': {
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate, sdch',
            'Accept-Language': 'en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Dnt': '1',
            'Host': 'static.koukuko.com',
            'Pragma': 'no-cache',
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36'
            }
    }
}



#########setup#########
BASE = os.path.dirname(__file__)
_conn = aiohttp.TCPConnector(use_dns_cache=True, limit=10, conn_timeout=60)
env = Environment(loader=FileSystemLoader(os.path.join(BASE, 'templates')), trim_blocks=True)



################
class IslandSwitcher:
    available_island = ['nimingban', 'kukuku']

    def __init__(self, island='nimingban'):
        assert island in self.available_island
        self.island = island

    def detect_by_url(self, url):
        for island in self.available_island:
            if island in url:
                self.island = island
                return
        raise ValueError('Unknown url: {}'.format(url))

    @property
    def cdn_host(self):<commit_msg>change jinja loader path to '.'<commit_after>import os
import aiohttp
import asyncio
import re
import traceback
from functools import partial
from jinja2 import Environment, FileSystemLoader
from datetime import datetime
import click
from tqdm import tqdm
import logging
from . import version as __version__
logging.basicConfig(level=logging.INFO, format='{asctime}: {message}', style='{')


##########constant#########

_island_info = {
    'nimingban': {
        'CDNHOST': 'http://img1.nimingban.com',
        'headers': {
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate, sdch',
            'Accept-Language': 'en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Dnt': '1',
            'Host': 'img1.nimingban.com',
            'Pragma': 'no-cache',
            'Referer': 'http://h.nimingban.com/t/117617?page=10',
            'Upgrade-Insecure-Requests': '1',
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36'
            }
        },
    'kukuku': {
        'CDNHOST': 'http://static.koukuko.com/h',
        'headers': {
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate, sdch',
            'Accept-Language': 'en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Dnt': '1',
            'Host': 'static.koukuko.com',
            'Pragma': 'no-cache',
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36'
            }
    }
}



#########setup#########
BASE = os.path.dirname(__file__)
_conn = aiohttp.TCPConnector(use_dns_cache=True, limit=10, conn_timeout=60)
env = Environment(loader=FileSystemLoader(os.path.join('.', 'templates')), trim_blocks=True)



################
class IslandSwitcher:
    available_island = ['nimingban', 'kukuku']

    def __init__(self, island='nimingban'):
        assert island in self.available_island
        self.island = island

    def detect_by_url(self, url):
        for island in self.available_island:
            if island in url:
                self.island = island
                return
        raise ValueError('Unknown url: {}'.format(url))

    @property
    def cdn_host(self):
{'fraction_non_alphanumeric': 0.172781984080761, 'fraction_numerical': 0.03533294505921181, 'mean_word_length': 2.6695156695156697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '1032371', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1772, 'n_words': 332}