code stringlengths 1 1.49M | vector listlengths 0 7.38k | snippet listlengths 0 7.38k |
|---|---|---|
# -*- coding: utf-8 -*-
#########################################################################
## This scaffolding model makes your app work on Google App Engine too
## File is released under public domain and you can use without limitations
#########################################################################
... | [
[
4,
0,
0.1867,
0.0964,
0,
0.66,
0,
0,
0,
0,
0,
0,
0,
0,
3
],
[
14,
1,
0.1687,
0.012,
1,
0.44,
0,
761,
3,
3,
0,
0,
18,
10,
1
],
[
14,
1,
0.2048,
0.012,
1,
0.44,
... | [
"if not request.env.web2py_runtime_gae:\n ## if NOT running on Google App Engine use SQLite or other DB\n db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])\nelse:\n ## connect to Google BigTable (optional 'google:datastore://namespace')\n db = DAL('google:datastore')\n ## store s... |
# -*- coding: utf-8 -*-
# this file is released under public domain and you can use without limitations
#########################################################################
## This is a sample controller
## - index is the default action of any application
## - user is required for authentication and authorization... | [
[
2,
0,
0.2303,
0.1316,
0,
0.66,
0,
780,
0,
0,
1,
0,
0,
0,
3
],
[
8,
1,
0.2237,
0.0921,
1,
0.74,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
1,
0.2763,
0.0132,
1,
0.74,
... | [
"def index():\n \"\"\"\n example action using the internationalization operator T and flash\n rendered by views/default/index.html or views/generic.html\n\n if you need a simple wiki simple replace the two lines below with:\n return auth.wiki()\n \"\"\"",
" \"\"\"\n example action using th... |
# -*- coding: utf-8 -*-
# This is an app-specific example router
#
# This simple router is used for setting languages from app/languages directory
# as a part of the application path: app/<lang>/controller/function
# Language from default.py or 'en' (if the file is not found) is used as
# a default_language
#
# ... | [
[
1,
0,
0.5526,
0.0263,
0,
0.66,
0,
687,
0,
1,
0,
0,
687,
0,
0
],
[
1,
0,
0.5789,
0.0263,
0,
0.66,
0.3333,
126,
0,
1,
0,
0,
126,
0,
0
],
[
14,
0,
0.6316,
0.0263,
0,
... | [
"from fileutils import abspath",
"from languages import read_possible_languages",
"possible_languages = read_possible_languages(abspath('applications', app))",
"routers = {\n app: dict(\n default_language = possible_languages['default'][0],\n languages = [lang for lang in possible_languages\n... |
#!/usr/bin/env python
from setuptools import setup
from gluon.fileutils import tar, untar, read_file, write_file
import tarfile
import sys
def tar(file, filelist, expression='^.+$'):
"""
tars dir/files into file, only tars file that match expression
"""
tar = tarfile.TarFile(file, 'w')
try:
... | [
[
1,
0,
0.037,
0.0123,
0,
0.66,
0,
182,
0,
1,
0,
0,
182,
0,
0
],
[
1,
0,
0.0494,
0.0123,
0,
0.66,
0.1667,
948,
0,
4,
0,
0,
948,
0,
0
],
[
1,
0,
0.0617,
0.0123,
0,
0... | [
"from setuptools import setup",
"from gluon.fileutils import tar, untar, read_file, write_file",
"import tarfile",
"import sys",
"def tar(file, filelist, expression='^.+$'):\n \"\"\"\n tars dir/files into file, only tars file that match expression\n \"\"\"\n\n tar = tarfile.TarFile(file, 'w')\n ... |
"""
web2py handler for isapi-wsgi for IIS. Requires:
http://code.google.com/p/isapi-wsgi/
"""
# The entry point for the ISAPI extension.
def __ExtensionFactory__():
import os
import sys
path = os.path.dirname(os.path.abspath(__file__))
os.chdir(path)
sys.path = [path] + [p for p in sys.path if not... | [
[
8,
0,
0.0676,
0.1081,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
2,
0,
0.3378,
0.2703,
0,
0.66,
0.5,
892,
0,
0,
1,
0,
0,
0,
4
],
[
1,
1,
0.2432,
0.027,
1,
0.87,
... | [
"\"\"\"\nweb2py handler for isapi-wsgi for IIS. Requires:\nhttp://code.google.com/p/isapi-wsgi/\n\"\"\"",
"def __ExtensionFactory__():\n import os\n import sys\n path = os.path.dirname(os.path.abspath(__file__))\n os.chdir(path)\n sys.path = [path] + [p for p in sys.path if not p == path]\n impo... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This file is part of the web2py Web Framework
Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>
License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
This is a CGI handler for Apache
Requires apache+[mod_cgi or mod_cgid].
In httpd.conf put something like:
... | [
[
8,
0,
0.4365,
0.7619,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.8413,
0.0159,
0,
0.66,
0.125,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.8571,
0.0159,
0,
0.66,... | [
"\"\"\"\nThis file is part of the web2py Web Framework\nCopyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>\nLicense: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)\n\nThis is a CGI handler for Apache\nRequires apache+[mod_cgi or mod_cgid].",
"import os",
"import sys",
"import wsgiref.handlers",
"pat... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Sropulpof
# Copyright (C) 2008 Société des arts technologiques (SAT)
# http://www.sat.qc.ca
# All rights reserved.
#
# This file is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Soft... | [
[
8,
0,
0.093,
0.0194,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1085,
0.0039,
0,
0.66,
0.0588,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.1124,
0.0039,
0,
0.66,... | [
"\"\"\"\nThis script parse a directory tree looking for python modules and packages and\ncreate ReST files appropriately to create code documentation with Sphinx.\nIt also create a modules index. \n\"\"\"",
"import os",
"import optparse",
"options = ['members',\n 'undoc-members',\n# 'inh... |
"""Convert a FAQ (AlterEgo) markdown dump into ReSt documents using pandoc
**Todo**
#. add titles
#. add logging
#. add CLI with optparse
"""
import os
import sys
import glob
import subprocess
import logging
indir = 'faq_markdown'
outdir = 'faq_rst'
inpath = os.path.join('.', indir)
outpath = os.path.join('.', out... | [
[
8,
0,
0.0952,
0.1667,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2381,
0.0238,
0,
0.66,
0.0769,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.2619,
0.0238,
0,
0.66... | [
"\"\"\"Convert a FAQ (AlterEgo) markdown dump into ReSt documents using pandoc\n\n**Todo**\n#. add titles\n#. add logging\n#. add CLI with optparse\n\"\"\"",
"import os",
"import sys",
"import glob",
"import subprocess",
"import logging",
"indir = 'faq_markdown'",
"outdir = 'faq_rst'",
"inpath = os.... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Sropulpof
# Copyright (C) 2008 Société des arts technologiques (SAT)
# http://www.sat.qc.ca
# All rights reserved.
#
# This file is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Soft... | [
[
8,
0,
0.0886,
0.0185,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1033,
0.0037,
0,
0.66,
0.0588,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.107,
0.0037,
0,
0.66,... | [
"\"\"\"\nThis script parse a directory tree looking for python modules and packages and\ncreate ReST files appropriately to create code documentation with Sphinx.\nIt also create a modules index. \n\"\"\"",
"import os",
"import optparse",
"options = ['members',\n 'undoc-members',\n# 'inh... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Sropulpof
# Copyright (C) 2008 Société des arts technologiques (SAT)
# http://www.sat.qc.ca
# All rights reserved.
#
# This file is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Soft... | [
[
8,
0,
0.093,
0.0194,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1085,
0.0039,
0,
0.66,
0.0588,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.1124,
0.0039,
0,
0.66,... | [
"\"\"\"\nThis script parse a directory tree looking for python modules and packages and\ncreate ReST files appropriately to create code documentation with Sphinx.\nIt also create a modules index. \n\"\"\"",
"import os",
"import optparse",
"options = ['members',\n 'undoc-members',\n# 'inh... |
import os
import subprocess
import codecs
#--- BZR: changelog information
def write_changelog_bzr(repo_path, output_dir,
output_file='bzr_revision_log.txt',
target_encoding='utf-8'):
"""Write the bzr changelog to a file whi... | [
[
1,
0,
0.0115,
0.0115,
0,
0.66,
0,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.023,
0.0115,
0,
0.66,
0.1667,
394,
0,
1,
0,
0,
394,
0,
0
],
[
1,
0,
0.0345,
0.0115,
0,
0... | [
"import os",
"import subprocess",
"import codecs",
"def write_changelog_bzr(repo_path, output_dir, \n output_file='bzr_revision_log.txt', \n target_encoding='utf-8'):\n \"\"\"Write the bzr changelog to a file which can then be in... |
#
# A pair of directives for inserting content that will only appear in
# either html or latex.
#
from docutils.nodes import Body, Element
from docutils.writers.html4css1 import HTMLTranslator
try:
from sphinx.latexwriter import LaTeXTranslator
except ImportError:
from sphinx.writers.latex import LaTeXTranslat... | [
[
1,
0,
0.0625,
0.0104,
0,
0.66,
0,
127,
0,
2,
0,
0,
127,
0,
0
],
[
1,
0,
0.0729,
0.0104,
0,
0.66,
0.125,
949,
0,
1,
0,
0,
949,
0,
0
],
[
7,
0,
0.125,
0.0938,
0,
0.... | [
"from docutils.nodes import Body, Element",
"from docutils.writers.html4css1 import HTMLTranslator",
"try:\n from sphinx.latexwriter import LaTeXTranslator\nexcept ImportError:\n from sphinx.writers.latex import LaTeXTranslator\n\n import warnings\n warnings.warn(\"The numpydoc.only_directives modul... |
from cStringIO import StringIO
import compiler
import inspect
import textwrap
import tokenize
from compiler_unparse import unparse
class Comment(object):
""" A comment block.
"""
is_comment = True
def __init__(self, start_lineno, end_lineno, text):
# int : The first line number in the block. ... | [
[
1,
0,
0.0063,
0.0063,
0,
0.66,
0,
764,
0,
1,
0,
0,
764,
0,
0
],
[
1,
0,
0.0127,
0.0063,
0,
0.66,
0.1,
738,
0,
1,
0,
0,
738,
0,
0
],
[
1,
0,
0.019,
0.0063,
0,
0.66... | [
"from cStringIO import StringIO",
"import compiler",
"import inspect",
"import textwrap",
"import tokenize",
"from compiler_unparse import unparse",
"class Comment(object):\n \"\"\" A comment block.\n \"\"\"\n is_comment = True\n def __init__(self, start_lineno, end_lineno, text):\n #... |
from distutils.core import setup
import setuptools
import sys, os
version = "0.2.dev"
setup(
name="numpydoc",
packages=["numpydoc"],
package_dir={"numpydoc": ""},
version=version,
description="Sphinx extension to support docstrings in Numpy format",
# classifiers from http://pypi.python.org/py... | [
[
1,
0,
0.0323,
0.0323,
0,
0.66,
0,
152,
0,
1,
0,
0,
152,
0,
0
],
[
1,
0,
0.0645,
0.0323,
0,
0.66,
0.25,
182,
0,
1,
0,
0,
182,
0,
0
],
[
1,
0,
0.0968,
0.0323,
0,
0.... | [
"from distutils.core import setup",
"import setuptools",
"import sys, os",
"version = \"0.2.dev\"",
"setup(\n name=\"numpydoc\",\n packages=[\"numpydoc\"],\n package_dir={\"numpydoc\": \"\"},\n version=version,\n description=\"Sphinx extension to support docstrings in Numpy format\",\n # c... |
""" Turn compiler.ast structures back into executable python code.
The unparse method takes a compiler.ast tree and transforms it back into
valid python code. It is incomplete and currently only works for
import statements, function calls, function definitions, assignments, and
basic expressions.
... | [
[
8,
0,
0.0076,
0.014,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0163,
0.0012,
0,
0.66,
0.1667,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.0174,
0.0012,
0,
0.66,... | [
"\"\"\" Turn compiler.ast structures back into executable python code.\n\n The unparse method takes a compiler.ast tree and transforms it back into\n valid python code. It is incomplete and currently only works for\n import statements, function calls, function definitions, assignments, and\n basic expr... |
"""
==============
phantom_import
==============
Sphinx extension to make directives from ``sphinx.ext.autodoc`` and similar
extensions to use docstrings loaded from an XML file.
This extension loads an XML file in the Pydocweb format [1] and
creates a dummy module that contains the specified docstrings. This
can be ... | [
[
8,
0,
0.0525,
0.0988,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1049,
0.0062,
0,
0.66,
0.25,
201,
0,
7,
0,
0,
201,
0,
0
],
[
2,
0,
0.1235,
0.0185,
0,
0.66,
... | [
"\"\"\"\n==============\nphantom_import\n==============\n\nSphinx extension to make directives from ``sphinx.ext.autodoc`` and similar\nextensions to use docstrings loaded from an XML file.",
"import imp, sys, compiler, types, os, inspect, re",
"def setup(app):\n app.connect('builder-inited', initialize)\n ... |
from numpydoc import setup
| [
[
1,
0,
1,
1,
0,
0.66,
0,
32,
0,
1,
0,
0,
32,
0,
0
]
] | [
"from numpydoc import setup"
] |
import re, inspect, textwrap, pydoc
import sphinx
from docscrape import NumpyDocString, FunctionDoc, ClassDoc
class SphinxDocString(NumpyDocString):
# string conversion routines
def _str_header(self, name, symbol='`'):
return ['.. rubric:: ' + name, '']
def _str_field_list(self, name):
ret... | [
[
1,
0,
0.0067,
0.0067,
0,
0.66,
0,
540,
0,
4,
0,
0,
540,
0,
0
],
[
1,
0,
0.0134,
0.0067,
0,
0.66,
0.1667,
522,
0,
1,
0,
0,
522,
0,
0
],
[
1,
0,
0.0201,
0.0067,
0,
... | [
"import re, inspect, textwrap, pydoc",
"import sphinx",
"from docscrape import NumpyDocString, FunctionDoc, ClassDoc",
"class SphinxDocString(NumpyDocString):\n # string conversion routines\n def _str_header(self, name, symbol='`'):\n return ['.. rubric:: ' + name, '']\n\n def _str_field_list(... |
"""
========
numpydoc
========
Sphinx extension that handles docstrings in the Numpy standard format. [1]
It will:
- Convert Parameters etc. sections to field lists.
- Convert See Also section to a See also entry.
- Renumber references.
- Extract the signature from the docstring, if it can't be determined otherwise.... | [
[
8,
0,
0.0769,
0.1453,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1624,
0.0085,
0,
0.66,
0.1111,
688,
0,
3,
0,
0,
688,
0,
0
],
[
1,
0,
0.1709,
0.0085,
0,
0.66... | [
"\"\"\"\n========\nnumpydoc\n========\n\nSphinx extension that handles docstrings in the Numpy standard format. [1]\n\nIt will:",
"import os, re, pydoc",
"from docscrape_sphinx import get_doc_object, SphinxDocString",
"import inspect",
"def mangle_docstrings(app, what, name, obj, options, lines,\n ... |
# -*- coding: utf-8 -*-
# default_application, default_controller, default_function
# are used when the respective element is missing from the
# (possibly rewritten) incoming URL
#
default_application = 'init' # ordinarily set in base routes.py
default_controller = 'default' # ordinarily set in app-specific routes... | [
[
14,
0,
0.0352,
0.005,
0,
0.66,
0,
558,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.0402,
0.005,
0,
0.66,
0.1111,
335,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.0452,
0.005,
0,
0.66... | [
"default_application = 'init' # ordinarily set in base routes.py",
"default_controller = 'default' # ordinarily set in app-specific routes.py",
"default_function = 'index' # ordinarily set in app-specific routes.py",
"routes_app = ((r'/(?P<app>welcome|admin|app)\\b.*', r'\\g<app>'),\n (r... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
if '__file__' in globals():
path = os.path.dirname(os.path.abspath(__file__))
elif hasattr(sys, 'frozen'):
path = os.path.dirname(os.path.abspath(sys.executable)) # for py2exe
else: # should never happen
path = os.getcwd()
os.chdir(path)... | [
[
1,
0,
0.1212,
0.0303,
0,
0.66,
0,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.1515,
0.0303,
0,
0.66,
0.1667,
509,
0,
1,
0,
0,
509,
0,
0
],
[
4,
0,
0.2879,
0.1818,
0,
... | [
"import os",
"import sys",
"if '__file__' in globals():\n path = os.path.dirname(os.path.abspath(__file__))\nelif hasattr(sys, 'frozen'):\n path = os.path.dirname(os.path.abspath(sys.executable)) # for py2exe\nelse: # should never happen\n path = os.getcwd()",
" path = os.path.dirname(os.path.ab... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This file is part of the web2py Web Framework
Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>
License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
"""
##############################################################################
# Configuration paramete... | [
[
8,
0,
0.0566,
0.0472,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.1226,
0.0094,
0,
0.66,
0.037,
779,
1,
0,
0,
0,
0,
4,
0
],
[
14,
0,
0.1321,
0.0094,
0,
0.66,... | [
"\"\"\"\nThis file is part of the web2py Web Framework\nCopyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>\nLicense: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)\n\"\"\"",
"LOG_STATS = False # web2py level log statistics",
"APPSTATS = True # GAE level usage statistics and profiling",
"D... |
import logging
logger = logging.getLogger('x90-analyze')
logger.setLevel(logging.DEBUG)
# File Handler
hdlr = logging.FileHandler('logs/run.log')
formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
hdlr.setLevel(logging.DEBUG)
# Stream handle... | [
[
1,
0,
0.037,
0.037,
0,
0.66,
0,
715,
0,
1,
0,
0,
715,
0,
0
],
[
14,
0,
0.1111,
0.037,
0,
0.66,
0.0667,
532,
3,
1,
0,
0,
71,
10,
1
],
[
8,
0,
0.1481,
0.037,
0,
0.6... | [
"import logging",
"logger = logging.getLogger('x90-analyze')",
"logger.setLevel(logging.DEBUG)",
"hdlr = logging.FileHandler('logs/run.log')",
"formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s')",
"hdlr.setFormatter(formatter)",
"logger.addHandler(hdlr)",
"hdlr.setLevel(logging.D... |
import os
import re
import shutil
import commands
import _mysql
import hashlib
import logger
# Analyze project.
def analyze_metrics(project, revision, url, db, folder):
analyze_code_metrics(project, revision, url, db, folder)
analyze_filemetrics(project, revision, url, db, folder)
# Get code metrics:
def analyze_co... | [
[
1,
0,
0.0175,
0.0175,
0,
0.66,
0,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.0351,
0.0175,
0,
0.66,
0.1111,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.0526,
0.0175,
0,
... | [
"import os",
"import re",
"import shutil",
"import commands",
"import _mysql",
"import hashlib",
"import logger",
"def analyze_metrics(project, revision, url, db, folder):\n\tanalyze_code_metrics(project, revision, url, db, folder)\n\tanalyze_filemetrics(project, revision, url, db, folder)",
"\tanal... |
##
## Mercurial-analyzer
##
## Todo: skriv om...
from xml.dom import minidom
import logger
## Parses a dom file
def parsedom(file):
try:
dom = minidom.parse(file)
except Exception:
logger.printerror("Failed to parse the xml file " + file);
exit()
return dom
class Project:
name="-noname-"
type="svn"
u... | [
[
1,
0,
0.0496,
0.0083,
0,
0.66,
0,
290,
0,
1,
0,
0,
290,
0,
0
],
[
1,
0,
0.0579,
0.0083,
0,
0.66,
0.125,
532,
0,
1,
0,
0,
532,
0,
0
],
[
2,
0,
0.1116,
0.0661,
0,
0... | [
"from xml.dom import minidom",
"import logger",
"def parsedom(file):\n\ttry:\n\t\tdom = minidom.parse(file)\n\texcept Exception:\n\t logger.printerror(\"Failed to parse the xml file \" + file);\n\t exit()\n\n\treturn dom",
"\ttry:\n\t\tdom = minidom.parse(file)\n\texcept Exception:\n\t logger.printerror(\"... |
##
## mercurial-analyzer
##
## Requires: Cloc (sudo apt-get install cloc)
import analyzelib
import settingsreader
from database import DbHandler
import logger
def getType(types, name):
try:
ret = types[name];
return ret
except Exception:
logger.printerror("Missing type "+name)
exit();
logger.printinfo("... | [
[
1,
0,
0.1667,
0.0278,
0,
0.66,
0,
443,
0,
1,
0,
0,
443,
0,
0
],
[
1,
0,
0.1944,
0.0278,
0,
0.66,
0.0769,
621,
0,
1,
0,
0,
621,
0,
0
],
[
1,
0,
0.2222,
0.0278,
0,
... | [
"import analyzelib",
"import settingsreader",
"from database import DbHandler",
"import logger",
"def getType(types, name):\n\ttry:\n\t\tret = types[name];\n\t\treturn ret\n\texcept Exception:\n\t\tlogger.printerror(\"Missing type \"+name)\n\t\texit();",
"\ttry:\n\t\tret = types[name];\n\t\treturn ret\n\t... |
#====================================================================
# 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 ... | [
[
1,
0,
0.3514,
0.0135,
0,
0.66,
0,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.3649,
0.0135,
0,
0.66,
0.1111,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.3784,
0.0135,
0,
... | [
"import os",
"import re",
"import tempfile",
"import shutil",
"ignore_pattern = re.compile('^(.svn|target|bin|classes)')",
"java_pattern = re.compile('^.*\\.java')",
"annot_pattern = re.compile('import org\\.apache\\.http\\.annotation\\.')",
"def process_dir(dir):\n files = os.listdir(dir)\n for... |
#!/usr/bin/env python
#
# Copyright 2006, 2007 Google Inc. All Rights Reserved.
# Author: danderson@google.com (David Anderson)
#
# Script for uploading files to a Google Code project.
#
# This is intended to be both a useful script for people who want to
# streamline project uploads and a reference implementation for
... | [
[
8,
0,
0.1875,
0.0081,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.1976,
0.004,
0,
0.66,
0.0833,
777,
1,
0,
0,
0,
0,
3,
0
],
[
1,
0,
0.2056,
0.004,
0,
0.66,
... | [
"\"\"\"Google Code file uploader script.\n\"\"\"",
"__author__ = 'danderson@google.com (David Anderson)'",
"import httplib",
"import os.path",
"import optparse",
"import getpass",
"import base64",
"import sys",
"def upload(file, project_name, user_name, password, summary, labels=None):\n \"\"\"Uplo... |
#!/usr/bin/env python
#
# Copyright 2006, 2007 Google Inc. All Rights Reserved.
# Author: danderson@google.com (David Anderson)
#
# Script for uploading files to a Google Code project.
#
# This is intended to be both a useful script for people who want to
# streamline project uploads and a reference implementation for
... | [
[
8,
0,
0.1875,
0.0081,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.1976,
0.004,
0,
0.66,
0.0833,
777,
1,
0,
0,
0,
0,
3,
0
],
[
1,
0,
0.2056,
0.004,
0,
0.66,
... | [
"\"\"\"Google Code file uploader script.\n\"\"\"",
"__author__ = 'danderson@google.com (David Anderson)'",
"import httplib",
"import os.path",
"import optparse",
"import getpass",
"import base64",
"import sys",
"def upload(file, project_name, user_name, password, summary, labels=None):\n \"\"\"Uplo... |
#!/usr/bin/env python3
import random
class MastermindGame():
def __init__(self):
self._generated_string = ""
used_digits = set()
for i in range(4):
digit = random.randrange(0, 10, 1)
while digit in used_digits:
digit = random.randrange(0, 10, 1)
... | [
[
1,
0,
0.05,
0.025,
0,
0.66,
0,
715,
0,
1,
0,
0,
715,
0,
0
],
[
3,
0,
0.475,
0.725,
0,
0.66,
0.5,
894,
0,
2,
0,
0,
0,
0,
11
],
[
2,
1,
0.25,
0.225,
1,
0.96,
0,... | [
"import random",
"class MastermindGame():\n def __init__(self):\n self._generated_string = \"\"\n used_digits = set()\n for i in range(4):\n digit = random.randrange(0, 10, 1)\n while digit in used_digits:\n digit = random.randrange(0, 10, 1)",
" d... |
#!/usr/bin/env python3
import random
class MastermindGame():
def __init__(self):
self._generated_string = ""
used_digits = set()
for i in range(4):
digit = random.randrange(0, 10, 1)
while digit in used_digits:
digit = random.randrange(0, 10, 1)
... | [
[
1,
0,
0.05,
0.025,
0,
0.66,
0,
715,
0,
1,
0,
0,
715,
0,
0
],
[
3,
0,
0.475,
0.725,
0,
0.66,
0.5,
894,
0,
2,
0,
0,
0,
0,
11
],
[
2,
1,
0.25,
0.225,
1,
0.68,
0,... | [
"import random",
"class MastermindGame():\n def __init__(self):\n self._generated_string = \"\"\n used_digits = set()\n for i in range(4):\n digit = random.randrange(0, 10, 1)\n while digit in used_digits:\n digit = random.randrange(0, 10, 1)",
" d... |
import time
def yesno(question):
val = raw_input(question + " ")
return val.startswith("y") or val.startswith("Y")
use_pysqlite2 = yesno("Use pysqlite 2.0?")
use_autocommit = yesno("Use autocommit?")
use_executemany= yesno("Use executemany?")
if use_pysqlite2:
from pysqlite2 import dbapi2 as s... | [
[
1,
0,
0.0164,
0.0164,
0,
0.66,
0,
654,
0,
1,
0,
0,
654,
0,
0
],
[
2,
0,
0.0656,
0.0492,
0,
0.66,
0.125,
796,
0,
1,
1,
0,
0,
0,
3
],
[
14,
1,
0.0656,
0.0164,
1,
0.... | [
"import time",
"def yesno(question):\n val = raw_input(question + \" \")\n return val.startswith(\"y\") or val.startswith(\"Y\")",
" val = raw_input(question + \" \")",
" return val.startswith(\"y\") or val.startswith(\"Y\")",
"use_pysqlite2 = yesno(\"Use pysqlite 2.0?\")",
"use_autocommit = y... |
import time
def yesno(question):
val = raw_input(question + " ")
return val.startswith("y") or val.startswith("Y")
use_pysqlite2 = yesno("Use pysqlite 2.0?")
if use_pysqlite2:
use_custom_types = yesno("Use custom types?")
use_dictcursor = yesno("Use dict cursor?")
use_rowcursor = yesno("... | [
[
1,
0,
0.0103,
0.0103,
0,
0.66,
0,
654,
0,
1,
0,
0,
654,
0,
0
],
[
2,
0,
0.0412,
0.0309,
0,
0.66,
0.1111,
796,
0,
1,
1,
0,
0,
0,
3
],
[
14,
1,
0.0412,
0.0103,
1,
0... | [
"import time",
"def yesno(question):\n val = raw_input(question + \" \")\n return val.startswith(\"y\") or val.startswith(\"Y\")",
" val = raw_input(question + \" \")",
" return val.startswith(\"y\") or val.startswith(\"Y\")",
"use_pysqlite2 = yesno(\"Use pysqlite 2.0?\")",
"if use_pysqlite2:\... |
#!/usr/bin/env python
from pysqlite2.test import test
test()
| [
[
1,
0,
0.6667,
0.3333,
0,
0.66,
0,
472,
0,
1,
0,
0,
472,
0,
0
],
[
8,
0,
1,
0.3333,
0,
0.66,
1,
224,
3,
0,
0,
0,
0,
0,
1
]
] | [
"from pysqlite2.test import test",
"test()"
] |
from pysqlite2 import dbapi2 as sqlite
import os, threading
def getcon():
#con = sqlite.connect("db", isolation_level=None, timeout=5.0)
con = sqlite.connect(":memory:")
cur = con.cursor()
cur.execute("create table test(i, s)")
for i in range(10):
cur.execute("insert into test(i, s) values ... | [
[
1,
0,
0.0125,
0.0125,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
1,
0,
0.025,
0.0125,
0,
0.66,
0.1,
688,
0,
2,
0,
0,
688,
0,
0
],
[
2,
0,
0.1062,
0.125,
0,
0.66,... | [
"from pysqlite2 import dbapi2 as sqlite",
"import os, threading",
"def getcon():\n #con = sqlite.connect(\"db\", isolation_level=None, timeout=5.0)\n con = sqlite.connect(\":memory:\")\n cur = con.cursor()\n cur.execute(\"create table test(i, s)\")\n for i in range(10):\n cur.execute(\"ins... |
from __future__ import with_statement
from pysqlite2 import dbapi2 as sqlite3
from datetime import datetime, timedelta
import time
def read_modify_write():
# Open connection and create example schema and data.
# In reality, open a database file instead of an in-memory database.
con = sqlite3.connect(":memo... | [
[
1,
0,
0.0091,
0.0091,
0,
0.66,
0,
777,
0,
1,
0,
0,
777,
0,
0
],
[
1,
0,
0.0182,
0.0091,
0,
0.66,
0.1429,
987,
0,
1,
0,
0,
987,
0,
0
],
[
1,
0,
0.0273,
0.0091,
0,
... | [
"from __future__ import with_statement",
"from pysqlite2 import dbapi2 as sqlite3",
"from datetime import datetime, timedelta",
"import time",
"def read_modify_write():\n # Open connection and create example schema and data.\n # In reality, open a database file instead of an in-memory database.\n c... |
from pysqlite2 import dbapi2 as sqlite3
Cursor = sqlite3.Cursor
class EagerCursor(Cursor):
def __init__(self, con):
Cursor.__init__(self, con)
self.rows = []
self.pos = 0
def execute(self, *args):
sqlite3.Cursor.execute(self, *args)
self.rows = Cursor.fetchall(self)
... | [
[
1,
0,
0.0196,
0.0196,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.0588,
0.0196,
0,
0.66,
0.25,
647,
7,
0,
0,
0,
0,
0,
0
],
[
3,
0,
0.3922,
0.6078,
0,
0.6... | [
"from pysqlite2 import dbapi2 as sqlite3",
"Cursor = sqlite3.Cursor",
"class EagerCursor(Cursor):\n def __init__(self, con):\n Cursor.__init__(self, con)\n self.rows = []\n self.pos = 0\n\n def execute(self, *args):\n sqlite3.Cursor.execute(self, *args)",
" def __init__(se... |
#!/usr/bin/env python
#
# Cross-compile and build pysqlite installers for win32 on Linux or Mac OS X.
#
# The way this works is very ugly, but hey, it *works*! And I didn't have to
# reinvent the wheel using NSIS.
import os
import sys
import urllib
import zipfile
from setup import get_amalgamation
# Cross-compiler
... | [
[
1,
0,
0.1176,
0.0147,
0,
0.66,
0,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.1324,
0.0147,
0,
0.66,
0.0833,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.1471,
0.0147,
0,
... | [
"import os",
"import sys",
"import urllib",
"import zipfile",
"from setup import get_amalgamation",
"if sys.platform == \"darwin\":\n CC = \"/usr/local/i386-mingw32-4.3.0/bin/i386-mingw32-gcc\"\n LIBDIR = \"lib.macosx-10.6-i386-2.5\"\n STRIP = \"/usr/local/i386-mingw32-4.3.0/bin/i386-mingw32-gcc ... |
# -*- coding: utf-8 -*-
#
# pysqlite documentation build configuration file, created by
# sphinx-quickstart.py on Sat Mar 22 02:47:54 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't pic... | [
[
1,
0,
0.1061,
0.0076,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
14,
0,
0.2045,
0.0076,
0,
0.66,
0.0769,
518,
0,
0,
0,
0,
0,
5,
0
],
[
14,
0,
0.2273,
0.0076,
0,
... | [
"import sys",
"templates_path = ['.templates']",
"source_suffix = '.rst'",
"master_doc = 'index'",
"project = 'pysqlite'",
"copyright = u'2008-2009, Gerhard Häring'",
"version = '2.6'",
"release = '2.6.0'",
"today_fmt = '%B %d, %Y'",
"pygments_style = 'sphinx'",
"html_style = 'default.css'",
"... |
from pysqlite2 import dbapi2 as sqlite3
FIELD_MAX_WIDTH = 20
TABLE_NAME = 'people'
SELECT = 'select * from %s order by age, name_last' % TABLE_NAME
con = sqlite3.connect("mydb")
cur = con.cursor()
cur.execute(SELECT)
# Print a header.
for fieldDesc in cur.description:
print fieldDesc[0].ljust(FIELD_MAX_WIDTH) ,... | [
[
1,
0,
0.5,
0.5,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
]
] | [
"from pysqlite2 import dbapi2 as sqlite3"
] |
from pysqlite2 import dbapi2 as sqlite3
def progress():
print "Query still executing. Please wait ..."
con = sqlite3.connect(":memory:")
con.execute("create table test(x)")
# Let's create some data
con.executemany("insert into test(x) values (?)", [(x,) for x in xrange(300)])
# A progress handler, executed ever... | [
[
1,
0,
0.0345,
0.0345,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
2,
0,
0.1207,
0.069,
0,
0.66,
0.1,
82,
0,
0,
0,
0,
0,
0,
1
],
[
8,
1,
0.1379,
0.0345,
1,
0.66,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"def progress():\n print(\"Query still executing. Please wait ...\")",
" print(\"Query still executing. Please wait ...\")",
"con = sqlite3.connect(\":memory:\")",
"con.execute(\"create table test(x)\")",
"con.executemany(\"insert into test(x) values (?)\",... |
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect("mydb")
cur = con.cursor()
SELECT = "select name_last, age from people order by age, name_last"
# 1. Iterate over the rows available from the cursor, unpacking the
# resulting sequences to yield their elements (name_last, age):
cur.execute(SELECT)
for (na... | [
[
1,
0,
0.0588,
0.0588,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.1765,
0.0588,
0,
0.66,
0.1429,
761,
3,
1,
0,
0,
242,
10,
1
],
[
14,
0,
0.2941,
0.0588,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\"mydb\")",
"cur = con.cursor()",
"SELECT = \"select name_last, age from people order by age, name_last\"",
"cur.execute(SELECT)",
"for (name_last, age) in cur:\n print('%s is %d years old.' % (name_last, age))",
" print('%s is %d y... |
from pysqlite2 import dbapi2 as sqlite3
# Create a connection to the database file "mydb":
con = sqlite3.connect("mydb")
# Get a Cursor object that operates in the context of Connection con:
cur = con.cursor()
# Execute the SELECT statement:
cur.execute("select * from people order by age")
# Retrieve all rows as a ... | [
[
1,
0,
0.0769,
0.0769,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.3077,
0.0769,
0,
0.66,
0.25,
761,
3,
1,
0,
0,
242,
10,
1
],
[
14,
0,
0.5385,
0.0769,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\"mydb\")",
"cur = con.cursor()",
"cur.execute(\"select * from people order by age\")",
"print(cur.fetchall())"
] |
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect("mydb")
| [
[
1,
0,
0.3333,
0.3333,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
1,
0.3333,
0,
0.66,
1,
761,
3,
1,
0,
0,
242,
10,
1
]
] | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\"mydb\")"
] |
from pysqlite2 import dbapi2 as sqlite3
class MySum:
def __init__(self):
self.count = 0
def step(self, value):
self.count += value
def finalize(self):
return self.count
con = sqlite3.connect(":memory:")
con.create_aggregate("mysum", 1, MySum)
cur = con.cursor()
cur.execute("creat... | [
[
1,
0,
0.05,
0.05,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
3,
0,
0.35,
0.45,
0,
0.66,
0.1111,
865,
0,
3,
0,
0,
0,
0,
0
],
[
2,
1,
0.225,
0.1,
1,
0.21,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"class MySum:\n def __init__(self):\n self.count = 0\n\n def step(self, value):\n self.count += value\n\n def finalize(self):",
" def __init__(self):\n self.count = 0",
" self.count = 0",
" def step(self, value):\n ... |
# A minimal SQLite shell for experiments
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect(":memory:")
con.isolation_level = None
cur = con.cursor()
buffer = ""
print "Enter your SQL commands to execute in SQLite."
print "Enter a blank line to exit."
while True:
line = raw_input()
if line == ""... | [
[
1,
0,
0.5,
0.5,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
]
] | [
"from pysqlite2 import dbapi2 as sqlite3"
] |
from pysqlite2 import dbapi2 as sqlite3
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
con = sqlite3.connect(":memory:")
con.row_factory = dict_factory
cur = con.cursor()
cur.execute("select 1 as a")
print cur.fetchone()["a"]
| [
[
1,
0,
0.0769,
0.0769,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
2,
0,
0.3846,
0.3846,
0,
0.66,
0.1667,
131,
0,
2,
1,
0,
0,
0,
1
],
[
14,
1,
0.3077,
0.0769,
1,
0... | [
"from pysqlite2 import dbapi2 as sqlite3",
"def dict_factory(cursor, row):\n d = {}\n for idx, col in enumerate(cursor.description):\n d[col[0]] = row[idx]\n return d",
" d = {}",
" for idx, col in enumerate(cursor.description):\n d[col[0]] = row[idx]",
" d[col[0]] = row[... |
from pysqlite2 import dbapi2 as sqlite3
import datetime
con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
cur = con.cursor()
cur.execute("create table test(d date, ts timestamp)")
today = datetime.date.today()
now = datetime.datetime.now()
cur.execute("insert into test(d,... | [
[
1,
0,
0.05,
0.05,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
1,
0,
0.1,
0.05,
0,
0.66,
0.0667,
426,
0,
1,
0,
0,
426,
0,
0
],
[
14,
0,
0.2,
0.05,
0,
0.66,
0.1... | [
"from pysqlite2 import dbapi2 as sqlite3",
"import datetime",
"con = sqlite3.connect(\":memory:\", detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)",
"cur = con.cursor()",
"cur.execute(\"create table test(d date, ts timestamp)\")",
"today = datetime.date.today()",
"now = datetime.datetime.no... |
from pysqlite2 import dbapi2 as sqlite3
def authorizer_callback(action, arg1, arg2, dbname, source):
if action != sqlite3.SQLITE_SELECT:
return sqlite3.SQLITE_DENY
if arg1 == "private_table":
return sqlite3.SQLITE_DENY
return sqlite3.SQLITE_OK
con = sqlite3.connect(":memory:")
con.executes... | [
[
1,
0,
0.1111,
0.1111,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
2,
0,
0.6111,
0.6667,
0,
0.66,
1,
423,
0,
5,
1,
0,
0,
0,
0
],
[
4,
1,
0.5,
0.2222,
1,
0.96,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"def authorizer_callback(action, arg1, arg2, dbname, source):\n if action != sqlite3.SQLITE_SELECT:\n return sqlite3.SQLITE_DENY\n if arg1 == \"private_table\":\n return sqlite3.SQLITE_DENY\n return sqlite3.SQLITE_OK",
" if action != sqlite3.S... |
from pysqlite2 import dbapi2 as sqlite3
# The shared cache is only available in SQLite versions 3.3.3 or later
# See the SQLite documentaton for details.
sqlite3.enable_shared_cache(True)
| [
[
1,
0,
0.1667,
0.1667,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
8,
0,
1,
0.1667,
0,
0.66,
1,
965,
3,
1,
0,
0,
0,
0,
1
]
] | [
"from pysqlite2 import dbapi2 as sqlite3",
"sqlite3.enable_shared_cache(True)"
] |
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect(":memory:")
| [
[
1,
0,
0.3333,
0.3333,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
1,
0.3333,
0,
0.66,
1,
761,
3,
1,
0,
0,
242,
10,
1
]
] | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\":memory:\")"
] |
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect("mydb")
cur = con.cursor()
who = "Yeltsin"
age = 72
cur.execute("select name_last, age from people where name_last=? and age=?", (who, age))
print cur.fetchone()
| [
[
1,
0,
0.0909,
0.0909,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.2727,
0.0909,
0,
0.66,
0.1667,
761,
3,
1,
0,
0,
242,
10,
1
],
[
14,
0,
0.4545,
0.0909,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\"mydb\")",
"cur = con.cursor()",
"who = \"Yeltsin\"",
"age = 72",
"cur.execute(\"select name_last, age from people where name_last=? and age=?\", (who, age))",
"print(cur.fetchone())"
] |
from __future__ import with_statement
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect(":memory:")
con.execute("create table person (id integer primary key, firstname varchar unique)")
# Successful, con.commit() is called automatically afterwards
with con:
con.execute("insert into person(firstname) v... | [
[
1,
0,
0.0526,
0.0526,
0,
0.66,
0,
777,
0,
1,
0,
0,
777,
0,
0
],
[
1,
0,
0.1053,
0.0526,
0,
0.66,
0.25,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.2105,
0.0526,
0,
0... | [
"from __future__ import with_statement",
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\":memory:\")",
"con.execute(\"create table person (id integer primary key, firstname varchar unique)\")",
" con.execute(\"insert into person(firstname) values (?)\", (\"Joe\",))",
"try:\n with... |
from pysqlite2 import dbapi2 as sqlite3
import md5
def md5sum(t):
return md5.md5(t).hexdigest()
con = sqlite3.connect(":memory:")
con.create_function("md5", 1, md5sum)
cur = con.cursor()
cur.execute("select md5(?)", ("foo",))
print cur.fetchone()[0]
| [
[
1,
0,
0.0909,
0.0909,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
1,
0,
0.1818,
0.0909,
0,
0.66,
0.1429,
604,
0,
1,
0,
0,
604,
0,
0
],
[
2,
0,
0.4091,
0.1818,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"import md5",
"def md5sum(t):\n return md5.md5(t).hexdigest()",
" return md5.md5(t).hexdigest()",
"con = sqlite3.connect(\":memory:\")",
"con.create_function(\"md5\", 1, md5sum)",
"cur = con.cursor()",
"cur.execute(\"select md5(?)\", (\"foo\",))",
"pr... |
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect("mydb")
con.row_factory = sqlite3.Row
cur = con.cursor()
cur.execute("select name_last, age from people")
for row in cur:
assert row[0] == row["name_last"]
assert row["name_last"] == row["nAmE_lAsT"]
assert row[1] == row["age"]
assert row[1... | [
[
1,
0,
0.0833,
0.0833,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.25,
0.0833,
0,
0.66,
0.2,
761,
3,
1,
0,
0,
242,
10,
1
],
[
14,
0,
0.3333,
0.0833,
0,
0.... | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\"mydb\")",
"con.row_factory = sqlite3.Row",
"cur = con.cursor()",
"cur.execute(\"select name_last, age from people\")",
"for row in cur:\n assert row[0] == row[\"name_last\"]\n assert row[\"name_last\"] == row[\"nAmE_lAsT\"]\n ass... |
from pysqlite2 import dbapi2 as sqlite3
class Point(object):
def __init__(self, x, y):
self.x, self.y = x, y
def adapt_point(point):
return "%f;%f" % (point.x, point.y)
sqlite3.register_adapter(Point, adapt_point)
con = sqlite3.connect(":memory:")
cur = con.cursor()
p = Point(4.0, -3.2)
cur.execute... | [
[
1,
0,
0.0588,
0.0588,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
3,
0,
0.2353,
0.1765,
0,
0.66,
0.125,
652,
0,
1,
0,
0,
186,
0,
0
],
[
2,
1,
0.2647,
0.1176,
1,
0... | [
"from pysqlite2 import dbapi2 as sqlite3",
"class Point(object):\n def __init__(self, x, y):\n self.x, self.y = x, y",
" def __init__(self, x, y):\n self.x, self.y = x, y",
" self.x, self.y = x, y",
"def adapt_point(point):\n return \"%f;%f\" % (point.x, point.y)",
" retur... |
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect(":memory:")
cur = con.cursor()
# Create the table
con.execute("create table person(lastname, firstname)")
AUSTRIA = u"\xd6sterreich"
# by default, rows are returned as Unicode
cur.execute("select ?", (AUSTRIA,))
row = cur.fetchone()
assert row[0] == AUST... | [
[
1,
0,
0.0238,
0.0238,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.0714,
0.0238,
0,
0.66,
0.0588,
761,
3,
1,
0,
0,
242,
10,
1
],
[
14,
0,
0.0952,
0.0238,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\":memory:\")",
"cur = con.cursor()",
"con.execute(\"create table person(lastname, firstname)\")",
"AUSTRIA = u\"\\xd6sterreich\"",
"cur.execute(\"select ?\", (AUSTRIA,))",
"row = cur.fetchone()",
"con.text_factory = str",
"cur.execut... |
from pysqlite2 import dbapi2 as sqlite3
class CountCursorsConnection(sqlite3.Connection):
def __init__(self, *args, **kwargs):
sqlite3.Connection.__init__(self, *args, **kwargs)
self.numcursors = 0
def cursor(self, *args, **kwargs):
self.numcursors += 1
return sqlite3.Connectio... | [
[
1,
0,
0.0667,
0.0667,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
3,
0,
0.4333,
0.5333,
0,
0.66,
0.2,
293,
0,
2,
0,
0,
809,
0,
2
],
[
2,
1,
0.3333,
0.2,
1,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"class CountCursorsConnection(sqlite3.Connection):\n def __init__(self, *args, **kwargs):\n sqlite3.Connection.__init__(self, *args, **kwargs)\n self.numcursors = 0\n\n def cursor(self, *args, **kwargs):\n self.numcursors += 1\n return s... |
from pysqlite2 import dbapi2 as sqlite3
def collate_reverse(string1, string2):
return -cmp(string1, string2)
con = sqlite3.connect(":memory:")
con.create_collation("reverse", collate_reverse)
cur = con.cursor()
cur.execute("create table test(x)")
cur.executemany("insert into test(x) values (?)", [("a",), ("b",)]... | [
[
1,
0,
0.0667,
0.0667,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
2,
0,
0.2333,
0.1333,
0,
0.66,
0.1111,
722,
0,
2,
1,
0,
0,
0,
1
],
[
13,
1,
0.2667,
0.0667,
1,
0... | [
"from pysqlite2 import dbapi2 as sqlite3",
"def collate_reverse(string1, string2):\n return -cmp(string1, string2)",
" return -cmp(string1, string2)",
"con = sqlite3.connect(\":memory:\")",
"con.create_collation(\"reverse\", collate_reverse)",
"cur = con.cursor()",
"cur.execute(\"create table test... |
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect(":memory:")
cur = con.cursor()
cur.executescript("""
create table person(
firstname,
lastname,
age
);
create table book(
title,
author,
published
);
insert into book(title, author, publis... | [
[
1,
0,
0.0417,
0.0417,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.125,
0.0417,
0,
0.66,
0.3333,
761,
3,
1,
0,
0,
242,
10,
1
],
[
14,
0,
0.1667,
0.0417,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\":memory:\")",
"cur = con.cursor()",
"cur.executescript(\"\"\"\n create table person(\n firstname,\n lastname,\n age\n );\n\n create table book("
] |
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect(":memory:")
# enable extension loading
con.enable_load_extension(True)
# Load the fulltext search extension
con.execute("select load_extension('./fts3.so')")
# alternatively you can load the extension using an API call:
# con.load_extension("./fts3.so")
... | [
[
1,
0,
0.0357,
0.0357,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.1071,
0.0357,
0,
0.66,
0.1429,
761,
3,
1,
0,
0,
242,
10,
1
],
[
8,
0,
0.2143,
0.0357,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\":memory:\")",
"con.enable_load_extension(True)",
"con.execute(\"select load_extension('./fts3.so')\")",
"con.enable_load_extension(False)",
"con.execute(\"create virtual table recipe using fts3(name, ingredients)\")",
"con.executescript... |
from pysqlite2 import dbapi2 as sqlite3
persons = [
("Hugo", "Boss"),
("Calvin", "Klein")
]
con = sqlite3.connect(":memory:")
# Create the table
con.execute("create table person(firstname, lastname)")
# Fill the table
con.executemany("insert into person(firstname, lastname) values (?, ?)", persons)
# P... | [
[
1,
0,
0.0476,
0.0476,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.2143,
0.1905,
0,
0.66,
0.1667,
70,
0,
0,
0,
0,
0,
5,
0
],
[
14,
0,
0.381,
0.0476,
0,
0.... | [
"from pysqlite2 import dbapi2 as sqlite3",
"persons = [\n (\"Hugo\", \"Boss\"),\n (\"Calvin\", \"Klein\")\n ]",
"con = sqlite3.connect(\":memory:\")",
"con.execute(\"create table person(firstname, lastname)\")",
"con.executemany(\"insert into person(firstname, lastname) values (?, ?)\", persons)",
... |
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect("mydb")
cur = con.cursor()
who = "Yeltsin"
age = 72
cur.execute("select name_last, age from people where name_last=:who and age=:age",
locals())
print cur.fetchone()
| [
[
1,
0,
0.0833,
0.0833,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.25,
0.0833,
0,
0.66,
0.1667,
761,
3,
1,
0,
0,
242,
10,
1
],
[
14,
0,
0.4167,
0.0833,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\"mydb\")",
"cur = con.cursor()",
"who = \"Yeltsin\"",
"age = 72",
"cur.execute(\"select name_last, age from people where name_last=:who and age=:age\",\n locals())",
"print(cur.fetchone())"
] |
# Not referenced from the documentation, but builds the database file the other
# code snippets expect.
from pysqlite2 import dbapi2 as sqlite3
import os
DB_FILE = "mydb"
if os.path.exists(DB_FILE):
os.remove(DB_FILE)
con = sqlite3.connect(DB_FILE)
cur = con.cursor()
cur.execute("""
create table people
... | [
[
1,
0,
0.1429,
0.0357,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
1,
0,
0.1786,
0.0357,
0,
0.66,
0.0909,
688,
0,
1,
0,
0,
688,
0,
0
],
[
14,
0,
0.25,
0.0357,
0,
0... | [
"from pysqlite2 import dbapi2 as sqlite3",
"import os",
"DB_FILE = \"mydb\"",
"if os.path.exists(DB_FILE):\n os.remove(DB_FILE)",
" os.remove(DB_FILE)",
"con = sqlite3.connect(DB_FILE)",
"cur = con.cursor()",
"cur.execute(\"\"\"\n create table people\n (\n name_last v... |
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect("mydb")
cur = con.cursor()
who = "Yeltsin"
age = 72
cur.execute("select name_last, age from people where name_last=:who and age=:age",
{"who": who, "age": age})
print cur.fetchone()
| [
[
1,
0,
0.0833,
0.0833,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.25,
0.0833,
0,
0.66,
0.1667,
761,
3,
1,
0,
0,
242,
10,
1
],
[
14,
0,
0.4167,
0.0833,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\"mydb\")",
"cur = con.cursor()",
"who = \"Yeltsin\"",
"age = 72",
"cur.execute(\"select name_last, age from people where name_last=:who and age=:age\",\n {\"who\": who, \"age\": age})",
"print(cur.fetchone())"
] |
from pysqlite2 import dbapi2 as sqlite3
import datetime
con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES)
cur = con.cursor()
cur.execute('select ? as "x [timestamp]"', (datetime.datetime.now(),))
dt = cur.fetchone()[0]
print dt, type(dt)
| [
[
1,
0,
0.125,
0.125,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
1,
0,
0.25,
0.125,
0,
0.66,
0.1667,
426,
0,
1,
0,
0,
426,
0,
0
],
[
14,
0,
0.5,
0.125,
0,
0.66,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"import datetime",
"con = sqlite3.connect(\":memory:\", detect_types=sqlite3.PARSE_COLNAMES)",
"cur = con.cursor()",
"cur.execute('select ? as \"x [timestamp]\"', (datetime.datetime.now(),))",
"dt = cur.fetchone()[0]",
"print(dt, type(dt))"
] |
from pysqlite2 import dbapi2 as sqlite3
def char_generator():
import string
for c in string.letters[:26]:
yield (c,)
con = sqlite3.connect(":memory:")
cur = con.cursor()
cur.execute("create table characters(c)")
cur.executemany("insert into characters(c) values (?)", char_generator())
cur.execute("s... | [
[
1,
0,
0.0667,
0.0667,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
2,
0,
0.3,
0.2667,
0,
0.66,
0.1429,
806,
0,
0,
0,
0,
0,
0,
0
],
[
1,
1,
0.2667,
0.0667,
1,
0.17,... | [
"from pysqlite2 import dbapi2 as sqlite3",
"def char_generator():\n import string\n for c in string.letters[:26]:\n yield (c,)",
" import string",
" for c in string.letters[:26]:\n yield (c,)",
" yield (c,)",
"con = sqlite3.connect(\":memory:\")",
"cur = con.cursor()",
... |
from pysqlite2 import dbapi2 as sqlite3
con = sqlite3.connect("mydb")
cur = con.cursor()
newPeople = (
('Lebed' , 53),
('Zhirinovsky' , 57),
)
for person in newPeople:
cur.execute("insert into people (name_last, age) values (?, ?)", person)
# The changes will not be saved unless the transaction... | [
[
1,
0,
0.0625,
0.0625,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
14,
0,
0.1875,
0.0625,
0,
0.66,
0.2,
761,
3,
1,
0,
0,
242,
10,
1
],
[
14,
0,
0.3125,
0.0625,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"con = sqlite3.connect(\"mydb\")",
"cur = con.cursor()",
"newPeople = (\n ('Lebed' , 53),\n ('Zhirinovsky' , 57),\n )",
"for person in newPeople:\n cur.execute(\"insert into people (name_last, age) values (?, ?)\", person)",
" cur.execute(\"ins... |
from pysqlite2 import dbapi2 as sqlite3
class Point(object):
def __init__(self, x, y):
self.x, self.y = x, y
def __conform__(self, protocol):
if protocol is sqlite3.PrepareProtocol:
return "%f;%f" % (self.x, self.y)
con = sqlite3.connect(":memory:")
cur = con.cursor()
p = Point(4... | [
[
1,
0,
0.0625,
0.0625,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
3,
0,
0.375,
0.4375,
0,
0.66,
0.1667,
652,
0,
2,
0,
0,
186,
0,
0
],
[
2,
1,
0.2812,
0.125,
1,
0.... | [
"from pysqlite2 import dbapi2 as sqlite3",
"class Point(object):\n def __init__(self, x, y):\n self.x, self.y = x, y\n\n def __conform__(self, protocol):\n if protocol is sqlite3.PrepareProtocol:\n return \"%f;%f\" % (self.x, self.y)",
" def __init__(self, x, y):\n self.... |
from pysqlite2 import dbapi2 as sqlite3
class Point(object):
def __init__(self, x, y):
self.x, self.y = x, y
def __repr__(self):
return "(%f;%f)" % (self.x, self.y)
def adapt_point(point):
return "%f;%f" % (point.x, point.y)
def convert_point(s):
x, y = map(float, s.split(";"))
r... | [
[
1,
0,
0.0213,
0.0213,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
3,
0,
0.117,
0.1277,
0,
0.66,
0.0455,
652,
0,
2,
0,
0,
186,
0,
0
],
[
2,
1,
0.0957,
0.0426,
1,
0... | [
"from pysqlite2 import dbapi2 as sqlite3",
"class Point(object):\n def __init__(self, x, y):\n self.x, self.y = x, y\n\n def __repr__(self):\n return \"(%f;%f)\" % (self.x, self.y)",
" def __init__(self, x, y):\n self.x, self.y = x, y",
" self.x, self.y = x, y",
" def... |
from pysqlite2 import dbapi2 as sqlite3
class IterChars:
def __init__(self):
self.count = ord('a')
def __iter__(self):
return self
def next(self):
if self.count > ord('z'):
raise StopIteration
self.count += 1
return (chr(self.count - 1),) # this is a 1-... | [
[
1,
0,
0.0417,
0.0417,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
3,
0,
0.3542,
0.5,
0,
0.66,
0.125,
192,
0,
3,
0,
0,
0,
0,
3
],
[
2,
1,
0.1875,
0.0833,
1,
0.68,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"class IterChars:\n def __init__(self):\n self.count = ord('a')\n\n def __iter__(self):\n return self\n\n def next(self):",
" def __init__(self):\n self.count = ord('a')",
" self.count = ord('a')",
" def __iter__(self):\n ... |
from pysqlite2 import dbapi2 as sqlite3
import apsw
apsw_con = apsw.Connection(":memory:")
apsw_con.createscalarfunction("times_two", lambda x: 2*x, 1)
# Create pysqlite connection from APSW connection
con = sqlite3.connect(apsw_con)
result = con.execute("select times_two(15)").fetchone()[0]
assert result == 30
con.c... | [
[
1,
0,
0.0833,
0.0833,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
1,
0,
0.1667,
0.0833,
0,
0.66,
0.1667,
654,
0,
1,
0,
0,
654,
0,
0
],
[
14,
0,
0.3333,
0.0833,
0,
... | [
"from pysqlite2 import dbapi2 as sqlite3",
"import apsw",
"apsw_con = apsw.Connection(\":memory:\")",
"apsw_con.createscalarfunction(\"times_two\", lambda x: 2*x, 1)",
"con = sqlite3.connect(apsw_con)",
"result = con.execute(\"select times_two(15)\").fetchone()[0]",
"con.close()"
] |
from pysqlite2 import dbapi2 as sqlite3
import datetime, time
def adapt_datetime(ts):
return time.mktime(ts.timetuple())
sqlite3.register_adapter(datetime.datetime, adapt_datetime)
con = sqlite3.connect(":memory:")
cur = con.cursor()
now = datetime.datetime.now()
cur.execute("select ?", (now,))
print cur.fetcho... | [
[
1,
0,
0.0714,
0.0714,
0,
0.66,
0,
987,
0,
1,
0,
0,
987,
0,
0
],
[
1,
0,
0.1429,
0.0714,
0,
0.66,
0.125,
426,
0,
2,
0,
0,
426,
0,
0
],
[
2,
0,
0.3214,
0.1429,
0,
0... | [
"from pysqlite2 import dbapi2 as sqlite3",
"import datetime, time",
"def adapt_datetime(ts):\n return time.mktime(ts.timetuple())",
" return time.mktime(ts.timetuple())",
"sqlite3.register_adapter(datetime.datetime, adapt_datetime)",
"con = sqlite3.connect(\":memory:\")",
"cur = con.cursor()",
"... |
# Author: Paul Kippes <kippesp@gmail.com>
import unittest
from pysqlite2 import dbapi2 as sqlite
class DumpTests(unittest.TestCase):
def setUp(self):
self.cx = sqlite.connect(":memory:")
self.cu = self.cx.cursor()
def tearDown(self):
self.cx.close()
def CheckTableDump(self):
... | [
[
1,
0,
0.0577,
0.0192,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0769,
0.0192,
0,
0.66,
0.2,
987,
0,
1,
0,
0,
987,
0,
0
],
[
3,
0,
0.4615,
0.7115,
0,
0.66,... | [
"import unittest",
"from pysqlite2 import dbapi2 as sqlite",
"class DumpTests(unittest.TestCase):\n def setUp(self):\n self.cx = sqlite.connect(\":memory:\")\n self.cu = self.cx.cursor()\n\n def tearDown(self):\n self.cx.close()",
" def setUp(self):\n self.cx = sqlite.conn... |
# Mimic the sqlite3 console shell's .dump command
# Author: Paul Kippes <kippesp@gmail.com>
def _iterdump(connection):
"""
Returns an iterator to the dump of the database in an SQL text format.
Used to produce an SQL dump of the database. Useful to save an in-memory
database for later restoration. T... | [
[
2,
0,
0.5317,
0.9524,
0,
0.66,
0,
339,
0,
1,
0,
0,
0,
0,
11
],
[
8,
1,
0.127,
0.1111,
1,
0.03,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
1,
0.2063,
0.0159,
1,
0.03,
... | [
"def _iterdump(connection):\n \"\"\"\n Returns an iterator to the dump of the database in an SQL text format.\n\n Used to produce an SQL dump of the database. Useful to save an in-memory\n database for later restoration. This function should not be called\n directly but instead called from the Conn... |
#!/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... | [
[
1,
0,
0.0588,
0.0118,
0,
0.66,
0,
715,
0,
1,
0,
0,
715,
0,
0
],
[
1,
0,
0.0706,
0.0118,
0,
0.66,
0.125,
614,
0,
1,
0,
0,
614,
0,
0
],
[
1,
0,
0.0824,
0.0118,
0,
0... | [
"import logging",
"import shutil",
"import sys",
"import urlparse",
"import SimpleHTTPServer",
"import BaseHTTPServer",
"class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\n \"\"\"Handle playfoursquare.com requests, for testing.\"\"\"\n\n def do_GET(self):\n logging.warn('do_GET: %s, %s',... |
#!/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... | [
[
1,
0,
0.0201,
0.0067,
0,
0.66,
0,
426,
0,
1,
0,
0,
426,
0,
0
],
[
1,
0,
0.0268,
0.0067,
0,
0.66,
0.0769,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.0336,
0.0067,
0,
... | [
"import datetime",
"import sys",
"import textwrap",
"import common",
"from xml.dom import pulldom",
"PARSER = \"\"\"\\\n/**\n * Copyright 2009 Joe LaPenna\n */\n\npackage com.joelapenna.foursquare.parsers;\n\nimport com.joelapenna.foursquare.Foursquare;",
"BOOLEAN_STANZA = \"\"\"\\\n } else i... |
#!/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.... | [
[
8,
0,
0.0631,
0.0991,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1261,
0.009,
0,
0.66,
0.05,
2,
0,
1,
0,
0,
2,
0,
0
],
[
1,
0,
0.1351,
0.009,
0,
0.66,
0.... | [
"\"\"\"\nPull a oAuth protected page from foursquare.\n\nExpects ~/.oget to contain (one on each line):\nCONSUMER_KEY\nCONSUMER_KEY_SECRET\nUSERNAME\nPASSWORD",
"import httplib",
"import os",
"import re",
"import sys",
"import urllib",
"import urllib2",
"import urlparse",
"import user",
"from xml.... |
#!/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... | [
[
1,
0,
0.1111,
0.037,
0,
0.66,
0,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.1481,
0.037,
0,
0.66,
0.1429,
394,
0,
1,
0,
0,
394,
0,
0
],
[
1,
0,
0.1852,
0.037,
0,
0.6... | [
"import os",
"import subprocess",
"import sys",
"BASEDIR = '../main/src/com/joelapenna/foursquare'",
"TYPESDIR = '../captures/types/v1'",
"captures = sys.argv[1:]",
"if not captures:\n captures = os.listdir(TYPESDIR)",
" captures = os.listdir(TYPESDIR)",
"for f in captures:\n basename = f.split('... |
#!/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... | [
[
1,
0,
0.0263,
0.0088,
0,
0.66,
0,
715,
0,
1,
0,
0,
715,
0,
0
],
[
1,
0,
0.0439,
0.0088,
0,
0.66,
0.0833,
290,
0,
1,
0,
0,
290,
0,
0
],
[
1,
0,
0.0526,
0.0088,
0,
... | [
"import logging",
"from xml.dom import minidom",
"from xml.dom import pulldom",
"BOOLEAN = \"boolean\"",
"STRING = \"String\"",
"GROUP = \"Group\"",
"DEFAULT_INTERFACES = ['FoursquareType']",
"INTERFACES = {\n}",
"DEFAULT_CLASS_IMPORTS = [\n]",
"CLASS_IMPORTS = {\n# 'Checkin': DEFAULT_CLASS_IMP... |
# 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... | [
[
1,
0,
0.2075,
0.0189,
0,
0.66,
0,
934,
0,
1,
0,
0,
934,
0,
0
],
[
1,
0,
0.2264,
0.0189,
0,
0.66,
0.25,
801,
0,
2,
0,
0,
801,
0,
0
],
[
3,
0,
0.5189,
0.5283,
0,
0.... | [
"import cgi",
"from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer",
"class WamiHandler(BaseHTTPRequestHandler):\n dirname = \"/tmp/\"\n \n def do_GET(self):\n f = open(self.get_name())\n self.send_response(200)\n self.send_header('content-type','audio/x-wav')\n se... |
'''
Created on 21-03-2011
@author: maciek
'''
def formatString(format, **kwargs):
'''
'''
if not format: return ''
for arg in kwargs.keys():
format = format.replace("{" + arg + "}", "##" + arg + "##")
format = format.replace ("{", "{{")
format = format.replace("}", "}}")
for... | [
[
8,
0,
0.1304,
0.2174,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
2,
0,
0.6739,
0.6957,
0,
0.66,
1,
798,
0,
2,
1,
0,
0,
0,
9
],
[
8,
1,
0.413,
0.087,
1,
0.05,
0,
... | [
"'''\nCreated on 21-03-2011\n\n@author: maciek\n'''",
"def formatString(format, **kwargs):\n '''\n '''\n if not format: return ''\n \n for arg in kwargs.keys():\n format = format.replace(\"{\" + arg + \"}\", \"##\" + arg + \"##\")\n format = format.replace (\"{\", \"{{\")",
" '''\n ... |
'''
Created on 21-03-2011
@author: maciek
'''
from IndexGenerator import IndexGenerator
from optparse import OptionParser
import os
import tempfile
import shutil
import logging
logging.basicConfig(level = logging.DEBUG)
parser = OptionParser()
parser.add_option('-n', '--app-name', action='store', dest='appName', hel... | [
[
8,
0,
0.0341,
0.0568,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0682,
0.0114,
0,
0.66,
0.0303,
933,
0,
1,
0,
0,
933,
0,
0
],
[
1,
0,
0.0795,
0.0114,
0,
0.66... | [
"'''\nCreated on 21-03-2011\n\n@author: maciek\n'''",
"from IndexGenerator import IndexGenerator",
"from optparse import OptionParser",
"import os",
"import tempfile",
"import shutil",
"import logging",
"logging.basicConfig(level = logging.DEBUG)",
"parser = OptionParser()",
"parser.add_option('-n... |
'''
Created on 21-03-2011
@author: maciek
'''
from formater import formatString
import os
class IndexGenerator(object):
'''
Generates Index.html for iOS app OTA distribution
'''
basePath = os.path.dirname(__file__)
templateFile = os.path.join(basePath,"templates/index.tmpl")
releaseUrls = ""
... | [
[
8,
0,
0.0526,
0.0877,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1053,
0.0175,
0,
0.66,
0.3333,
11,
0,
1,
0,
0,
11,
0,
0
],
[
1,
0,
0.1228,
0.0175,
0,
0.66,
... | [
"'''\nCreated on 21-03-2011\n\n@author: maciek\n'''",
"from formater import formatString",
"import os",
"class IndexGenerator(object):\n '''\n Generates Index.html for iOS app OTA distribution\n '''\n basePath = os.path.dirname(__file__)\n templateFile = os.path.join(basePath,\"templates/index.... |
# Django settings for iphone12580 project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = '' # Or path to database file ... | [
[
14,
0,
0.0375,
0.0125,
0,
0.66,
0,
309,
1,
0,
0,
0,
0,
4,
0
],
[
14,
0,
0.05,
0.0125,
0,
0.66,
0.0455,
7,
2,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.0875,
0.0375,
0,
0.66,... | [
"DEBUG = True",
"TEMPLATE_DEBUG = DEBUG",
"ADMINS = (\n # ('Your Name', 'your_email@domain.com'),\n)",
"MANAGERS = ADMINS",
"DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.",
"DATABASE_NAME = '' # Or path to database file if using sqlite... |
from django.db import models
# Create your models here.
| [
[
1,
0,
0.3333,
0.3333,
0,
0.66,
0,
40,
0,
1,
0,
0,
40,
0,
0
]
] | [
"from django.db import models"
] |
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
... | [
[
8,
0,
0.1522,
0.2609,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.3478,
0.0435,
0,
0.66,
0.3333,
944,
0,
1,
0,
0,
944,
0,
0
],
[
3,
0,
0.5435,
0.2609,
0,
0.66... | [
"\"\"\"\nThis file demonstrates two different styles of tests (one doctest and one\nunittest). These will both pass when you run \"manage.py test\".\n\nReplace these with more appropriate tests for your application.\n\"\"\"",
"from django.test import TestCase",
"class SimpleTest(TestCase):\n def test_basic_a... |
# -*- coding: utf-8 -*-
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.shortcuts import render_to_response
from django.core.paginator import Paginator,InvalidPage,EmptyPage
def test(request):
return HttpResponse("hello iphone")
def index(request):
return render_to_response("in... | [
[
1,
0,
0.1053,
0.0526,
0,
0.66,
0,
779,
0,
3,
0,
0,
779,
0,
0
],
[
1,
0,
0.1579,
0.0526,
0,
0.66,
0.1429,
852,
0,
1,
0,
0,
852,
0,
0
],
[
1,
0,
0.2105,
0.0526,
0,
... | [
"from django.http import HttpResponseRedirect, HttpResponse, Http404",
"from django.shortcuts import render_to_response",
"from django.core.paginator import Paginator,InvalidPage,EmptyPage",
"def test(request):\n return HttpResponse(\"hello iphone\")",
" return HttpResponse(\"hello iphone\")",
"def ... |
#!/usr/bin/env 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 ... | [
[
1,
0,
0.1818,
0.0909,
0,
0.66,
0,
879,
0,
1,
0,
0,
879,
0,
0
],
[
7,
0,
0.5,
0.5455,
0,
0.66,
0.5,
0,
0,
1,
0,
0,
0,
0,
2
],
[
1,
1,
0.3636,
0.0909,
1,
0.47,
... | [
"from django.core.management import execute_manager",
"try:\n import settings # Assumed to be in the same directory.\nexcept ImportError:\n import sys\n 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 dj... |
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^iphone12580/', include('iphone12580.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admin... | [
[
1,
0,
0.0455,
0.0455,
0,
0.66,
0,
341,
0,
1,
0,
0,
341,
0,
0
],
[
1,
0,
0.1818,
0.0455,
0,
0.66,
0.3333,
302,
0,
1,
0,
0,
302,
0,
0
],
[
8,
0,
0.2273,
0.0455,
0,
... | [
"from django.conf.urls.defaults import *",
"from django.contrib import admin",
"admin.autodiscover()",
"urlpatterns = patterns('',\n # Example:\n # (r'^iphone12580/', include('iphone12580.foo.urls')),\n\n # Uncomment the admin/doc line below and add 'django.contrib.admindocs' \n # to INSTALLED_APP... |
#!/usr/bin/env 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 ... | [
[
1,
0,
0.1818,
0.0909,
0,
0.66,
0,
879,
0,
1,
0,
0,
879,
0,
0
],
[
7,
0,
0.5,
0.5455,
0,
0.66,
0.5,
0,
0,
1,
0,
0,
0,
0,
2
],
[
1,
1,
0.3636,
0.0909,
1,
0.05,
... | [
"from django.core.management import execute_manager",
"try:\n import settings # Assumed to be in the same directory.\nexcept ImportError:\n import sys\n 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 dj... |
import sys
import os
from PIL import Image
def detectEdge(img, w, h):
left, upper, right, lower = w,h,0,0
pixels = img.load()
threshold = 10
for x in range(0,w):
for y in xrange(0,h):
pix = pixels[x,y]
if (pix[0]<(254-threshold) or pix[1]<(254-threshold) or pix[2... | [
[
1,
0,
0.0645,
0.0323,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.0968,
0.0323,
0,
0.66,
0.25,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.129,
0.0323,
0,
0.6... | [
"import sys",
"import os",
"from PIL import Image",
"def detectEdge(img, w, h):\n \n left, upper, right, lower = w,h,0,0\n pixels = img.load()\n threshold = 10\n for x in range(0,w):\n for y in xrange(0,h):\n pix = pixels[x,y]",
" left, upper, right, lower = w,h,0,0",
"... |
# 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... | [
[
1,
0,
0.2075,
0.0189,
0,
0.66,
0,
934,
0,
1,
0,
0,
934,
0,
0
],
[
1,
0,
0.2264,
0.0189,
0,
0.66,
0.25,
801,
0,
2,
0,
0,
801,
0,
0
],
[
3,
0,
0.5189,
0.5283,
0,
0.... | [
"import cgi",
"from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer",
"class WamiHandler(BaseHTTPRequestHandler):\n dirname = \"/tmp/\"\n \n def do_GET(self):\n f = open(self.get_name())\n self.send_response(200)\n self.send_header('content-type','audio/x-wav')\n se... |
#!/usr/bin/env python
import time
import os
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
DEBUG = 0
# read SPI data from MCP3008 chip, 8 possible adc's (0 thru 7)
def readadc(adcnum, clockpin, mosipin, misopin, cspin):
if ((adcnum > 7) or (adcnum < 0)):
return -1
GPIO.output(cspin, Tr... | [
[
1,
0,
0.0182,
0.0091,
0,
0.66,
0,
654,
0,
1,
0,
0,
654,
0,
0
],
[
1,
0,
0.0273,
0.0091,
0,
0.66,
0.0556,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.0364,
0.0091,
0,
... | [
"import time",
"import os",
"import RPi.GPIO as GPIO",
"GPIO.setmode(GPIO.BCM)",
"DEBUG = 0",
"def readadc(adcnum, clockpin, mosipin, misopin, cspin):\n if ((adcnum > 7) or (adcnum < 0)):\n return -1\n GPIO.output(cspin, True)\n\n GPIO.output(clockpin, False) # start c... |
#coding=utf8
from django.db import models
class Address(models.Model):
name = models.CharField(max_length=20)
address = models.CharField(max_length=100)
pub_date = models.DateField()
| [
[
1,
0,
0.2857,
0.1429,
0,
0.66,
0,
40,
0,
1,
0,
0,
40,
0,
0
],
[
3,
0,
0.7857,
0.5714,
0,
0.66,
1,
149,
0,
0,
0,
0,
996,
0,
3
],
[
14,
1,
0.7143,
0.1429,
1,
0.28,
... | [
"from django.db import models",
"class Address(models.Model):\n name = models.CharField(max_length=20)\n address = models.CharField(max_length=100)\n pub_date = models.DateField()",
" name = models.CharField(max_length=20)",
" address = models.CharField(max_length=100)",
" pub_date = models.Date... |
"""
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... | [
[
8,
0,
0.2188,
0.375,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.5,
0.0625,
0,
0.66,
0.5,
944,
0,
1,
0,
0,
944,
0,
0
],
[
3,
0,
0.8438,
0.375,
0,
0.66,
1,... | [
"\"\"\"\nThis file demonstrates writing tests using the unittest module. These will pass\nwhen you run \"manage.py test\".\n\nReplace this with more appropriate tests for your application.\n\"\"\"",
"from django.test import TestCase",
"class SimpleTest(TestCase):\n def test_basic_addition(self):\n \"\... |
from django.conf.urls.defaults import patterns, url
__author__ = 'Administrator'
urlpatterns = patterns('address.views',
url(r'^test/$','test')
) | [
[
1,
0,
0.1667,
0.1667,
0,
0.66,
0,
341,
0,
2,
0,
0,
341,
0,
0
],
[
14,
0,
0.5,
0.1667,
0,
0.66,
0.5,
777,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.8333,
0.5,
0,
0.66,
... | [
"from django.conf.urls.defaults import patterns, url",
"__author__ = 'Administrator'",
"urlpatterns = patterns('address.views',\n url(r'^test/$','test')\n)"
] |
from django.contrib import admin
from address.models import Address
__author__ = 'Administrator'
admin.site.register(Address) | [
[
1,
0,
0.2,
0.2,
0,
0.66,
0,
302,
0,
1,
0,
0,
302,
0,
0
],
[
1,
0,
0.4,
0.2,
0,
0.66,
0.3333,
980,
0,
1,
0,
0,
980,
0,
0
],
[
14,
0,
0.6,
0.2,
0,
0.66,
0.6667,... | [
"from django.contrib import admin",
"from address.models import Address",
"__author__ = 'Administrator'",
"admin.site.register(Address)"
] |
# Create your views here.
import urllib2
from django.http import HttpResponse
from django.shortcuts import render_to_response
from models import Address
def latest_address(request):
addresslist = Address.objects.order_by('-pub_date')[:10]
return render_to_response('latest_address.html', {'addresslist':... | [
[
1,
0,
0.1429,
0.0714,
0,
0.66,
0,
345,
0,
1,
0,
0,
345,
0,
0
],
[
1,
0,
0.2143,
0.0714,
0,
0.66,
0.2,
779,
0,
1,
0,
0,
779,
0,
0
],
[
1,
0,
0.2857,
0.0714,
0,
0.6... | [
"import urllib2",
"from django.http import HttpResponse",
"from django.shortcuts import render_to_response",
"from models import Address",
"def latest_address(request):\n addresslist = Address.objects.order_by('-pub_date')[:10]\n return render_to_response('latest_address.html', {'addresslist':addressl... |
from BeautifulSoup import BeautifulSoup
__author__ = 'Administrator'
import urllib,urllib2,cookielib
from BeautifulSoup import BeautifulSoup
myCookie = urllib2.HTTPCookieProcessor(cookielib.CookieJar())
openner = urllib2.build_opener(myCookie)
post_data = {'email':'yinjj472@nenu.edu.cn',
'pass... | [
[
1,
0,
0.0312,
0.0312,
0,
0.66,
0,
878,
0,
1,
0,
0,
878,
0,
0
],
[
14,
0,
0.0938,
0.0312,
0,
0.66,
0.0909,
777,
1,
0,
0,
0,
0,
3,
0
],
[
1,
0,
0.1562,
0.0312,
0,
0... | [
"from BeautifulSoup import BeautifulSoup",
"__author__ = 'Administrator'",
"import urllib,urllib2,cookielib",
"from BeautifulSoup import BeautifulSoup",
"myCookie = urllib2.HTTPCookieProcessor(cookielib.CookieJar())",
"openner = urllib2.build_opener(myCookie)",
"post_data = {'email':'yinjj472@nenu.edu.c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.