code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
'''
Created on 2012-7-27
列表解析
@author: root
'''
list = [1,9,8,4]
#语法关键 sth (for) elem (in) list,加上筛选条件,甚至可以完全替换原来列表中到元素
list = [elem for elem in list if elem%2==0]
print(list) | Python |
'''
Created on 2012-7-26
@author: root
'''
import os
#获取当前模块所在到目录
print(os.getcwd())
#当前用户到home目录
print(os.path.expanduser('~'))
current = os.getcwd()
(dirname,file) = os.path.split(current)
print(dirname)
print(file) | Python |
'''
Created on 2012-7-24
元组,相当与不可变到数组
@author: root
'''
a_tuple = ("a", "b", "mpilgrim", "z", "example")
| Python |
'''
Created on 2012-7-24
集合
@author: root
'''
setA = {1,3,4,5}
#以列表为基础创建集合
aList = ['a','b','c'',d']
setB = set(aList)
print(setB)
print(type(setA))
print(len(setB))
#空集合
a = set()
#空字典
b = {}
print(type(a))
print(type(b))
#集合所无序的
a.update('taylor')
a.add('jim')
#集合中不能出现相同到值
a.update({1,26,3},{5,5,5})
a.update([10,20,3... | Python |
'''
Created on 2012-7-26
@author: root
'''
print(type(None))
if(not None):
print(True)
| Python |
'''
Created on 2012-7-26
字典,相当与map
@author: root
'''
dictA = {'server':'db.diveintopy','database':'rtrtr'}
print(dictA['server'])
#不存在到键值抛出异常
#dictA['db']
#修改
dictA['server']='localserver'
#添加
dictA['user']='admin'
print(dictA)
b={1000:['kb','mb','gb','tb'],1024:['kib','mib','gib']}
print(b[1000][3])
| Python |
'''
Created on 2012-7-24
@author: root
'''
#声明一个列表,类似与ArrayList
a_list = ['a', 'b', 'mpilgrim', 'z', 'example']
a_list.append('taylor')
#支持负索引
print(a_list[-1])
#所有列表中到元素
a_list[ : ]
#列表中位置1到位置3到元素
a_list[0 :3 ]
#检索
count = a_list.count('taylor')
index = a_list.index('taylor' )
if 'taylor' in a_list:
print(True)... | Python |
'''
Created on 2012-7-20
@author: qiang.chen
'''
#整数除法
print(13.5//5)
#浮点数除法
print(13/5)
#取余
print(6.5%5)
#幂运算
print(-3**2) | Python |
'''
Created on 2012-7-20
三引号之间可以输入多行string
@author: qiang.chen
'''
a = 'what\'s your name? '
b = "My name's taylor chan!"
print(a+b)
c = 1234562322222222222222222233333333333333333333333
print(repr(type(c)))
name = input("please input your username:")
password = input("please input your password: ")
if(nam... | Python |
'''
Created on 2012-7-20
@author: qiang.chen
'''
#dfdfdfds#
import sys
sys.path
sys
print("this is taylor's first python programm");
a = input("please input yourname :")
x = 15
if(x == 12):
print('x == 12') #代码缩进
else:
print("x != 12") #代码缩进
x = x - 6
print(str(x))#没有括号,用代码缩进... | Python |
'''
Created on 2012-7-20
@author: qiang.chen
'''
x = 5
y = 10
if x==5 and y != 10:
print("x==5 y != 10")
else:
print("fdfdfd")
print(x==5 or y == 10)
if(not True):
print("not true") | Python |
'''
Created on 2012-7-20
@author: qiang.chen
'''
#布尔型其实是整形常量
true = True
#0为假,所有非0为真,包括负数
false = False
integer = 10
#整数可以任意大
long =3232300000000000000000000000000
#双精度浮点数
double = 3.1415926
#复数
z = 9.54847754-8.31441J
print(type(long))
floatA = 1.12345678901234567890
print(floatA)
print(float(2... | Python |
'''
Created on 2012-7-24
@author: root
'''
import sys
print(sys.__name__)
| Python |
'''
Created on 2012-7-20
@author: qiang.chen
'''
__num = 12
def printFun():
#全局变量保留字,其实可以不使用
global __num
num = __num + 1
print("printFun's num = "+str(num))
printFun() | Python |
'''
Created on 2012-7-20
@author: qiang.chen
'''
class MyClass():
'''
自定义的类
'''
__userName = '' #私有属性前必须使用两个下划线为前缀
#
#代表Python中特殊方法专用的标识,如__init__代表构造器
def __init__(self,name):
'''
相当与构造器
'''
self.__userName = name
... | Python |
# -*- coding: utf-8 -*-
'''
Created on 03.01.2013
@author: heller
'''
import sys, os, win32com.client
from ui import MainWindow
from PyQt4 import QtGui
from util import flushLogfiles
def pidRunning(pid):
'''Check For the existence of a pid.'''
wmi = win32com.client.GetObject('winmgmts:')
prc = wmi.ExecQuer... | Python |
# -*- coding: utf-8 -*-
import os, copy
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import Qt, pyqtSignal
from util import formatTime
class IconSizeComboBox(QtGui.QComboBox):
supportedIconSizes = (32, 48, 128, 256)
textTemplate = "%ix%i px"
IconSizeChanged = pyqtSignal(int)
def __init__(s... | Python |
# -*- coding: utf-8 -*-
'''
Created on 03.01.2013
@author: heller
'''
import time, os
import json
import urllib2
import xml.dom.minidom
import xml.parsers.expat
from util import LogHandler, formatTime
from PyQt4 import QtGui, QtCore
username = 'hasustyle'
class PlayerSummary(object):
def __init__(self):
pa... | Python |
# -*- coding: utf-8 -*-
'''
Created on 03.01.2013
@author: heller
'''
#import os, time
import ctypes
#import pickle
#import subprocess, threading
import shutil
import codecs
#from ctypes import byref
from types import *
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import Qt, pyqtSignal
from win32api import *... | Python |
# -*- coding: utf-8 -*-
#
# This code is due to Andreas Maier and licensed under the MIT License http://opensource.org/licenses/MIT
# http://code.activestate.com/recipes/576507-sort-strings-containing-german-umlauts-in-correct-/
#
import codecs
import time, datetime
import threading, string
from types import *
ST... | Python |
import pickle, os, time
import subprocess, threading
import ctypes
from ctypes import byref
from win32api import *
try:
from winxpgui import *
except ImportError:
from win32gui import *
from win32gui_struct import *
import win32com.client
usr32 = ctypes.windll.user32
from PyQt4 import QtGui, QtCore
from PyQ... | Python |
# -*- coding: utf-8 -*-
import os
import ctypes
import time
import urllib2
import threading
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import Qt, pyqtSignal
from ctypes import byref
from win32api import *
try:
from winxpgui import *
except ImportError:
from win32gui import *
from win32gui_struct import ... | Python |
from pandac.PandaModules import * # Basic Panda modules
from direct.showbase.DirectObject import DirectObject # For event handling
from direct.actor.Actor import Actor # For animated models
from direct.interval.IntervalGlobal import * # For compound intervals
from d... | Python |
from pandac.PandaModules import * # Basic Panda modules
from direct.showbase.DirectObject import DirectObject # For event handling
from direct.actor.Actor import Actor # For animated models
from direct.interval.IntervalGlobal import * # For compound intervals
from d... | Python |
import random
from fire import Fire
class Room(object):
#Static "rooms collapsed"
roomsCollapsed = 0
def __init__(self, levelfile):
#Open and format file
data = open(levelfile).readlines()
data = [line.rstrip() for line in data]
#Set Room Information
se... | Python |
import direct.directbase.DirectStart # Starts Panda
from pandac.PandaModules import * # Basic Panda modules
from direct.showbase.DirectObject import DirectObject # For event handling
from direct.actor.Actor import Actor # For animated models
from direct.inte... | Python |
from pandac.PandaModules import * # Basic Panda modules
from direct.showbase.DirectObject import DirectObject # For event handling
from direct.actor.Actor import Actor # For animated models
from direct.interval.IntervalGlobal import * # For compound intervals
from d... | Python |
import direct.directbase.DirectStart #starts Panda
from pandac.PandaModules import * #basic Panda modules
from direct.showbase.DirectObject import DirectObject #for event handling
from direct.actor.Actor import Actor #for animated models
from direct.interval.IntervalGlobal import * #for compound intervals
fro... | Python |
"""
Name: neural_networks.py
Purpose: Create a neural network specifically designed to
play the Finito game
Author: Erin
"""
import sorto_game as sorto
import numpy
# Week 1:
# Wrote Skeleton
# Week 2:
# Started code, including
# initializing weights and
# integration with the Sorto machine
# Notes... | Python |
import pygame
import firepump # tem que terminar ainda
import opcoes # tem que terminar opcoes ainda
from pygame.locals import *
from sys import exit
from random import choice
import time
import os
import jogadorOnlineUsuario # tem que fazer ainda
import jogadorOnlineServidor # tem que fazer ainda
largura... | Python |
import sys
import hashlib
from datetime import datetime
class PrettyPrint:
'''
Class for printing Binwalk results to screen/log files.
An instance of PrettyPrint is available via the Binwalk.display object.
The PrettyPrint.results() method is of particular interest, as it is suitable for use as a B... | Python |
import urllib2
from config import *
class Update:
'''
Class for updating Binwalk configuration and signatures files from the subversion trunk.
Example usage:
from binwalk import Update
Update().update()
'''
BASE_URL = "http://binwalk.googlecode.com/svn/trunk/src/binwalk/"
MAGIC_PREFIX = "magic/"
CONFIG_P... | Python |
import common
from smartsig import SmartSignature
class MagicFilter:
'''
Class to filter libmagic results based on include/exclude rules and false positive detection.
An instance of this class is available via the Binwalk.filter object.
Example code which creates include, exclude, and grep filters before running ... | Python |
import os.path
import tempfile
from common import str2int
class MagicParser:
'''
Class for loading, parsing and creating libmagic-compatible magic files.
This class is primarily used internally by the Binwalk class, and a class instance of it is available via the Binwalk.parser object.
One useful method however... | Python |
import os
import magic
from config import *
from update import *
from filter import *
from parser import *
from smartsig import *
from extractor import *
from prettyprint import *
from common import file_size
class Binwalk:
'''
Primary Binwalk class.
Interesting class objects:
self.filter - An instance o... | Python |
import os
import sys
import shlex
import tempfile
import subprocess
from config import *
from common import file_size
class Extractor:
'''
Extractor class, responsible for extracting files from the target file and executing external applications, if requested.
An instance of this class is accessible via the Binwalk... | Python |
# Common functions.
import os
import re
def file_size(filename):
'''
Obtains the size of a given file.
@filename - Path to the file.
Returns the size of the file.
'''
# Using open/lseek works on both regular files and block devices
fd = os.open(filename, os.O_RDONLY)
try:
return os.lseek(fd, 0, os.SEEK_END... | Python |
import re
from common import str2int, get_quoted_strings
class SmartSignature:
'''
Class for parsing smart signature tags in libmagic result strings.
This class is intended for internal use only, but a list of supported 'smart keywords' that may be used
in magic files is available via the SmartSignature.KEYWORDS... | Python |
import os
class Config:
'''
Binwalk configuration class, used for accessing user and system file paths.
After instatiating the class, file paths can be accessed via the self.paths dictionary.
System file paths are listed under the 'system' key, user file paths under the 'user' key.
For example, to get the path... | Python |
#!/usr/bin/env python
from os import listdir, path
from distutils.core import setup
# Generate a new magic file from the files in the magic directory
print "generating binwalk magic file"
magic_files = listdir("magic")
magic_files.sort()
fd = open("binwalk/magic/binwalk", "wb")
for magic in magic_files:
fpath = path.... | Python |
#!/usr/bin/env python
# Generates LZMA signatures for each valid LZMA property in the properties list.
properties = [
0x5D,
0x01,
0x02,
0x03,
0x04,
0x09,
0x0A,
0x0B,
0x0C,
0x12,
0x13,
0x14,
0x1B,
0x1C,
0x24,
0x2D,
0x2E,
0x2F,
0x30,
0x31,
0x36,
0x37,
0x38,
0x39,
0x3F,
0x40,
0x41,
0x48,
0x4... | Python |
#!/usr/bin/env python
# A hacky extraction utility for extracting the contents of BFF volume entries.
# It can't parse a BFF file itself, but expects the BFF volume entry to already
# be extracted to a file; it then extracts the original file from the volume entry
# file. Thus, it is best used with binwalk.
import o... | Python |
#!/usr/bin/env python
import os
import sys
import zlib
try:
zlib_file = sys.argv[1]
except:
print "Usage: %s <zlib compressed file>" % sys.argv[0]
sys.exit(1)
plaintext_file = os.path.splitext(zlib_file)[0]
try:
plaintext = zlib.decompress(open(zlib_file, 'rb').read())
open(plaintext_file, 'wb').write(plaintex... | Python |
#!/usr/bin/env python
# Utility for extracting WDK "filesystems", such as those found in the DIR-100.
import os
import sys
import struct
import shutil
import subprocess
# Default to big endian
ENDIANESS = "big"
# Unpack size bytes of data starting at offset
def unpack(data, offset, size):
sizes = {
2 : "H",
4 :... | Python |
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
from django import forms
class UserCreationForm(forms.ModelForm):
"""
A form that creates a user, with no privileges, from the given username and password.
"""
username = forms.RegexField(max_length=30, ... | Python |
#!/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 ... | Python |
from finisht.success.models import Success
from django.forms import ModelForm
from django import forms
class SuccessForm(ModelForm):
class Meta:
model = Success
fields = ('description',)
| Python |
from django.contrib.auth.models import User
from django.db import models
class Success(models.Model):
description = models.TextField(max_length=250)
completed_on = models.DateTimeField(auto_now_add=True)
user = models.ForeignKey(User)
class Meta:
verbose_name_plural = "Successes"
def __un... | Python |
from django.contrib import admin
from finisht.success.models import Success
class SuccessAdmin(admin.ModelAdmin):
list_display = ('description',)
ordering = ('completed_on',)
admin.site.register(Success, SuccessAdmin)
| Python |
#!/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 ... | Python |
from django.contrib.auth.models import User
from django.contrib import admin
UserAdmin = admin.site._registry[User]
UserAdmin.list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff', 'date_joined')
UserAdmin.list_filter = ('is_staff', 'is_superuser', 'date_joined')
| Python |
from django.views.generic.simple import direct_to_template
from django.contrib.auth.views import *
from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin
from finisht.views import *
admin.autodiscover()
import useradmin
urlpatterns = patterns('',
('^tools/$', di... | Python |
from finisht.friend.models import Friend
from django.forms import ModelForm
from django import forms
class FriendForm(ModelForm):
class Meta:
model = Friend
fields = ('friend_user',)
| Python |
from django.contrib.auth.models import User
from django.db import models
class Friend(models.Model):
main_user = models.IntegerField()
friend_user = models.ForeignKey(User)
pending = models.BooleanField()
def __unicode__(self):
return u'%s' %(self.main_user)
| Python |
from django.contrib.auth.models import User
from finisht.friend.models import Friend
def are_friends(user1, user2):
primary_friend = Friend.objects.filter(main_user=user1, friend_user=user2, pending=False)
secondary_friend = Friend.objects.filter(main_user=user2, friend_user=user1, pending=False)
if primar... | Python |
from django.contrib.auth import authenticate, login as auth_login
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import AuthenticationForm
from django.shortcuts import render_to_response
from django.template import Requ... | 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 |
'''
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 |
# import panda main module
import direct.directbase.DirectStart
import math
from pandac.PandaModules import *
from direct.showbase import *
# module for task controlling
from direct.task import Task
# load configuration file (carica file di configurazione)
import conf
mouse_wheel_command = {'up':'out', 'down':'in'}... | Python |
# -*- coding: utf-8 -*-
import os # per os.join
import math
# import panda main module
import direct.directbase.DirectStart
from pandac.PandaModules import deg2Rad, rad2Deg
from direct.showbase.PythonUtil import rad90, rad180
from direct.gui.OnscreenText import OnscreenText
# questi sono anche su main.py (...)
K_... | Python |
# -*- coding: utf-8 -*-
# Progetto Firepower (http://code.google.com/p/firepower)
# Inizio: 15 settembre 2009
#
'''
main.py
Panda3D "Hello world": caricamento finestra Panda3D.
= Dipendenze =
Panda3D: è reperibile su http://www.panda3d.org
'''
# if you test this game in a new platform and it works
# please add... | Python |
# import panda main module
import direct.directbase.DirectStart
from pandac.PandaModules import *
# set the ambient light
class Lights:
def __init__(self, parent):
# 12 minute = 720 seconds = 1 day in the game
self.daySeconds = 720
self.days = 0
self.hour = self.daySeconds / 24.0
... | Python |
import os
# import tarfile module to extracting map data
import tarfile
# import panda main module
import direct.directbase.DirectStart
from pandac.PandaModules import *
# functions and classes for reading the configuration file
import conf
# class that manages the map
class Map:
def __init__(self, map_name):
... | Python |
# reads configuration file and store options
import ConfigParser
CONFIG_FILE = 'cfg.txt'
cp = ConfigParser.ConfigParser()
# loads and reads CONFIG_FILE
cp.read(CONFIG_FILE)
try:
zoom_inv = eval(cp.get('ui', 'zoom inversion'))
except:
zoom_inv = False
print 'Zoom inversion: ', zoom_inv
class ReadConfig:
... | Python |
# import panda main module
import direct.directbase.DirectStart
from pandac.PandaModules import *
# module for task controlling
from direct.task import Task
class Camera():
def __init__(self, map):
# map istance
self.map = map
# range of movement
self.hMin = 11
self.hMax =... | Python |
# Django settings for app_srv_monitor project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
#DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_ENGINE = 'sqlite3' # 'postgre... | Python |
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib import admin
from django.db import models
# In the settings and such you will be able to change the screen name
# Here we are using App Grouping to describe a set of applications
# in a more commercial setting like a consu... | Python |
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'^app_srv_monitor/', include('app_srv_monitor.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contr... | Python |
# Create your views here.
| Python |
from django.contrib import admin
import datetime
from app_srv_monitor.home.models import ApplicationGrouping
from app_srv_monitor.home.models import SubGroup
from app_srv_monitor.home.models import Application
from app_srv_monitor.home.models import ApplicationTestPage
from app_srv_monitor.home.models import ServerMode... | Python |
#!/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 ... | Python |
#!/usr/bin/env python
import re
import os
import sys
import shutil
PACKAGE_NAME = 'com.google.android.apps.dashclock.api'
def main():
root = sys.argv[1]
for path, _, files in os.walk(root):
for f in [f for f in files if f.endswith('.html')]:
fp = open(os.path.join(path, f), 'r')
html = fp.read()... | Python |
#====================================================================
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you ... | Python |
#!/user/bin/env python
# -*- coding:UTF-8 -*-
'''
'''
import win32com.client
from time import sleep
import sys, time
import pythoncom
import threading
import re
#1、加入多线程
#2、加入异常处理
#3、加入读写文件
stopEvent=threading.Event()
class EventSink(object):
def OnNavigateComplete2(self,*args):
stopEvent.set()
#wait ... | Python |
#!/user/bin/env python
# -*- coding:UTF-8 -*-
'''
'''
import win32com.client
from time import sleep
import sys, time
import pythoncom
import threading
import re
stopEvent=threading.Event()
class EventSink(object):
def OnNavigateComplete2(self,*args):
stopEvent.set()
#wait for ie ok
def waitUntilReady(... | Python |
#!/user/bin/env python
# -*- coding:UTF-8 -*-
'''
'''
import win32com.client
from time import sleep
import sys, time
import pythoncom
import threading
import re
stopEvent=threading.Event()
class EventSink(object):
def OnNavigateComplete2(self,*args):
stopEvent.set()
#wait for ie ok
def waitUntilReady(... | Python |
#!/user/bin/env python
# -*- coding:UTF-8 -*-
'''
'''
import win32com.client
from time import sleep
import sys, time
import pythoncom
import threading
import re
#1、加入多线程
#2、加入异常处理
#3、加入读写文件
stopEvent=threading.Event()
class EventSink(object):
def OnNavigateComplete2(self,*args):
stopEvent.set()
#wait ... | Python |
import urllib
import urllib.request
import re,os,sys,subprocess
#根据总数来判断
if len(sys.argv)<3:
print("请输入两个参数,例如:python read_file.py data.txt 2")
system.exit(0)
data_file_name=sys.argv[1]
thread_num=int(sys.argv[2])
data_file=open(data_file_name)
i=0;
total=0
line=data_file.readline(... | Python |
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib import admin
from django.db import models
# In the settings and such you will be able to change the screen name
# Here we are using App Grouping to describe a set of applications
# in a more commercial setting like a consu... | Python |
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'^app_srv_monitor/', include('app_srv_monitor.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contr... | Python |
from django.contrib import admin
import datetime
from app_srv_monitor.home.models import ApplicationGrouping
from app_srv_monitor.home.models import SubGroup
from app_srv_monitor.home.models import Application
from app_srv_monitor.home.models import ApplicationTestPage
from app_srv_monitor.home.models import ServerMode... | Python |
# Create your views here.
| Python |
#!/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 ... | Python |
# Django settings for app_srv_monitor project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
#DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_ENGINE = 'sqlite3' # 'postgre... | Python |
#print 'Content-Type: application/xml'
#print ''
#
#f = open( 'voter-info-gadget.xml', 'r' )
#xml = f.read()
#f.close()
#
#print xml
#import re
#from pprint import pformat, pprint
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
#def dumpRequest( req ):... | Python |
#!/usr/bin/env python
import math
# z() and zz() are a quick and dirty hack to deal with the Aleutian Islands.
# We should use a more correct algorithm for extendBounds like the one
# in the Maps API, but this is good enough to fix the immediate problem.
def z( n ):
if n > 0.0:
return n - 360.0
return n
def zz( ... | Python |
#!/usr/bin/env python
array = [
{
'abbr': 'AL',
'name': 'Alabama',
'parties': {
'dem': { 'date': '02-05' },
'gop': { 'date': '02-05' }
}
},
{
'abbr': 'AK',
'name': 'Alaska',
'parties': {
'dem': { 'date': '02-05', 'type': 'caucus' },
'gop': { 'date': '02-05', 'type': 'caucus' }
}
},
{
... | Python |
#!/usr/bin/env python
# shpUtils.py
# Original version by Zachary Forest Johnson
# http://indiemaps.com/blog/index.php/code/pyShapefile.txt
# This version modified by Michael Geary
from struct import unpack
import dbfUtils
XY_POINT_RECORD_LENGTH = 16
db = []
def loadShapefile( filename ):
# open dbf file and get fe... | Python |
#!/usr/bin/env python
# makepolys.py
import codecs
import json
import math
import os
import random
import re
import shutil
import stat
import sys
import time
from geo import Geo
import shpUtils
import states
#states = json.load( open('states.json') )
jsonpath = 'json'
shapespath = 'shapefiles'
geo = Geo()
keysep ... | Python |
#!/usr/bin/env python
# dbfUtils.py
# By Raymond Hettinger
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362715
import struct, datetime, decimal, itertools
def dbfreader(f):
"""Returns an iterator over records in a Xbase DBF file.
The first row returned contains the field names.
The second row contai... | Python |
#!/usr/bin/env python
# get-strings.py
# By Michael Geary - http://mg.to/
# See UNLICENSE or http://unlicense.org/ for public domain notice.
# Reads the JSON feed for a Google Docs spreadsheet containing the
# localized strings for the Google Election Center gadget, then writes
# the strings for each language into a ... | Python |
#!/usr/bin/env python
# coding: utf-8
# make-hi.py - special HI processing for 2010
# Copyright (c) 2010 Michael Geary - http://mg.to/
# Use under either the MIT or GPL license
# http://www.opensource.org/licenses/mit-license.php
# http://www.opensource.org/licenses/gpl-2.0.php
import re
def convert( input, output )... | Python |
#!/usr/bin/python
from firewalladmin import model
from firewalladmin.lib import iptables, bridge
#bridge.startup()
iptables.startup()
for category in model.Blacklists.select():
iptables.create(category.category)
iptables.update(category.category, category.ips)
if not category.enabled:
iptables.toggle(category.ca... | Python |
#!/usr/bin/env python
from firewalladmin import model
model.create_database()
| Python |
import model
def check(username, password):
""" Checks username and password """
if (model.Users.selectBy(username=username, password=password).count() != 1):
return 'Wrong username or password.' | Python |
import cherrypy
import model
from firewalladmin.lib import template, http, iptables, easyadns
class DenyList:
@cherrypy.expose
@template.theme('denylist.html')
def index(self):
try:
return template.render(message=cherrypy.session.pop('msg', None),
bl... | Python |
import cherrypy
import model
from firewalladmin.lib import template, http, iptables
class AllowList:
@cherrypy.expose
@template.theme('allowlist.html')
def index(self):
return template.render(allowlist=model.AllowList.select(),
message=cherrypy.session.pop('msg', None))
@cherrypy.... | Python |
import os
model_path = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
# Use Database for application data
import sqlobject
# Connection
db_connection = sqlobject.connectionForURI('sqlite://%s/backend.db' % model_path)
sqlobject.sqlhub.processConnection = db_connection
class Users(sqlobject.SQLObject):... | Python |
import cherrypy
def redirect(url='/'):
raise cherrypy.HTTPRedirect(cherrypy.url(url))
| 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.