コード例 #1
0
ファイル: cssmin.py プロジェクト: hortont424/hortona.com
def main():
    for root, dirs, files in os.walk(sys.argv[1]):
        for filename in files:
            f = os.path.join(root, filename)

            if filename.startswith("."):
                continue

            contents = readFileContents(f)
            
            out = codecs.open(f, encoding='utf-8', mode='w+')
            out.write(cssmin(contents))
            out.close()
コード例 #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import codecs

from settings import *
from renderer import readFileContents

for root, dirs, files in os.walk(sys.argv[1]):
    for filename in files:
        f = os.path.join(root, filename)

        if filename.startswith("."):
            continue

        data = readFileContents(f)
        data = data.replace("${baseurl}", www_prefix)
        data = data.replace("${staticurl}", static_prefix)

        out = codecs.open(f, encoding="utf-8", mode="w+")
        out.write(data)
        out.close()
コード例 #3
0
ファイル: classify.py プロジェクト: hortont424/hortont.com
from build import generatePostList
from renderer import readFileContents
from reverend.thomas import Bayes

import json

guesser = Bayes()

for controlFilename in generatePostList("posts"):
    control = json.loads(readFileContents(controlFilename), encoding='utf-8')
    content = readFileContents(controlFilename.replace(".control", ""))

    for cat in control["categories"]:
        guesser.train(cat, content)

for controlFilename in generatePostList("posts"):
    control = json.loads(readFileContents(controlFilename), encoding='utf-8')
    content = readFileContents(controlFilename.replace(".control", ""))

    for guess in guesser.guess(content):
        if guess[1] > 0.05 and guess[0] not in control["categories"] and not guess[0] == "personal":
            print control["title"], guess[0]