code
stringlengths
1
1.72M
language
stringclasses
1 value
# -*- coding: utf-8 -*- """ jinja2.exceptions ~~~~~~~~~~~~~~~~~ Jinja exceptions. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ class TemplateError(Exception): """Baseclass for all template errors.""" def __init__(self, message=None): i...
Python
# -*- coding: utf-8 -*- """ jinja2.environment ~~~~~~~~~~~~~~~~~~ Provides a class that holds runtime and parsing time options. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ import os import sys from jinja2 import nodes from jinja2.defaults import * from ...
Python
# -*- coding: utf-8 -*- """ jinja2 ~~~~~~ Jinja2 is a template engine written in pure Python. It provides a Django inspired non-XML syntax but supports inline expressions and an optional sandboxed environment. Nutshell -------- Here a small example of a Jinja2 template:: {% ...
Python
# -*- coding: utf-8 -*- """ jinja2.filters ~~~~~~~~~~~~~~ Bundled jinja filters. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ import re import math from random import choice from operator import itemgetter from itertools import imap, groupby from jinja2....
Python
# -*- coding: utf-8 -*- """ jinja2.defaults ~~~~~~~~~~~~~~~ Jinja default filters and tags. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ from jinja2.utils import generate_lorem_ipsum, Cycler, Joiner # defaults for the parser / lexer BLOCK_START_STRING ...
Python
# -*- coding: utf-8 -*- """ jinja2._stringdefs ~~~~~~~~~~~~~~~~~~ Strings of all Unicode characters of a certain category. Used for matching in Unicode-aware languages. Run to regenerate. Inspired by chartypes_create.py from the MoinMoin project, original implementation from Pygments. :co...
Python
# -*- coding: utf-8 -*- """ jinja2.parser ~~~~~~~~~~~~~ Implements the template parser. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ from jinja2 import nodes from jinja2.exceptions import TemplateSyntaxError, TemplateAssertionError from jinja2.utils impo...
Python
# -*- coding: utf-8 -*- """ jinja2.visitor ~~~~~~~~~~~~~~ This module implements a visitor for the nodes. :copyright: (c) 2010 by the Jinja Team. :license: BSD. """ from jinja2.nodes import Node class NodeVisitor(object): """Walks the abstract syntax tree and call visitor functions for every...
Python
"""A fast, lightweight, and secure session WSGI middleware for use with GAE.""" from Cookie import CookieError, SimpleCookie from base64 import b64decode, b64encode import datetime import hashlib import hmac import logging import pickle import os import threading import time from google.appengine.api import memcache f...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Bottle is a fast and simple micro-framework for small web applications. It offers request dispatching (Routes) with url parameter support, templates, a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and template engines - all in a single file an...
Python
''' Module which prompts the user for translations and saves them. TODO: implement @author: Rodrigo Damazio ''' class Translator(object): ''' classdocs ''' def __init__(self, language): ''' Constructor ''' self._language = language def Translate(self, string_names): print string_names
Python
''' Module which brings history information about files from Mercurial. @author: Rodrigo Damazio ''' import re import subprocess REVISION_REGEX = re.compile(r'(?P<hash>[0-9a-f]{12}):.*') def _GetOutputLines(args): ''' Runs an external process and returns its output as a list of lines. @param args: the argume...
Python
''' Module which parses a string XML file. @author: Rodrigo Damazio ''' from xml.parsers.expat import ParserCreate import re #import xml.etree.ElementTree as ET class StringsParser(object): ''' Parser for string XML files. This object is not thread-safe and should be used for parsing a single file at a time...
Python
#!/usr/bin/python ''' Entry point for My Tracks i18n tool. @author: Rodrigo Damazio ''' import mytracks.files import mytracks.translate import mytracks.validate import sys def Usage(): print 'Usage: %s <command> [<language> ...]\n' % sys.argv[0] print 'Commands are:' print ' cleanup' print ' translate' p...
Python
''' Module which compares languague files to the master file and detects issues. @author: Rodrigo Damazio ''' import os from mytracks.parser import StringsParser import mytracks.history class Validator(object): def __init__(self, languages): ''' Builds a strings file validator. Params: @para...
Python
''' Module for dealing with resource files (but not their contents). @author: Rodrigo Damazio ''' import os.path from glob import glob import re MYTRACKS_RES_DIR = 'MyTracks/res' ANDROID_MASTER_VALUES = 'values' ANDROID_VALUES_MASK = 'values-*' def GetMyTracksDir(): ''' Returns the directory in which the MyTrac...
Python
import sys import yaml import hashlib NS = 'Emitter' DEFINE = 'YAML_GEN_TESTS' EVENT_COUNT = 5 def encode_stream(line): for c in line: if c == '\n': yield '\\n' elif c == '"': yield '\\"' elif c == '\t': yield '\\t' elif ord(c) < 0x20: ...
Python
#!/usr/bin/python import xml.parsers.expat; import sys; import re; parser=xml.parsers.expat.ParserCreate('UTF-8'); values_en = {} values_lang = {} values_hash = {} name='' def parse(lang, values): def start_element(n, attrs): global name; if n != u'string': return name=attrs[u'name'] def end_element(...
Python
#==================================================================== # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you ...
Python
# distutils build script # To install fuse-python, run 'python setup.py install' # This setup.py based on that of shout-python (py bindings for libshout, # part of the icecast project, http://svn.xiph.org/icecast/trunk/shout-python) try: from setuptools import setup from setuptools.dist import Distribution ex...
Python
# # Copyright (C) 2006 Csaba Henk <csaba.henk@creo.hu> # # This program can be distributed under the terms of the GNU LGPL. # See the file COPYING. # from optparse import Option, OptionParser, OptParseError, OptionConflictError from optparse import HelpFormatter, IndentedHelpFormatter, SUPPRESS_HELP from fu...
Python
try: set() set = set except: from sets import Set as set
Python
__version__ = "0.2.1"
Python
# # Copyright (C) 2001 Jeff Epler <jepler@unpythonic.dhs.org> # Copyright (C) 2006 Csaba Henk <csaba.henk@creo.hu> # # This program can be distributed under the terms of the GNU LGPL. # See the file COPYING. # # suppress version mismatch warnings try: import warnings warnings.filterwarnings('i...
Python
#!/usr/bin/env python import os, sys from errno import * from stat import * import fcntl try: import _find_fuse_parts except ImportError: pass import fuse from fuse import Fuse if not hasattr(fuse, '__version__'): raise RuntimeError, \ "your fuse-py doesn't know of fuse.__version__, probably it's...
Python
#!/usr/bin/env python # PermFS - A file system for privilege separation # Copyright (C) 2011 dionescu, usmanm # import os, stat, errno, sys import datetime import shutil import fcntl import gi, perm import subprocess # Pull in some spaghetti to make this stuff work # without fuse-py being installed try: im...
Python
#!/usr/bin/env python import os, sys from errno import * from stat import * import fcntl try: import _find_fuse_parts except ImportError: pass import fuse from fuse import Fuse if not hasattr(fuse, '__version__'): raise RuntimeError, \ "your fuse-py doesn't know of fuse.__version__, probably it's...
Python
# GID Importer for UIDs for PermFS import pwd GROUPPATH = '/etc/group' CACHE = False class GIDImporter: def __init__(self): self.group = open(GROUPPATH, 'r') if CACHE: self.gidmap = self.get_all_gids() def close(self): self.group.close() def get_all_gids(self): ...
Python
import sys import ply.yacc as yacc import ply.lex as lex sys.path.insert(0,"../..") names = { } result = None error = False tokens = ( 'NAME','BOOLEAN' ) literals = ['&','|','=','!','(',')'] # Tokens t_NAME = r'[ug]\d+' t_BOOLEAN = r'[01]' t_ignore = " \t" def t_newline(t): r'\n+' t.lexer.lineno...
Python
#!/usr/bin/env python # PermFS - A file system for privilege separation # Copyright (C) 2011 dionescu, usmanm # import os, stat, errno, sys import datetime import shutil import fcntl import gi, perm import subprocess # Pull in some spaghetti to make this stuff work # without fuse-py being installed try: im...
Python
#!/usr/bin/env python import time import random LFSFS = '/home/usmanm/fuse' FUSEFS = '/home/usmanm/xmp/home/usmanm' EXT3FS = '/home/usmanm/local' NOOFBYTES = 100000 NOOFITER = 1000 def create_files(): f_lfs = open(LFSFS + '/hello', 'w') f_fuse = open(FUSEFS + '/hello', 'w') f_ext3 = open(EXT3FS + '/hell...
Python
#!/usr/bin/env python import time import random import os LFSFS = '/home/usmanm/fuse' FUSEFS = '/home/usmanm/xmp/home/usmanm' EXT3FS = '/home/usmanm/local' NOOFDIRS = 1000 def main(): start = time.time() for j in range(NOOFDIRS): os.mkdir(LFSFS + '/dir' + str(j)) print 'LFS mkdir: ' + str(time.t...
Python
#!/usr/bin/env python import time import random import os LFSFS = '/home/usmanm/fuse' FUSEFS = '/home/usmanm/xmp/home/usmanm' EXT3FS = '/home/usmanm/local' NOOFDIRS = 1000 def main(): start = time.time() for j in range(NOOFDIRS): os.mkdir(LFSFS + '/dir' + str(j)) print 'LFS mkdir: ' + str(time.t...
Python
#!/usr/bin/env python import time import random LFSFS = '/home/usmanm/fuse' FUSEFS = '/home/usmanm/xmp/home/usmanm' EXT3FS = '/home/usmanm/local' NOOFBYTES = 100000 NOOFITER = 1000 def create_files(): f_lfs = open(LFSFS + '/hello', 'w') f_fuse = open(FUSEFS + '/hello', 'w') f_ext3 = open(EXT3FS + '/hell...
Python
import sys, os, glob from os.path import realpath, dirname, join from traceback import format_exception ddd = realpath(join(dirname(sys.argv[0]), '..')) for d in [ddd, '.']: for p in glob.glob(join(d, 'build', 'lib.*')): sys.path.insert(0, p) try: import fuse except ImportError: raise RuntimeErr...
Python
# DB API for PermFS import os, pg, solver, stat CREATE_TABLE = 'create table %(tname)s \ (fs text NOT NULL, \ path text NOT NULL, \ mode integer NOT NULL, \ uid integer NOT NULL, \ gid integer NOT NULL, \ r text, \ w text, \ x text, \ p text, \ PRIMARY KEY (fs, path));' class Perm: def __init__(self, fsname): ...
Python
#!/usr/bin/env python import sys from pprint import pprint from rdflib.Namespace import Namespace from rdflib import plugin, RDF, RDFS, URIRef, ConjunctiveGraph from rdflib.store import Store from rdflib.Graph import Graph from rdflib.syntax.NamespaceManager import NamespaceManager from FuXi.Rete import ReteNetwork f...
Python
import unittest from rdflib.Graph import Graph, ConjunctiveGraph from FuXi.Horn.HornRules import HornFromN3 from rdflib import plugin, Namespace, RDF, Variable, Literal from cStringIO import StringIO from FuXi.Rete.Util import generateTokenSet from FuXi.Rete.RuleStore import SetupRuleStore FOAF = Namespace('http://xml...
Python
import unittest from pprint import pprint from rdflib.Graph import Graph, ConjunctiveGraph from FuXi.Horn.HornRules import HornFromN3 from rdflib import plugin, Namespace, RDF, Variable, Literal, URIRef from cStringIO import StringIO from FuXi.Rete.Util import generateTokenSet from FuXi.DLP import non_DHL_OWL_Semantics...
Python
#!/usr/bin/env python ''' Created on Sep 16, 2010 @author: onewnan Run all FuXi tests. Note the discovery mechanisms require sources on the python path. If a coverage tool is installed this module can help generate coverage statistics, e.g., coverage erase coverage run --branch --source="FuXi" suite.py -...
Python
import unittest, os, time, sys from cStringIO import StringIO from rdflib import RDF, URIRef from FuXi.Rete import * from FuXi.Rete.RuleStore import N3RuleStore, SetupRuleStore from FuXi.Rete.Util import renderNetwork, generateTokenSet from FuXi.Horn.PositiveConditions import Uniterm, BuildUnitermFromTuple from ...
Python
#!/bin/env python import unittest from FuXi.Syntax.InfixOWL import * from FuXi.Rete.Network import ReteNetwork from FuXi.Rete.RuleStore import SetupRuleStore from FuXi.DLP import SKOLEMIZED_CLASS_NS from rdflib import Namespace from rdflib.Graph import Graph EX = Namespace('http://example.com#') class UnionSkolemized...
Python
from pprint import pprint, pformat from FuXi.Rete import * from FuXi.Syntax.InfixOWL import * from FuXi.Rete.AlphaNode import SUBJECT,PREDICATE,OBJECT,VARIABLE from FuXi.Rete.BetaNode import LEFT_MEMORY,RIGHT_MEMORY from FuXi.Rete.RuleStore import N3RuleStore, SetupRuleStore from FuXi.Rete.Util import renderNetwork,gen...
Python
""" FuXi Harness for W3C SPARQL1.1 Entailment Evaluation Tests """ import unittest from pprint import pprint from urllib2 import urlopen from FuXi.Rete.RuleStore import SetupRuleStore from FuXi.Horn.HornRules import HornFromN3 from FuXi.Rete.Proof import ImmutableDict from FuXi.SPARQL.BackwardChainingStore import * fr...
Python
import sys, unittest, copy from rdflib.Graph import Graph from rdflib.util import first from rdflib import RDF, RDFS, Namespace, Variable, Literal, URIRef, BNode from rdflib.syntax.NamespaceManager import NamespaceManager from FuXi.Rete.RuleStore import N3RuleStore,SetupRuleStore from FuXi.Rete import ReteNetwork from ...
Python
import ez_setup ez_setup.use_setuptools() from setuptools import setup setup(name="FuXi", version="1.3", description="An OWL / N3-based in-memory, logic reasoning system for RDF", author="Chime Ogbuji", author_email="chimezie@gmail.com", package_dir = { 'FuXi': 'lib', }, ...
Python
#!python """Bootstrap setuptools installation If you want to use setuptools in your package's setup.py, just include this file in the same directory with it, and add this to the top of your setup.py:: from ez_setup import use_setuptools use_setuptools() If you want to require a specific version of setuptools...
Python
""" """ class Node(object): """ A node in a Rete network. Behavior between Alpha and Beta (Join) nodes """ def updateDescendentMemory(self,memory): if memory.successor not in [mem.successor for mem in self.descendentMemory]: self.descendentMemory.append(memory) def con...
Python
""" See: http://www.w3.org/2000/10/swap/doc/CwmBuiltins """ import unittest, os, time, sys from cStringIO import StringIO from rdflib import Namespace, Variable, Literal, URIRef from rdflib.Graph import Graph,ReadOnlyGraphAggregate,ConjunctiveGraph from rdflib.util import first STRING_NS = Namespace("http://www.w3.org/...
Python
""" Utility functions for a Boost Graph Library (BGL) DiGraph via the BGL Python Bindings """ import itertools, pickle from FuXi.Rete.AlphaNode import AlphaNode from rdflib.Graph import Graph from rdflib.syntax.NamespaceManager import NamespaceManager from rdflib import BNode, Namespace, Collection, Variable, U...
Python
#!/usr/bin/env python # encoding: utf-8 """ Implementation of Sideways Information Passing graph (builds it from a given ruleset) """ import unittest, os, sys, itertools try: from hashlib import md5 as createDigest except: from md5 import new as createDigest from FuXi.Horn.PositiveConditions import * from FuX...
Python
#!/usr/bin/env python from pprint import pprint from FuXi.Rete.Proof import GenerateProof from FuXi.Rete import ReteNetwork from FuXi.Rete.AlphaNode import SUBJECT,PREDICATE,OBJECT,VARIABLE from FuXi.Rete.BetaNode import PartialInstanciation, LEFT_MEMORY, RIGHT_MEMORY from FuXi.Rete.RuleStore import N3RuleStore, SetupR...
Python
from __future__ import generators import sys from rdflib import BNode, RDF, Namespace, Variable from rdflib.store import Store,VALID_STORE, CORRUPTED_STORE, NO_STORE, UNKNOWN from rdflib.Literal import Literal from pprint import pprint from rdflib.syntax.NamespaceManager import NamespaceManager from rdflib.term_utils i...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Implements a Sip-Strategy formed from a basic graph pattern and a RIF-Core ruleset as a series of top-down derived SPARQL evaluations against a fact graph, generating a walk through the proof space in the process. Native Prolog-like Python implementation for RIF-Core,...
Python
from Network import ReteNetwork, InferredGoal from BetaNode import BetaNode from AlphaNode import AlphaNode,ReteToken,BuiltInAlphaNode from ReteVocabulary import RETE_NS
Python
""" http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/492216 Iterator algebra implementations of join algorithms: hash join, merge join, and nested loops join, as well as a variant I dub "bisect join". Requires Python 2.4. Author: Jim Baker, jbaker@zyasoft.com """ import operator def identity(x): """x -...
Python
""" """ from RuleStore import N3Builtin from rdflib import Variable, BNode,RDF,Variable,Literal,RDFS, URIRef, Namespace from rdflib.Graph import Graph from ReteVocabulary import RETE_NS from Node import Node OWL_NS = Namespace("http://www.w3.org/2002/07/owl#") SUBJECT = 0 PREDICATE = 1 OBJECT = 2 VARIABLE =...
Python
#!/usr/local/bin/python # -*- coding: utf-8 -*- """ Proof Markup Language Construction: Proof Level Concepts (Abstract Syntax) A set of Python objects which create a PML instance in order to serialize as OWL/RDF """ try: import boost.graph as bgl bglGraph = bgl.Digraph() except: try: from pydo...
Python
""" Implements the behavior associated with the 'join' (Beta) node in a RETE network: - Stores tokens in two memories - Tokens in memories are checked for consistent bindings (unification) for variables in common *across* both - Network 'trigger' is propagated downward This reference implementation fol...
Python
""" A Rete Network Building and 'Evaluation' Implementation for RDFLib Graphs of Notation 3 rules. The DLP implementation uses this network to automatically building RETE decision trees for OWL forms of DLP Uses Python hashing mechanism to maximize the efficiency of the built pattern network. The network : - comp...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- """ [[[ One method, called magic sets,is a general algorithm for rewriting logical rules so that they may be implemented bottom-UP (= forward chaining) in a way that is that by working bottom-up, we can take advantage of efficient methods for doing massive joins. ]]] --...
Python
from rdflib import Namespace RETE_NS = Namespace("http://metacognition.info/ontologies/ReteVocabulary.owl#")
Python
import itertools from FuXi.Rete.Proof import * from rdflib import RDFS, RDF, Variable from rdflib.util import first from rdflib.store import Store from rdflib.store.REGEXMatching import NATIVE_REGEX from rdflib.sparql.Algebra import * from rdflib.sparql.graphPattern import BasicGraphPattern from rdflib.sparql.bison.Que...
Python
import copy from itertools import chain, takewhile from FuXi.Horn.PositiveConditions import QNameManager,SetOperator, Condition, Or, And, Uniterm, BuildUnitermFromTuple from FuXi.Rete.RuleStore import N3Builtin from FuXi.Rete.Util import selective_memoize from FuXi.Rete.RuleStore import * from FuXi.Rete.Proof import Im...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- """ RDFLib Python binding for OWL Abstract Syntax see: http://www.w3.org/TR/owl-semantics/syntax.html http://owl-workshop.man.ac.uk/acceptedLong/submission_9.pdf 3.2.3 Axioms for complete classes without using owl:equivalentClass Named class description of type 2 ...
Python
#!/usr/local/bin/python # -*- coding: utf-8 -*- """ Stratified Negation Semantics for DLP using SPARQL to handle the negation """ from pprint import pprint from rdflib.Graph import Graph from rdflib.util import first from rdflib import RDF, RDFS, Namespace, Variable, Literal, URIRef, BNode from rdflib.syntax.NamespaceM...
Python
#-- """ Solution: Unadorned: Query: rdfs:subClassOf_bf(KneeJoint,?Class) Query fact: rdfs:subClassOf_derived_query_bf(KneeJoint) 7. Forall ?C3 ?C2 ?C1 ( rdfs:subClassOf_derived_bf(?C1 ?C3) :- And( rdfs:subClassOf_derived_bf(?C1 ?C2) rdfs:subClassOf_derived_bf(?C2 ?C3) ) ) ...
Python
#!/usr/local/bin/python # -*- coding: utf-8 -*- """ """ import copy, warnings from rdflib import BNode, RDF, Namespace, Variable, RDFS from FuXi.Horn.PositiveConditions import And, Or, Uniterm, PredicateExtentFactory, SetOperator,Exists def HasNestedConjunction(conjunct): rt=False for item in conjunct: ...
Python
#!/usr/bin/env python # encoding: utf-8 """ Helper Functions for reducing DL axioms into a normal forms """ from cStringIO import StringIO from rdflib.Graph import Graph from rdflib.util import first from rdflib import URIRef, RDF, RDFS, Namespace, Variable, Literal, URIRef, BNode from rdflib.syntax.NamespaceManager im...
Python
#!/usr/local/bin/python # -*- coding: utf-8 -*- """ This module implements a Description Horn Logic implementation as defined by Grosof, B. et.al. ("Description Logic Programs: Combining Logic Programs with Description Logic" [1]) in section 4.4. As such, it implements recursive mapping functions "T", "Th" and "Tb" w...
Python
from FuXi.Syntax.InfixOWL import OWL_NS from cStringIO import StringIO from FuXi.Horn.HornRules import Clause, Ruleset, Rule, HornFromN3 from rdflib import URIRef, RDF, RDFS, Namespace, Variable, Literal, URIRef LIST_MEMBERSHIP_SEMANTICS=\ """ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. @prefix list: <...
Python
#!/usr/local/bin/python # -*- coding: utf-8 -*- """ The language of positive RIF conditions determines what can appear as a body (the if-part) of a rule supported by the basic RIF logic. As explained in Section Overview, RIF's Basic Logic Dialect corresponds to definite Horn rules, and the bodies of such rules are...
Python
#!/usr/local/bin/python # -*- coding: utf-8 -*- """ This section defines Horn rules for RIF Phase 1. The syntax and semantics incorporates RIF Positive Conditions defined in Section Positive Conditions """ import itertools from FuXi.Horn.PositiveConditions import * from FuXi.Horn import DATALOG_SAFETY_NONE,DATALOG_SAF...
Python
import unittest, os, time, sys from FuXi.Syntax.InfixOWL import * from rdflib import plugin,RDF,RDFS,URIRef,URIRef,Literal,Variable from rdflib.util import first from rdflib.store import Store from cStringIO import StringIO from rdflib.Graph import Graph,ReadOnlyGraphAggregate,ConjunctiveGraph from rdflib.syntax.Namesp...
Python
#!/usr/bin/env python # encoding: utf-8 """ BackwardFixpointProcedure.py .. A sound and complete query answering method for recursive databases based on meta-interpretation called Backward Fixpoint Procedure .. Uses RETE-UL as the RIF PRD implementation of a meta-interpreter of an adorned ruleset that builds large, c...
Python
import doctest from rdflib.Graph import Graph from rdflib import RDF, URIRef, Namespace, Literal, BNode def IdentifyHybridPredicates(graph,derivedPredicates): """ Takes an RDF graph and a list of derived predicates and return those predicates that are both EDB (extensional) and IDB (intensional) predicates...
Python
#!/usr/bin/env python # encoding: utf-8 """ testSeralizationOfEval.py Created by Chimezie Ogbuji on 2010-08-15. Copyright (c) 2010 __MyCompanyName__. All rights reserved. """ import sys, os, unittest from BackwardFixpointProcedure import BFP_RULE, BFP_NS from FuXi.Horn.PositiveConditions import Uniterm from FuXi.Horn...
Python
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python
#!/usr/bin/python import os import subprocess import sys BASEDIR = '../main/src/com/joelapenna/foursquare' TYPESDIR = '../captures/types/v1' captures = sys.argv[1:] if not captures: captures = os.listdir(TYPESDIR) for f in captures: basename = f.split('.')[0] javaname = ''.join([c.capitalize() for c in basena...
Python
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
Python
# Run from the commandline: # # python server.py # POST audio to http://localhost:9000 # GET audio from http://localhost:9000 # # A simple server to collect audio using python. To be more secure, # you might want to check the file names and place size restrictions # on the incoming data. import cgi from BaseHTTPSe...
Python
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python
#!/usr/bin/python import os import subprocess import sys BASEDIR = '../main/src/com/joelapenna/foursquare' TYPESDIR = '../captures/types/v1' captures = sys.argv[1:] if not captures: captures = os.listdir(TYPESDIR) for f in captures: basename = f.split('.')[0] javaname = ''.join([c.capitalize() for c in basena...
Python
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
Python
# # Run the build process by entering 'setup.py py2exe' or # 'python setup.py py2exe' in a console prompt. # # If everything works well, you should find a subdirectory named 'dist' # containing some files, among them hello.exe and test_wx.exe. from distutils.core import setup from glob import glob import py2exe impor...
Python
#!/usr/bin/env python from gradelib import * r = Runner(save("jos.out"), stop_breakpoint("cons_getc")) @test(10, "PTE_SHARE [testpteshare]") def test_pte_share(): r.user_test("testpteshare") r.match('fork handles PTE_SHARE right', 'spawn handles PTE_SHARE right') @test(20, "start the ...
Python
#!/usr/bin/env python import re from gradelib import * r = Runner(save("jos.out"), stop_breakpoint("readline")) def E(s, trim=False): """Expand $En in s to the environment ID of the n'th user environment, accounting for idle environments.""" tmpl = "%x" if trim else "%08x" return re.sub(r...
Python
#!/usr/bin/env python import re from gradelib import * r = Runner(save("jos.out"), stop_breakpoint("readline")) @test(0, "running JOS") def test_jos(): r.run_qemu() @test(20, parent=test_jos) def test_printf(): r.match("6828 decimal is 15254 octal!") BACKTRACE_RE = r"^ *ebp +f01[0-9a-z]{5} +eip ...
Python
import sys, os, re, time, socket, select, subprocess, errno, shutil from subprocess import check_call, Popen from optparse import OptionParser __all__ = [] ################################################################## # Test structure # __all__ += ["test", "end_part", "run_tests", "get_current_test"] TESTS = [...
Python
#!/usr/bin/env python import os, re, threading, socket, time, urllib2, shutil, struct, difflib from gradelib import * r = Runner(save("jos.out"), stop_breakpoint("readline")) def match_packet_seq(got, expect): s = difflib.SequenceMatcher(None, got, [d for n, d in expect]) msgs, bad = [], False ...
Python
#!/usr/bin/env python from gradelib import * r = Runner(save("jos.out"), stop_breakpoint("readline")) @test(0, "running JOS") def test_jos(): r.run_qemu() @test(20, "Physical page allocator", parent=test_jos) def test_check_page_alloc(): r.match(r"check_page_alloc\(\) succeeded!") @test(20, "Pag...
Python
#!/usr/bin/env python from gradelib import * r = Runner(save("jos.out"), stop_breakpoint("readline")) @test(10) def test_divzero(): r.user_test("divzero") r.match('Incoming TRAP frame at 0xefbfff..', 'TRAP frame at 0xf.......', ' trap 0x00000000 Divide error', ...
Python
#!/usr/bin/env python from gradelib import * r = Runner(save("jos.out"), stop_breakpoint("readline")) def matchtest(parent, name, *args, **kw): def do_test(): r.match(*args, **kw) test(5, name, parent=parent)(do_test) @test(0, "internal FS tests [fs/test.c]") def test_fs(): r.user_tes...
Python
import os, time class MyException(Exception): pass def passing(*args): pass def sleeping(s): seconds = s while seconds > 0: time.sleep(min(seconds, 0.1)) seconds -= 0.1 os.environ['ROBOT_THREAD_TESTING'] = str(s) return s def returning(arg): return arg def failing(msg='...
Python
#!/usr/bin/env python """Helper script to run all Robot Framework's unit tests. usage: run_utest.py [options] options: -q, --quiet Minimal output -v, --verbose Verbose output -d, --doc Show test's doc string instead of name and class (implies verbosity) -h, --help ...
Python
#!/usr/bin/env python import urllib2 import shutil import os from os.path import join, exists, dirname, abspath from glob import glob from subprocess import call from zipfile import ZipFile JASMINE_REPORTER_URL='https://github.com/larrymyers/jasmine-reporters/zipball/0.2.1' BASE = abspath(dirname(__file__)) REPORT_DI...
Python