<commit_before>#coding:utf-8
import datetime
import sys
import os
sys.path.append(os.path.dirname(__file__))
import shutil
import web
import markdown2
perpage = 5
try:
    import conf
    path = conf.path
    css_path = conf.csspath
    web.config.debug=conf.debug
    domain = conf.domain
except:
    icopath = './'
    path = './md'
    css_path = './css'
    web.config.debug=True
    domain ='http://127.0.0.1:8080'

class base:
    def __init__(self):
        self.entities = []
        if not os.path.isdir(path):
            os.mkdir(path)
        for p in os.listdir(path):
            if os.path.isdir(p):
                continue
            ext = os.path.splitext(p)[1]
            if ext == '.md':
                self.entities.append(os.path.join(path,p))
        self.entities.sort(reverse=True)
    def entity(self, idx):
        return self.generate(idx, idx+1)
    def entities(self):
        return self.generate(0, len(self.entities))
    def generate(self, begin, end):
        es = [] #entities in page
        if len(self.entities) == 0:
            return es
        for i in range(begin, end):
            e = {}
            e['date'] = os.path.splitext(self.entities[i])[0].replace(path+os.sep, '')
            with open(self.entities[i], 'rb') as f:
                e['id'] = i
                title = f.readline()
                title_tag = f.readline()
                image = f.readline()
                e['title'] = markdown2.markdown(title)
                e['image'] = markdown2.markdown(image)#.replace('<img src="', '<img width="480" height="360" src="/')
                content = title + title_tag + image + f.read()
                c = markdown2.markdown(content)#.replace('<img src="', '<img width="480" height="360" src="/')
                e['content'] = c
                es.append(e)
                f.close()
        return es

class static:
    def GET(self, name):
        if name == 'favicon.ico':
            with open(os.path.join(icopath, name), 'rb') as f:
                content = f.read()
                f.close()<commit_msg>compatible ios<commit_after>#coding:utf-8
import datetime
import sys
import os
sys.path.append(os.path.dirname(__file__))
import shutil
import web
import markdown2
perpage = 5
try:
    import conf
    path = conf.path
    css_path = conf.csspath
    web.config.debug=conf.debug
    domain = conf.domain
except:
    icopath = './'
    path = './md'
    css_path = './css'
    web.config.debug=True
    domain ='http://127.0.0.1:8080'

class base:
    def __init__(self):
        self.entities = []
        if not os.path.isdir(path):
            os.mkdir(path)
        for p in os.listdir(path):
            if os.path.isdir(p):
                continue
            ext = os.path.splitext(p)[1]
            if ext == '.md':
                self.entities.append(os.path.join(path,p))
        self.entities.sort(reverse=True)
    def entity(self, idx):
        return self.generate(idx, idx+1)
    def entities(self):
        return self.generate(0, len(self.entities))
    def generate(self, begin, end):
        es = [] #entities in page
        if len(self.entities) == 0:
            return es
        for i in range(begin, end):
            e = {}
            e['date'] = os.path.splitext(self.entities[i])[0].replace(path+os.sep, '')
            with open(self.entities[i], 'rb') as f:
                e['id'] = i
                title = f.readline()
                title_tag = f.readline()
                image = f.readline()
                e['title'] = markdown2.markdown(title)
                e['image'] = markdown2.markdown(image).replace('<img src="', '<img width="200" height="200" src="/')
                content = title + title_tag + image + f.read()
                c = markdown2.markdown(content)#.replace('<img src="', '<img width="480" height="360" src="/')
                e['content'] = c
                es.append(e)
                f.close()
        return es

class static:
    def GET(self, name):
        if name == 'favicon.ico':
            with open(os.path.join(icopath, name), 'rb') as f:
                content = f.read()
                f.close()
{'fraction_non_alphanumeric': 0.14728495915425277, 'fraction_numerical': 0.01585776069197501, 'mean_word_length': 1.7902144772117963, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1594854', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1297, 'n_words': 294}