code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
#
| Python |
import os
import re
from webob import Request, Response
from webob import exc
from tempita import HTMLTemplate
VIEW_TEMPLATE = HTMLTemplate("""\
<html>
<head>
<title>{{page.title}}</title>
</head>
<body>
<h1>{{page.title}}</h1>
{{if message}}
<div style="background-color: #99f">{{message}}</div>
{{endif}}
<div>{... | Python |
import os
import urllib
import time
import re
from cPickle import load, dump
from webob import Request, Response, html_escape
from webob import exc
class Commenter(object):
def __init__(self, app, storage_dir):
self.app = app
self.storage_dir = storage_dir
if not os.path.exists(storage... | Python |
#!/usr/bin/python
import yaml, codecs, sys, os.path, optparse
class Style:
def __init__(self, header=None, footer=None,
tokens=None, events=None, replaces=None):
self.header = header
self.footer = footer
self.replaces = replaces
self.substitutions = {}
for doma... | Python |
#!/usr/bin/python
import yaml, codecs, sys, os.path, optparse
class Style:
def __init__(self, header=None, footer=None,
tokens=None, events=None, replaces=None):
self.header = header
self.footer = footer
self.replaces = replaces
self.substitutions = {}
for doma... | Python |
NAME = 'PyYAML'
VERSION = '3.05'
DESCRIPTION = "YAML parser and emitter for Python"
LONG_DESCRIPTION = """\
YAML is a data serialization format designed for human readability and
interaction with scripting languages. PyYAML is a YAML parser and
emitter for Python.
PyYAML features a complete YAML 1.1 parser, Unicode ... | Python |
from setup import *
from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext
if __name__ == '__main__':
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
author=AUTHOR,
... | Python |
class Token(object):
def __init__(self, start_mark, end_mark):
self.start_mark = start_mark
self.end_mark = end_mark
def __repr__(self):
attributes = [key for key in self.__dict__
if not key.endswith('_mark')]
attributes.sort()
arguments = ', '.join(['%s=... | Python |
# Scanner produces tokens of the following types:
# STREAM-START
# STREAM-END
# DIRECTIVE(name, value)
# DOCUMENT-START
# DOCUMENT-END
# BLOCK-SEQUENCE-START
# BLOCK-MAPPING-START
# BLOCK-END
# FLOW-SEQUENCE-START
# FLOW-MAPPING-START
# FLOW-SEQUENCE-END
# FLOW-MAPPING-END
# BLOCK-ENTRY
# FLOW-ENTRY
# KEY
# VALUE
# AL... | Python |
__all__ = ['BaseLoader', 'SafeLoader', 'Loader']
from reader import *
from scanner import *
from parser import *
from composer import *
from constructor import *
from resolver import *
class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, BaseResolver):
def __init__(self, stream):
Reader.... | Python |
__all__ = ['Composer', 'ComposerError']
from error import MarkedYAMLError
from events import *
from nodes import *
class ComposerError(MarkedYAMLError):
pass
class Composer(object):
def __init__(self):
self.anchors = {}
def check_node(self):
# Drop the STREAM-START event.
if se... | Python |
__all__ = ['BaseDumper', 'SafeDumper', 'Dumper']
from emitter import *
from serializer import *
from representer import *
from resolver import *
class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver):
def __init__(self, stream,
default_style=None, default_flow_style=None,
c... | Python |
# Abstract classes.
class Event(object):
def __init__(self, start_mark=None, end_mark=None):
self.start_mark = start_mark
self.end_mark = end_mark
def __repr__(self):
attributes = [key for key in ['anchor', 'tag', 'implicit', 'value']
if hasattr(self, key)]
argu... | Python |
__all__ = ['BaseConstructor', 'SafeConstructor', 'Constructor',
'ConstructorError']
from error import *
from nodes import *
import datetime
try:
set
except NameError:
from sets import Set as set
import binascii, re, sys, types
class ConstructorError(MarkedYAMLError):
pass
class BaseConstructor(ob... | Python |
__all__ = ['CBaseLoader', 'CSafeLoader', 'CLoader',
'CBaseDumper', 'CSafeDumper', 'CDumper']
from _yaml import CParser, CEmitter
from constructor import *
from serializer import *
from representer import *
from resolver import *
class CBaseLoader(CParser, BaseConstructor, BaseResolver):
def __init__(... | Python |
__all__ = ['Serializer', 'SerializerError']
from error import YAMLError
from events import *
from nodes import *
class SerializerError(YAMLError):
pass
class Serializer(object):
ANCHOR_TEMPLATE = u'id%03d'
def __init__(self, encoding=None,
explicit_start=None, explicit_end=None, version=No... | Python |
__all__ = ['BaseResolver', 'Resolver']
from error import *
from nodes import *
import re
class ResolverError(YAMLError):
pass
class BaseResolver(object):
DEFAULT_SCALAR_TAG = u'tag:yaml.org,2002:str'
DEFAULT_SEQUENCE_TAG = u'tag:yaml.org,2002:seq'
DEFAULT_MAPPING_TAG = u'tag:yaml.org,2002:map'
... | Python |
class Node(object):
def __init__(self, tag, value, start_mark, end_mark):
self.tag = tag
self.value = value
self.start_mark = start_mark
self.end_mark = end_mark
def __repr__(self):
value = self.value
#if isinstance(value, list):
# if len(value) == 0:
... | Python |
# This module contains abstractions for the input stream. You don't have to
# looks further, there are no pretty code.
#
# We define two classes here.
#
# Mark(source, line, column)
# It's just a record and its only use is producing nice error messages.
# Parser does not use it for any other purposes.
#
# Reader(so... | Python |
# The following YAML grammar is LL(1) and is parsed by a recursive descent
# parser.
#
# stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
# implicit_document ::= block_node DOCUMENT-END*
# explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
# block_node_or_inden... | Python |
__all__ = ['BaseRepresenter', 'SafeRepresenter', 'Representer',
'RepresenterError']
from error import *
from nodes import *
import datetime
try:
set
except NameError:
from sets import Set as set
import sys, copy_reg, types
class RepresenterError(YAMLError):
pass
class BaseRepresenter(object):
... | Python |
# Emitter expects events obeying the following grammar:
# stream ::= STREAM-START document* STREAM-END
# document ::= DOCUMENT-START node DOCUMENT-END
# node ::= SCALAR | sequence | mapping
# sequence ::= SEQUENCE-START node* SEQUENCE-END
# mapping ::= MAPPING-START (node node)* MAPPING-END
__all__ = ['Emitter', 'Emi... | Python |
from error import *
from tokens import *
from events import *
from nodes import *
from loader import *
from dumper import *
try:
from cyaml import *
except ImportError:
pass
def scan(stream, Loader=Loader):
"""
Scan a YAML stream and produce scanning tokens.
"""
loader = Loader(stream)
... | Python |
__all__ = ['Mark', 'YAMLError', 'MarkedYAMLError']
class Mark(object):
def __init__(self, name, index, line, column, buffer, pointer):
self.name = name
self.index = index
self.line = line
self.column = column
self.buffer = buffer
self.pointer = pointer
def get... | Python |
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | Python |
# coding: utf-8
from config.url import urls
import web
app = web.application(urls, globals())
def notfound():
return web.notfound('Sorry, the page you were looking for was not found.')
def internalerror():
return web.internalerror('Bad, bad server. No donut for you.')
app.notfound = notfound
if __name__ =... | Python |
# coding: utf-8
#
# 获得文件夹的大小
# @author wangtao
# @version 2011.07.10
#
import os
import sys
from os.path import join, getsize
inputdir = sys.argv[1]
def getdirsize(dir):
size = 0L
for root, dirs, files in os.walk(dir):
size += sum([getsize(join(root, name)) for name in files])
return size
if ... | Python |
#!/usr/bin/env python
# coding: utf-8
import web
from config import settings
from datetime import datetime
render = settings.render
db = settings.db
class hello:
def GET(self):
return 'Hello, Feed!'
class redirect:
def GET(self, path):
web.seeother('/' + path)
class index:
def GET(s... | Python |
#!/usr/bin/env python
# coding: utf-8
import web
from config import settings
from datetime import datetime
render = settings.render
db = settings.db
class hello:
def GET(self):
return 'Hello, Feed!'
class redirect:
def GET(self, path):
web.seeother('/' + path)
class index:
def GET(s... | Python |
# coding: utf-8
def getVisit():
visit = db.select('sys', what='value', where='`sid` =1' , limit=1)
return visit[0]['value'] | Python |
#!/usr/bin/env python
# coding: utf-8
import web
import options
db = web.database(dbn='mysql', db='feed', user='root', pw='yunlian', host='127.0.0.1')
def getVisit():
return 4
#visit = db.select('sys', what='value', where='`sid` =1' , limit=1)
#return visit[0]['value']
def getTableSize():
size = db.... | Python |
#!/usr/bin/env python
# coding: utf-8
import web
import options
db = web.database(dbn='mysql', db='feed', user='root', pw='yunlian', host='127.0.0.1')
def getVisit():
return 4
#visit = db.select('sys', what='value', where='`sid` =1' , limit=1)
#return visit[0]['value']
def getTableSize():
size = db.... | Python |
#!/usr/bin/env python
# coding: utf-8
pre_fix = 'controllers.'
urls = (
'/(.*)/', pre_fix + 'feed.redirect',
'/', pre_fix + 'feed.index',
'/list/(.+)', pre_fix + 'feed.listx',
'/hello', pre_fix +'feed.hello',
'/readOne/(.+)', pre_fix +'feed.readOne',
'/readRSS/(.+)', pr... | Python |
#!/usr/bin/env python
# coding: utf-8
pre_fix = 'controllers.'
urls = (
'/(.*)/', pre_fix + 'feed.redirect',
'/', pre_fix + 'feed.index',
'/list/(.+)', pre_fix + 'feed.listx',
'/hello', pre_fix +'feed.hello',
'/readOne/(.+)', pre_fix +'feed.readOne',
'/readRSS/(.+)', pr... | 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 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import ez_setup
ez_setup.use_setuptools()
from setuptools import setup, find_packages
from finddata import find_package_data
setup(
name = 'Feedjack',
version = '0.9.16',
url = 'http://www.feedjack.org/',
author = 'Gustavo Picón',
author_email = 'gpic... | Python |
# Note: you may want to copy this into your setup.py file verbatim, as
# you can't import this from another package, when you don't know if
# that package is installed yet.
import os
import sys
from fnmatch import fnmatchcase
from distutils.util import convert_path
# Provided as an attribute, so you can append to the... | Python |
# -*- coding: utf-8 -*-
"""
feedjack
Gustavo Picón
fjcache.py
"""
import md5
from django.core.cache import cache
from django.conf import settings
T_HOST = 1
T_ITEM = 2
T_META = 3
def str2md5(key):
""" Returns the md5 hash of a string.
"""
ctx = md5.new()
ctx.update(key.encode('utf-8'))
retur... | Python |
# -*- coding: utf-8 -*-
"""
feedjack
Gustavo Picón
fjcloud.py
"""
import math
from feedjack import fjlib
from feedjack import fjcache
def getsteps(levels, tagmax):
""" Returns a list with the max number of posts per "tagcloud level"
"""
ntw = levels
if ntw < 2:
ntw = 2
steps = [(stp, 1 ... | Python |
# -*- coding: utf-8 -*-
# pylint: disable-msg=W0232, R0903, W0131
"""
feedjack
Gustavo Picón
models.py
"""
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from feedjack import fjcache
SITE_ORDERBY_CHOICES = (
(1, _('Date publi... | Python |
# -*- coding: utf-8 -*-
"""
feedjack
Gustavo Picón
urls.py
"""
from django.conf.urls.defaults import patterns
from django.views.generic.simple import redirect_to
from feedjack import views
urlpatterns = patterns('',
(r'^rss20.xml$', redirect_to,
{'url':'/feed/rss/'}),
(r'^feed/$', redirect_to,
... | Python |
# -*- coding: utf-8 -*-
"""
feedjack
Gustavo Picón
admin.py
"""
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from feedjack import models
class LinkAdmin(admin.ModelAdmin):
pass
class SiteAdmin(admin.ModelAdmin):
list_display = ('url', 'name')
filter_vertic... | Python |
# -*- coding: utf-8 -*-
"""
feedjack
Gustavo Picón
views.py
"""
from django.utils import feedgenerator
from django.shortcuts import render_to_response
from django.http import HttpResponse
from django.utils.cache import patch_vary_headers
from django.template import Context, loader
from feedjack import models
from f... | Python |
# -*- coding: utf-8 -*-
"""
feedjack
Gustavo Picón
__init__.py
"""
| Python |
# -*- coding: utf-8 -*-
"""
feedjack
Gustavo Picón
fjlib.py
"""
from django.conf import settings
from django.db import connection
from django.core.paginator import Paginator, InvalidPage
from django.http import Http404
from django.utils.encoding import smart_unicode
from feedjack import models
from feedjack import f... | Python |
#!/usr/bin/env python
#
# -------------------------------
# projects/python/collatz/main.py
# Copyright (C) 2009
# Glenn P. Downing
# -------------------------------
# To run the program
# main.py < Collatz.in > Collatz.out
# To document the program
# pydoc -w main
# -------
# globals
# -------
i = 0 # inpu... | Python |
#!/usr/bin/env python
# --------------------------------------
# projects/python/collatz/TestCollatz.py
# Copyright (C) 2009
# Glenn P. Downing
# --------------------------------------
# To run the tests
# TestCollatz.py
# To document the tests
# pydoc -w TestCollatz
import main
import unittest
# ---------... | Python |
#!/usr/bin/env python
#
# -------------------------------
# projects/python/collatz/main.py
# Copyright (C) 2009
# Glenn P. Downing
# -------------------------------
# To run the program
# main.py < Collatz.in > Collatz.out
# To document the program
# pydoc -w main
# -------
# globals
# -------
i = 0 # inpu... | Python |
#!/usr/bin/env python
# --------------------------------------
# projects/python/collatz/TestCollatz.py
# Copyright (C) 2009
# Glenn P. Downing
# --------------------------------------
# To run the tests
# TestCollatz.py
# To document the tests
# pydoc -w TestCollatz
import main
import unittest
# ---------... | Python |
#!/usr/bin/env pypy
import os, sys, logging, re
import argparse
import fnmatch
configurations = {'lite', 'pro'}
package_dirs = {
'lite': ('src/cx/hell/android/pdfview',),
'pro': ('src/cx/hell/android/pdfviewpro',)
}
file_replaces = {
'lite': (
'cx.hell.android.pdfview.',
'"cx.hell.an... | Python |
#!/usr/local/bin/python
"""
This script converts a subset of SVG into an HTML imagemap
Note *subset*. It only handles <path> elements, for which it only pays
attention to the M and L commands. Futher, it only notices the "translate"
transform.
It was written to generate the examples in the documentation for maphil... | Python |
#!/usr/local/bin/python
"""
Based on: http://wxpsvg.googlecode.com/svn/trunk/svg/pathdata.py
According to that project, this file is licensed under the LGPL
"""
try:
from pyparsing import (ParserElement, Literal, Word, CaselessLiteral,
Optional, Combine, Forward, ZeroOrMore, nums, oneOf, Group, ParseExcep... | Python |
#!/usr/local/bin/python
"""
Based on: http://wxpsvg.googlecode.com/svn/trunk/svg/pathdata.py
According to that project, this file is licensed under the LGPL
"""
try:
from pyparsing import (ParserElement, Literal, Word, CaselessLiteral,
Optional, Combine, Forward, ZeroOrMore, nums, oneOf, Group, ParseExcep... | Python |
#!/usr/local/bin/python
"""
This script converts a subset of SVG into an HTML imagemap
Note *subset*. It only handles <path> elements, for which it only pays
attention to the M and L commands. Futher, it only notices the "translate"
transform.
It was written to generate the examples in the documentation for maphil... | Python |
#!/usr/bin/env python
import calendar
import logging
import os
import stat
import time
from threading import Thread, Lock
from crypto import CryptoHelper
from S3 import Connection
from SQLiteHelper import SQLiteHelper as SQL
import constants as C
class SafeDepositBox(Thread):
def __init__(self):
Thread.__... | Python |
#!/usr/bin/env python
import readline
import cmd
import logging
import sys
class LockboxCommands(cmd.Cmd):
def __init__(self):
cmd.Cmd.__init__(self)
self.prompt = 'Lockbox > '
def do_viewlog(self): pass
# local credentials
def do_updateawsaccesskey(self): pass
d... | Python |
#!/usr/bin/env python
import os
from util import log, init_dir
import M2Crypto
DECODE = 0
ENCODE = 1
def _filter_cipher(input, output, cipher):
while 1:
data = input.read(32000)
if len(data) == 0:
break
enc = cipher.update(data)
output.write(enc)
output.write(cipher.final())
output.f... | Python |
#!/usr/bin/env python
import os, re, subprocess, sys
import logging
import atexit
from logging import DEBUG, INFO, WARN, ERROR, FATAL
from time import time
from collections import defaultdict
import tempfile as tf
logging.basicConfig(stream=sys.stderr, level=logging.INFO,
format="%(levelname).1... | Python |
import hashlib
import json
import os
import base64
from util import log, tempfile
class FileNotFound(Exception): pass
class PermissionDenied(Exception): pass
AESKEY_FILE = 'aes.key'
CONTENT_FILE = 'contents'
def _hash_path(filepath):
return hashlib.md5(filepath).hexdigest()
def _hash_flatten_filepath(filepath):
... | Python |
import os
import sqlite3
import constants as C
SQL_SCHEMA = 'SDB.sql'
class SQLiteHelper:
def __init__(self, admin_directory, reset=False):
self.db_path = os.path.join(admin_directory, C.SDB_DB_NAME)
if reset:
if os.path.exists(self.db_path):
os.remove(self.db_path)
... | Python |
#!/usr/bin/env python
# known_files dict of list index
STATUS = 0
MTIME = 1
LOCK = 2
# File states
NOT_VISITED = 'not visted'
UNCHANGED = 'unchanged'
UPDATED = 'updated'
PNEW = 'poss. new'
IDLE_WINDOW = 2 # sec
SDB_DB_NAME = "safedepositbox.db"
| Python |
#!/usr/bin/env python
__all__ = ['bundle',
'constants',
'crypto',
'S3',
'util',
'SQLiteHelper',
'rsync',
'setup',
]
# enable access to external libaries.
import extern
| Python |
import os
import random
import re
import string
import time
import ConfigParser
import Queue
import boto.s3
import calendar
import constants as C
import socket
from bundle import AWSFileBundle as bundler
from util import log
BUCKET_NAME_PADDING_LEN = 20
METADATA_TAG_MD5 = 'orig_file_md5'
def Policy(object):
@sta... | Python |
#!/usr/bin/env python
| Python |
#!/usr/bin/env python
import boto
conn = boto.connect_sdb("AKIAJUHIZBILIEB4IOVA", "JpgOeEjrOC2q9Qf2XuLxrAZnW2iQ0rk762EGAzXv")
try:
domain = conn.get_domain('sdb')
except SDBResponseError:
domain = conn.create_domain('sdb')
data = {}
data['some-item'] = {'color':'blue','price':10,'size':'small'}
data['some-ot... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This is a pure Python implementation of the [rsync algorithm](TM96).
[TM96] Andrew Tridgell and Paul Mackerras. The rsync algorithm.
Technical Report TR-CS-96-05, Canberra 0200 ACT, Australia, 1996.
http://samba.anu.edu.au/rsync/.
### Example Use Case: ###
# On t... | Python |
#!/usr/bin/env python
import M2Crypto
def ocb():
pass
k = M2Crypto.RSA.gen_key(2048,11, ocb)
| Python |
#!/usr/bin/env python
import os
import stat
for root, dirs, files in os.walk(os.path.expanduser("~/Dropbox/GoodReader")):
st = os.stat(root)
print os.path.isdir(root), st.st_ino, st.st_mtime, root
for fi in files:
print " ", fi
| Python |
#!/usr/bin/env python
import xdelta3
| Python |
#!/usr/bin/env python
import os
import base64
import hashlib
import zlib
import time
BLOCK_SIZE = 4194304 # bytes (4 MB)
def time_compression(data, lib, level):
start = time.time()
out = lib.compress(data, level)
finish = time.time()
print lib.__name__, level, (finish - start), float(len(out)) / len(... | Python |
#
# SDBStatusBar.py
# SafeDepositBox
#
# Created by Matt Tierney on 2/28/11.
# Copyright (c) 2011 NYU. All rights reserved.
#
from Foundation import *
from AppKit import *
from SafeDepositBox import SafeDepositBox
from threading import Thread
start_time = NSDate.date()
class SDBStatusBar(NSObject):
statusb... | Python |
#
# main.py
# SafeDepositBox
#
# Created by Matt Tierney on 2/27/11.
# Copyright NYU 2011. All rights reserved.
#
#import modules required by application
import objc
#import Foundation
#import AppKit
from Foundation import *
from AppKit import *
from PyObjCTools import AppHelper
# import modules containing cla... | Python |
#
# SetupWindowController.py
# SafeDepositBox
#
# Created by Matt Tierney on 2/27/11.
# Copyright (c) 2011 NYU. All rights reserved.
#
from objc import YES, NO, IBAction, IBOutlet
from Foundation import *
from AppKit import *
import ConfigParser
import os
import SafeDepositBoxAppDelegate
from SDBStatusBar import ... | Python |
#
# SafeDepositBoxAppDelegate.py
# SafeDepositBox
#
# Created by Matt Tierney on 2/27/11.
# Copyright NYU 2011. All rights reserved.
#
from objc import YES, NO, IBAction, IBOutlet
from Foundation import *
from AppKit import *
from SDBStatusBar import SDBStatusBar
import SetupWindowController
import os
start_time... | Python |
#!/usr/bin/env python
import cython
"""
This is a pure Python implementation of the [rsync algorithm](TM96).
[TM96] Andrew Tridgell and Paul Mackerras. The rsync algorithm.
Technical Report TR-CS-96-05, Canberra 0200 ACT, Australia, 1996.
http://samba.anu.edu.au/rsync/.
### Example Use Case: ###
# On the system... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# import cython
"""
This is a pure Python implementation of the [rsync algorithm](TM96).
[TM96] Andrew Tridgell and Paul Mackerras. The rsync algorithm.
Technical Report TR-CS-96-05, Canberra 0200 ACT, Australia, 1996.
http://samba.anu.edu.au/rsync/.
### Example Use Case... | Python |
#!/usr/bin/env python
import objc
from Foundation import *
from AppKit import *
from PyObjCTools import NibClassBuilder, AppHelper
start_time = NSDate.date()
class Timer(NSObject):
'''
Application delegate
'''
statusbar = None
def applicationDidFinishLaunching_(self, notification):
... | Python |
import objc, re, os
from Foundation import *
from AppKit import *
from PyObjCTools import NibClassBuilder, AppHelper
status_images = {'sdb':'safe3.png'}
# Create syncing images...
start_time = NSDate.date()
class StatusBar(NSObject):
images = {}
statusbar = None
state = 'sdb'
def openfolder_(self, notificat... | Python |
'''
Minimal setup.py example, run with:
% python setup.py py2app
'''
from distutils.core import setup
import py2app
NAME = 'SafeDepositBox'
SCRIPT = 'SafeDepositBox.py'
VERSION = '0.1'
ID = 'safedepositbox'
plist = dict(
CFBundleName = NAME,
CFBundleShortVersionString = ' '.join([NAME, VERS... | Python |
import objc, re, os
from Foundation import *
from AppKit import *
from PyObjCTools import NibClassBuilder, AppHelper
status_images = {'sdb':'safe3.png'}
# Create syncing images...
start_time = NSDate.date()
class StatusBar(NSObject):
images = {}
statusbar = None
state = 'sdb'
def openfolder_(self, n... | Python |
#!/usr/bin/env python
from Tkinter import *
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
self.button.pack(side=LEFT)
self.hi_there = Button(frame, text="Hello", command=s... | Python |
from distutils.core import setup
import py2app
NAME = 'SafeDepositBox'
SCRIPT = 'SnowLeopard-SafeDepositBox.py'
VERSION = '0.1'
ID = 'safedepositbox'
plist = dict(
CFBundleName = NAME,
CFBundleShortVersionString = ' '.join([NAME, VERSION]),
CFBundleGetInfoString = NAME,
CFBun... | Python |
#!/usr/bin/env python
import BaseHTTPServer
import urllib, urlparse, urllib2
import cgitb, mimetypes
import ConfigParser
import json
import getpass, os, platform, sys, socket, time
from string import Template
from os.path import basename, join, isfile, isdir, expanduser, split
shutdown_time = -1
import signal
signa... | Python |
#! /usr/bin/env python
# encoding: utf-8
# waf 1.6.10
VERSION='0.3.3'
import sys
APPNAME='p2t'
top = '.'
out = 'build'
CPP_SOURCES = ['poly2tri/common/shapes.cc',
'poly2tri/sweep/cdt.cc',
'poly2tri/sweep/advancing_front.cc',
'poly2tri/sweep/sweep_context.cc',
... | Python |
from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'feedsaver.views.home', name='home'),
# url(r'^feedsaver/', include('feedsaver.foo.urls')),
# Uncomment the admin/doc line below to en... | Python |
# Django settings for feedsaver project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'database3... | Python |
# -*- coding:utf-8 -*-
from django.db import models
class News(models.Model):
SUBJECT_CHOICES = (
(u'br', u'Brasil'),
(u'mu', u'Mundo'),
(u'ne', u'Negócios'),
(u'ci', u'Ciência'),
(u'te', u'Tecnologia'),
(u'en', u'Entretenimento'),
(u'es', u'Esportes'),
... | Python |
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 a... | Python |
# Create your views here.
| Python |
# -*- coding:utf8 -*-
#!/usr/bin/env python
import os
import feedparser
import copy
import rfc822
import time
import datetime
import HTMLParser
import urllib
import lxml.html
import chardet
from django.core.management.base import BaseCommand, CommandError
from django.db.models import Q
from django.utils.encoding impor... | Python |
# -*- coding:utf8 -*-
#!/usr/bin/env python
import nltk, re
import numpy as np
from django.utils.encoding import smart_str, smart_unicode
from scikits.learn.svm import SVC
from django.core.management.base import BaseCommand, CommandError
from feedsaver.saver.models import *
def mountY():
# Array que conterá o numer... | Python |
# -*- coding:utf8 -*-
#!/usr/bin/env python
from time import sleep
import nltk, re, math,threading
from django.utils.encoding import smart_str, smart_unicode
from django.core.management.base import BaseCommand, CommandError
from feedsaver.saver.models import *
def loop(self,subject):
global nglobal
stopwords = nltk... | Python |
# -*- coding:utf8 -*-
#!/usr/bin/env python
import os
import feedparser
import copy
import rfc822
import time
import datetime
from xml.etree import cElementTree as ElementTree
from threading import *
#from datetime import datetime
from django.core.management.base import BaseCommand, CommandError
from django.db.models... | Python |
# -*- coding:utf8 -*-
#!/usr/bin/env python
import nltk, re
from django.utils.encoding import smart_str, smart_unicode
from django.core.management.base import BaseCommand, CommandError
from feedsaver.saver.models import News,NewsArchive
def loop(self,ns):
stopwords = nltk.corpus.stopwords.words('portuguese')
... | Python |
# -*- coding:utf8 -*-
#!/usr/bin/env python
import os
import feedparser
import copy
import rfc822
import time
import datetime
import HTMLParser
import urllib
import lxml.html
import chardet
import threading
from unicodedata import normalize
from django.core.management.base import BaseCommand, CommandError
from django.... | Python |
#!/usr/bin/env python
from django.core.management import execute_manager
import imp
try:
imp.find_module('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 t... | Python |
'''
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... | Python |
'''
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... | Python |
'''
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 = ""
... | Python |
import os
import sys
from multiprocessing import Process, current_process, freeze_support
import multiprocessing
from pyftpdlib import ftpserver
class YourHandler(ftpserver.FTPHandler):
def on_login(self, username):
# do something when user login
pass
def on_logout(self, usern... | Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.