code
stringlengths
1
1.72M
language
stringclasses
1 value
# gozerbot/monitor.py # # """ monitors .. call callback on bot output. """ ## gozerlib import s from gozerlib.monitor import Monitor ## gozerlib.socket.irc imports from ircevent import Ircevent ## classes class Outmonitor(Monitor): """ monitor for bot output (bot.send). """ def handle(self, bot, txt): ...
Python
# gozerlib/socket/irc/irc.py # # """ an Irc object handles the connection to the irc server .. receiving, sending, connect and reconnect code. """ ## gozerlib imports from gozerlib.utils.exception import handle_exception from gozerlib.socket.utils.generic import getrandomnick, toenc, fromenc, strippedtxt f...
Python
# gozerbot/channels.py # # """ channel related data. implemented with a persisted dict of dicts. :example: key = channels[event.channel]['key'] """ ## gozerlib imports from gozerlib.utils.pdod import Pdod class Channels(Pdod): """ channels class .. per channel data. ...
Python
# gozerlib/utils/exception.py # # """ exception related functions. """ ## basic imports import sys import traceback import logging import thread import os import logging ## define exceptionlist = [] exceptionevents = [] ## functions def exceptionmsg(): """ create exception message as a string. """ exctyp...
Python
# gozerlib/utils/lockmanager.py # # """ manages locks """ ## basic imports import thread import threading ## classes class LockManager(object): """ place to hold locks """ def __init__(self): self.locks = {} def allocate(self, name): """ allocate a new lock """ self.locks[nam...
Python
# lib/utils/generic.py # # """ generic functions. """ ## lib imports from exception import handle_exception from trace import calledfrom from lazydict import LazyDict from gozerlib.datadir import datadir ## simplejson import from simplejson import dumps ## generic imports import time import sys import re import...
Python
# gozerlib/utils/trace.py # # """ trace related functions """ ## basic imports import sys import os ## define stopmarkers = ['gozerlib', 'commonplugs', 'waveplugs', 'socketplugs', 'waveapi', 'feedprovider'] ## functions def calledfrom(frame): """ return the plugin name where given frame occured. """ try:...
Python
# gozerlib/utils/lazydict.py # # thnx to maze """ a lazydict allows dotted access to a dict .. dict.key. """ ## simplejson imports from simplejson import loads, dumps ## basic imports from xml.sax.saxutils import unescape import copy import logging ## defines cpy = copy.deepcopy ## classes class LazyDict(dict)...
Python
# gozerlib/utils/xmpp.py # # """ XMPP related helper functions. """ def stripped(userhost): """ strip resource from userhost. """ return userhost.split('/')[0] def resource(userhost): """ return resource of userhost. """ try: return userhost.split('/')[1] except ValueError: return...
Python
# gozerlib/utils/limlist.py # # """ limited list """ class Limlist(list): """ list with limited number of items """ def __init__(self, limit): self.limit = limit list.__init__(self) def insert(self, index, item): """ insert item at index .. pop oldest item if limit is reached ""...
Python
# lib/utils/timeutils.py # # """ time related helper functions. """ ## lib imports from exception import handle_exception ## basic imports import time import re import calendar ## vars leapfactor = float(6*60*60)/float(365*24*60*60) timere = re.compile('(\S+)\s+(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)') bdmonth...
Python
# gozerbot/pdod.py # # """ pickled dicts of dicts """ __copyright__ = 'this file is in the public domain' from gozerlib.utils.lazydict import LazyDict from gozerlib.utils.locking import lockdec from gozerlib.persist import Persist import thread pdodlock = thread.allocate_lock() locked = lockdec(pdodlock) class P...
Python
# gozerlib/utils/id.py # # from gozerlib.utils.generic import toenc import uuid def getrssid(url, time): key = unicode(url) + unicode(time) return str(uuid.uuid3(uuid.NAMESPACE_DNS, toenc(key)))
Python
# gozerlio/utils/log.py # # """ log module. """ import logging import sys LEVELS = {'debug': logging.DEBUG, 'info': logging.INFO, 'warning': logging.WARNING, 'error': logging.ERROR, 'critical': logging.CRITICAL} def setloglevel(level_name): level = LEVELS.get(level_name, ...
Python
# gozerbot/dol.py # # """ dict of lists """ __copyright__ = 'this file is in the public domain' class Dol(dict): """ dol is dict of lists """ def insert(self, nr, item, issue): """ add issue to item entry """ if self.has_key(item): self[item].insert(nr, issue) else: ...
Python
# gozerlib/utils/locking.py # # """ generic functions """ ## lib imports from trace import whichmodule from lockmanager import LockManager, RlockManager ## generic imports import logging import sys ## defines locks = [] lockmanager = LockManager() rlockmanager = RlockManager() ## classes class Locked(object): ...
Python
# gozerlib/utils/statdict.py # # """ stats dict """ ## classes class StatDict(dict): """ dictionary to hold stats """ def set(self, item, value): """ set item to value """ self[item] = value def upitem(self, item, value=1): """ increase item """ if not self.has_key(item...
Python
# gozerlib/utils/name.py # # """ name related helper functions. """ ## basic imports import string import os ## define allowednamechars = string.ascii_letters + string.digits + '!.@-' + os.sep ## functions def stripname(name, allowed=""): """ strip all not allowed chars from name. """ res = "" for c ...
Python
# gozerlib/utils/rsslist.py # # """ create a list of rss data """ ## lib imports from exception import handle_exception ## basic imports import xml.dom.minidom ## functions def gettext(nodelist): """ get text data from nodelist """ result = "" for node in nodelist: if node.nodeType == node.T...
Python
# gozerbot/pdol.py # # """ pickled dict of lists """ __copyright__ = 'this file is in the public domain' from gozerlib.persist import Persist class Pdol(Persist): """ pickled dict of lists """ def __init__(self, fname): Persist.__init__(self, fname) if not self.data: self.data...
Python
# lib/utils/url.py # # most code taken from maze """ url related functions. """ ## lib imports from generic import fromenc from gozerlib.config import cfg ## basic imports import logging import time import sys import re import traceback import Queue import urllib import urllib2 import urlparse import socket import...
Python
# gozerlib/monitor.py # # """ monitor the bots output. """ ## gozerlib imports from gozerlib.config import cfg as config from utils.exception import handle_exception from utils.trace import calledfrom from config import cfg as config from threadloop import ThreadLoop from runner import cbrunners import threads as th...
Python
# gozerbot/morphs.py # # """ convert input/output stream. """ ## gozerlib imports from gozerlib.utils.exception import handle_exception from gozerlib.utils.trace import calledfrom ## basic imports import sys ## classes class Morph(object): """ transform stream. :param func: morphing functio...
Python
# gozerbot/periodical.py # # __author__ = "Wijnand 'tehmaze' Modderman - http://tehmaze.com" __license__ = "BSD License" ## gozerlib imports from utils.exception import handle_exception from utils.trace import calledfrom, whichmodule from utils.locking import lockdec from utils.timeutils import strtotime import thre...
Python
# gozerlib/wave/bot.py # # """ google wave bot. """ ## gozerlib imports from gozerlib.persist import Persist from gozerlib.botbase import BotBase from gozerlib.plugins import plugs from gozerlib.utils.generic import getversion from gozerlib.callbacks import callbacks from gozerlib.outputcache import add from gozerli...
Python
# gozerlib/wave/event.py # # """ google wave events. """ ## gozerlib imports from gozerlib.eventbase import EventBase from gozerlib.utils.exception import handle_exception from gozerlib.gae.utils.auth import finduser from gozerlib.gae.wave.waves import Wave ## basic imports import logging import cgi import re imp...
Python
# gozerlib/wave/waves.py # # """ class to repesent a wave. """ ## gozerlib imports from gozerlib.channelbase import ChannelBase from gozerlib.utils.exception import handle_exception from gozerlib.utils.locking import lockdec ## from simplejson import dumps ## google imports import google ## basic imports impo...
Python
# gozerlib/utils/web.py # # """ web related functions. """ ## gozerlib imports from gozerlib.utils.generic import fromenc, getversion ## gaelib imports from auth import finduser ## google imports from google.appengine.api import users as gusers from google.appengine.ext.webapp import template ## basic imports ...
Python
# gozerlib/utils/web.py # # """ google auth related functions. """ ## gozerlib imports from gozerlib.utils.trace import whichmodule ## google imports from google.appengine.api import users as gusers ## basic imports import logging def finduser(): """ try to find the email of the current logged in user. """...
Python
# gozerlib/web/bot.py # # """ web bot. """ ## gozerlib imports from gozerlib.botbase import BotBase from gozerlib.outputcache import add class WebBot(BotBase): """ webbot just inherits from botbase for now. """ def __init__(self, cfg=None, users=None, plugs=None, *args, **kwargs): BotBase.__init__...
Python
# gozerlib/web/event.py # # """ web event. """ ## gozerlib imports from gozerlib.eventbase import EventBase from gozerlib.utils.generic import splittxt from gozerlib.utils.xmpp import stripped ## gaelib imports from gozerlib.gae.utils.auth import checkuser from gozerlib.gae.wave.waves import Wave ## basic imports...
Python
# gaelib/plugs/gae.py # # ## lib imports from gozerlib.commands import cmnds from gozerlib.examples import examples ## commands def handle_gaeflushcache(bot, ievent): """ flush the cache .. flush all with no arguments otherwise delete specific. """ from google.appengine.api.memcache import flush_all, d...
Python
# gozerlib/xmpp/bot.py # # """ XMPP bot. """ ## gozerlib imports from gozerlib.botbase import BotBase ## google imports from google.appengine.api import xmpp ## basic imports import types import logging class XMPPBot(BotBase): """ XMPPBot just inherits from BotBase for now. """ def __init__(self, cfg=...
Python
# gaelib/xmpp/event.py # # """ an xmpp event. """ ## gozerlib imports from gozerlib.eventbase import EventBase from gozerlib.utils.xmpp import stripped, resource from gozerlib.utils.lazydict import LazyDict ## gaelibs imports from gozerlib.gae.utils.auth import checkuser ## google imports from google.appengine.a...
Python
# gozerlib/plugs/user.py # # """ users related commands. """ ## gozerlib imports from gozerlib.utils.generic import getwho from gozerlib.utils.exception import handle_exception from gozerlib.utils.name import stripname from gozerlib.users import users from gozerlib.commands import cmnds from gozerlib.examples import...
Python
# gozerlib/plugs/outputcache.py # # ## gozerlib imports from gozerlib.commands import cmnds from gozerlib.outputcache import get, set from gozerlib.callbacks import callbacks from gozerlib.examples import examples ## callbacks def handle_outputcachepollerwave(bot, event): """ callback used in gadget polling. "...
Python
# gozerlib/plugs/reverse.py # # __copyright__ = 'this file is in the public domain' __author__ = 'Hans van Kranenburg <hans@knorrie.org>' ## gozerlib imports from gozerlib.utils.generic import waitforqueue from gozerlib.commands import cmnds from gozerlib.examples import examples ## basic imports import types de...
Python
# gozerbot/plugs/reload.py # # """ reload plugin. """ ## gozerlib imports from gozerlib.utils.exception import handle_exception from gozerlib.plugins import plugs from gozerlib.commands import cmnds from gozerlib.examples import examples from gozerlib.admin import plugin_packages from gozerlib.boot import savecmndta...
Python
# gozerlib/plugs/not.py # # """ negative grep. """ ## gozerlib imports from gozerlib.examples import examples from gozerlib.commands import cmnds from gozerlib.utils.generic import waitforqueue ## basic imports import getopt import re def handle_not(bot, ievent): """ negative grep. """ if not ievent.inque...
Python
# gozerlib/plugs/userstate.py # # """ userstate is stored in gozerdata/userstates. """ ## gozerlib imports from gozerlib.commands import cmnds from gozerlib.examples import examples from gozerlib.persiststate import UserState from gozerlib.errors import NoSuchUser ## commands def handle_userstate(bot, ievent): ...
Python
# gozerlib/plugs/welcome.py # # from gozerlib.commands import cmnds def handle_welcome(bot, event): event.reply("Welcome to FEEDPROVIDER .. The JSON everywhere bot ;] for wave/web/xmpp/IRC/console") cmnds.add('welcome', handle_welcome, ['USER', 'GUEST'])
Python
# gozerlib/plugs/grep.py # # """ grep the output of bot comamnds. """ ## gozerlib imports from gozerlib.commands import cmnds from gozerlib.utils.generic import waitforqueue from gozerlib.examples import examples ## basic imports import getopt import re def handle_grep(bot, ievent): """ <txt> .. grep the resu...
Python
# gozerlib/plugs/irc.py # # """ irc related commands. """ ## gozerbot imports from gozerlib.callbacks import callbacks from gozerlib.socket.partyline import partyline from gozerlib.commands import cmnds from gozerlib.examples import examples import gozerlib.threads as thr ## basic imports import Queue ## define ...
Python
# gozerlib/plugs/tail.py # # """ tail bot results. """ ## gozerlib imports from gozerlib.utils.generic import waitforqueue from gozerlib.commands import cmnds from gozerlib.examples import examples ## commands def handle_tail(bot, ievent): """ used in a pipeline .. show last <nr> elements. """ if not ieven...
Python
# gozerlib/plugs/count.py # # """ count number of items in result queue. """ ## gozerlib imports from gozerlib.commands import cmnds from gozerlib.utils.generic import waitforqueue from gozerlib.examples import examples def handle_count(bot, ievent): """ show nr of elements in result list. """ if not ievent...
Python
# gozerlib/plugs/uniq.py # # used in a pipeline .. unique elements """ # Wijnand 'tehmaze' Modderman - http://tehmaze.com # BSD License """ used in a pipeline .. unique elements """ __author__ = "Wijnand 'tehmaze' Modderman - http://tehmaze.com" __license__ = 'BSD' ## gozerlib imports from gozerlib.examples import ...
Python
# gozerlib/plugs/core.py # # """ core bot commands. """ ## gozerbot imports from gozerlib.utils.timeutils import elapsedstring from gozerlib.utils.generic import getversion from gozerlib.utils.exception import handle_exception from gozerlib.commands import cmnds from gozerlib.examples import examples from gozerlib.p...
Python
# plugs/choice.py # # """ the choice command can be used with a string or in a pipeline. """ ## gozerlib imports from gozerlib.utils.generic import waitforqueue from gozerlib.commands import cmnds from gozerlib.examples import examples ## basic imports import random def handle_choice(bot, ievent): """ make a ...
Python
# plugs/more.py # # """ access the output cache. """ from gozerlib.commands import cmnds from gozerlib.examples import examples def handle_less(bot, ievent): """ get entry from the output cache. """ try: if len(ievent.args) == 3: (who, index1, index2) = ievent.args elif len(ievent...
Python
# gozerlib/plugs/sort.py # # Sorting """ sort bot results. """ __author__ = "Wijnand 'maze' Modderman <http://tehmaze.com>" __license__ = "BSD" ## gozerlib imports from gozerlib.commands import cmnds from gozerlib.utils.generic import waitforqueue from gozerlib.examples import examples ## basic imports import opt...
Python
# feedprovider basic plugins # # """ register all .py files """ import os (f, tail) = os.path.split(__file__) __all__ = [] for i in os.listdir(f): if i.endswith('.py'): __all__.append(i[:-3]) elif os.path.isdir(f + os.sep + i) and not i.startswith('.'): __all__.append(i) try: __all__.re...
Python
# gozerlib/plugs/misc.py # # """ misc commands. """ ## gozerbot imports from gozerlib.utils.exception import handle_exception from gozerlib.commands import cmnds from gozerlib.examples import examples from gozerlib.persiststate import UserState ## basic imports import time import os import threading import thread ...
Python
# gozerlib/plugs/admin.py # # """ admin related commands. """ ## gozerlib imports from gozerlib.commands import cmnds from gozerlib.examples import examples from gozerlib.persist import Persist from gozerlib.boot import savecmndtable, savepluginlist, boot from gozerlib.admin import plugin_packages from gozerlib.conf...
Python
# gozerlib/persiststate.py # # """ persistent state classes. """ ## gozerlib imports from gozerlib.utils.trace import calledfrom from persist import Persist ## basic imports import types import os import sys import logging class PersistState(Persist): """ base persitent state class. """ def __init__(sel...
Python
# gozerlib/boot.py # # """ admin related data and functions. """ ## gozerlib imports from gozerlib.persist import Persist from gozerlib.plugins import plugs from gozerlib.commands import cmnds from gozerlib.admin import plugin_packages, default_plugins from gozerlib.callbacks import callbacks import admin import use...
Python
# gozerlib/commands.py # # """ commands are the first word. """ ## lib imports from utils.xmpp import stripped from utils.trace import calledfrom, whichmodule from utils.exception import handle_exception from utils.lazydict import LazyDict from errors import NoSuchCommand ## basic imports import logging import sys...
Python
# gozerlib/eggs.py # # """ eggs related functions this module is used to load the eggs on which gozerlib depends from specified dir .. most of the time this is the jsbnest dir. """ ## gozerlib imports from utils.exception import handle_exception from gozerlib.config import cfg as config ## basic im...
Python
# gozerlib/channelbase.py # # """ provide a base class for channels (waves, xmpp, web). """ ## gozerlib imports from gozerlib.utils.lazydict import LazyDict from gozerlib.persist import Persist ## basic imports import time class ChannelBase(Persist): """ Base class for all channel objects. ...
Python
# gozerlib/persist/persist.py # # """ allow data to be written to disk or BigTable in JSON format. creating the persisted object restores data. """ ## lib imports from utils.trace import whichmodule, calledfrom from utils.lazydict import LazyDict from utils.exception import handle_exception from utils.nam...
Python
# gozerlib/threadloop.py # # """ class to implement start/stoppable threads. """ ## lib imports from threads import start_new_thread ## basic imports import Queue import time import logging ## classes class ThreadLoop(object): """ implement startable/stoppable threads. """ def __init__(self, name="", que...
Python
# gozerlib/errors.py # # """ gozerlib exceptions. """ from gozerlib.utils.trace import calledfrom import sys class FeedProviderError(Exception): pass class CantSaveConfig(FeedProviderError): pass class NoOwnerSet(FeedProviderError): pass class NoSuchUser(FeedProviderError): pass class NoSuchBotTy...
Python
# gozerlib/eventbase.py # # """ base class of all events. """ ## imports from utils.lazydict import LazyDict from utils.generic import splittxt ## simplejson imports from simplejson import dumps, loads ## basic imports from xml.sax.saxutils import unescape import copy import logging ## defines cpy = copy.deep...
Python
# gozerlib/tasks.py # # ## gozerlib imports from gozerlib.utils.trace import calledfrom from gozerlib.plugins import plugs ## basic imports import logging import sys class Task(object): def __init__(self, name, func): self.name = name self.func = func def handle(self, *args, **kwargs): ...
Python
# gozerlib/users.py # # """ bot's users in JSON file. NOT USED AT THE MOMENT. """ ## lib imports from utils.exception import handle_exception, exceptionmsg from utils.generic import stripped from persist import Persist from utils.lazydict import LazyDict from datadir import datadir from config import cfg as maincon...
Python
#!/usr/bin/env python """Universal feed parser Handles RSS 0.9x, RSS 1.0, RSS 2.0, CDF, Atom 0.3, and Atom 1.0 feeds Visit http://feedparser.org/ for the latest version Visit http://feedparser.org/docs/ for the latest documentation Required: Python 2.1 or later Recommended: Python 2.3 or later Recommended: CJKCodecs...
Python
# gozerlib/plugins.py # # """ holds all the plugins. plugins are imported modules. """ ## lib imports from commands import cmnds from eventbase import EventBase from persist import Persist from utils.lazydict import LazyDict from utils.exception import handle_exception from admin import cmndtable from errors import ...
Python
# gozerlib/runner.py # # """ threads management to run jobs. """ __copyright__ = 'this file is in the public domain' ## gozerlib imports from gozerlib.threads import getname, start_new_thread from gozerlib.utils.exception import handle_exception from gozerlib.utils.locking import lockdec from gozerlib.threadloop im...
Python
# gozerlib/datadir.py # # """ the datadir of the bot. """ ## basic imports import re import os ## define datadir = 'gozerdata' ## functions def makedirs(ddir=None): """ make subdirs in datadir. users, db, fleet, pgp, plugs and old. """ ddir = ddir or datadir curdir = os.getcwd() if not os.path...
Python
# gozerlib/jsbimport.py # # """ use the imp module to import modules. """ import time import sys import imp import os import thread import logging def _import(name): mods = [] mm = "" for m in name.split('.'): mm += m mods.append(mm) mm += "." for mod in mods: logging...
Python
# gozerlib/botbase.py # # """ base class for all bots. """ ## lib imports from utils.lazydict import LazyDict from plugins import plugs as coreplugs from callbacks import callbacks, gn_callbacks from eventbase import EventBase from errors import NoSuchCommand, PlugsNotConnected, NoOwnerSet from datadir import datadi...
Python
# gozerlib package # # """ gozerlib core package. """ __version__ = "0.2.1" __all__ = ['persistconfig', 'rest', 'jsbimport', 'admin', 'boot', 'botbase', 'callbacks', 'channelbase', 'commands', 'config', 'contrib', 'datadir', 'eggs', 'errors', 'eventbase', 'examples', 'fleet', 'gae', 'gozernet', 'less', 'monitor', 'o...
Python
# gozerlib/less.py # # """ maintain bot output cache. """ # gozerlib imports from utils.limlist import Limlist class Less(object): """ output cache .. caches upto <nr> item of txt lines per nick. :param nr: size of backlog :type nr: integer """ def __init__(self, nr): ...
Python
# gozerlib/examples.py # # """ examples is a dict of example objects. """ ## basic imports import re class Example(object): """ an example. :param descr: description of the example :type descr: string :param ex: the example :type ex: string """ def __init__(se...
Python
# gozerlib/callbacks.py # # """ bot callbacks .. callbacks occure on registered events. a precondition function can optionaly be provided to see if the callback should fire. """ ## gozerlib imports from threads import getname from utils.exception import handle_exception from utils.trace import calledfro...
Python
# gozerlib/admin.py # # """ admin related data and functions. """ ## gozerlib imports from gozerlib.persist import Persist ## defines plugin_packages = ['gozerlib.plugs', 'commonplugs', 'myplugs', 'waveplugs', 'socketplugs'] default_plugins = ['gozerlib.plugs.admin', ] loaded = False cmndtable = None pluginlist ...
Python
''' Created on 10/01/2011 @author: jguerrer ''' class Vertex: ''' classdocs ''' def __init__(self, id , coords , incidentEdge): ''' Constructor ''' #print "VErtice: " + id + " " + str(coords) self.id = id; self.coords = coords; ...
Python
""" GM1050 Advanced Principles and Algorithm of GIS 2010/2011 - Mini Project - The simplification of a map A shapefile of departments in western Europe is given. By the Douglas-Peuker algorithm this shapefile is simplified. Where several topological relations should remain @author: Bas, Josafat and Elise ...
Python
""" GM1050 Advanced Principles and Algorithm of GIS 2010/2011 - Mini Project - The simplification of a map A shapefile of departments in western Europe is given. By the Douglas-Peuker algorithm this shapefile is simplified. Where several topological relations should remain @author: Bas, Josafat and Elise ...
Python
''' Created on 05/01/2011 @author: Josafat Guerrero josafatisai@gmail.com ''' import math from Face import Face from Vertex import Vertex from HalfEdge import HalfEdge from shapely.coords import CoordinateSequence from spyderlib.widgets.editortools import EdgeLine #-- OGR try: from osgeo ...
Python
import os import sys #-- general import import os #-- OGR try: from osgeo import ogr except ImportError: import ogr #-- Shapely from shapely.wkb import loads as wkbloads from shapely.wkt import loads as wktloads from shapely.geometry import Point, LineString, Polygon from shapely.ops import ...
Python
''' Created on 10/01/2011 @author: jguerrer ''' class Face(object): ''' classdocs name is a plain string outhercomponent is also a plain string innercomponent is an innerstring ''' def __init__(self, id, outerCompoment , innerComponents): ''' ...
Python
''' Created on 10/01/2011 @author: jguerrer ''' class HalfEdge(object): ''' classdocs ''' def __init__(self,id,origin, twin, incidentFace,next,prev,end): ''' Constructor ''' self.id=id self.origin = origin self.twin = twin ...
Python
""" GM1050 Advanced Principles and Algorithm of GIS 2010/2011 - Mini Project - The simplification of a map A shapefile of departments in western Europe is given. By the Douglas-Peuker algorithm this shapefile is simplified. Where several topological relations should remain @author: Bas, Josafat and Elise ...
Python
import math def simplify_points (pts, tolerance): anchor = 0 floater = len(pts) - 1 size = math.ceil(len(pts)*tolerance) stack = [] keep = set() stack.append((anchor, floater)) if pts[0] == pts[-1]: if len(pts) <= 3: return pts else: ...
Python
# pure-Python Douglas-Peucker line simplification/generalization # # this code was written by Schuyler Erle <schuyler@nocat.net> and is # made available in the public domain. # # the code was ported from a freely-licensed example at # http://www.3dsoftware.com/Cartography/Programming/PolyLineReduction/ # # ...
Python
#!/cygdrive/c/Python27/python import feedparser import urllib2 import codecs import sqlite3 import datetime import sys from wx import Frame, DefaultPosition, Size, Menu, MenuBar, App, grid from wx import EVT_MENU, EVT_CLOSE from twisted.python import log from twisted.internet import wxreactor wxreactor...
Python
#!/cygdrive/c/Python27/python import sys, os from twisted.internet import wxreactor wxreactor.install () from twisted.internet import reactor, defer from twisted.python import log import wx # not sure why i can't go wx.grid, but here we are from wx import grid ID_EXIT = 101 ID_DOWNLOAD = 102 class Fra...
Python
#!/usr/bin/python import os def main(): lists = [ "ISODrivers/Galaxy/galaxy.prx", "ISODrivers/March33/march33.prx", "ISODrivers/March33/march33_620.prx", "ISODrivers/Inferno/inferno.prx", "Popcorn/popcorn.prx", "Satelite/satelite.prx", "Stargate/stargate.prx", "SystemControl/systemctrl.prx", ...
Python
#!/usr/bin/python class FakeTime: def time(self): return 1225856967.109 import os, gzip, StringIO gzip.time = FakeTime() def create_gzip(input, output): f_in=open(input, 'rb') temp=StringIO.StringIO() f=gzip.GzipFile(fileobj=temp, mode='wb') f.writelines(f_in) f.close() f_in.close() fout=open(out...
Python
#!/usr/bin/python from hashlib import * import sys, struct def sha512(psid): if len(psid) != 16: return "".encode() for i in range(512): psid = sha1(psid).digest() return psid def get_psid(str): if len(str) != 32: return "".encode() b = "".encode() for i in range(0, len(str), 2): b += struct.pack('B...
Python
#!/usr/bin/python import sys, hashlib def toNID(name): hashstr = hashlib.sha1(name.encode()).hexdigest().upper() return "0x" + hashstr[6:8] + hashstr[4:6] + hashstr[2:4] + hashstr[0:2] if __name__ == "__main__": assert(toNID("sceKernelCpuSuspendIntr") == "0x092968F4") for name in sys.argv[1:]: print ("%s: %s"...
Python
#!/usr/bin/python """ pspbtcnf_editor: An script that add modules from pspbtcnf """ import sys, os, re from getopt import * from struct import * BTCNF_MAGIC=0x0F803001 verbose = False def print_usage(): print ("%s: pspbtcnf.bin [-o output.bin] [-a add_module_name:before_module_name:flag]" %(os.path...
Python
#!/usr/bin/python class FakeTime: def time(self): return 1225856967.109 import sys, os, struct, gzip, hashlib, StringIO gzip.time = FakeTime() def binary_replace(data, newdata, offset): return data[0:offset] + newdata + data[offset+len(newdata):] def prx_compress(output, hdr, input, mod_name="", mod_a...
Python
# coding: utf-8 from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.support.wait import WebDriverWait import unit...
Python
from django.db import models from apps.common.models import CommonItem # Create your models here. class Post(CommonItem): title = models.CharField(max_length=90) slug = models.SlugField(max_length=40) body = models.TextField() @models.permalink def get_absolute_url(self): return ('post_view', (), { '...
Python
""" This file demonstrates writing tests using the unittest module. These will pass when you run "manage.py test". Replace this with more appropriate tests for your application. """ from django.test import TestCase class SimpleTest(TestCase): def test_basic_addition(self): """ Tests that 1 + 1 a...
Python
from django.contrib.syndication.views import Feed from django.contrib.sites.models import Site class BlogFeed(Feed): title = str(Site.objects.get_current().name) link = '/' description = 'The latest stories from ' + title def items(self): # Import needs to be inside due to dependency issue from feedbag.app...
Python
# Create your views here. from django.http import HttpResponse from django.shortcuts import render_to_response from django.template import RequestContext def blog(request): return render_to_response('blog.html', {}, context_instance=RequestContext(request)) def post(request, year, month, day, sl...
Python
from feedbag.apps.blog.models import Post from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap def post_sitemap(): info_dict = { 'queryset': Post.objects.all(), 'date_field': 'created_at', } return GenericSitemap(info_dict, priority=0.6)
Python
from django.contrib import admin from django.db import models from feedbag.apps.blog.models import Post, Comment class PostAdmin(admin.ModelAdmin): ordering = ('-created_at', 'id') prepopulated_fields = {"slug": ("title",)} admin.site.register(Post, PostAdmin) class CommentAdmin(admin.ModelAdmin): ordering ...
Python