code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django_model_utils.models import StatMixin, PageMixin
from tagging.fields import TagField
from tagging.models import Tag
from django.contrib.auth.models import User
from gironimo.category.models import Category
def get_image_pat... | Python |
"""This middleware takes the session identifier in a POST message and adds it to the cookies instead.
This is necessary because SWFUpload won't send proper cookies back; instead, all the cookies are
added to the form that gets POST-ed back to us.
"""
from django.conf import settings
from django.core.urlresolvers impo... | Python |
from django.conf.urls.defaults import *
urlpatterns = patterns('gironimo.gallery.views',
url(r'^neu/$', 'new', name='gallery_new'),
url(r'^(?P<slug>[a-z0-9_-]+)/add/$', 'add', name='gallery_add'),
url(r'^(?P<slug>[a-z0-9_-]+)/edit/$', 'edit', name='gallery_edit'),
url(r'^(?P<slug>[a-z0-9_-]+)/edit-inf... | Python |
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from gironimo.gallery.models import Album, Picture
class PictureInline(admin.TabularInline):
model = Picture
extra = 3
class AlbumAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['... | Python |
from gironimo.imagequery import Format, register_format
class GalleryDetailFormat(Format):
def execute(self, query):
return query.fit(650, 406).image_format('JPEG').query_name('gallery_detail')
class GalleryEditFormat(Format):
def execute(self, query):
return query.fit(100, 100).image_format... | Python |
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
from gironimo.settings import MEDIA_ROOT
from django.conf ... | Python |
import os.path
from django.conf.urls.defaults import patterns, include, url
from django.conf import settings
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': os.path.join(os.path.dirname(admin.__file__), ... | Python |
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect
from gironimo.gallery.models import Album
def index(request):
'''
Shows all available galleries
'''
galleries = Album.objects.all()
return render_to_response(... | Python |
#!/usr/bin/env python
from os import mkdir, makedirs, environ, chdir, getcwd, system, listdir
from os.path import join
from shutil import copy, copytree, move, rmtree
# Usage
def Usage():
return 'Usage: createversion.py <version>'
# Run Xcode
def RunXcode(project, target):
system('/usr/bin/xcodebuild -projec... | Python |
dataTypes = ["CPUndefinedDataType", "CPIntegerDataType", "CPUnsignedIntegerDataType", "CPFloatingPointDataType", "CPComplexFloatingPointDataType", "CPDecimalDataType"]
types = { "CPUndefinedDataType" : [],
"CPIntegerDataType" : ["int8_t", "int16_t", "int32_t", "int64_t"],
"CPUnsignedIntegerDataType" : ... | Python |
#!/usr/bin/python
#
# HD44780 20x4 LCD Test Script for
# Raspberry Pi
#
# Author : Patrick Gramsl
# Site : http://gramsl.eu
# LCD control original by Matt Hawkins (http://www.raspberrypi-spy.co.uk/)
# Temperatur read original by Simon Monk (https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperatu... | Python |
#!/usr/bin/python
#
# HD44780 20x4 LCD Test Script for
# Raspberry Pi
#
# Author : Patrick Gramsl
# Site : http://gramsl.eu
# LCD control original by Matt Hawkins (http://www.raspberrypi-spy.co.uk/)
# Temperatur read original by Simon Monk (https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperatu... | Python |
#!/usr/bin/python
#
# HD44780 20x4 LCD Test Script for
# Raspberry Pi
#
# Author : Patrick Gramsl
# Site : http://gramsl.eu
# The wiring for the LCD is as follows:
# 1 : GND
# 2 : 5V
# 3 : Contrast (0-5V)*
# 4 : RS (Register Select)
# 5 : R/W (Read Write) - GROUND THIS PIN
# 6 : Enable or Strobe
# 7 : Data Bit... | Python |
#!/usr/bin/python
#
# HD44780 20x4 LCD Test Script for
# Raspberry Pi
#
# Author : Patrick Gramsl
# Site : http://gramsl.eu
# The wiring for the LCD is as follows:
# 1 : GND
# 2 : 5V
# 3 : Contrast (0-5V)*
# 4 : RS (Register Select)
# 5 : R/W (Read Write) - GROUND THIS PIN
# 6 : Enable or Strobe
# 7 : Data Bit... | Python |
#!/usr/bin/python
import time
import datetime
from Adafruit_LEDBackpack import LEDBackpack
# ===========================================================================
# 8x8 Pixel Display
# ===========================================================================
class EightByEight:
disp = None
... | Python |
#!/usr/bin/python
import time
import datetime
from Adafruit_LEDBackpack import LEDBackpack
# ===========================================================================
# 8x8 Pixel Display
# ===========================================================================
class EightByEight:
disp = None
... | Python |
#! /usr/bin/python
# Llibreries
import cgi, os, re, sys, string, time, shlex
def print_error(reason):
print "<TITLE>Hay que Engrasarlo!!</TITLE>\n"
print "<H1>Error: You did not provide a %s\n"%reason
sys.exit()
# Programa principal
print "Content-type: text/html\n\n"
form = cgi.FieldStorage()
print "<title>Llis... | Python |
#! /usr/bin/python
# Llibreries
import cgi, os, re, sys, string, time, shlex
def print_error(reason):
print "<TITLE>Hay que Engrasarlo!!</TITLE>\n"
print "<H1>Error: You did not provide a %s\n"%reason
sys.exit()
# Programa principal
print "Content-type: text/html\n\n"
form = cgi.FieldStorage()
print "<title>Llis... | Python |
#! /usr/bin/python
# Llibreries
import cgi, os, re, sys, string, time
model = {
"54" : 100,
"71" : 200,
"82" : 300,
"139" : 600 }
model_names = {
"54" : "Economic",
"71" : "Semi-Luxe",
"82" : "Luxe",
"139" : "Limusina"
}
motor = {
"Diesel" : 1.1,
"Gasolina" : 0.8 }
def print_error(reason):
print "<TITLE>Hay qu... | Python |
#! /usr/bin/python
# Llibreries
import cgi, os, re, sys, string, time
model = {
"54" : 100,
"71" : 200,
"82" : 300,
"139" : 600 }
model_names = {
"54" : "Economic",
"71" : "Semi-Luxe",
"82" : "Luxe",
"139" : "Limusina"
}
motor = {
"Diesel" : 1.1,
"Gasolina" : 0.8 }
def print_error(reason):
print "<TITLE>Hay qu... | Python |
#!/usr/bin/env python
# -*- coding: utf-8; -*-
#
#
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.api import memcache
from django.utils import simplejson
import logging
def fib(n):
if n<0:
logging.error('n must be >=0')
return
if n==1:... | Python |
#!/usr/bin/env python
# -*- coding: utf-8; -*-
#
#
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.api import memcache
from django.utils import simplejson
import logging
def fib(n):
if n<0:
logging.error('n must be >=0')
return
if n==1:... | Python |
#!/usr/bin/python
#
# Copyright (C) 2012 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 ... | Python |
#!/usr/bin/python
#
# Copyright (C) 2012 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 ... | Python |
#!/usr/bin/env python
#
# Copyright (c) 2002, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this ... | Python |
#!/usr/bin/env python
# Copyright (c) 2010, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this l... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
#!/usr/bin/python2.4
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 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 ... | Python |
# Copyright 2011 Google Inc. All Rights Reserved.
"""Locked file interface that should work on Unix and Windows pythons.
This module first tries to use fcntl locking to ensure serialized access
to a file, then falls back on a lock file if that is unavialable.
Usage:
f = LockedFile('filename', 'r+b', 'rb')
f.... | Python |
# Copyright 2011 Google Inc. All Rights Reserved.
"""Multi-credential file store with lock support.
This module implements a JSON credential store where multiple
credentials can be stored in one file. That file supports locking
both in a single process and across processes.
The credential themselves are keyed off o... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
# Copyright (C) 2011 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 or agreed to in writ... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
__version__ = "1.0c2"
| Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
# Copyright (C) 2012 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 or agreed to in writ... | Python |
# Copyright (C) 2007 Joe Gregorio
#
# Licensed under the MIT License
"""MIME-Type Parser
This module provides basic functions for handling mime-types. It can handle
matching mime-types against a list of media-ranges. See section 14.1 of the
HTTP specification [RFC 2616] for a complete explanation.
http://www.w3.o... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
# Copyright (C) 2010 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 or agreed to in writ... | Python |
__version__ = "1.0c2"
| Python |
#!/usr/bin/python2.4
#
# Copyright (C) 2010 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 l... | Python |
#!/usr/bin/python2.4
#
# Copyright (C) 2010 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 l... | Python |
"""
iri2uri
Converts an IRI to a URI.
"""
__author__ = "Joe Gregorio (joe@bitworking.org)"
__copyright__ = "Copyright 2006, Joe Gregorio"
__contributors__ = []
__version__ = "1.0.0"
__license__ = "MIT"
__history__ = """
"""
import urlparse
# Convert an IRI to a URI following the rules in RFC 3987
#
# The characte... | Python |
from __future__ import generators
"""
httplib2
A caching http interface that supports ETags and gzip
to conserve bandwidth.
Requires Python 2.3 or later
Changelog:
2007-08-18, Rick: Modified so it's able to use a socks proxy if needed.
"""
__author__ = "Joe Gregorio (joe@bitworking.org)"
__copyright__ = "Copyright... | Python |
"""SocksiPy - Python SOCKS module.
Version 1.00
Copyright 2006 Dan-Haim. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
... | Python |
import Cookie
import datetime
import time
import email.utils
import calendar
import base64
import hashlib
import hmac
import re
import logging
# Ripped from the Tornado Framework's web.py
# http://github.com/facebook/tornado/commit/39ac6d169a36a54bb1f6b9bf1fdebb5c9da96e09
#
# Tornado is licensed under the Apache Licen... | Python |
# This is the version of this source code.
manual_verstr = "1.5"
auto_build_num = "211"
verstr = manual_verstr + "." + auto_build_num
try:
from pyutil.version_class import Version as pyutil_Version
__version__ = pyutil_Version(verstr)
except (ImportError, ValueError):
# Maybe there is no pyutil insta... | Python |
"""
The MIT License
Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the ... | Python |
"""
The MIT License
Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the ... | Python |
"""
The MIT License
Copyright (c) 2007-2010 Leah Culver, Joe Stump, Mark Paschal, Vic Fryzel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the ... | Python |
# Early, and incomplete implementation of -04.
#
import re
import urllib
RESERVED = ":/?#[]@!$&'()*+,;="
OPERATOR = "+./;?|!@"
EXPLODE = "*+"
MODIFIER = ":^"
TEMPLATE = re.compile(r"{(?P<operator>[\+\./;\?|!@])?(?P<varlist>[^}]+)}", re.UNICODE)
VAR = re.compile(r"^(?P<varname>[^=\+\*:\^]+)((?P<explode>[\+\*])|(?P<part... | Python |
import json
import subprocess
from math import log
from file_generator import generate_alphabet, random_string
ALPHABET_SIZES = [6, 7, 8]
ALGORITHMS = ['Brute force', 'Horspool', 'BNDM', 'BOM']
COMMAND = './search {alphabet_size} ~/y/ri-data/random{alphabet_size}.txt {patterns}'
MAX_LENGTH = 256
NUM_SAMPLES = 5
VERBO... | Python |
import sys
import random
import string
WORD_SIZE = 4
BUFFER_SIZE = 16 * 1024
def generate_alphabet(size):
return string.digits[:size]
def generate_index(alphabet, word_size):
if word_size == 1:
return alphabet
index = []
for a in alphabet:
for d in generate_index(alphabet, word_size... | Python |
#!/usr/bin/python
import subprocess
rfile = lambda n: "files/random{}.txt".format(n)
results = []
for r1 in range(1, 61):
f1 = rfile(r1)
for r2 in range(r1 + 1, 61):
f2 = rfile(r2)
command = "java TfIdfViewer {} {}".format(f1, f2)
out = subprocess.check_output(command, shell=True)
... | Python |
#!/usr/bin/python
import subprocess
from matplotlib import pyplot as plt
from matplotlib import patches
FILE = lambda n: "files/{}.txt".format(n)
CMD = "java TfIdfViewer {} {}"
NOVELS = ('DarwinOriginofSpecies',
'DickensAChristmasCarol',
'DickensGreatExpectations',
'DickensThePickwickPape... | Python |
#!/usr/bin/python
import subprocess
rfile = lambda n: "files/fortnow{}.txt".format(n)
results = []
for r1 in range(1, 61):
f1 = rfile(r1)
for r2 in range(r1 + 1, 61):
f2 = rfile(r2)
command = "java TfIdfViewer {} {}".format(f1, f2)
out = subprocess.check_output(command, shell=True)
... | Python |
#!/usr/bin/python
import subprocess
rfile = lambda n: "files/random{}.txt".format(n)
results = []
for r1 in range(1, 61):
f1 = rfile(r1)
for r2 in range(r1 + 1, 61):
f2 = rfile(r2)
command = "java TfIdfViewer {} {}".format(f1, f2)
out = subprocess.check_output(command, shell=True)
... | Python |
#!/usr/bin/python
import subprocess
from matplotlib import pyplot as plt
from matplotlib import patches
FILE = lambda n: "files/{}.txt".format(n)
CMD = "java TfIdfViewer {} {}"
NOVELS = ('DarwinOriginofSpecies',
'DickensAChristmasCarol',
'DickensGreatExpectations',
'DickensThePickwickPape... | Python |
#!/usr/bin/python
import subprocess
rfile = lambda n: "files/fortnow{}.txt".format(n)
results = []
for r1 in range(1, 61):
f1 = rfile(r1)
for r2 in range(r1 + 1, 61):
f2 = rfile(r2)
command = "java TfIdfViewer {} {}".format(f1, f2)
out = subprocess.check_output(command, shell=True)
... | Python |
#!/usr/bin/python
import os
for i in range(1, 44):
os.system("java org.apache.lucene.demo.IndexFiles -docs txt/{} -index txt-index/i{}".format(i, i))
os.system("java CountWords txt-index/i{} > txt-out/i{}.out".format(i, i))
| Python |
#!/usr/bin/python
import os
for i in range(1, 44):
os.system("java org.apache.lucene.demo.IndexFiles -docs txt/{} -index txt-index/i{}".format(i, i))
os.system("java CountWords txt-index/i{} > txt-out/i{}.out".format(i, i))
| Python |
import numpy as np
from scipy.optimize import curve_fit
from matplotlib import pyplot as plt
AFILE = "all.out"
NFILE = "subset/i{}.out"
N = 44
COLOR1 = (.2, .6, .9)
COLOR2 = (.6, .1, .2)
S = 1000
s = 100
ticks = lambda n, m: zip(*[(10**i, str(10**i)) for i in range(n, m)])
# Zipf's law
# Get experimen... | Python |
def find_changes(seq, ref):
"""
Finds all positions in a sequence when the value changes
from ref to a different value and vice versa.
"""
changes_to = []
changes_from = []
for i in range(1, len(seq)):
if seq[i - 1] != seq[i]:
if seq[i] == ref:
changes_t... | Python |
from operator import itemgetter
from collections import defaultdict
# Input
index = dict() # Map from IATA to id
n = 0 # Number of ids
iatas, names, coords = [], [], []
with open('airports.txt') as fp:
ID, NAME, CITY, COUNTRY, IATA, ICAO, LAT, LON = range(8)
for line in fp.read().split('\n')[:-1]:
... | Python |
from operator import itemgetter
from collections import defaultdict
# Input
index = dict() # Map from IATA to id
n = 0 # Number of ids
iatas, names, coords = [], [], []
with open('airports.txt') as fp:
ID, NAME, CITY, COUNTRY, IATA, ICAO, LAT, LON = range(8)
for line in fp.read().split('\n')[:-1]:
... | Python |
dataTypes = ["CPUndefinedDataType", "CPIntegerDataType", "CPUnsignedIntegerDataType", "CPFloatingPointDataType", "CPComplexFloatingPointDataType", "CPDecimalDataType"]
types = { "CPUndefinedDataType" : [],
"CPIntegerDataType" : ["int8_t", "int16_t", "int32_t", "int64_t"],
"CPUnsignedIntegerDataType" : ... | Python |
#!/usr/bin/env python
from os import mkdir, makedirs, environ, chdir, getcwd, system, listdir
from os.path import join
from shutil import copy, copytree, move, rmtree
# Usage
def Usage():
return 'Usage: createversion.py <version>'
# Run Xcode
def RunXcode(project, target):
system('/usr/bin/xcodebuild -projec... | Python |
#
# 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 or agreed to in writing, software
# distributed under... | Python |
# Copyright 2012 Google Inc. All Rights Reserved.
#
# 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 or ... | Python |
# Copyright 2012 Google Inc. All Rights Reserved.
#
# 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 or ... | Python |
# Copyright 2012 Google Inc. All Rights Reserved.
#
# 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 or ... | Python |
# Copyright 2012 Google Inc. All Rights Reserved.
#
# 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 or ... | Python |
#!/usr/bin/env python
from codecs import getencoder
import re, time, os.path, sys, getopt
from osaterminology.makeidentifier import getconverter
from appscript import terminology
from aem import Application, findapp, AEType
######################################################################
# default tables
#####... | Python |
datei = open( "bon.xml", "w" )
datei.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
datei.write("<quittung>\n")
datei.write("<geschaeft>Linnemann</geschaeft>\n")
datei.write("\t<titel>Quittung</titel>\n")
datei.write("\t<adresse>Suedring-Shopping-Center</adresse>\n")
datei.write("\t<strasse>Pohlweg 110</strasse>... | Python |
import xml.etree.ElementTree as ET
file = ET.parse("bon.xml")
root = file.getroot()
products = root.find( "positionen" )
anzahl = 0
price = 0
for product in products:
anzahl = int(product.findtext("anzahl"))
price += int(product.findtext("preis"))*anzahl
gesamtprice = 0
gesamtprice = int(root.findte... | Python |
def getpreis(string):
bon = open("bon2.xml","r",encoding = "utf8")
gpreis = 0
for preis in bon:
if string in preis:
print(string)
gpreis += int(string)
return gpreis
bon.close()
print ("Der erreichnete Gesamtpreis beträgt: " +str(getpreis("<Preis>")... | Python |
a = "";
for i in range(2,6):
a += "*";
for j in range(1,i):
if i == 4:
b = "###";
print (b);
else:
print (a);
| Python |
a = "";
for i in range(2,6):
a += "*";
for j in range(1,i):
print (a);
| Python |
a = 5
while a != 10:
print(a)
a += 1 | Python |
import os, sys
os.environ["DJANGO_SETTINGS_MODULE"] = "dvk.settings"
ROOT_PATH = os.path.dirname(__file__)
sys.path.append(ROOT_PATH)
# Google App Engine imports.
from google.appengine.ext.webapp import util
# Force Django to reload its settings.
from django.conf import settings
settings._target = None
import dja... | 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
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 |
# -*- coding: utf-8 -*-
#===============================================================================
# FIDO2 project
# 2008-05-14: Sergeyev V.V.
# http://pythondevside.com
#===============================================================================
from django.conf.urls.defaults import *
urlpatterns = patter... | Python |
# Django settings for dvk project.
import os
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
TIME_ZONE = 'Europe/Moscow'
LANGUAGE_CODE = 'ru-RU'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the in... | Python |
# -*- coding: utf-8 -*-
#===============================================================================
# FIDO2 project models declarations file
# 2008-05-14: Sergeyev V.V.
# http://pythondevside.com
#===============================================================================
# Идеи для игры:
# Можно: Написать п... | Python |
# -*- coding: utf-8 -*-
#===============================================================================
# FIDO2 project game day's routines file
# 2008-05-14: Sergeyev V.V.
# http://pythondevside.com
#===============================================================================
from google.appengine.api import use... | Python |
# -*- coding: utf-8 -*-
#===============================================================================
# FIDO2 project URLs dispatcher
# 2008-05-14: Sergeyev V.V.
# http://pythondevside.com
#===============================================================================
from django.conf.urls.defaults import *
#---... | Python |
# -*- coding: utf-8 -*-
#===============================================================================
# FIDO2 project - database fixtures
# 2008-05-14: Sergeyev V.V.
# http://pythondevside.com
#===============================================================================
from google.appengine.api import users
fr... | Python |
# -*- coding: utf-8 -*-
#===============================================================================
# FIDO2 project views (controllers) file
# 2008-05-14: Sergeyev V.V.
# http://pythondevside.com
#===============================================================================
from google.appengine.api import use... | Python |
# -*- coding: utf-8 -*-
#===============================================================================
# FIDO2 project AJAX handlers file
# 2008-05-14: Sergeyev V.V.
# http://pythondevside.com
#===============================================================================
from google.appengine.api import users
fro... | Python |
try:
import xml.etree.cElementTree as ET
except ImportError:
import xml.etree.ElementTree as ET
class TorrentDao:
# Constructor del Dao, en caso de que todavia no tenga el archivo root
def __init__(self, file):
with open(file, "r+") as f:
if 'root' not in f.readline():
f.seek(0)
old ... | Python |
#!/usr/bin/env python
import os
import sys
import pygame
import time
import math
from pygame.locals import *
from globals import *
from grid import GameGrid
from snake import Snake, BasicSnake
from ai import AI, AIGrid, AISnake
# pygame.init() causes delays upon quit due to SDL mixer on my system
# pygame.time.get_t... | 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.