code
stringlengths
1
1.72M
language
stringclasses
1 value
from foaflib.helpers.basehelper import BaseHelper from foaflib.utils.activitystreamevent import ActivityStreamEvent class Delicious(BaseHelper): def __init__(self): try: import feedparser self.feedparser = feedparser self._supported = True except ImportError: ...
Python
import foaflib.helpers.blog as blog from foaflib.helpers.delicious import Delicious from foaflib.helpers.identica import Identica from foaflib.helpers.twitter_ import Twitter try: from feedformatter import Feed _CAN_DO_FEEDS_ = True except ImportError: _CAN_DO_FEEDS_ = False _ALL_HELPERS_ = [Delicious] _A...
Python
from hashlib import sha1 from foaflib.utils.basicscutter import BasicScutter class FileStorageScutter(BasicScutter): def __init__(self, directory, seed_uris=None): BasicScutter.__init__(self, seed_uris) self.directory = directory def handle_person(self, foafperson): filename = self.d...
Python
class ActivityStreamEvent(object): def __init__(self): self.type = "" self.detail = "" self.link = "" self.timestamp = None def __cmp__(self, other): return cmp(self.timestamp, other.timestamp)
Python
from robotparser import RobotFileParser from urlparse import urljoin import rdflib from foaflib.classes.person import Person class BasicScutter(object): def __init__(self, seed_uris=None): self.useragent = "foaflib" if seed_uris is None: seed_uris = [] self.current_list = see...
Python
import rdflib class OnlineAccount(object): def __init__(self, graph=None, node=None): self.accountServiceHomepage = "" self.accountName = "" self.accountProfilePage = "" if graph and node: for homepage in graph.objects(subject=node, predicate=rdflib.URIRef('http://xmlns.com/foa...
Python
import rdflib from rdflib.Graph import ConjunctiveGraph as Graph from urllib import urlopen from foaflib.classes.onlineaccount import OnlineAccount _SINGLETONS = """gender openid birthday pubkeyAddress""".split() _BASIC_MULTIS = """mbox mbox_sha1sum jabberID aimChatID icqChatID yahooChatID msnChatID weblog tipjar mad...
Python
import rdflib from rdflib.Graph import ConjunctiveGraph as Graph from urllib import urlopen from foaflib.classes.agent import Agent _SINGLETONS = "title name nick givenname firstName surname family_name homepage geekcode meyersBriggs dnaChecksum plan".split() _BASIC_MULTIS = "schoolHomepage workplaceHomepage img curr...
Python
#!/usr/bin/env python from setuptools import setup setup(name="foaflib", version="0.2", description="Python library for working with FOAF data", author="Luke Maurits", author_email="luke@maurits.id.au", url="http://code.google.com/p/foaflib/", packages=["foaflib", "foaflib.classes"...
Python
#!/usr/bin/env python from setuptools import setup setup(name="foaflib", version="0.1", description="Python library for working with FOAF data", author="Luke Maurits", author_email="luke@maurits.id.au", url="http://code.google.com/p/foaflib/", packages=["foaflib", "foaflib.classes"...
Python
from foaflib.utils.activitystreamevent import ActivityStreamEvent try: from urllib import urlopen from urlparse import urljoin from BeautifulSoup import BeautifulSoup from feedparser import parse _CAN_DO_ = True except ImportError: _CAN_DO_ = False def get_latest(foafprofile): entries = []...
Python
from foaflib.utils.activitystreamevent import ActivityStreamEvent class BaseHelper(object): def __init__(self): self._supported = False def _accept_account(self, onlineaccount): return False def _handle_account(self, onlineaccount): return None def get_latest(self, foafperso...
Python
from foaflib.utils.activitystreamevent import ActivityStreamEvent from foaflib.helpers.basehelper import BaseHelper class Identica(BaseHelper): def __init__(self): BaseHelper.__init__(self) try: import feedparser self.feedparser = feedparser self._supported = Tr...
Python
from foaflib.helpers.basehelper import BaseHelper from foaflib.utils.activitystreamevent import ActivityStreamEvent class Twitter(BaseHelper): def __init__(self): BaseHelper.__init__(self) try: import twitter self.twitter = twitter import time self.t...
Python
from foaflib.helpers.basehelper import BaseHelper from foaflib.utils.activitystreamevent import ActivityStreamEvent class Delicious(BaseHelper): def __init__(self): try: import feedparser self.feedparser = feedparser self._supported = True except ImportError: ...
Python
import foaflib.helpers.blog as blog from foaflib.helpers.delicious import Delicious from foaflib.helpers.identica import Identica from foaflib.helpers.twitter_ import Twitter _ALL_HELPERS_ = [Delicious] _ALL_HELPERS_.append(Identica) _ALL_HELPERS_.append(Twitter) class ActivityStream(object): def __init__(self, ...
Python
from hashlib import sha1 from foaflib.utils.basicscutter import BasicScutter class FileStorageScutter(BasicScutter): def __init__(self, directory, seed_uris=None): BasicScutter.__init__(self, seed_uris) self.directory = directory def handle_person(self, foafperson): filename = self.d...
Python
class ActivityStreamEvent(object): def __init__(self): self.type = "" self.detail = "" self.link = "" self.timestamp = None def __cmp__(self, other): return cmp(self.timestamp, other.timestamp)
Python
from robotparser import RobotFileParser from urlparse import urljoin import rdflib from foaflib.classes.person import Person class BasicScutter(object): def __init__(self, seed_uris=None): self.useragent = "foaflib" if seed_uris is None: seed_uris = [] self.current_list = see...
Python
import rdflib class OnlineAccount(object): def __init__(self, graph=None, node=None): self.accountServiceHomepage = "" self.accountName = "" self.accountProfilePage = "" if graph and node: for homepage in graph.objects(subject=node, predicate=rdflib.URIRef('http://xmlns.com/foa...
Python
import rdflib from rdflib.Graph import ConjunctiveGraph as Graph from urllib import urlopen from foaflib.classes.onlineaccount import OnlineAccount _SINGLETONS = """gender openid birthday pubkeyAddress""".split() _BASIC_MULTIS = """mbox mbox_sha1sum jabberID aimChatID icqChatID yahooChatID msnChatID weblog tipjar mad...
Python
import rdflib from rdflib.Graph import ConjunctiveGraph as Graph from urllib import urlopen from foaflib.classes.agent import Agent _SINGLETONS = "title name nick givenname firstName surname family_name homepage geekcode meyersBriggs dnaChecksum plan".split() _BASIC_MULTIS = "schoolHomepage workplaceHomepage img curr...
Python
#!/usr/bin/env python from setuptools import setup setup(name="foaflib", version="0.1", description="Python library for working with FOAF data", author="Luke Maurits", author_email="luke@maurits.id.au", url="http://code.google.com/p/foaflib/", packages=["foaflib", "foaflib.classes"...
Python
#!/usr/bin/env python from setuptools import setup setup(name="foaflib", version="0.1", description="Python library for working with FOAF data", author="Luke Maurits", author_email="luke@maurits.id.au", url="http://code.google.com/p/foaflib/", packages=["foaflib", "foaflib.classes"...
Python
from foaflib.utils.activitystreamevent import ActivityStreamEvent try: from urllib import urlopen from urlparse import urljoin from BeautifulSoup import BeautifulSoup from feedparser import parse _CAN_DO_ = True except ImportError: _CAN_DO_ = False def get_latest(foafprofile): entries = []...
Python
from foaflib.utils.activitystreamevent import ActivityStreamEvent class BaseHelper(object): def __init__(self): self._supported = False def _accept_account(self, onlineaccount): return False def _handle_account(self, onlineaccount): return None def get_latest(self, foafperso...
Python
from foaflib.utils.activitystreamevent import ActivityStreamEvent from foaflib.helpers.basehelper import BaseHelper class Identica(BaseHelper): def __init__(self): BaseHelper.__init__(self) try: import feedparser self.feedparser = feedparser self._supported = Tr...
Python
from foaflib.helpers.basehelper import BaseHelper from foaflib.utils.activitystreamevent import ActivityStreamEvent class Twitter(BaseHelper): def __init__(self): BaseHelper.__init__(self) try: import twitter self.twitter = twitter import time self.t...
Python
from foaflib.helpers.basehelper import BaseHelper from foaflib.utils.activitystreamevent import ActivityStreamEvent class Delicious(BaseHelper): def __init__(self): try: import feedparser self.feedparser = feedparser self._supported = True except ImportError: ...
Python
import foaflib.helpers.blog as blog from foaflib.helpers.delicious import Delicious from foaflib.helpers.identica import Identica from foaflib.helpers.twitter_ import Twitter try: from feedformatter import Feed _CAN_DO_FEEDS_ = True except ImportError: _CAN_DO_FEEDS_ = False _ALL_HELPERS_ = [Delicious] _A...
Python
from hashlib import sha1 from foaflib.utils.basicscutter import BasicScutter class FileStorageScutter(BasicScutter): def __init__(self, directory, seed_uris=None): BasicScutter.__init__(self, seed_uris) self.directory = directory def handle_person(self, foafperson): filename = self.d...
Python
class ActivityStreamEvent(object): def __init__(self): self.type = "" self.detail = "" self.link = "" self.timestamp = None def __cmp__(self, other): return cmp(self.timestamp, other.timestamp)
Python
from robotparser import RobotFileParser from urlparse import urljoin import rdflib from foaflib.classes.person import Person class BasicScutter(object): def __init__(self, seed_uris=None): self.useragent = "foaflib" if seed_uris is None: seed_uris = [] self.current_list = see...
Python
import rdflib class OnlineAccount(object): def __init__(self, graph=None, node=None): self.accountServiceHomepage = "" self.accountName = "" self.accountProfilePage = "" if graph and node: for homepage in graph.objects(subject=node, predicate=rdflib.URIRef('http://xmlns.com/foa...
Python
import rdflib from rdflib.Graph import ConjunctiveGraph as Graph from urllib import urlopen from foaflib.classes.onlineaccount import OnlineAccount _SINGLETONS = """gender openid birthday pubkeyAddress""".split() _BASIC_MULTIS = """mbox mbox_sha1sum jabberID aimChatID icqChatID yahooChatID msnChatID weblog tipjar mad...
Python
import rdflib from rdflib.Graph import ConjunctiveGraph as Graph from urllib import urlopen from foaflib.classes.agent import Agent _SINGLETONS = "title name nick givenname firstName surname family_name homepage geekcode meyersBriggs dnaChecksum plan".split() _BASIC_MULTIS = "schoolHomepage workplaceHomepage img curr...
Python
#!/usr/bin/env python from setuptools import setup setup(name="foaflib", version="0.1", description="Python library for working with FOAF data", author="Luke Maurits", author_email="luke@maurits.id.au", url="http://code.google.com/p/foaflib/", packages=["foaflib", "foaflib.classes"...
Python
#!/usr/bin/env python #coding=utf-8 from xml.dom import minidom import urllib import httplib import re import os import time import sys import hashlib fsock = open('error.log', 'a') fsock.write(time.strftime('%Y-%m-%d %X',time.localtime())+"\n") fsock.flush() sys.stderr = fsock pid = open('pid','w')...
Python
#!/usr/bin/env python #coding=utf-8 from xml.dom import minidom import urllib import httplib import re import os import time import sys import hashlib fsock = open('error.log', 'a') fsock.write(time.strftime('%Y-%m-%d %X',time.localtime())+"\n") fsock.flush() sys.stderr = fsock pid = open('pid','w')...
Python
#!/usr/bin/python # -*- coding: UTF-8 -*- # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: import subprocess import os import sys from webbrowser import _iscommand as is_command import gtk import mimetypes, mimetools import config import locale import ctypes try: import i18n except: from gettext import gette...
Python
#!/usr/bin/env python # -*- coding:utf8 -*- import json import config import time import base64 import urllib, urllib2 import gtk import threading import gobject import utils import hotot import os import sys import subprocess try: import i18n except: from gettext import gettext as _ reload(sys) sys.setdefaultencodi...
Python
#!/usr/bin/python # -*- coding: UTF-8 -*- # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: import glib import gtk import pango import os from xml.sax.saxutils import escape queue = list() actual_notification = None def gtknotification(title, text, icon_file=None, const=None, callback=None, tooltip=None): ...
Python
#!/usr/bin/env python # -*- coding:utf8 -*- '''Hotot @author: U{Shellex Wei <5h3ll3x@gmail.com>} @license: LGPLv3+ ''' import gtk import gobject import view import config import agent import keybinder import utils try: import appindicator except ImportError: HAS_INDICATOR = False else: HAS_INDICATOR = True...
Python
#!/usr/bin/env python # -*- coding:utf8 -*- import gtk gtk.gdk.threads_init() ## fix issue 24 import webkit import agent import config from webkit import WebView import utils import json import gobject try: import i18n except: from gettext import gettext as _ class MainView(WebView): def __init__(self): W...
Python
#!/usr/bin/python # -*- coding: UTF-8 -*- # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: # Author: Huang Jiahua <jhuangjiahua@gmail.com> # License: LGPLv3+ # Last modified: app = 'hotot' import os, sys import gettext import json import re if os.path.isdir(os.path.dirname(sys.argv[0]) + '/../build/mo'): ...
Python
# -*- coding: UTF-8 -*- import os import pickle import json import gtk import sys import glob import shutil import glib PROGRAM_NAME = 'hotot' EXT_DIR_NAME = 'ext' CONF_DIR = os.path.join(glib.get_user_config_dir(), PROGRAM_NAME) DB_DIR = os.path.join(CONF_DIR, 'db') CACHE_DIR = os.path.join(glib.get_user_cache_dir()...
Python
#!/usr/bin/python # -*- coding: UTF-8 -*- # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: # Author: Shellex Wai <5h3ll3x@gmail.com> # License: GNU LGPL # Last modified: """ """ __revision__ = '0.1' if __name__=="__main__": import hotot.hotot hotot.hotot.main()
Python
#!/usr/bin/env python # -*- coding:utf8 -*- from distutils.core import setup from DistUtilsExtra.command import * from glob import glob import os, os.path def get_data_files(root, data_dir): return [ (root + parent[len(data_dir):], [ os.path.join(parent, fn) for fn in files ]) for pare...
Python
#!/usr/bin/env python # -*- coding:utf8 -*- import re import json import os.path TEMPLATE = "data/index.html" DEFAULT_LOCALE_FILE = 'data/_locales/en/messages.json' JS_FILE_DIR = ['data/js/'] LOCALE_FILE_DIR = 'data/_locales/' template_tag_re = re.compile('data-i18n-[a-z0-9]+="(.+?)"') js_tag_re = re.compile('''...
Python
# Django settings for foiaqui project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@domain.com'), ) MANAGERS = ADMINS DATABASE_ENGINE = 'mysql' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. DATABASE_NAME = 'foiaqui' # Or path to database file if using sql...
Python
#!/usr/bin/python from django.core.management import execute_manager try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run ...
Python
from django.db import models class Poll(models.Model): question = models.CharField(maxlength=200) pub_date = models.DateTimeField('date published') def __str__(self): return self.question class Admin: pass class Choice(models.Model): poll = models.ForeignKey(Poll) choice = mode...
Python
from django.shortcuts import render_to_response from foiaqui.polls.models import Poll from django.shortcuts import render_to_response, get_object_or_404 def index(request): latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] return render_to_response('polls/index.html', {'latest_poll_list': latest_...
Python
from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^polls/$', 'foiaqui.polls.views.index'), (r'^polls/(?P<poll_id>\d+)/$', 'foiaqui.polls.views.detail'), (r'^polls/(?P<poll_id>\d+)/results/$', 'foiaqui.polls.views.results'), (r'^polls/(?P<poll_id>\d+)/vote/$', 'foiaqui.polls.views.vo...
Python
from django.db import models import datetime # mobility classification MOBILITY = ( ('WK', 'Walking'), ('VE', 'Vehicle'), ) QUANTITY = ( ('AL','Alone'), ('FO','Folloied'), ) THIEF = ( ('ON','One'), ('MA','Many'), ) WEAPON = ( ('MW','Melee'), ('GN','Guns'), ('NN','None'), ) ...
Python
# Django from django.shortcuts import render_to_response from django.shortcuts import render_to_response, get_object_or_404 from django.http import HttpResponse, HttpResponseRedirect # Python from datetime import datetime # foiaqui from foiaqui.crimes.models import Incident # XML view def xml(request): """ Sends a ...
Python
from django.db import models # Create your models here.
Python
from django.shortcuts import render_to_response from foiaqui.crimes.models import Incident def index(request): # How many incidents we have n = Incident.objects.count() # Transform in a language text if n == 0: text = "Nao ha nenhum incidente registrado." elif n == 1: text = "Atualmente nos temos <strong>%d...
Python
#!/usr/bin/python from django.core.management import execute_manager try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run ...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def main(): line_infos = [[0]*1024 for i in range(10)] for idx in range(10): for flag in range(1024): flag |= 0xFC00 p1 = (idx and [idx-1] or [0xF])[0] while not flag & (1 <<...
Python
import xq_data xq_data.main() import xq_position_data xq_position_data.main() import history_data history_data.main() import bitmap_data bitmap_data.main()
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * from xq_data import * def capture_scores(): capture_scores = [[0]*32 for i in range(33)] e = [10000, 1041, 1040, 2000, 1088, 1096, 1020] m = [1000, 41, 40, 200, 88, 96, 20] def level(src_type, dst_type): retur...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def main(): line_infos = [[0]*1024 for i in range(10)] for idx in range(10): for flag in range(1024): flag |= 0xFC00 p1 = (idx and [idx-1] or [0xF])[0] while not flag & (1 <<...
Python
RedKing = 0; RedAdvisor = 1; RedBishop = 2; RedRook = 3; RedKnight = 4; RedCannon = 5; RedPawn = 6; BlackKing = 7; BlackAdvisor = 8; BlackBishop = 9; BlackRook = 10; BlackKnight = 11; BlackCannon = 12; BlackPawn = 13; EmptyType = 14; InvalidType = 15; RedKingFlag = 1 << 0; RedAdvisorFlag = 1 << 1; R...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def u(x): return SquareDowns[x] def d(x): return SquareUps[x] def l(x): return SquareLefts[x] def r(x): return SquareRights[x] SquareDowns = [0]*91 SquareUps = [0]*91 SquareLefts = [0]*91 SquareRights = [0]*91 Xs = [9]*91...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * from xq_data import * RedKingPawnValues = [0]*91 BlackKingPawnValues = [0]*91 AdvisorBishopValues = [0]*91 RedRookValues = [0]*91 BlackRookValues = [0]*91 RedKnightValues = [0]*91 BlackKnightValues = [0]*91 RedCannonValues ...
Python
import os import sys if sys.platform == "win32": cpppath = [r'D:\toolbox\boost_1_36_0', r'D:\Python26\include'] libpath = [r'D:\toolbox\boost_1_36_0\lib_x86\lib', r'D:\Python26\libs'] env = Environment(tools=['mingw'], CPPPATH=cpppath, LIBPATH=libpath) ccflags = '-O3' libs=['boost_python-mg...
Python
#coding=utf-8 class Mirror(object): flags = range(4) def __init__(self): object.__init__(self) self.m1_map = dict(zip('abcdefghi0123456789', 'ihgfedcba0123456789')) self.m2_map = dict(zip('abcdefghi0123456789', 'ihgfedcba9876543210')) def move(self, move, flag): if ...
Python
import os import sys import dbhash import cPickle import random import mirror class Reader(object): def __init__(self): bookfile = os.path.join(os.path.dirname(sys.argv[0]), 'snake.book') self.book = dbhash.open(bookfile, 'r') self.mirror = mirror.Mirror() def flag(self,...
Python
#!/usr/bin/env python #coding=utf-8 def main(): import sys if len(sys.argv) == 1: import pyfolium.protocol engine = pyfolium.protocol.Engine() engine.run()
Python
import os import sys import datetime import time import folium import pipe import pyfolium.book.reader class Engine(folium.Engine): def __init__(self): folium.Engine.__init__(self) self.book = pyfolium.book.reader.Reader() self.logfile = None logdir = os.path.join...
Python
#!/usr/bin/env python #coding=utf-8 def main(): import sys if len(sys.argv) == 1: import pyfolium.protocol engine = pyfolium.protocol.Engine() engine.run()
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def main(): line_infos = [[0]*1024 for i in range(10)] for idx in range(10): for flag in range(1024): flag |= 0xFC00 p1 = (idx and [idx-1] or [0xF])[0] while not flag & (1 <<...
Python
import xq_data xq_data.main() import engine_data engine_data.main() import history_data history_data.main() import bitmap_data bitmap_data.main()
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * from xq_data import * RedKingPawnValues = [0]*91 BlackKingPawnValues = [0]*91 AdvisorBishopValues = [0]*91 RedRookValues = [0]*91 BlackRookValues = [0]*91 RedKnightValues = [0]*91 BlackKnightValues = [0]*91 RedCannonValues ...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * from xq_data import * def capture_scores(): capture_scores = [[0]*32 for i in range(33)] e = [10000, 1041, 1040, 2000, 1088, 1096, 1020] m = [1000, 41, 40, 200, 88, 96, 20] def level(src_type, dst_type): retur...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def main(): line_infos = [[0]*1024 for i in range(10)] for idx in range(10): for flag in range(1024): flag |= 0xFC00 p1 = (idx and [idx-1] or [0xF])[0] while not flag & (1 <<...
Python
RedKing = 0; RedAdvisor = 1; RedBishop = 2; RedRook = 3; RedKnight = 4; RedCannon = 5; RedPawn = 6; BlackKing = 7; BlackAdvisor = 8; BlackBishop = 9; BlackRook = 10; BlackKnight = 11; BlackCannon = 12; BlackPawn = 13; EmptyType = 14; InvalidType = 15; RedKingFlag = 1 << 0; RedAdvisorFlag = 1 << 1; R...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def u(x): return SquareUps[x] def d(x): return SquareDowns[x] def l(x): return SquareLefts[x] def r(x): return SquareRights[x] SquareUps = [0]*91 SquareDowns = [0]*91 SquareLefts = [0]*91 SquareRights = [0]*91 Xs = [9]*91...
Python
import sys cpp_path = [r'D:\toolbox\boost_1_35_0'] lib_path = ['#bin', r'D:\toolbox\boost_1_35_0\stage\lib'] BuildDir('build', 'src', duplicate=0) env = Environment(CPPPATH=cpp_path, LIBPATH=lib_path) if sys.platform == "win32": if 1: env.Tool('mingw') ccflag = '-O3' else: env.Tool('icl') ccf...
Python
import xq_data xq_data.main() import engine_data engine_data.main() import history_data history_data.main() import bitlines_data bitlines_data.main()
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * from xq_data import * RedKingPawnValues = [0]*91 BlackKingPawnValues = [0]*91 AdvisorBishopValues = [0]*91 RedRookValues = [0]*91 BlackRookValues = [0]*91 RedKnightValues = [0]*91 BlackKnightValues = [0]*91 RedCannonValues ...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * from xq_data import * def capture_scores(): capture_scores = [[0]*32 for i in range(33)] e = [10000, 1041, 1040, 2000, 1088, 1096, 1020] m = [1000, 41, 40, 200, 88, 96, 20] def level(src_type, dst_type): retur...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def main(): line_infos = [[0]*1024 for i in range(10)] for idx in range(10): for flag in range(1024): flag |= 0xFC00 p1 = (idx and [idx-1] or [0xF])[0] while not flag & (1 <<...
Python
RedKing = 0; RedAdvisor = 1; RedBishop = 2; RedRook = 3; RedKnight = 4; RedCannon = 5; RedPawn = 6; BlackKing = 7; BlackAdvisor = 8; BlackBishop = 9; BlackRook = 10; BlackKnight = 11; BlackCannon = 12; BlackPawn = 13; EmptyType = 14; InvalidType = 15; RedKingFlag = 1 << 0; RedAdvisorFlag = 1 << 1; R...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def u(x): return SquareUps[x] def d(x): return SquareDowns[x] def l(x): return SquareLefts[x] def r(x): return SquareRights[x] SquareUps = [0]*91 SquareDowns = [0]*91 SquareLefts = [0]*91 SquareRights = [0]*91 Xs = [9]*91...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def main(): line_infos = [[0]*1024 for i in range(10)] for idx in range(10): for flag in range(1024): flag |= 0xFC00 p1 = (idx and [idx-1] or [0xF])[0] while not flag & (1 <<...
Python
import sys cpp_path = ['#include'] lib_path = ['#bin'] env = Environment(CPPPATH=cpp_path, LIBPATH=lib_path) if sys.platform == "win32": env.Tool('mingw') ccflag = '-O3' ccflag = '-O3 -march=prescott' defines = {'NDEBUG':None} Export("env") Export("ccflag") Export("defines") env.SConscript('src/sconsc...
Python
import xq_data xq_data.main() import engine_data engine_data.main() import history_data history_data.main() import bitlines_data bitlines_data.main()
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * from xq_data import * RedKingPawnValues = [0]*91 BlackKingPawnValues = [0]*91 AdvisorBishopValues = [0]*91 RedRookValues = [0]*91 BlackRookValues = [0]*91 RedKnightValues = [0]*91 BlackKnightValues = [0]*91 RedCannonValues ...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * from xq_data import * def capture_scores(): capture_scores = [[0]*32 for i in range(32)] e = [10000, 1041, 1040, 2000, 1088, 1096, 1020] m = [1000, 41, 40, 200, 88, 96, 20] def level(src_type, dst_type): retur...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def main(): line_infos = [[0]*1024 for i in range(10)] for idx in range(10): for flag in range(1024): flag |= 0xFC00 p1 = (idx and [idx-1] or [0xF])[0] while not flag & (1 <<...
Python
RedKing = 0; RedAdvisor = 1; RedBishop = 2; RedRook = 3; RedKnight = 4; RedCannon = 5; RedPawn = 6; BlackKing = 7; BlackAdvisor = 8; BlackBishop = 9; BlackRook = 10; BlackKnight = 11; BlackCannon = 12; BlackPawn = 13; EmptyType = 14; InvalidType = 15; RedKingFlag = 1 << 0; RedAdvisorFlag = 1 << 1; R...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def u(x): return SquareUps[x] def d(x): return SquareDowns[x] def l(x): return SquareLefts[x] def r(x): return SquareRights[x] SquareUps = [0]*91 SquareDowns = [0]*91 SquareLefts = [0]*91 SquareRights = [0]*91 Xs = [9]*91...
Python
#!/usr/bin/env python #coding=utf-8 import os import string from consts import * def main(): line_infos = [[0]*1024 for i in range(10)] for idx in range(10): for flag in range(1024): flag |= 0xFC00 p1 = (idx and [idx-1] or [0xF])[0] while not flag & (1 <<...
Python
import random import _xq class Book(object): def readflag(self, fen): _ = [] for flag in range(4): new= _xq.mirror4fen(fen, flag) if not new.endswith('b'): _.append([new, flag]) _.sort() return _[0] if _[0][0] >= _[1][0] else _[1]...
Python
import os import sys import book class dictbook(book.Book): def __init__(self): book.Book.__init__(self) self.load() def load(self): bookfile = os.path.join(os.path.dirname(sys.argv[0]), 'book.dict') self.dict = {} for line in open(bookfile): _ ...
Python
import time import _xq import snake.book.dictbook class Engine(_xq.Engine): def __init__(self): _xq.Engine.__init__(self) self.book = snake.book.dictbook.dictbook() def run(self): while not self.readable(): pass line = self.readline() if lin...
Python
from distutils.core import setup import py2exe setup( console = ["main.py"], )
Python
#!/usr/bin/env python #coding=utf-8 def main(): import sys if len(sys.argv) == 1: import snake.protocol engine = snake.protocol.Engine() engine.run() if __name__ == "__main__": main()
Python