# -*- coding: utf-8 -*-
from django import template
register = template.Library()
@register.filter
def rupluralize(value, arg="дурак,дурака,дураков"):
args = arg.split(",")
if not value:
return args[2]
number = abs(int(value))
a = number % 10
b = number % 100
if (a == 1) and (b != 11):
return args[0]
elif (a > 1) and (a < 5) and ((b < 10) or (b > 20)):
return args[1]
else:
return args[2]
# recupete le mtime d'un fichier
import os
file="c:\gce.png"
mtime = os.stat(file).st_mtime
# le transforme en time
import time
print time.localtime(mtime)
# le transforme en datetime
import datetime
print datetime.datetime.fromtimestamp(mtime)
import sqlite3
c = sqlite3.connect('medialib.db')
sql="SELECT name FROM sqlite_master WHERE type='table';"
r=c.execute(sql)
for row in r.fetchall():
print row
cur = c.cursor()
cur.execute('CREATE TABLE foo (o_id INTEGER PRIMARY KEY, fruit VARCHAR(20), veges VARCHAR(30))')
con.commit()
cur.execute('INSERT INTO foo (o_id, fruit, veges) VALUES(NULL, "apple", "broccoli")')
con.commit()
print cur.lastrowid
print """
****************************************************
****************************************************
**************** 22.14 29/09/09 ********************
***** ODIS [ OPEN DYNAMIC INFORMATION SYSTEM ] *****
****************************************************
****************************************************
"""
import urllib
import re
url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
sdigits = "12345"
print """
GNU PUBLIC LICENCE
~~~~~ Resolving nothings ~~~~~~
!!!!CAREFULL!!!! KERNEL PANIC! ~
IT MAY CAUSE A OVERCLOCK OF YOURS SYSTEM!!!
If this is the first time you see this message, please contact
the tecnical especialized of VisualBasic Programming.
If you can read this massenge, please stop everything that your doing
and then reboot the system!
System will be disconnected in 10s.
"""
print """
**********************************
******* First fase engaged *******
**********************************
"""
for content in range(18):
content = urllib.urlopen (url + sdigits).read()
print content
sdigits = ''.join([letter for letter in content if letter.isdigit()])
print """
**********************************
****** Second fase engaged *******
**********************************
"""
sdigits = "53522"
for content in range(181):
content = urllib.urlopen (url + sdigits).read()
print content
sdigits = ''.join([letter for letter in content if letter.isdigit()])
print """
**********************************
******* Final fase engaged *******
**********************************
"""
sdigits = "46059"
for content in range(10):
content = urllib.urlopen (url + sdigits).read()
print content
sdigits = ''.join([letter for letter in content if letter.isdigit()])
print" "
print" "
print" "
print" "
print "! Your final nothing is", sdigits
import time
time.sleep(60)