diff --git a/.gitignore b/.gitignore deleted file mode 100644 index fbb98a6..0000000 --- a/.gitignore +++ /dev/null @@ -1,39 +0,0 @@ -*.py[cod] - -# C extensions -*.so - -# Packages -*.egg -*.egg-info -dist -build -eggs -parts -bin -var -sdist -develop-eggs -.installed.cfg -lib -lib64 - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox -nosetests.xml - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - - -beginnerscorner/tests/sqlite/test1.db -.idea \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index f88b6c8..0000000 --- a/README.md +++ /dev/null @@ -1,11 +0,0 @@ -pythonfoo -========= - -python development tests and HowTos from pythonfoo-group -* https://wiki.chaosdorf.de/Pythonfoo -* https://chaosdorf.github.com/pythonfoo/ - -this is the beginners corner and samples repo -you can find our projects under: -* https://github.com/pythonfoo - diff --git a/beginnerscorner/PySFML/README b/beginnerscorner/PySFML/README deleted file mode 100644 index f19af55..0000000 --- a/beginnerscorner/PySFML/README +++ /dev/null @@ -1,2 +0,0 @@ -# you NEED first: -apt-get install python-sfml diff --git a/beginnerscorner/PySFML/example1/ex1.py b/beginnerscorner/PySFML/example1/ex1.py deleted file mode 100644 index 997a096..0000000 --- a/beginnerscorner/PySFML/example1/ex1.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/var/bin/python - -# Include the PySFML extension -from PySFML import * - -# Create the main window -window = sf.RenderWindow(sf.VideoMode(800, 600), "PySFML test") - -# Create a graphical string to display -text = sf.String("Hello SFML") - -# Start the game loop -running = True -while running: - event = sf.Event() - while window.GetEvent(event): - if event.Type == sf.Event.Closed: - running = False - - # Draw the text, and update the window - window.Clear() - window.Draw(text) - window.Display() diff --git a/beginnerscorner/PySFML/example1/ex2.py b/beginnerscorner/PySFML/example1/ex2.py deleted file mode 100644 index d8623d3..0000000 --- a/beginnerscorner/PySFML/example1/ex2.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/var/bin/python - -# Include the PySFML extension -from PySFML import * -import time - -# Create the main window -window = sf.RenderWindow(sf.VideoMode(800, 600), "PySFML mover ;)") - -# Create a graphical string to display -textX = 0 -textY = 0 -text = sf.String("Hello SFML") -frameRate = sf.String("0") -frameRate.Move(650,5) -# Start the game loop -running = True - -fpsTimer = time.time() -fpsCounter = 0 -while running: - event = sf.Event() - while window.GetEvent(event): - if event.Type == sf.Event.Closed: - running = False - elif event.Type == sf.Event.KeyPressed: - print event.Key.Code - if event.Key.Code == 291: #left - text.Move(-5,0) - elif event.Key.Code == 292: #right - text.Move(5,0) - elif event.Key.Code == 293: #up - text.Move(0,-5) - elif event.Key.Code == 294: #down - text.Move(0,5) - - if (time.time() - fpsTimer) >= 1: - frameRate.SetText(str(fpsCounter) + ' fps') - fpsTimer = time.time() - fpsCounter = 0 - # Draw the text, and update the window - window.Clear() - window.Draw(text) - window.Draw(frameRate) - window.Display() - fpsCounter += 1 diff --git a/beginnerscorner/PySFML/example1/ex3.py b/beginnerscorner/PySFML/example1/ex3.py deleted file mode 100644 index f882a0e..0000000 --- a/beginnerscorner/PySFML/example1/ex3.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/var/bin/python - -# Include the PySFML extension -from PySFML import * -import time - -# Create the main window -window = sf.RenderWindow(sf.VideoMode(800, 600), "PySFML test") -#window.SetFramerateLimit(60) - -# Create a graphical string to display -text = sf.String("Hello SFML") - -fps = sf.String("0") -fps.Move(400,0) -fpsCounter = 0 -counterTime = time.time() - - -# Start the game loop -running = True - -while running: - - fpsCounter +=1 - if time.time() - counterTime >=1: - fps.SetText(str(fpsCounter)) - fpsCounter = 0 - counterTime = time.time() - - event = sf.Event() - while window.GetEvent(event): - if event.Type == sf.Event.Closed: - running = False - elif event.Type == sf.Event.KeyPressed: - #http://www.sfml-dev.org/documentation/1.6/namespacesf_1_1Key.php - if event.Key.Code == 291: #left - text.Move(-5,0) - elif event.Key.Code == 292: #right - text.Move(5,0) - elif event.Key.Code == 293: #up - text.Move(0,-5) - elif event.Key.Code == 294: #down - text.Move(0,5) - elif event.Key.Code == sf.Key.Q: #lefrrot q - text.Rotate(-5) - elif event.Key.Code == sf.Key.E: #rightrot e - text.Rotate(+5) - print event.Key.Code - - # Draw the text, and update the window - window.Clear() - window.Draw(fps) - window.Draw(text) - window.Display() - diff --git a/beginnerscorner/PySFML/example1/test.bmp b/beginnerscorner/PySFML/example1/test.bmp deleted file mode 100644 index 5e26c84..0000000 Binary files a/beginnerscorner/PySFML/example1/test.bmp and /dev/null differ diff --git a/beginnerscorner/PySFML/example4/ex4.py b/beginnerscorner/PySFML/example4/ex4.py deleted file mode 100644 index 0f89f03..0000000 --- a/beginnerscorner/PySFML/example4/ex4.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/var/bin/python - -# Include the PySFML extension -from PySFML import * - -# Create the main window -window = sf.RenderWindow(sf.VideoMode(800, 600), "PySFML test") - -# Create a graphical string to display -text = sf.String("BMP SFML") - - -window.SetFramerateLimit(60) - -running = True - -texture = sf.Image() -texture.LoadFromFile("test.png") -sprite = sf.Sprite(texture) -# Start the game loop -running = True -while running: - event = sf.Event() - while window.GetEvent(event): - if event.Type == sf.Event.Closed: - running = False - - - # Draw the text, and update the window - window.Clear(sf.Color.Blue) - window.Draw(sprite) - window.Draw(text) - window.Display() diff --git a/beginnerscorner/PySFML/example4/test.bmp b/beginnerscorner/PySFML/example4/test.bmp deleted file mode 100644 index 5e26c84..0000000 Binary files a/beginnerscorner/PySFML/example4/test.bmp and /dev/null differ diff --git a/beginnerscorner/PySFML/example4/test.png b/beginnerscorner/PySFML/example4/test.png deleted file mode 100644 index f01ff7d..0000000 Binary files a/beginnerscorner/PySFML/example4/test.png and /dev/null differ diff --git a/beginnerscorner/PySFML/example5/ex5.py b/beginnerscorner/PySFML/example5/ex5.py deleted file mode 100644 index c0c2e5c..0000000 --- a/beginnerscorner/PySFML/example5/ex5.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/var/bin/python - -# Include the PySFML extension -from PySFML import * - -# Create the main window -window = sf.RenderWindow(sf.VideoMode(800, 600), "PySFML test") - -# Create a graphical string to display -text = sf.String("PNG SFML") - - -window.SetFramerateLimit(60) - -running = True - -texture = sf.Image() -texture.LoadFromFile("test.png") -text = sf.Sprite(texture) -# Start the game loop -running = True - - -while running: - event = sf.Event() - while window.GetEvent(event): - if event.Type == sf.Event.Closed: - running = False - - elif event.Type == sf.Event.KeyPressed: - #http://www.sfml-dev.org/documentation/1.6/namespacesf_1_1Key.php - if event.Key.Code == 291: #left - text.Move(-5,0) - elif event.Key.Code == 292: #right - text.Move(5,0) - elif event.Key.Code == 293: #up - text.Move(0,-5) - elif event.Key.Code == 294: #down - text.Move(0,5) - elif event.Key.Code == sf.Key.Q: #lefrrot q - text.Rotate(-5) - elif event.Key.Code == sf.Key.E: #rightrot e - text.Rotate(+5) - print event.Key.Code - elif event.Type == 10: - print event.MouseMove.X - x = event.MouseMove.X - print event.MouseMove.Y - y = event.MouseMove.Y - print "----------------" - text.SetPosition(x,y) - else: - print event.Type - - - - # Draw the text, and update the window - window.Clear(sf.Color.Blue) - window.Draw(text) - window.Draw(text) - window.Display() - - diff --git a/beginnerscorner/PySFML/example5/test.bmp b/beginnerscorner/PySFML/example5/test.bmp deleted file mode 100644 index 5e26c84..0000000 Binary files a/beginnerscorner/PySFML/example5/test.bmp and /dev/null differ diff --git a/beginnerscorner/PySFML/example5/test.png b/beginnerscorner/PySFML/example5/test.png deleted file mode 100644 index b4baef0..0000000 Binary files a/beginnerscorner/PySFML/example5/test.png and /dev/null differ diff --git a/beginnerscorner/PySFML/example6/.ex6.py.swp b/beginnerscorner/PySFML/example6/.ex6.py.swp deleted file mode 100644 index ed2602d..0000000 Binary files a/beginnerscorner/PySFML/example6/.ex6.py.swp and /dev/null differ diff --git a/beginnerscorner/PySFML/example6/ex6.py b/beginnerscorner/PySFML/example6/ex6.py deleted file mode 100644 index 46d92ad..0000000 --- a/beginnerscorner/PySFML/example6/ex6.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python - -# Include the PySFML extension -from PySFML import * -import time -# Create the main window -window = sf.RenderWindow(sf.VideoMode(800, 600), "PySFML test") - -# Create a graphical string to display -text = sf.String("PNG SFML") -fps = sf.String("0") -fps.Move(400,0) -fpsCounter = 0 -counterTime = time.time() - - -# window.SetFramerateLimit(60) - -running = True - -texture = sf.Image() -texture.LoadFromFile("test.png") -text = sf.Sprite(texture) -# Start the game loop -running = True - - -while running: - fpsCounter +=1 - if time.time() - counterTime >=1: - fps.SetText(str(fpsCounter)) - fpsCounter = 0 - counterTime = time.time() - - event = sf.Event() - while window.GetEvent(event): - if event.Type == sf.Event.Closed: - running = False - - elif event.Type == sf.Event.KeyPressed: - #http://www.sfml-dev.org/documentation/1.6/namespacesf_1_1Key.php - if event.Key.Code == 291: #left - text.Move(-5,0) - elif event.Key.Code == 292: #right - text.Move(5,0) - elif event.Key.Code == 293: #up - text.Move(0,-5) - elif event.Key.Code == 294: #down - text.Move(0,5) - elif event.Key.Code == sf.Key.Q: #lefrrot q - text.Rotate(-5) - elif event.Key.Code == sf.Key.E: #rightrot e - text.Rotate(+5) - print event.Key.Code - elif event.Type == 10: - print event.MouseMove.X - x = event.MouseMove.X - print event.MouseMove.Y - y = event.MouseMove.Y - print "----------------" - text.SetPosition(x,y) - else: - print event.Type - - - - # Draw the text, and update the window - window.Clear(sf.Color.Blue) - window.Draw(text) - # window.Draw(text) - window.Draw(fps) - window.Display() - - diff --git a/beginnerscorner/PySFML/example6/test.bmp b/beginnerscorner/PySFML/example6/test.bmp deleted file mode 100644 index 5e26c84..0000000 Binary files a/beginnerscorner/PySFML/example6/test.bmp and /dev/null differ diff --git a/beginnerscorner/PySFML/example6/test.png b/beginnerscorner/PySFML/example6/test.png deleted file mode 100644 index f3cd5a8..0000000 Binary files a/beginnerscorner/PySFML/example6/test.png and /dev/null differ diff --git a/beginnerscorner/PySFML/howto1.pdf b/beginnerscorner/PySFML/howto1.pdf deleted file mode 100644 index 0593ee8..0000000 Binary files a/beginnerscorner/PySFML/howto1.pdf and /dev/null differ diff --git a/beginnerscorner/PySFML/imageManipulate/changeColor.py b/beginnerscorner/PySFML/imageManipulate/changeColor.py deleted file mode 100644 index 59480a4..0000000 --- a/beginnerscorner/PySFML/imageManipulate/changeColor.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -# -*- coding:utf-8 -*- -# Include the PySFML extension -from PySFML import * -import time -import sys, os - -# Create the main window -window = sf.RenderWindow(sf.VideoMode(800, 600), "PySFML test") - -#window.SetBackgroundColor(sf.Color(0,0,0)) - -fps = sf.String("0") -fps.Move(400,0) -fpsCounter = 0 -counterTime = time.time() - - -# Start the game loop -running = True - -texture = sf.Image() -texture.LoadFromFile(os.path.dirname(sys.argv[0]) + "/nyan.png") - -iSprite = sf.Sprite(texture) - -bgColor = sf.Color(0,0,0) -Width = iSprite.GetSize()[0] -Height = iSprite.GetSize()[1] -while running: - - fpsCounter +=1 - if time.time() - counterTime >=1: - fps.SetText(str(fpsCounter)) - fpsCounter = 0 - counterTime = time.time() - - event = sf.Event() - while window.GetEvent(event): - if event.Type == sf.Event.Closed: - running = False - elif event.Type == sf.Event.KeyPressed: - #http://www.sfml-dev.org/documentation/1.6/namespacesf_1_1Key.php - if event.Key.Code == sf.Key.Q: #.... - #text.Move(-5,0) - running = False - elif event.Key.Code == sf.Key.E: #execute - - for iX in range(int(Width)): - for iY in range(int(Height)): - Pixel = texture.GetPixel(iX, iY) - Pixel.b = 255 - #Pixel.a = 255 - texture.SetPixel(iX, iY, Pixel) - iSpryte = sf.Sprite(texture) - - - - window.Clear(bgColor) - window.Draw(fps) - window.Draw(iSprite) - window.Display() diff --git a/beginnerscorner/PySFML/imageManipulate/nyan.png b/beginnerscorner/PySFML/imageManipulate/nyan.png deleted file mode 100644 index 89c8909..0000000 Binary files a/beginnerscorner/PySFML/imageManipulate/nyan.png and /dev/null differ diff --git a/beginnerscorner/PySFML/pong1/ball.png b/beginnerscorner/PySFML/pong1/ball.png deleted file mode 100644 index b50142d..0000000 Binary files a/beginnerscorner/PySFML/pong1/ball.png and /dev/null differ diff --git a/beginnerscorner/PySFML/pong1/pong1.py b/beginnerscorner/PySFML/pong1/pong1.py deleted file mode 100644 index 7f7ea70..0000000 --- a/beginnerscorner/PySFML/pong1/pong1.py +++ /dev/null @@ -1,234 +0,0 @@ -#!/usr/bin/env python -# -*- coding:utf-8 -*- - - -# Include the PySFML extension -from PySFML import * -import time -# Create the main window -window = sf.RenderWindow(sf.VideoMode(800, 700), "PySFML test") - -# Counter for show FPS -fpsCounter = 0 -counterTime = time.time() - - -window.SetFramerateLimit(60) - -running = True - -texture = sf.Image() -texture.LoadFromFile("test.png") -balltex = sf.Image() -balltex.LoadFromFile("ball.png") -ballstring = sf.Sprite(balltex) -balkenstring = sf.Sprite(texture) -# Start the game loop -running = True -x = 0 - -class txtBox(object): - def __init__(self, txt, x, y): - self._xPosition = x - self._yPosition = y - self._txt = txt - self._sftxt = sf.String(self._txt) - self._sftxt.Move(x, y) - self._sftxt.SetText(self._txt) - self._visible = True - - @property - def xPosition(self): - return self._xPosition - @xPosition.setter - def xPosition(self, value): - self._xPosition = value - - @property - def yPosition(self): - return self._yPosition - @yPosition.setter - def yPosition(self, value): - self._yPosition = value - - @property - def txt(self): - return self._txt - @txt.setter - def txt(self, value): - self._txt = value - self._sftxt.SetText(value) - - @property - def visible(self): - return self._visible - @visible.setter - def visible(self,value): - self._visible = value - - def Show(self): - window.Draw(self._sftxt) - - -class BallObj(object): - def __init__(self, x, y, dx=0, dy=0): - self.x = x - self.y = y - self.dx = dx - self.dy = dy - self._outofwindow = False - self._reversecount = 0 - @property - def outofwindow(self): - return self._outofwindow - - @property - def revcount(self): - return str(self._reversecount) - def newgame(self): - self._reversecount = 0 - def advance(self): - self.x += self.dx - self.y += self.dy - if self.y >= 575 or self.y <=0: - self.dy = -self.dy - if self.x >= 775: - self.dx = -self.dx - if self.x <=90: # Bug if here <= 0 not nice but funktional - self._outofwindow = True - - def kontakt(self, spin): - self.dx = -self.dx - self.dy = self.dy + spin - if not gameover: - self._reversecount += 1 - -class BalkenObj(object): - def __init__(self, x, y, speed): - self.x = x - self.y = y - self.speed = speed - self.yOld = y - self._spin = 1 - self.info = 0 - self._usecount = 0 - self.time = time.time() - @property - def outofwindow(self): - return self._outofwindow - @property - def spin(self): - return self._spin - - def SetPosition(self, xp, yp): - if yp >= 500: - self.y = 500 - else: - self.y = yp - # Spin Element - # Bug - Schnelle Bewegung gibt viele Punkte.... (Zeipruefung als Loesung?) - if time.time() - self.time <= 0.02: - if self.yOld - self.y < -1: - self._spin = 2 - elif self.yOld - self.y > 1: - self._spin = -2 - else: - self._spin = 0 - self.info = "1 " + str(time.time() - self.time) - self.yOld = self.y - else: - self._spin = 0 - self.info = 0 - self.time = time.time() - -# Menue Bottom -line1 = sf.Shape.Line(0,600,800,600,2,sf.Color.Yellow) -# Game Messages -headertxt = txtBox("PONG",500, 600) -fpstxt = txtBox("FPS: 60 Rev: 0",200,600) -helpmsg = txtBox("Keys: n = New Game, h = Help, q or ESC = quit",50,650) -helpmsg.visible = False -# Runnig -gameover = True -nogame = True - - - -while running: - fpsCounter +=1 - if time.time() - counterTime >=1: - fpstxt.txt = "FPS: " + str(fpsCounter) - fpsCounter = 0 - counterTime = time.time() - - event = sf.Event() - while window.GetEvent(event): - if event.Type == sf.Event.Closed: - running = False - - elif event.Type == sf.Event.KeyPressed: - if event.Key.Code == 104: #h for Help - if helpmsg.visible: - helpmsg.visible = False - else: - helpmsg.visible = True - # Mouse Movement - elif event.Type == 10: - if not gameover: - x = event.MouseMove.X - y = event.MouseMove.Y - balken.SetPosition(x,y) - - elif event.Key.Code == 113: #Q for Quit - running = False - elif event.Key.Code == 256: #ESC for Quit - running = False - elif event.Key.Code == 110: #N for Next Game - if gameover: - gameover = False - nogame = False - balken = BalkenObj(0,0,10) # Startlocation Balken + KeySpeed - ball = BallObj(700, 200) # Startlocation Ball - ball.dy = 1 - ball.dx = 4 - ball.newgame() -# print event.Key.Code -# helps to find the Key-Code - - if not gameover: - ball.advance() - if ball.outofwindow: - gameover = True - count = ball.revcount - - - # Ball beruehrt Balken - if ball.x <= 100: - if ball.y >= balken.y and ball.y <= balken.y + 100: - ball.kontakt(balken.spin) - print "Spin: " + str(balken.spin) - print "Spininfo: " + str(balken.info) - # Ball movement - ballstring.SetPosition(ball.x, ball.y) - # Balken movement - balkenstring.SetPosition(balken.x, balken.y) - # Draw the text, and update the window - window.Clear(sf.Color.Blue) - if helpmsg.visible: - helpmsg.Show() - - headertxt.Show() - # SFML Polygon Test - window.Draw(line1) - - if not gameover: - window.Draw(ballstring) - window.Draw(balkenstring) - if gameover and not nogame: - fpstxt.txt = " Game Over - Rev: " + count - fpstxt.Show() - - - window.Display() - - diff --git a/beginnerscorner/PySFML/pong1/pong2.py b/beginnerscorner/PySFML/pong1/pong2.py deleted file mode 100644 index 34b9fe0..0000000 --- a/beginnerscorner/PySFML/pong1/pong2.py +++ /dev/null @@ -1,273 +0,0 @@ -#!/var/bin/python - -# This is an Example created for the Pythonfoo Workshop at Chaosdorf -# Chaosdorf.de -# in 2012 by Oerb -# -# Include the PySFML extension - - -from PySFML import * -import time - -# Window to Show the Game and Manage Key input -class windowmanager(object): - def __init__(self,name): - self._backgroundcolor = sf.Color.Blue - self.winX = 800 - self.winY = 700 - self._window = sf.RenderWindow(sf.VideoMode(self.winX, self.winY), name) - self._window.SetFramerateLimit(60) - self._running = True - # Frames per Scound Counterelements - self._fpsCounter = 0 - self._counterTime = time.time() - self.fps = 0 - self.fpsBox = pongTxtBox("0") - self.fpsBox.xPos = 50 - self.fpsBox.yPos = 650 - - # PongObjekt Indizierer - self._PongObjIndexer = 0 - self._PongObjDict = {} - self.registerPongObj(self.fpsBox) - - def show(self): - while self._running: - # Frames per scound showelemts - self.fpsZahl = str(self._fpsCount()) - self._PongObjDict[0].text = self.fpsZahl - # sending the Keypress and Mouseevents to the PongObjects - self._eventmanager() - # SFML Part for clearing, drawing Window - self._window.Clear(self._backgroundcolor) - self._draw() - self._window.Display() - - # Zeichnen der SMFL Objekte - def _draw(self): - # registerierte Objekte in Drawlist uebernehmen - # da sie fuer jeden show neu erzeugt wird - for key in self._PongObjDict: - if self._PongObjDict[key].visible: - self._window.Draw(self._PongObjDict[key].show()) - - def _eventmanager(self): - event = sf.Event() - # special all over Keys - while self._window.GetEvent(event): - if event.Type == sf.Event.Closed: - self._running = False - elif event.Key.Code == 113: #Q for Quit - self._running = False - elif event.Key.Code == 256: #ESC for Quit - self._running = False - # sending eventinfo to PongObjekts for manipulations - for key in self._PongObjDict: - self._PongObjDict[key].eventmanager(event) - - def _fpsCount(self): - # Frames per secound math - self._fpsCounter +=1 - if time.time() - self._counterTime >=1: - self.fps = self._fpsCounter - self._fpsCounter = 0 - self._counterTime = time.time() - return self.fps - - # when PongObj ist initialized it must be registered here - # so that it will be shown when visible = True - def registerPongObj(self, pongObj): - # a PongObject must be registered to be showen and get events - self._PongObjDict[self._PongObjIndexer] = pongObj - #return self._PongObjIndexer - self._PongObjIndexer += 1 - return self._PongObjIndexer - -# Definition der Elternklasse von PongObjekten, von der -# weitere Pongobjekte abgeleitet werden sollen. -class pongObj(object): - def __init__(self, PongObjTyp): - self._xPosition = 0 - self._yPosition = 0 - self._PongObjTyp = PongObjTyp - self._visible = True - - @property - def xPos(self): - return self._xPosition - @xPos.setter - def xPos(self, value): - self._xPosition = value - - @property - def yPos(self): - return self._yPosition - @yPos.setter - def yPos(self, value): - self._yPosition = value - - @property - def objID(self): - return self._PongObjID - - @property - def PongObjTyp(self): - return self._PongObjTyp - - @property - def visible(self): - return self._visible - @visible.setter - def visible(self, value): - self._visible = value - - def eventmanager(self,event): - pass # ist eine Pseudoanweisung die nichts tut - - def show(self): - pass - -# Nachfolgend PongObjekt Kind-Klassen -class pongBall(pongObj): - def __init__(self, imagename): - super(pongBall,self).__init__("Ball") # fuer Klassenvererbung erf. - self._window = windowmanager("Window") - self._imagename = imagename - self._dx = 0 - self._dy = 0 - self._outofwindow = False - self._reversecount = 0 - self._gameover = True - self._visible = False - self._Points = 0 - self._spin = 0 - self._Balken1 = pongBalken("test.png") - self._Balken1.visible = False - self._window.registerPongObj(self._Balken1) - self._window.registerPongObj(self) - self._window.show() - - @property - def outofwindow(self): - return self._outofwindow - - @property - def revcount(self): - return str(self._reversecount) - - def _newgame(self): - self._gameover = False - self._visible = True - self._Balken1.visible = True - self.xPos = 700 - self.yPos = 200 - self._outofwindow = False - self._dy = 1 - self._dx = -4 - self._reversecount = 0 - - def advance(self): - if not self._gameover: - #print self.xPos, " ", self.yPos - self.xPos += self._dx - self.yPos += self._dy - if self.yPos >= 575 or self.yPos <= 0: - self._dy = -self._dy - if self.xPos >= 775: - self._dx = -self._dx - if self.xPos <=90: # Bug if here <= 0 not nice but funktional - self._outofwindow = True - if self.xPos <= 100: - if self.yPos >= self._Balken1.yPos and self.yPos <= self._Balken1.yPos + 100: - self._kontakt(self._spin) - - def _kontakt(self, spin): - self._dx = -self._dx - self._dy = self._dy + spin - if not self._gameover: - self._reversecount += 1 - - def _setGameOver(self): - self._gameover = True - self.visible = False - self._Balken1.visible = False - self._Points = self.revcount - print "Set Gameover" - def eventmanager(self,event): - if event.Key.Code == 110: # N for new Game - if self._gameover: - self._newgame() - - def show(self): - if not self._gameover: - self.advance() - if self._outofwindow: - self._setGameOver() - self._texture = sf.Image() - self._texture.LoadFromFile(self._imagename) - self._sprite = sf.Sprite(self._texture) - self._sprite.SetPosition(self._xPosition,self._yPosition) - return self._sprite - -# der Schlaeger/Balken -class pongBalken(pongObj): - def __init__(self,imagename): - super(pongBalken,self).__init__("Balken") # fuer Klassenvererbung erf. - self._imagename = imagename - - @property - def yPos(self): - return self._yPosition - @yPos.setter - def yPos(self, value): - if value >= 500: - self._yPosition = 500 - else: - self._yPosition = value - - def eventmanager(self,event): - if event.Type == 10: - self._xPosition = 0 #event.MouseMove.X - self._yPosition = event.MouseMove.Y - - def show(self): - self._texture = sf.Image() - self._texture.LoadFromFile(self._imagename) - self._sprite = sf.Sprite(self._texture) - self._sprite.SetPosition(self._xPosition,self._yPosition) - return self._sprite - -# Einen Text anzeigen -class pongTxtBox(pongObj): - def __init__(self, text): - super(pongTxtBox, self).__init__("TxtBox") # fuer Klassenvererbung erf. - self._text = text - - # Hier muessen noch Propertys fuer Schrift und Groesse hin - - @property - def text(self): - return self._text - @text.setter - def text(self, value): - self._text = value - - def eventmanager(self,event): - pass - def show(self): - self._sftxt = sf.String(self._text) - self._sftxt.SetPosition(self._xPosition, self._yPosition) - return self._sftxt - -# Klasse fuer den Hauptprogrammteil -class main(object): - def __init__(self): - # damit das Spiel startet muss ein Ball initialisiert werden - Ball = pongBall("ball.png") - -# _Main Start -# wird nur ausgefuehrt bei direktem Probrammaufruf nicht bei Moduleinbindung -if __name__ == "__main__": - start = main() - diff --git a/beginnerscorner/PySFML/pong1/pongVererbung1.py b/beginnerscorner/PySFML/pong1/pongVererbung1.py deleted file mode 100644 index 23afae5..0000000 --- a/beginnerscorner/PySFML/pong1/pongVererbung1.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/var/bin/python - -# This is an Example created for the Pythonfoo Workshop at the Chaosdorf -# in 2012 by Oerb - -# Include the PySFML extension -from PySFML import * -import time - -class windowmanager(object): - def __init__(self,name): - self._backgroundcolor = sf.Color.Blue - self._drawlist = [] - self.winX = 800 - self.winY = 600 - self._window = sf.RenderWindow(sf.VideoMode(self.winX, self.winY), name) - self._window.SetFramerateLimit(60) - self._running = True - self._fpsCounter = 0 - self._counterTime = time.time() - self.fps = 0 - # testelement - self.testlist = [] - self.testlist.append(sf.String("Hello SFML")) - text2 = sf.String("Next") - text2.SetPosition(0, 100) - self.testlist.append(text2) - - - - def show(self): - while self._running: - self._drawlist = [] - # fps Kram im test - fpsZahl = str(self._fpsCount()) - text3 = sf.String(fpsZahl) - text3.SetPosition(0,200) - for e in self.testlist: - self._drawlist.append(e) - self._drawlist.append(text3) - # must have - self._eventmanager() - self._window.Clear(self._backgroundcolor) - self._draw(self._drawlist) - self._window.Display() - - def _draw(self, drawlist): - # Draw Elements - for drawelement in drawlist: - self._window.Draw(drawelement) - - def _eventmanager(self): - event = sf.Event() - while self._window.GetEvent(event): - if event.Type == sf.Event.Closed: - self._running = False - - def _fpsCount(self): - self._fpsCounter +=1 - if time.time() - self._counterTime >=1: - self.fps = self._fpsCounter - self._fpsCounter = 0 - self._counterTime = time.time() - return self.fps - -# Definition der Elternklasse von PongObjekten, von der -# weitere Pongobjekte abgeleitet werden sollen. - -class pongObj(object): - def __init__(self): - _xPosition - _yPosition - - def _eventmanager(self,event): - pass # ist eine Pseudoanweisung die nichts tut - - -class pongBall(pongObj): - def __init__(self, imagename, startx, starty): - _xPosition = startx - _yPosition = starty - def _eventmanager(self,event): - if event.Type == 10: - _xPosition = event.MouseMove.X - _yPosition = event.MouseMove.Y - print "X: " + _xPosition + " Y: " + _yPosition - - -# _Main Start -window = windowmanager("Window") -window.show() diff --git a/beginnerscorner/PySFML/pong1/test.bmp b/beginnerscorner/PySFML/pong1/test.bmp deleted file mode 100644 index 5e26c84..0000000 Binary files a/beginnerscorner/PySFML/pong1/test.bmp and /dev/null differ diff --git a/beginnerscorner/PySFML/pong1/test.png b/beginnerscorner/PySFML/pong1/test.png deleted file mode 100644 index 04038d4..0000000 Binary files a/beginnerscorner/PySFML/pong1/test.png and /dev/null differ diff --git a/beginnerscorner/PySFML/pong1/testsfmlview.py b/beginnerscorner/PySFML/pong1/testsfmlview.py deleted file mode 100644 index 5719065..0000000 --- a/beginnerscorner/PySFML/pong1/testsfmlview.py +++ /dev/null @@ -1,268 +0,0 @@ -#!/var/bin/python - -# This is an Example created for the Pythonfoo Workshop at the Chaosdorf -# in 2012 by Oerb - -# Include the PySFML extension -from PySFML import * -import time - -class windowmanager(object): - def __init__(self,name): - self._backgroundcolor = sf.Color.Blue - self.winX = 800 - self.winY = 600 - self._drawlist = [] - self._window = sf.RenderWindow(sf.VideoMode(self.winX, self.winY), name) - self._window.SetFramerateLimit(60) - self._running = True - self._fpsCounter = 0 - self._counterTime = time.time() - self.fps = 0 - self.fpsBox = pongTxtBox("0") - self.fpsBox.xPos = 0 - self.fpsBox.yPos = 50 - - - # PongObjekt Indizierer - self._PongObjIndexer = 0 - self._PongObjDict = {} - - self.registerPongObj(self.fpsBox) - - - def show(self): - while self._running: - self.fpsZahl = str(self._fpsCount()) - self._PongObjDict[0].text = self.fpsZahl - self._eventmanager() - self._window.Clear(self._backgroundcolor) - self._draw() - self._window.Display() - - # Zeichnen der SMFL Objekte - def _draw(self): - # registerierte Objekte in Drawlist uebernehmen - # da sie fuer jeden show neu erzeugt wird - for key in self._PongObjDict: - if self._PongObjDict[key].visible: - self._window.Draw(self._PongObjDict[key].show()) - - def _eventmanager(self): - event = sf.Event() - while self._window.GetEvent(event): - if event.Type == sf.Event.Closed: - self._running = False - elif event.Key.Code == 113: #Q for Quit - self._running = False - elif event.Key.Code == 256: #ESC for Quit - self._running = False - # sending eventinfo to PongObjekts for manipulations - for key in self._PongObjDict: - self._PongObjDict[key].eventmanager(event) - - def _fpsCount(self): - self._fpsCounter +=1 - if time.time() - self._counterTime >=1: - self.fps = self._fpsCounter - self._fpsCounter = 0 - self._counterTime = time.time() - return self.fps - - # when PongObj ist initialized it must be registered here - # so that it will be shown when visible = True - def registerPongObj(self, pongObj): - self._PongObjDict[self._PongObjIndexer] = pongObj - #return self._PongObjIndexer - self._PongObjIndexer += 1 - return self._PongObjIndexer - -# Definition der Elternklasse von PongObjekten, von der -# weitere Pongobjekte abgeleitet werden sollen. -class pongObj(object): - def __init__(self, PongObjTyp): - self._xPosition = 0 - self._yPosition = 0 - self._PongObjTyp = PongObjTyp - self._visible = True - - @property - def xPos(self): - return self._xPosition - @xPos.setter - def xPos(self, value): - self._xPosition = value - - @property - def yPos(self): - return self._yPosition - @yPos.setter - def yPos(self, value): - self._yPosition = value - - @property - def objID(self): - return self._PongObjID - - @property - def PongObjTyp(self): - return self._PongObjTyp - - @property - def visible(self): - return self._visible - @visible.setter - def visible(self, value): - self._visible = value - - def eventmanager(self,event): - pass # ist eine Pseudoanweisung die nichts tut - - def show(self): - pass - -# Nachfolgend PongObjekt Kind-Klassen -class pongBall(pongObj): - def __init__(self, imagename): - super(pongBall,self).__init__("Ball") # fuer Klassenvererbung erf. - self._window = windowmanager("Window") - self._imagename = imagename - self._dx = 0 - self._dy = 0 - self._outofwindow = False - self._reversecount = 0 - self._gameover = True - self._visible = False - self._Points = 0 - self._spin = 0 - self._Balken1 = pongBalken("test.png") - self._Balken1.visible = False - self._window.registerPongObj(self._Balken1) - self._window.registerPongObj(self) - self._window.show() - - - @property - def outofwindow(self): - return self._outofwindow - - @property - def revcount(self): - return str(self._reversecount) - - def _newgame(self): - self._gameover = False - self._visible = True - self._outofwindow = False - self._Balken1.visible = True - self.xPos = 700 - self.yPos = 200 - self._dy = 1 - self._dx = -4 - self._reversecount = 0 -# print "NewGame" - - def advance(self): - if not self._gameover: - self._xPosition += self._dx - self._yPosition += self._dy - if self.yPos >= 575 or self.yPos <= 0: - self._dy = -self._dy - if self._xPosition >= 775: - self._dx = -self._dx - if self._xPosition <=90: # Bug if here <= 0 not nice but funktional - self._outofwindow = True - if self._xPosition <= 100: - if self._yPosition >= self._Balken1.yPos and self._yPosition <= self._Balken1.yPos + 100: - self._kontakt(self._spin) - - def _kontakt(self, spin): - self._dx = -self._dx - self._dy = self._dy + spin - if not self._gameover: - self._reversecount += 1 - - def _setGameOver(self): - self._gameover = True - self.visible = False - self._Balken1.visible = False - self._Points = self.revcount - - def eventmanager(self,event): - if event.Key.Code == 110: # N for new Game - if self._gameover: - self._newgame() - - - def show(self): - if not self._gameover: - self.advance() - if self._outofwindow: - self._setGameOver() - self._texture = sf.Image() - self._texture.LoadFromFile(self._imagename) - self._sprite = sf.Sprite(self._texture) - self._sprite.SetPosition(self._xPosition,self._yPosition) - return self._sprite - -# der Schlaeger/Balken -class pongBalken(pongObj): - def __init__(self,imagename): - super(pongBalken,self).__init__("Balken") # fuer Klassenvererbung erf. - self._imagename = imagename - - @property - def yPos(self): - return self._yPosition - @yPos.setter - def yPos(self, value): - if value >= 500: - self._yPosition = 500 - else: - self._yPosition = value - - def eventmanager(self,event): - if event.Type == 10: - self._xPosition = 0 #event.MouseMove.X - self._yPosition = event.MouseMove.Y - - def show(self): - self._texture = sf.Image() - self._texture.LoadFromFile(self._imagename) - self._sprite = sf.Sprite(self._texture) - self._sprite.SetPosition(self._xPosition,self._yPosition) - return self._sprite - -# Einen Text anzeigen -class pongTxtBox(pongObj): - def __init__(self, text): - super(pongTxtBox, self).__init__("TxtBox") # fuer Klassenvererbung erf. - self._text = text - - @property - def text(self): - return self._text - @text.setter - def text(self, value): - self._text = value - - def eventmanager(self,event): - pass - def show(self): - self._sftxt = sf.String(self._text) - self._sftxt.SetPosition(self._xPosition, self._yPosition) - return self._sftxt - -# Klasse fuer den Hauptprogrammteil -class main(object): - def __init__(self): - # damit das Spiel startet muss ein Ball initialisiert werden - Ball = pongBall("ball.png") -# Ball.xPos = 200 -# Ball.yPos = 200 - -# _Main Start -# wird nur ausgefuehrt bei direktem Probrammaufruf nicht bei Moduleinbindung -if __name__ == "__main__": - start = main() - diff --git a/beginnerscorner/args/args.md b/beginnerscorner/args/args.md deleted file mode 100644 index fe72f03..0000000 --- a/beginnerscorner/args/args.md +++ /dev/null @@ -1,426 +0,0 @@ -# Python basics: Functions and arguments -> by shezi (Johannes Spielmann, jps@shezi.de) -> A version of this also appeared on [shezi.de](http://shezi.de/index.php/2014/07/python-basics-function-syntax/) - - - -I've recently talked to some guys and girls about functions in Python and how to define and call them. Here's the distillation of everything that's interesting about the topic. [Footnote: By the way, I won't put comments in all of my functions, because they are so very short and just for illustration. You should __*always*__ put documentation in _your_ functions, though!] - -The first thing we do is define a function without any parameters. There syntax for this is: - - def fun(): - print("this is fun") - -This defines a function `fun` that can be called and that prints out the string given in its _function body_. What's the "function body", you ask? It's all the indented lines following `def fun():` (which, coincidentally, is called _function head_), and it's those lines that are executed when you call the function. Let's try it out: - - >>> fun() - this is fun - -As you can see, you call functions by giving them a list of arguments in parentheses -- and in our case, that list is empty. If you omit the argument list (sometimes also called parameter list), something entirely different happens: - - >>> fun - - -What does *that* mean? It means that instead of _calling_ the function, you _pointed_ at the function. Functions in Python behave like any other value, so you could assign them to a variable or pass them as a parameter to another function. But more about that later. - -Our function doesn't _return_ anything, so calling it doesn't produce a value. Well, actually, "no value" in Python means `None`, and we can see that, too: - - >>> val = fun() - this is fun - >>> print(repr(val)) - None - -One of the most important use cases of functions, however, is to compute something, which means we have to be able to indicate what the value of a function call should be. That's what the keyword `return` does. It works like this: - - def fun(): - print("this is still fun") - return "enjoyment" - -And we get the value back when we call the function: - - >>> val = fun() - >>> print(repr(val)) - 'enjoyment' - - -So let's say, we want to define a function that adds two variables. To do that, we need to tell Python that our function should accept two parameters: - - def add(a, b): - return a + b - -We already know what `return` means, but now the _argument list_ isn't empty any more. Instead, it has two entries, `a` and `b`, and that means you also have to call this function with two arguments: - - >>> add(2, 2) - 4 - -You can _not_ call the function with any other number of parameters, or you'll get an error: - - >>> add(1) - Traceback (most recent call last): - File "", line 1, in - TypeError: add() missing 1 required positional argument: 'b' - >>> - >>> add(2, 3, 4) - Traceback (most recent call last): - File "", line 1, in - TypeError: add() takes 2 positional arguments but 3 were given - -The arguments we defined here are so-called `positional` arguments. They are called this because their position, or order, is important. Calling a function with a different order of arguments changes the meaning, like this: - - def sub(a, b): - return a - b - - >>> sub(3, 2) - 1 - >>> sub(2, 3) - -1 - -Positional arguments, because they are identified by their position. - -But what if we want to allow someone to only specify one argument, assuming that people always mean 0 when they don't say anything? In that case, we can turn one of our positional arguments into keyword arguments, or default arguments [Footnote: These two words actually have distinct, specific meanings in Python 3. However, this difference is not very important in most use cases, so I'll use them interchangeably.]. This means that we specify a value that should be used when the argument is absent in the call: - - def add(a, b=0): - return a - b - -I can now leave the value for `b` out of the call and Python will substitute a zero for it: - - >>> add(1) - 1 - >>> add(1, 2) - 3 - -This argument is now a _default_ argument, because it can be defined either by its position or by its default value. It can _also_ be identified by is name, and that's why it's not a positional argument any more (as you saw above, it's still positional, too, though). Have a look at this: - - def sub(a=0, b=0): - return a - b - -Both `a` and `b` are now default arguments that I can omit, or I can identify them by their name -- and then the order isn't important any more. Here's how you can call this new `sub` function: - - >>> sub(3, 2) - 1 - >>> sub(3) - 3 - >>> sub() - 0 - >>> sub(a=4) - 4 - >>> sub(b=2) - -2 - >>> sub(a=4, b=2) - 2 - >>> sub(b=4, a=2) - -2 - -As you saw here, we can call this function like we did before, with positional arguments. We can also skip any of the arguments and get a value of 0 for those. We can also identify the arguments by their name, regardless of the order. That's also why they're called keyword arguments -- instead of their position I can call them by their keyword, their name. - -For most parts, this can get you very far. You can now create functions with as few or as many arguments as you need, and you can make some or all of these arguments with default values, so we can skip them or call them by their name. - - -## The hitch with keyword arguments - -Of course, not all is easy in the land of computers, so there's a hitch that we have to look out for when using keyword arguments. These arguments are only initialized when the function is defined, so they become what other languages would call _static_, they don't change from call to call. - -Well, what do I mean by that now?! It means that when you give a keyword argument a default value that can change, like a list, a dictionary or an object, you'll be surprised. Let's have a look: - - def wrong_insert(a, ls=[]): - """Insert a into the given list.""" - ls.append(a) - return ls - -Now when you use `insert`, at first nothing surprising happens: - - >>> wrong_insert(2, []) - [2] - >>> wrong_insert(3, [1, 2]) - [1, 2, 3] - >>> wrong_insert(1) # we can omit the keyword argument here! - [1] - -However, now something completely strange appears: - - >>> wrong_insert(1) # again! - [1, 1] - -Wait, what now?! Why is `1` twice in that list? Because you inserted twice into the same list. That default value is only created once when you define the function, so when you append something to the list, you append it _to the default value of that parameter_. So how do we do it right? We assign a default value that cannot be changed and test for it. There's one value that's perfectly suited for that task, and it's `None`: - - def right_insert(a, ls=None): - if ls is None: - ls = [] - ls.append(a) - return ls - -This one works as expected: - - >>> right_insert(2, []) - [2] - >>> right_insert(3, [1, 2]) - [1, 2, 3] - >>> right_insert(1) - [1] - >>> right_insert(1) - [1] - -Be very, very careful when you see a list, a dictionary or an object as a default value. Changing that value will happen and you probably won't expect it. - -There's more or less only one use case for putting a mutable value (like a dictionary) into a default value, and that's when you use it as a cache. You should certainly call it `CACHE` in that case, too! Here's an example: - - def fib(n, CACHE={}): - if n in CACHE: - return CACHE[n] - else: - if n < 1: - return 1 - else: - val = fib(n-1) + fib(n-2) - CACHE[n] = val - return val - -That's a neatly encapsulated cache. Since we named it in ALL-CAPS, we know that it's sort-of global, so we'll be on the lookout when finding such a variable. - -If you see any other list, dictionary or object as a default parameter value, be suspicious! - - -## varargs, lots of positional arguments - -But what if you don't know the number of positional arguments beforehand? Say, you want to add two _or more_ numbers? -There's a way to do that and it's called `varargs`, from "variable number of arguments". The syntax for that in Python is: - - def adder(*args): - result = 0 - for argument in args: - result = result + argument - return result - -And let's try it out: - - >>> adder(1) - 1 - >>> adder() - 0 - >>> adder(1, 1, 2, 3, 5, 8, 13, 21) - 54 - -So what happens here is that any argument that is not positional gets stuffed into a list, and this list is called `args`, because we gave it that name with an asterisk in front of it in the function definition. Any other name works as well, but it's a pretty strong convention to use `args` here. -And as you see, we can have any number of arguments, even none at all. Of course we can still specify that we want positional arguments in front of it: - - def subber(start, *args): - result = start - for argument in args: - result = result - argument - return result - -You can _not_ omit the first argument. It's a positional argument, so you cannot omit it. But we can omit the varargs: - - >>> subber(5, 2) - 3 - >>> subber(10, 1, 2, 3, 4) - 0 - >>> subber(10) - 10 - >>> subber() - Traceback (most recent call last): - File "", line 1, in - TypeError: subber() missing 1 required positional argument: 'start' - -Can you have more than one varargs? - - def subber(*args, *moreargs): - File "", line 1 - def subber(*args, *moreargs): - ^ - SyntaxError: invalid syntax - -No, you can't. And what would be the meaning of that anyway? Which list should Python add the arguments to? No, no, that doesn't mean anything, so you it's a syntax error, as it should be. - -Did you notice what simple trick Python does here for us? It takes the arguments that you pass into a function that don't go anywhere else, stuffs them into a list and gives us that list. It's really all that happens. - -But interestingly enough, the trick works in reverse, too: When you have a list of values that you want to use as arguments to a function, you can tell python to do just that, and with the _same_ syntax, too: - - >>> arglist = [10, 5, 4] - >>> subber(*arglist) - 1 - >>> subber(10, *arglist) - -9 - >>> subber(100, 1, 2, 3, 4, *arglist) - 71 - -Don't forget that asterisk, though: - - >>> subber(10, arglist) - Traceback (most recent call last): - File "", line 1, in - File "", line 2, in subber - TypeError: unsupported operand type(s) for +: 'int' and 'list' - - - -## kwargs, lots of keyword arguments and lots of other arguments - -So let's say you want to define a function that has a keyword argument, but you don't know what keyword that'll be, and you also don't know how many it should be. Sounds unlikely, but it's actually very useful when you do dynamic processing or datastructures you don't know much about. - -Of course, there's a syntax for it as well, and it's pretty similar to the varargs we saw before. It's called kwargs, for keyword arguments, uses two asterisks and instead of a list of arguments you get a dictionary: - - def dynamic(**kwargs): - print(kwargs) - -And it works as expected: - - >>> dynamic(hello='world', goodbye='lonelyness') - {'goodbye': 'lonelyness', 'hello': 'world'} - -Just as we saw before, the same works in reverse: When I have a dictionary with values that I want to use to call a function, I can just tell Python to unpack them into arguments: - - def do_stuff(key=0, lock=1, **kwargs): - print("doing stuff with key {} and lock {}".format(key, lock)) - print("and more arguments: {}".format(kwargs)) - - >>> params = {'key': 10, 'lock': 'Locke', 'something': 'else'} - >>> do_stuff(**params) - doing stuff with key 10 and lock Locke - and more arguments: {'something': 'else'} - - -So now we have all parts together and we can actually stick them together, so here's the full syntax for function definitions [at least in Python 2.7]: - -def fun(a, b, *args, **kwargs): - print(a, b, args, kwargs) - -Try it out for yourself! - -Actually, there's one more thing: You _could_ add in keyword arguments in the middle, between `b` and `*args`, but it wouldn't work the way you expected it to, and *that* would be confusing and unintuitive. So don't do that! - - - -## Functions are values! - -So why is the `args` and `kwargs` dance so useful? Especially `kwargs` -- what good could it be when you don't know the parameters to your function? - -To make this work for us, we have to know one more great thing about functions: they are values, just like everything else is. So you can rename functions, store them in variables, put them in lists and even pass them to other functions. Using `fun` from above, let's see: - - >>> fun(0, 0) - (0, 0, [], {}) - >>> morefun = fun - >>> morefun(0, 0) - (0, 0, [], {}) - >>> funlist = [fun, morefun] - >>> funlist[0](0, 0) - (0, 0, [], {}) - >>> def funfun(f): - print("calling f") - f(0, 0) - >>> funfun(fun) - calling f - (0, 0, [], {}) - -That last bit is really interesting: we can pass functions into functions. We can also return functions from functions -- because they're simply values that behave like any other. - -And finally, we can also _define_ functions inside of functions. In a way, when you write `def f(...):...`, this is just shorthand for `f = `, and it will behave exactly like any other variable. Think of functions as any other variable, just one that you can call to get a new value. - -So now let's put all this together. See if you can figure out what this next example does: - - def log_fun(f): - def inside(*args, **kwargs): - print("called with {} and {}".format(args, kwargs)) - result = f(*args, **kwargs) - print("resulted in {}".format(result)) - return result - return inside - -Wow! We defined a function that takes a function, creates a function, uses a function inside the inner function, and then returns that inner function. So, what does it do? `log_fun` _wraps_ the function we passed as parameter `f`, and returns a function that does the wrapping. The wrapping function then prints the arguments and kwarguments, calls `f` with them, prints the result of the call and finally returns the result of the call. All without knowing anythig about the parameters of `f` itself. From a parameter/return perspective, it behaves quite like `f` does -- only it prints out the parameters and results in between. How do we use it? Let's try: - - >>> new_f = log_fun(fun) - >>> new_f(0, 0) - called with (0, 0) and {} - 0 0 () {} - resulted in None - -You could be even more daring and _replace_ `fun` with that new logged version of fun: - - >>> fun = log_fun(fun) - >>> fun(0, 0) - called with (0, 0) and {} - 0 0 () {} - resulted in None - -Pretty neat, eh? You simply wrapped your function in some logging, without caring what the actual parameters are. That `log_fun` function is pretty useful when you want to debug your function calls without changing the functions themselves. - -Since wrapping, enhancing or _decorating_ functions is such a useful concept, there's a special syntax for it in python, with an `@`. These next two examples are exactly the same: - - def something(x): - print("X!", x) - something = log_fun(something) - -and this one: - - @log_fun - def something(x): - print("X!", x) - -And now you know what a _Decorator_ is in python: It's a function `d`that takes a function `f` and returns a function `f'`, and in-between does something with the original function `f` -- effectively enhancing the things `f` does. Don't be alarmed by the syntax, the two blocks above are exactly identical, semantically, so if you ever see one of the two, you can replace it with the other without fear. - -There's more to say about decorators, but there's another document for that. - - -## Overloading - -If you ever programmed in a compiled language like C, C++ or Java, you might have heard the term "overloading a function". It's a cool concept, and it basically means that two functions or methods can have the same name but a different parameter list. Like this (in Java): - - class OverloadingDemo - { - void simpleFunc() - { - System.out.println('simpleFunc v1 called') - } - - int simpleFunc(int param) - { - System.out.println('simpleFunc v2 called') - return param * 2; - } - - public static void main(String[] args) - { - simpleFunc(); - simpleFunc(2); - } - } - -If you compiled that program and ran it, the output would be: - - simpleFunc v1 called - simpleFunc v2 called - -The reason this works is because when you compile this program, the compiler can match the different calls to the different function definitions. So effectively, there are two functions in this Java class, one without parameters and one with parameters. - -Python works differently. When you define a function, as you remember, you simply give a value to a variable. So if you do this in Python: - - def fun(): - print("fun v1 called") - - def fun(a): - print("fun v2 called") - -Now there is _still_ only one version of `fun`, and it's the last one that you defined. The second definition of `fun` didn't overload the function, it replaced it. - -If you want your function to work the same way as the ones in the example above, you'll have to do it yourself: - - def fun(a=None): - if a is None: - print("fun v1 called") - else: - print("fun v2 called") - -So, the gist is that Python does not have built-in overloading. Instead, you can assign a `None` value for the parameter you want to overload and check for its existence yourself. - - - -## Conclusion - -Well, there's a surprising amount of stuff in Python functions. The most important things you have to remember are: - - * If you want a variable number of positional arguments, use `args`. If you want to variable number of named arguments, use `kwargs`. - * Function definitions have a lot of syntax, but they're nothing "magic". They just simply create a function object and assign that value to a name, the function name. - * You can not overload a function in the Java-sense, but you can overload them in other ways, with named arguments, args, kwargs and your own separation logic. - * **Do not use a mutable value as a default parameter value.** - -And finally, don't worry too much about it! =) diff --git a/beginnerscorner/args/args.py b/beginnerscorner/args/args.py deleted file mode 100644 index a2c53ab..0000000 --- a/beginnerscorner/args/args.py +++ /dev/null @@ -1,41 +0,0 @@ - - -def fun(a, *args): - - print("hello world", a, args) - -def fun2(a,b,c,d,e): - print(a,b,c,d,e) - -def fun3(a=0, b=0): - print(a,b) - -def fun4(a, b=0, *args, **kwargs): - print(a, b, args, kwargs) - -def function(positional, kw=0, *args, **kwargs): - print(positional, kw, args, kwargs) - -fun4(1, 2,3,4, c=6, d=8) - -arguments = [1,2,3] -fun4(arguments) - -someargs = {'a': 10, 'b': 100} -fun3(**someargs) - -print("ignore the rest") - -fun(1, 2) -fun(1) -fun(1,2,3) - -arguments = [2,3,34,5,5] -fun(1, *arguments) -fun2(*arguments) - -fun3(1,2) -fun3(a=2, b=3) -fun3(b=3, a=2) - -fun(1, b=2) \ No newline at end of file diff --git a/beginnerscorner/args/override.py b/beginnerscorner/args/override.py deleted file mode 100644 index 2230e3c..0000000 --- a/beginnerscorner/args/override.py +++ /dev/null @@ -1,19 +0,0 @@ - - -class A(): - def __init__(self, a): - self.a = a - print("AAAAAAAA: {}".format(a)) - -class B(A): - def __init__(self, a, b=0): - super(B, self).__init__(a) - self.b = b - print("BBBBBB: {}".format(b)) - - def __init__(self, a, b, c): - print("ABC") - - -A(10) -B(20, 0, 0) diff --git a/beginnerscorner/args/problem.py b/beginnerscorner/args/problem.py deleted file mode 100644 index 71f904f..0000000 --- a/beginnerscorner/args/problem.py +++ /dev/null @@ -1,30 +0,0 @@ - -def wrong_fun(item, ls=[]): - ls.append(item) - return ls - -def right_fun(item, ls=None): - if ls is None: - ls = [] - ls.append(item) - return ls - -def fib(n, CACHE={}): - if n in CACHE: - return CACHE[n] - else: - if n < 1: - return 1 - else: - val = fib(n-1) + fib(n-2) - CACHE[n] = val - return val - -print( wrong_fun(1, []) ) # --> [1] -print( wrong_fun(1, [0,0,0,0]) ) - -print( wrong_fun(9) ) # --> [1] -print( wrong_fun(1) ) # --> [1] - -print(right_fun(9)) -print(right_fun(1)) \ No newline at end of file diff --git a/beginnerscorner/crashcourse-0/01_print.py b/beginnerscorner/crashcourse-0/01_print.py deleted file mode 100644 index 313f258..0000000 --- a/beginnerscorner/crashcourse-0/01_print.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python - -# basic print -print 'foo' - -# different print -print('bar') - -# parameters -print("foo", 'bar') -print "foo", 'bar' - -# "return" -print "foo\nbar" -print 'foo\nbar' - -# no auto return -print "bar", -print 'foo' - -# concat print -print "#"+'foo'+'bar'+'#' - -# show special string stuff -print 8*'#' - -# some formatting stuff -print 'parse string %s and integer %i' % ('ssd', 23) - -''' i am -a multiline -print 'foo' -comment -''' - -print '''i am a long comment and should not be vissible -at -ALL!!1! -''' diff --git a/beginnerscorner/crashcourse-0/02_vars.py b/beginnerscorner/crashcourse-0/02_vars.py deleted file mode 100644 index 93e5fe1..0000000 --- a/beginnerscorner/crashcourse-0/02_vars.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python - -# basic vars -tmpTxt = '' # just a temp var! -fooTxt = 'i am a string' -fooInt = 101 -fooFloat = 1.01 - -# show what we have -print fooTxt, fooInt, fooFloat - -# concat errors! -#tmpTxt = fooTxt + fooInt + fooFloat - -# correct! -tmpTxt = fooTxt + str(fooInt) + str(fooFloat) - -# print what we have -print tmpTxt - -# add stuff -fooInt += 22 -fooFloat += fooInt - -print fooInt, fooFloat - - -# OVERWRITE / RE-ASSIGN -fooInt = 22 -fooFloat = fooInt - -print fooInt, fooFloat - diff --git a/beginnerscorner/crashcourse-0/03_functions.py b/beginnerscorner/crashcourse-0/03_functions.py deleted file mode 100644 index a3cc2e0..0000000 --- a/beginnerscorner/crashcourse-0/03_functions.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -# define a function -def imAfunction(): - print 'lolfunction' - -# define a internal function (void) -def imAnotherfunction(name): - print 'hello', name - -# define a return function -def imAcoolFunction(int1, int2): - # we COULD do it this way, but we make it nice ;) - #return int1 * int2 - res = int1 * int2 - return res - -# just show an empty function -def imEmpty(): - pass - -imAfunction() -imAnotherfunction('dave') -imAcoolFunction(3, 3) # NO OUTPUT -print imAcoolFunction(3, 3) - -fooInt = 11 -fooInt += imAcoolFunction(2, 2) -print fooInt - - diff --git a/beginnerscorner/crashcourse-0/04_if.py b/beginnerscorner/crashcourse-0/04_if.py deleted file mode 100644 index 1679c74..0000000 --- a/beginnerscorner/crashcourse-0/04_if.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python - -userName = 'Dave' - -# demonstrate uppercase, lowercase stuff -if userName == 'Dave': - print 'HELLO' -elif userName == 'anon': - print 'legion' -else: - print 'I CAN NOT ALLOW THAT', userName - - -icnat = 'I CAN NOT ALLOW THAT' - -# demonstrate negative -if userName != 'Dave' and userName != 'dave': - print icnat -else: - print 'hello', userName - - -# demonstrate some basic logic stuff -numOne = 1 -numTwo = 2 - -if numOne == 1 and numTwo == 2: - print "all true" -elif numOne != 1: - print "one is out space" -elif numTwo != 2: - print "two is out space" diff --git a/beginnerscorner/crashcourse-0/05_input.py b/beginnerscorner/crashcourse-0/05_input.py deleted file mode 100644 index 13dced4..0000000 --- a/beginnerscorner/crashcourse-0/05_input.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python - -# get user input -myInput = raw_input("enter some foo: ") - -# THIS is BALLZ (in python 2.6/2.7), describe why! -#myInput = input("enter some foo: ") - -print "you entered:", myInput - -# do stuff ONLY if this the input is a digit -if myInput.isdigit() == True: - print 'yes we digit' - - numberOne = 11 - numberTwo = 0 - - # this would fail - #numberTwo = myInput - - # convert FIRST - numberTwo = int(myInput) - - numberOne += numberTwo - print numberOne - -else: - print 'just text dude' - diff --git a/beginnerscorner/crashcourse-0/06_lists.py b/beginnerscorner/crashcourse-0/06_lists.py deleted file mode 100644 index 12c6093..0000000 --- a/beginnerscorner/crashcourse-0/06_lists.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -#### tuple -staticList = (23, 42, 'bar') -print staticList - -## better not show? could be confusing -# pack vars to list -#staticList = 23, 42, 'bar' -#print staticList -# extract list to vars -#a1, a2, a3 = staticList -#print a3 - -# access single item by index -print staticList[1] - -### list -aList = [3, 2, 4, 1, 'hamster', 'foo'] -print aList - -# access single item by index -print aList[3] - -aList.reverse() -print aList - -#sorted(aList) - -aList.sort() -print aList - -aList.append('bar') -print aList - -tmpFoo = aList.pop() -print 'tmpFoo:', tmpFoo, 'aList:', aList - -tmpFoo = aList.pop(-1) -print 'tmpFoo:', tmpFoo, 'aList:', aList - -# good examples at: http://effbot.org/zone/python-list.htm - - -### dictionary -aDict = {'blue':'blau', 'yellow':'gelb', 'pirated':'zugutenberg'} -print aDict - -print 'get by key:', aDict['pirated'] - -# access a non existing key -#print 'get by key:', aDict['nope'] - -# add stuff -aDict['cat'] = 'Katze' -print aDict - -# change stuff -aDict['cat'] = 'Hund' -print aDict diff --git a/beginnerscorner/crashcourse-0/07_loopiefruits.py b/beginnerscorner/crashcourse-0/07_loopiefruits.py deleted file mode 100644 index 5829e4f..0000000 --- a/beginnerscorner/crashcourse-0/07_loopiefruits.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python - -userName = "anon" - -# show a loop -for i in range(10): - print i - -# show after loop! -print 'afterloop:', i - -# show what variable means! -for hamster in range(3): - print userName, 'has', hamster, "hamsters" - -# what is "range" -print range(10) -print range(5, 10) -print range(6, 43, 4) -print range(-10, 0) -print range(0, -10, -2) - -# demonstrate some list stuff -randomList = ['foo', 42, 'hamster', 23] -for stuff in randomList: - print stuff - -# demonstrate while with name input -while userName != 'Dave': - userName = raw_input('ENTER CORRECT USERNAME:') - -print 'HELLO' diff --git a/beginnerscorner/crashcourse-0/08_additional_stuff.py b/beginnerscorner/crashcourse-0/08_additional_stuff.py deleted file mode 100644 index a7f9968..0000000 --- a/beginnerscorner/crashcourse-0/08_additional_stuff.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# what we would write "normally" -#!/usr/bin/python - -# thanks to derf (https://github.com/derf) -# thats the way today (system independent) -#!/usr/bin/env python - -# you ONLY need coding: utf-8 buts way nicer -# -*- coding: utf-8 -*- - -# demonstrate some encoding stuff -#fooBar = "\xc3".decode('latin1') -#print fooBar - -# demonstrate indend block-foo -if 1 == 2: - # tab indend - print 'foo' -else: - #space indend - print 'bar' - -# this would NOT work!!1! -''' -# mixed stuff -if 1 == 1: - # tab indend - print 'foo' - #space indend - print 'bar' -''' diff --git a/beginnerscorner/crashcourse-0/autorunSaved.py b/beginnerscorner/crashcourse-0/autorunSaved.py deleted file mode 100644 index b5910a6..0000000 --- a/beginnerscorner/crashcourse-0/autorunSaved.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/python - -# Whats this? -# I tried to write a piece of code that executes my changes in a file automatically. -# Worked great with Python 2.7. -# BUT it did not work with Python 2.6 -# I Wrote it under Ubuntu 12.04 but have Debian 6 on my Laptop. -# FOOOOO!!1! -# So I used "clear; python cc.py" for my Presentation instead -.- - -import os, time, subprocess -#http://www.cyberciti.biz/faq/python-execute-unix-linux-command-examples/ - -def clear(): - # clear the console - #os.environ.clear() - #os.system('CLS') # for windows! - os.system('clear') - -clear() - -print os.path.basename(__file__) -print 'PLEASE STAND BY FOR CHANGES' - -filesDates = {} -while True: - dirList = os.listdir(".") - for fname in dirList: - #print fname - #print "last modified: %s" % time.ctime(os.path.getmtime(fname)) - #print "created: %s" % time.ctime(os.path.getctime(fname)) - - # ignore myself! - if fname != os.path.basename(__file__): - mtime = os.path.getmtime(fname) - if not fname in filesDates: - # we are NOT interested in created files - # and on the first run just add all files with theyr dates - filesDates[fname] = {'mtime':mtime} - elif filesDates[fname]['mtime'] != mtime: - clear() - - # remember the new time - filesDates[fname]['mtime'] = mtime - res = 'nothing...' - try: - res = subprocess.check_output('python '+fname, shell=True) # stderr=subprocess.STDOUT, - except Exception as e: - res = 'ERROR: ' + str(e) - - # get the longest "string" in the output header - maxLen = len(str(mtime)) - if len(fname) > maxLen: - maxLen = len(fname) - - # remember to add the left and right space AND # to the calculation (+4 chars) - print (maxLen+4)*'#' # draw topline - print '#', 'OUTPUT'.center(maxLen, ' '), '#' - print '#', fname.center(maxLen, ' '), '#' - print '#', str(mtime).center(maxLen, ' '), '#' - print (maxLen+4)*'#' # draw bottomline - print res - - time.sleep(1.1) diff --git a/beginnerscorner/crashcourse-2/1-classes.py b/beginnerscorner/crashcourse-2/1-classes.py deleted file mode 100644 index a4de636..0000000 --- a/beginnerscorner/crashcourse-2/1-classes.py +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# -# Classes, Methods, Constructors - -# Der Klassenrumpf - -class foo(object): - pass - - -# Methoden -# Keine Umlaute oder Operatoren im Namen -# nur Methoden etc verwenden .... - - -class foo_methods(object): - print("Hurz") - - def print_Foo(self): - print("Foo") - -# --!! wie man sehen kann, wird print("Hurz") ausgegeben obwohl, -# die Classe noch nicht aufgerufen / Instanziiert wurde -# deshalb nur methoden definitionen in classen verwenden nicht direkten code... - -# richtig wäre: -# --------- von Hand ausbauen ---------- - - -class foo_methods(object): - def hurz(self): - print("Hurz") - - def print_Foo(self): - print("Foo") - - -# Instanziierung der Klasse - -instanz_von_foo = foo_methods() - -# aufruf der Methode print_Foo - -instanz_von_foo.print_Foo() -instanz_von_foo.hurz() - - -# einfache Parameterübergabe in Methoden - -class foo_methods(object): - def print_Foo(self, text): - print(text) - -instanz_von_foo = foo_methods() -instanz_von_foo.print_Foo("Hallo Pythonfoo") - - -# mehrere fest definierte Parameter -# ---- von Hand ausbauen-------- - -class foo_methods(object): - def print_Foo(self, text, multiplikator): - print multiplikator*text - -instanz_von_foo = foo_methods() -instanz_von_foo.print_Foo("Hallo Pythonfoo",5) - -# variable Anzahl von Parametern - -class foo_methods(object): - def print_Foo(self, *foo_parameter): - print "It is at Tuple: " , foo_parameter - for param in foo_parameter: - print param - -instanz_von_foo = foo_methods() -instanz_von_foo.print_Foo("Hallo Pythonfoo","Python ist cool") - -# variable Anzahl von Parametern in Dictionary - -class foo_methods(object): - - def print_Foo(self, **foo_parameter): - - print "just printed: " , foo_parameter - - if "gruss" in foo_parameter: - print "Die Grußformel lautet: " + foo_parameter["gruss"] - else: - print "Keine Grüße enthalten" - -instanz_von_foo = foo_methods() -instanz_von_foo.print_Foo(gruss = "Hallo Pythonfoo",sagt = "Python ist cool") - -# Construktor __init__ -# Der Konstruktor einer Classe ist die Methode, die als erstes -# bei der initialisierung der Classe aufgerufen wird. -# In python wird der Construktor __init__ genannt - - - -class foo(object): - def __init__(self): - print "Ich bin der __init__ Konstruktor und komme bei der Instantiierung" - - # Variablendeklaration in einer Klasse während der Initialisierung - - self.magic = "Variablen einer Classe werden mit self. begonnen" - - # Es gibt nur die Konvention private Variablen und Methoden in - # der Namensgebung mit Unterstrich zu beginnen. - - self._privat = "Private Variablen in Klassen unter Python gibt es nicht" - - -fooclass = foo() -print fooclass.magic -print fooclass._privat - - - -# Instantiierung mit Parameterübergabe -# Der Konstruktor kann bei der Instantiierung -# der Klasse vergleichbar zur Methode Parameter entgegennehmen - -class foo(object): - def __init__(self, text): - print text - -fooclass = foo("Hallo Pythonfoo") - -# was tut self oder Variablen in Klassen -# ------- die Prints nacheinander von Hand testen ----------- -# ------- immer ein geht nicht dahinter --------------------- - -class foo(object): - def __init__(self): - var1 = "Ich bin var1" - self.var2 = "Ich bin var2" - - def printvar1(self): - print var1 - - -foobar = foo() - -print var1 -# print foobar.var1 -# print foobar.printvar1() -# print foobar.var2 - -# wie man sehen kann, ist eine einfache Variable innerhalb -# einer Methode nur in der Methode selbs zu benutzen -# für den Zugriff aus anderen Methoden oder von außerhalb in die Klasse -# ist self erforderlich diff --git a/beginnerscorner/crashcourse-2/2-vererbung.py b/beginnerscorner/crashcourse-2/2-vererbung.py deleted file mode 100644 index c229785..0000000 --- a/beginnerscorner/crashcourse-2/2-vererbung.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Klassen Vererbung - -# in Python werden Klassen seit python 2.7 sauber deklariert, in dem man sie -# grundsätzlich von der Klasse object erben lässt. - -# foo erbt seien Eigenschaften von der Superklasse object -class foo(object): - def __init__(self): - print "I am foo" - -# jetzt lassen wir die Klasse b von der Klasse foo erben -class b(foo): - def printme(self): - print "and me too" - -foobar = b() - -#foobar.printme() - - - -# Überschreiben von Methoden - -class foo(object): - def printme(self): - print "I am foo" - - -class b(foo): - def printme(self): - print "I am b" - -foobar = foo() -B = b() - -foobar.printme() -# und jetzt die Überschriebene Methode -B.printme() - -# Das wirft bei der Benutzung von Konstruktoren Probleme auf wie man -# hier sehen kann: - -class foo(object): - def __init__(self): - print "ich bin foo" - -class b(foo): - def __init__(self): - print "ich bin b" - -foobar = foo() -B = b() - -# The Magic of super -# Denn man möchte bei einer abgeleiteten Klasse meistens auch -# den Konstruktor der Elternklasse mit aufrufen -# deshalb gibt es super - -class foo(object): - def __init__(self): - print "Ich bin foo" - -class b(foo): - def __init__(self): - super(b, self).__init__() - print "ich bin b" - -foobar = foo() -B = b() - diff --git a/beginnerscorner/crashcourse-2/3-import.py b/beginnerscorner/crashcourse-2/3-import.py deleted file mode 100644 index c6bf40b..0000000 --- a/beginnerscorner/crashcourse-2/3-import.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Import your Stuff -# als erstes machen wir mal eine Datei foo.py, mit einer Klasse namens bar, die -# wir dann in einem anderen Programm -# benutzen wollen. - -class bar(object): - def __init__(self): - self._text = "Ich bin bar aus foo oder auch foobar genannt!" - self.endline = "---------------------------------------------------" - def _printStuff(self, txt): - print(txt) - print(self.endline) - - def printText(self): - print(self._text) - print(self.endline) - - -# Jetzt erstellt man eine zweite Datei test.py, in der wir den neuen code importieren - -import foo - -foobar = foo.bar() - -foobar._printStuff("This is a Test") -foobar.printText() - -# alternativ kann man auch - -from foo import bar - -# schreiben, wobei die Instanziierung dann so lauten müsste: - -foobar = bar() - -# eine weitere Alternative: - -from foo import * - -# hier wird wie bei "from foo import bar" importiert jedoch sollten noch mehr -# klassen vorhanden sein, so würden diese mit importiert werden. - -# Jetzt legen wir ein Unterverzeichnis namens testlib an -# und erstellen mit touch __init__.py eine leere Datei in diesem Verzeichnis -# Die Datei ist dafür verantwortlich, dass Python mit import in diesem Verzeichnis sucht. -# danach verschieben wir die date foo.py in den neuen Unterordner. -# der Import sieht daraufhin wie folgt aus: - -import testlib.foo - -# und die Instanziierung - -foobar = testlib.foo.bar() - -# jetzt noch ein klein wenig magic... -# wir schreiben in die datei foo.py unter die Klasse noch ein wenig normalen code -# und führen den import wie oben noch einmal aus - -# unter der classe: - -foobar = bar() -i=0 -while i < 10: - foobar.printText() - i += 1 - -# wie man sehen kann, wird der code beim instanziieren automatisch mit ausgeführt -# das will man eigentlich nicht. Aus diesem Grund benutzt man main um Testcode -# in seine Libery zu implementieren. Dieser wird nur dann ausgeführt, -# wenn die Datei direkt ausgeführt wird. Ansonsten werden nur die -# betreffenden Elemente importiert. - -class main(object): - def __init__(self): - foobar = bar() - i = 0 - while i < 10: - foobar.printText() - i += 1 - -if __name__== "__main__": - start = main() -# schau __all__ das muss auf Modulebene implementiert werden um festzulegen, -# was man nicht importieren soll diff --git a/beginnerscorner/crashcourse-2/4-typeProof.py b/beginnerscorner/crashcourse-2/4-typeProof.py deleted file mode 100644 index 7ca0c14..0000000 --- a/beginnerscorner/crashcourse-2/4-typeProof.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Typenprüfung -# ============ - -# Der Befehl type() aus crashcourse-0 -#------------------------------------- - -var1 = 10 -var2 = 0.20 -var3 = "Hallo" -print type(var1) -print type(var2) -print type(var3) - -# type() und Klassen -#-------------------- - -class foo(object): - def __init__(self): - self._data = "Rot" - self.data = "blau" - print "Print inside Class: ", self._data - -class foobar(object): - pass - -# Instanziierung -fooClass = foo() -foobarClass = foobar() - - -print(type(fooClass)) - -# Typenprüfung mittels Type -if type(fooClass) == foo: - print "Jo fooClass is foo" -else: - print "Ups fooClass isn't foo" - -if type(foobarClass) == foo: - print "Jo foobarClass is foo" -else: - print "Ups foobarClass isn't foo" - -# Typenprüfung mittels isinstance - -if isinstance(fooClass, foo): - print "Jo ...shit!!! it is foo" -else: - print "F! it isn't foo" - -# Ableitungen von Klassen - -class subfoo(foo): - def __init__(self): - super(subfoo, self).__init__() - self.subdata = "Grün" - -classSubfoo = subfoo() - -print "Subfoo Data: ", classSubfoo.data, classSubfoo.subdata - - -# Typenprüfung type vs isinstance - -if type(classSubfoo) == foo: - print "by type Subfoo is foo" -else: - print "by type subfoo isn't foo" - -if isinstance(classSubfoo, foo): - print "by isinstance Subfoo is foo" -else: - print "by isinstance subfoo isn't foo" - - -# und man kann auch auf die Elternklasse der Elternklasse prüfen - -if isinstance(classSubfoo, object): - print "Jo, Subfoo Parent ist object" -else: - print "Subfoo ist not child of object" diff --git a/beginnerscorner/crashcourse-2/5-propertys.py b/beginnerscorner/crashcourse-2/5-propertys.py deleted file mode 100644 index ef077c8..0000000 --- a/beginnerscorner/crashcourse-2/5-propertys.py +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - - -# a simple Property -# ================= - -class propertyFoo(object): - def __init__(self): - self._x = 10 - - @property - def X(self): - print "Using @property" - return self._x - - - @X.setter - def X(self, value): - self._x = value - print "using @X.setter" - -foo = propertyFoo() - -print foo.X -foo.X = 12 -print foo.X - -# ----------- clear ------------------- -# propertys are usefull in case of Typefoo - -class propertyFoo(object): - def __init__(self): - self._x = 10 - - @property - def X(self): - return self._x - - - @X.setter - def X(self, value): - if isinstance(value, str): - self._x = value - else: - raise Exception("Exception: Type Missmatch. Only INT allowed") - - - -foo = propertyFoo() -print 4*"*" + " Now test if Integer works " - -foo.X = 12 -print foo.X - -print 4*"*" + " Now test if String works " - -foo.X = "FooBar" -print foo.X - -# ------------------ clear ------------------- -# a Property ListArray - -class address(object): - def __init__(self): - self._ID = None - self._Name = None - self._Vorname = None - - @property - def ID(self): - return self.__ID - - @ID.setter - def ID(self, value): - if isinstance(value, int): - self._ID = value - else: - raise Exception("Exception: Type Missmatch. Only INT allowed") - - @property - def Name(self): - return self._Name - - @Name.setter - def Name(self, value): - if isinstance(value, str): - self._Name = value - else: - raise Exception("Exception: Type Missmatch. Only STR allowed") - - - @property - def Vorname(self): - return self._Vorname - - @Vorname.setter - def Vorname(self, value): - if isinstance(value, str): - self._Vorname = value - else: - raise Exception("Exception: Type Missmatch. Only STR allowed") - - -adrList = [] - -adr1 = address() -adr1.ID = 0 -adr1.Name = "Mustermann" -adr1.Vorname = "Hans" -adrList.append(adr1) - -adr2 = address() -adr2.ID = 1 -adr2.Name = "Hanswurst" -adr2.Vorname = "Mortima" -adrList.append(adr2) - -for element in adrList: - print element - -for element in adrList: - print element.ID, element.Vorname, element.Name diff --git a/beginnerscorner/crashcourse-2/6-decorators-generators.py b/beginnerscorner/crashcourse-2/6-decorators-generators.py deleted file mode 100644 index 02b9d80..0000000 --- a/beginnerscorner/crashcourse-2/6-decorators-generators.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Decorators -# sind Funktionen, die vorher definiert werden müssen, die -# Funktionen entgegennehmen und diese verändern - -# Nachfolgend werden die Ergebnisse aus fak() -# gecached, so dass sie nur Berechnet werden, -# wenn sie noch nicht im Cache sind - -class CacheDecorator(object): - - def __init__(self): - self.cache = {} - self.func = None - - def cachedFunc(self, *args): - if args not in self.cache: - self.cache[args] = self.func(*args) - else: - print "cachedINFO" - return self.cache[args] - - def __call__(self, func): - self.func = func - return self.cachedFunc - -@CacheDecorator() -def fak(n): - ergebnis = 1 - for i in xrange(2, n+1): - ergebnis *= i - return ergebnis - - - -print fak(10) -print fak(20) -print fak(10) -print fak(20) - -# ------------------------------- -# Generators -# ------------------------------- - -# Beispiel random versus xrandom mittels Generatoren - -# 1. der pythonic range() weg -for i in range(10): - print "range i: ", i - -# 2. der Weg mit weniger speicher aber langsam wegen der prüfung auf <= 10 -i = 0 -while i <= 10: - print "While i: ", i - i += 1 - -# 3. der Weg wie in 2 jedoch als generatorfunktion - -def xgen(param): - while i <= 10: - x += 1 - yield x - -for i in xgen(10): - print "xgen i: ", i diff --git a/beginnerscorner/crashcourse-2/7-ExploringModules.py b/beginnerscorner/crashcourse-2/7-ExploringModules.py deleted file mode 100644 index ec47d31..0000000 --- a/beginnerscorner/crashcourse-2/7-ExploringModules.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Exploring Modules - -import sys - -# dir() shows what a Module contains -for element in dir(sys): - print element - -# Getting Help - -help(sys) - -# Getting Help on Method - -help(ses.flags) - - -# Using Documentation -print range.__doc__ - -# und wenn garnichts mehr geht man aber schon nen guter -# Pyhtoncoder ist helfen nur noch die sourcen aber -# dafür müssen diese natürlich mitinstalliert sein -import copy -print copy.__file__ - -# Kommentare und Hilfe in seine Objekte zu bekommen ist recht einfach. Einfach -# direkt hinter den Klassennamen oder hinter den Methodennamen in -# Kommentarzeichen meistens so """ Kommentartext """ schreiben - -class beispiel(object): - """ dies ist ein Besipielkommentar für die Klasse """ - - def doit(self): - """ das ist jetzt der Hilfetext für die Methode doit """ - pass - -test = beispiel() -print help(test) - diff --git a/beginnerscorner/crashcourse-2/8-OOP_popeln.py b/beginnerscorner/crashcourse-2/8-OOP_popeln.py deleted file mode 100644 index a287622..0000000 --- a/beginnerscorner/crashcourse-2/8-OOP_popeln.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - - -# some stuff with Propertys -# and why OOP is nice - -# merge a simple code to OOP - -import sqlite3 - - -filename = "initdata.pro" -path = "./" - -fullpath = path + filename - -connection = sqlite3.connect(fullpath) -cursor = connection.cursor() - -sqltxt = "SELECT adresse, name, vorname, key FROM adresse " - -cursor.execute(sqltxt) -data = cursor.fetchall() - -for line in data: - for element in line: - print element - print "--------------" - - - -print 8*"\n" diff --git a/beginnerscorner/crashcourse-2/8-OOP_popeln/1-beipsiel.py b/beginnerscorner/crashcourse-2/8-OOP_popeln/1-beipsiel.py deleted file mode 100644 index fdc828a..0000000 --- a/beginnerscorner/crashcourse-2/8-OOP_popeln/1-beipsiel.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - - -import sqlite3 - -class sqlitefoo(object): - def __init__(self): - self.filename = "initdata.pro" - self.path = "./" - - self.fullpath = self.path + self.filename - - def datafoo(self): - connection = sqlite3.connect(self.fullpath) - cursor = connection.cursor() - - sqltxt = "SELECT adresse, name, vorname, key FROM adresse " - - cursor.execute(sqltxt) - data = cursor.fetchall() - - for line in data: - for element in line: - print element - print "--------------" - - -def main(): - doit = sqlitefoo() - doit.datafoo() - -if __name__ == "__main__": - main() - - -print 8*"\n" diff --git a/beginnerscorner/crashcourse-2/8-OOP_popeln/2-beispiel.py b/beginnerscorner/crashcourse-2/8-OOP_popeln/2-beispiel.py deleted file mode 100644 index dc5cfc5..0000000 --- a/beginnerscorner/crashcourse-2/8-OOP_popeln/2-beispiel.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - - - -import sqlite3 - -class sqlitefoo(object): - def __init__(self): - self.filename = "initdata.pro" - self.path = "./" - - self.fullpath = self.path + self.filename - - def get_connection(self, fullpath): - connection = sqlite3.connect(self.fullpath) - return connection - - def datafoo(self): - connection = self.get_connection(self.fullpath) - cursor = connection.cursor() - - sqltxt = "SELECT adresse, name, vorname, key FROM adresse " - - cursor.execute(sqltxt) - data = cursor.fetchall() - - for line in data: - for element in line: - print element - print "--------------" - - -def main(): - doit = sqlitefoo() - doit.datafoo() - -if __name__ == "__main__": - main() - - -print 8*"\n" diff --git a/beginnerscorner/crashcourse-2/8-OOP_popeln/3-beispiel.py b/beginnerscorner/crashcourse-2/8-OOP_popeln/3-beispiel.py deleted file mode 100644 index 1beced8..0000000 --- a/beginnerscorner/crashcourse-2/8-OOP_popeln/3-beispiel.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import sqlite3 - -class sqlitefoo(object): - def __init__(self): - self.filename = "initdata.pro" - self.path = "./" - - self.fullpath = self.path + self.filename - - def get_connection(self, fullpath): - connection = sqlite3.connect(self.fullpath) - return connection - - def get_cursor(self, connection): - cursor = connection.cursor() - return cursor - - def datafoo(self): - - connection = self.get_connection(self.fullpath) - cursor = self.get_cursor(connection) - - sqltxt = "SELECT adresse, name, vorname, key FROM adresse " - - cursor.execute(sqltxt) - data = cursor.fetchall() - - for line in data: - for element in line: - print element - print "--------------" - - -def main(): - doit = sqlitefoo() - doit.datafoo() - -if __name__ == "__main__": - main() - - - -print 8*"\n" diff --git a/beginnerscorner/crashcourse-2/8-OOP_popeln/4-beispiel.py b/beginnerscorner/crashcourse-2/8-OOP_popeln/4-beispiel.py deleted file mode 100644 index 3f09eec..0000000 --- a/beginnerscorner/crashcourse-2/8-OOP_popeln/4-beispiel.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - - -import sqlite3 - -class sqlitefoo(object): - def __init__(self): - self.filename = "initdata.pro" - self.path = "./" - - self.fullpath = self.path + self.filename - - def get_connection(self, fullpath): - connection = sqlite3.connect(fullpath) - return connection - - def get_cursor(self, connection): - cursor = connection.cursor() - return cursor - - def get_connection_cursor(self, fullpath): - connection = self.get_connection(fullpath) - cursor = self.get_cursor(connection) - return cursor - - - def datafoo(self): - - cursor = self.get_connection_cursor(self.fullpath) - - sqltxt = "SELECT adresse, name, vorname, key FROM adresse " - - cursor.execute(sqltxt) - data = cursor.fetchall() - - for line in data: - for element in line: - print element - print "--------------" - - -def main(): - doit = sqlitefoo() - doit.datafoo() - -if __name__ == "__main__": - main() - - - -print 8*"\n" diff --git a/beginnerscorner/crashcourse-2/8-OOP_popeln/5-beispiel.py b/beginnerscorner/crashcourse-2/8-OOP_popeln/5-beispiel.py deleted file mode 100644 index c8d9c83..0000000 --- a/beginnerscorner/crashcourse-2/8-OOP_popeln/5-beispiel.py +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - - -import sqlite3 - -class sqlitefoo(object): - def __init__(self): - self.filename = "initdata.pro" - self.path = "./" - - self.fullpath = self.path + self.filename - - def get_connection(self, fullpath): - connection = sqlite3.connect(fullpath) - return connection - - def get_cursor(self, connection): - cursor = connection.cursor() - return cursor - - def get_connection_cursor(self, fullpath): - connection = self.get_connection(fullpath) - cursor = self.get_cursor(connection) - return cursor - - def fetch_data_bySQL(self, sqltxt): - cursor = self.get_connection_cursor(self.fullpath) - cursor.execute(sqltxt) - data = cursor.fetchall() - return data - - def get_data_by_tblName(self, tblName): - if tblName == "adresse": - sqltxt = "SELECT adresse, name, vorname, key FROM adresse " - data = self.fetch_data_bySQL(sqltxt) - return data - else: - raise Exception("EX 0002: Table " + tblName + "does not exist") - - - def datafoo(self): - data = self.get_data_by_tblName("adresse") - for line in data: - for element in line: - print element - print "--------------" - -class adresse(object): - def __init__(self): - self._adresse = "" - self._name = "" - self._vorname = "" - self._key = None - - @property - def adresse(self): - return self._adresse - - @adresse.setter - def adresse(self, value): - if type(value) == str: - self._adresse = value - else: - raise Exception("ES 0001: Type missmatch. has to be str") - - - @property - def name(self): - return self._name - - @name.setter - def name(self, value): - if type(value) == str: - self._name = value - else: - raise Exception("ES 0001: Type missmatch. has to be str") - - @property - def vorname(self): - return self._vorname - - @vorname.setter - def vorname(self, value): - if type(value) == str: - self._vorname = value - else: - raise Exception("ES 0001: Type missmatch. has to be str") - - - @property - def key(self): - return self._key - - @key.setter - def key(self, value): - if type(value) == int: - self._key = value - else: - raise Exception("ES 0001: Type missmatch. has to be str") - -def main(): - doit = sqlitefoo() - doit.datafoo() - -if __name__ == "__main__": - main() - - - -print 8*"\n" diff --git a/beginnerscorner/crashcourse-2/8-OOP_popeln/6-beispiel.py b/beginnerscorner/crashcourse-2/8-OOP_popeln/6-beispiel.py deleted file mode 100644 index 7a6f6f1..0000000 --- a/beginnerscorner/crashcourse-2/8-OOP_popeln/6-beispiel.py +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - - -import sqlite3 - -class sqlitefoo(object): - def __init__(self): - self.filename = "initdata.pro" - self.path = "./" - - self.fullpath = self.path + self.filename - - def get_connection(self, fullpath): - connection = sqlite3.connect(fullpath) - return connection - - def get_cursor(self, connection): - cursor = connection.cursor() - return cursor - - def get_connection_cursor(self, fullpath): - connection = self.get_connection(fullpath) - cursor = self.get_cursor(connection) - return cursor - - def fetch_data_bySQL(self, sqltxt): - cursor = self.get_connection_cursor(self.fullpath) - cursor.execute(sqltxt) - data = cursor.fetchall() - return data - - def get_dataproperty_Larray(self, tblName): - data = self.get_data_by_tblName(tblName) - propLarray = [] - for line in data: - adr = adresse() - adr.adresse = line[0] - adr.name = line[1] - adr.vorname = line[2] - adr.key = int(line[3]) - propLarray.append(adr) - return propLarray - - def get_data_by_tblName(self, tblName): - if tblName == "adresse": - sqltxt = "SELECT adresse, name, vorname, key FROM adresse " - data = self.fetch_data_bySQL(sqltxt) - return data - else: - raise Exception("EX 0002: Table " + tblName + "does not exist") - - -class adresse(object): - def __init__(self): - self._adresse = "" - self._name = "" - self._vorname = "" - self._key = None - - @property - def adresse(self): - return self._adresse - - @adresse.setter - def adresse(self, value): - if type(value) == str: - self._adresse = value - elif type(value) == unicode: - self._adresse = str(value) - else: - raise Exception("ES 0001: Type missmatch. has to be str") - - - @property - def name(self): - return self._name - - @name.setter - def name(self, value): - if type(value) == str: - self._name = value - elif type(value) == unicode: - self._name = str(value) - else: - raise Exception("ES 0001: Type missmatch. has to be str") - - @property - def vorname(self): - return self._vorname - - @vorname.setter - def vorname(self, value): - if type(value) == str: - self._vorname = value - elif type(value) == unicode: - self._vorname = str(value) - else: - raise Exception("ES 0001: Type missmatch. has to be str") - - - @property - def key(self): - return self._key - - @key.setter - def key(self, value): - if type(value) == int: - self._key = value - elif type(value) == unicode: - self._key = int(value) - else: - raise Exception("ES 0001: Type missmatch. has to be int") - -def main(): - doit = sqlitefoo() - propdatalist = doit.get_dataproperty_Larray("adresse") - for adr in propdatalist: - print adr.name - print adr.vorname - print adr.adresse - print adr.key - print 8*"-" - -if __name__ == "__main__": - main() - -# Wo man jetzt weiter machen könnte: -# ---------------------------------- -# TODO: get_dataproperty_Larray() zu ner eigenen adressHandler Klasse machen -# TODO: typenprüfung Str und Int an einer Stelle machen -# TODO: SQL-String generieren auf Input des Tabellennamens -# TODO: SQL-Input schreiben -# TODO: SQLITE File erzeugen und Tabelle erzeugen - -# Literaturempfehlung: -# ------------------------- -# Bezugsquelle: http://www.amazon.de/Expert-C-2008-Business-Objects/dp/1430210192 -# Author: Rockford Lhotka -# Titel: Expert C# 2008 Business Objects -# ------------------------- -# Projektlink: http://sourceforge.net/projects/habanero/ -# Projektname: Habanero -# Sprache: C# -# Info: OpenSource Business Application Framework -# ------------------------- -# Projektlink: https://www.openerp.com/de/ -# Projektname: openerp -# Sprache: Python -# Info: OpenSource Business Application Framework -# ------------------------- - - -print 8*"\n" diff --git a/beginnerscorner/decorators.py b/beginnerscorner/decorators.py deleted file mode 100644 index 5588cb9..0000000 --- a/beginnerscorner/decorators.py +++ /dev/null @@ -1,173 +0,0 @@ - -#Dekoratoren -#----------- - -# Dekoratoren sind Funktionen, die Funktionen verändern. - -# Zuerst brauchen wir eine Funktion, die irgend etwas macht: -# Signatur: `f`: int -> int -def f(n): - """Addiert etwas zum gegebenen Argument.""" - return n + 4 # garantiert zufällig gewählt -f(13) - - -# Nehmen wir an, wir wollen wissen, wann die Funktion aufgerufen wird, z.B. zum Debuggen. -# Wir könnten eine andere Funktion machen, die die Aufrufe protokolliert: -# Signatur: `fDebug`: int -> int -def fDebug(n): - """Addiert etwas zum gegebenen Argument und protokolliert das.""" - print(" aufgerufen mit %d" % n) - res = n + 4 - print(" Ergebnis ist: %d" % res) - return res -fDebug(13) - - -# Das ist nicht so toll, weil wir dann jeden Aufruf der Funktion durch unsere Debug-Funktion -# austauschen müssen -- und wenn wir wieder fertig sind, dann müssen wir die Funktion wieder -# zurücktauschen. - -fPrime = f -# Eine andere Variante wäre, die Funktion selbst zu modifizieren oder auszutauschen: -# Signatur: `f`: int -> int -def f(n): # debug-variante - """Addiert etwas zum gegebenen Argument und protokolliert das.""" - print(" aufgerufen mit %d" % n) - res = n + 4 - print(" Ergebnis ist: %d" % res) - return res -f(13) - -# und wieder zurück für später: -f = fPrime - - - -# Auch hier ist das Problem, dass wir unsere Funktion austauschen und hinterher wieder -# zurücktauschen müssen. Und diese Lösung ist auch nicht wiederbenutzbar. -# Besser wäre es also, wenn wir die Funktion (die das macht, was wir wollen), mit dem -# Verhalten, das wir zusätzlich/temporär haben wollen, zu modifizieren. -# Signatur: `fDebugProtocol`: int -> int -def fDebugProtocol(n): - print(" aufgerufen mit %d" % n) - res = f(n) - print(" Ergebnis ist: %d" % res) - return res -fDebugProtocol(13) - - -# Auch hier: die Funktion ist speziell für `f` gemacht, also nicht wiederverwendbar. -# Immerhin haben wir schon das Verhalten aus-faktoriert. -# Die Wiederverwendbarkeit erreichen wir jetzt, indem wir der `debugProtocol` die -# Funktion übergeben, die wir protokollieren wollen: -# Signatur: `debugProtocolForFunction`: (`f`: int -> int, int) -> int -def debugProtocolForFunction(someF, n): - print(" aufgerufen mit %d" % n) - res = someF(n) - print(" Ergebnis ist: %d" % res) - return res -debugProtocolForFunction(f, 13) - -# Besser, aber immer noch nicht toll: Wir müssen jeden Aufruf von `f` durch -# das `debugProtocol` ersetzen. -# Besser wäre es doch, die Funktion direkt zu modifizieren. Das erreichen wir, indem -# wir eine Funktion machen, die `f` als Argument nimmt und wieder eine Funktion zurückgibt. -# Das heißt, die Signatur ist -# debugF: (int -> int) -> (int -> int) -def debugF(someF): - # wir müssen wieder eine Funktion zurückgeben, also müssen wir eine machen: - def aux(n): - print(" aufgerufen mit %d" % n) - res = someF(n) # warum können wir hier f benutzen? Weil hier eine "Closure" vorhanden ist. - print(" Ergebnis ist: %d" % res) - return res - return aux - -# direkter Aufruf: -debugF(f)(13) - -# und für später: -f2 = debugF(f) -# beliebieger Code -f2(13) - -# Weil das sehr praktisch ist, gibt es dafür in Python eine spezielle Syntax: die @-Syntax. -# Dadurch wird `debugF` zum Dekorator. -@debugF -def f3(n): - """Gleiche Funktion wie vorhin!""" - return n + 4 - -def f7(n): - return n ** 2 -f7 = debugF(f7) - -# Jede Funktion, die eine Funktion nimmt und eine Funktion zurückgibt, kann als Dekorator benutzt werden. -# (Auch, wenn sich die Signaturen verändern (was auch sehr nützlich sein kann).) - -def needsPassword(f): - def aux(password, n): - if password != 'vErYsEcReT': - raise ValueError('password unknown') - return f(n) - return aux - -@needsPassword -def g(n): - return n + 7 - -g(7) # Falsche Signatur! -g('meinPasswort', 7) # ValueError weil falsches Passwort -g('vErYsEcReT', 7) # yay! - - - -# Komplizierter wird es, wenn der Dekorator auch noch ein Argument haben soll. - -def addTo(N): - def addNTo(f): - def aux(n): - return f(n) + N - return aux - return addNTo - - -# addTo: int -> ((int -> int) -> (int -> int)) -@addTo(7) # (int -> int) -> (int -> int) -def f(n): - return n * 2 - - - - - -# Dekorator, der zu jeder Ausgabe auch die Uhrzeit ausgibt. -# >>> output("hallo") # output: * -> None -# 19:30 hallo - -def timeOut(f): - def aux(*ausgabe): - print("the time is now!",) - f(*ausgabe) - # return None - return aux - - - -@timeOut -def output(*ausgabe): - print(*ausgabe) - - - - -lambda x : (x + 1) - -def no_name(x): - return x + 1 - - - - - diff --git a/beginnerscorner/docstrings.py b/beginnerscorner/docstrings.py deleted file mode 100644 index 4b31e75..0000000 --- a/beginnerscorner/docstrings.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/python -#shezi -#https://github.com/shezi -#CC BY-SA 4.0 - -""" -Im a module! - -how to use: -import docstrings -help(docstrings) -""" - - -## -# here is the description doxigen - -class A(): - """ - manny cool funcions - - first string in class = docu! - docstring - call me with - help(docstrings.A) - - """ - - # just a useless comment! - - # you cant make a docstring for a var - CLASS_VAR = 'just a var' - - def foo(self, bar): - """ - evil laugh (descrition string, max 120 chars! one sentence. - - a long block of text - with everyting `markdownm` - - the >>> is for doctest - import doctest - doctest.testmod(docstreings) - - @param bar does nothing - - >>> a = A() - >>> a.foo('BAR') - muhahah - - """ - - print("muhahah") diff --git a/beginnerscorner/glade/pygladeObj-TreeView/README b/beginnerscorner/glade/pygladeObj-TreeView/README deleted file mode 100644 index 1c2129e..0000000 --- a/beginnerscorner/glade/pygladeObj-TreeView/README +++ /dev/null @@ -1 +0,0 @@ -Just build a simple Treeview by Glade Objects. Push The Help Button in Menu to see the Treeview. diff --git a/beginnerscorner/glade/pygladeObj-TreeView/main.glade b/beginnerscorner/glade/pygladeObj-TreeView/main.glade deleted file mode 100644 index 327ebe7..0000000 --- a/beginnerscorner/glade/pygladeObj-TreeView/main.glade +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - True - - - True - True - - - True - _Datei - True - - - True - True - - - gtk-new - True - True - True - - - - - gtk-open - True - True - True - - - - - gtk-save - True - True - True - - - - - gtk-save-as - True - True - True - - - - - True - - - - - gtk-quit - True - True - True - - - - - - - - - True - _Bearbeiten - True - - - True - True - - - gtk-cut - True - True - True - - - - - gtk-copy - True - True - True - - - - - gtk-paste - True - True - True - - - - - gtk-delete - True - True - True - - - - - - - - - True - _Ansicht - True - - - - - True - _Hilfe - True - - - True - True - - - gtk-about - True - True - True - - - - - - - - - - False - 0 - - - - - True - - - False - 1 - - - - - True - True - - - 2 - - - - - True - 2 - - - False - 3 - - - - - - diff --git a/beginnerscorner/glade/pygladeObj-TreeView/start.py b/beginnerscorner/glade/pygladeObj-TreeView/start.py deleted file mode 100644 index 1bf6058..0000000 --- a/beginnerscorner/glade/pygladeObj-TreeView/start.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/python -import sys -import gtk -import gtk.glade -import gnome.ui - -""" In this Aplication ist Glade used in Mode GtkBuilder, 2.16 """ - -class mainwindowGTK: - """ This is the main Window of the aplication """ - - def __init__(self): - # Window Open - self.gladefile = "main.glade" - self.builder = gtk.Builder() - self.builder.add_from_file(self.gladefile) - self.builder.connect_signals(self) - self.window1 = self.builder.get_object("window1") - self.window1.show() - - def run(self): - try: - gtk.main() - except KeyboardInterrupt: - pass - - def quit(self): - gtk.main_quit() - - - def btnInfo_clicked(self, *args): - # Ueberschriften Container instantiieren - self.idColumn = gtk.TreeViewColumn('ID') - self.nameColumn = gtk.TreeViewColumn('Name') - self.vornameColumn = gtk.TreeViewColumn('Vorname') - - # Ueberschriften Container beschriften - self.idColumn.Title = "ID" - self.nameColumn.Title = "Name" - self.vornameColumn.Title = "Vorname" - - # instantiiert einen CellRenderer um die Daten Anzuzeigen - cell0 = gtk.CellRendererText() - cell1 = gtk.CellRendererText() - cell2 = gtk.CellRendererText() - - # Cells in die Columns packen und Daten anzeigen - self.idColumn.pack_start(cell0, True) - self.nameColumn.pack_start(cell1, True) - self.vornameColumn.pack_start(cell2, True) - - self.idColumn.set_attributes(cell0, text=0) - self.nameColumn.set_attributes(cell1, text=1) - self.vornameColumn.set_attributes(cell2, text=2) - - # treeview1 aus dem Glade.Gtk objekt Builder instantiieren - self.treeview1 = self.builder.get_object('treeview1') - - # Ueberschriften Container dem TreeView1 Anfuegen - self.treeview1.append_column(self.idColumn) - self.treeview1.append_column(self.nameColumn) - self.treeview1.append_column(self.vornameColumn) - - # gtk Liststore instantiieren, der die Daten uebernehmen soll - self.listStore1 = gtk.ListStore(int, str, str) - - # Daten in den Liststore geben - self.listStore1.append([0,"Leppin","Bjoern"]) - self.listStore1.append([1,"Pollmeier","Klaus"]) - - # ListStore in TreeView anzeigen - self.treeview1.set_model(self.listStore1) - - def on_window1_delete_event(self, *args): - self.quit() - -if __name__ == "__main__": - """ instantiate Class/Program an GTK """ - mawi = mainwindowGTK() - mawi.run() diff --git a/beginnerscorner/glade/pygladeObj3/main.glade b/beginnerscorner/glade/pygladeObj3/main.glade deleted file mode 100644 index 35984b2..0000000 --- a/beginnerscorner/glade/pygladeObj3/main.glade +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - True - - - True - True - - - True - _Datei - True - - - True - True - - - gtk-new - True - True - True - - - - - gtk-open - True - True - True - - - - - gtk-save - True - True - True - - - - - gtk-save-as - True - True - True - - - - - True - - - - - gtk-quit - True - True - True - - - - - - - - - True - _Bearbeiten - True - - - True - True - - - gtk-cut - True - True - True - - - - - gtk-copy - True - True - True - - - - - gtk-paste - True - True - True - - - - - gtk-delete - True - True - True - - - - - - - - - True - _Ansicht - True - - - - - True - _Hilfe - True - - - True - True - - - gtk-about - True - True - True - - - - - - - - - - False - 0 - - - - - True - - - False - 1 - - - - - True - Simple Forms - - - 2 - - - - - True - 2 - - - False - 3 - - - - - - diff --git a/beginnerscorner/glade/pygladeObj3/start.py b/beginnerscorner/glade/pygladeObj3/start.py deleted file mode 100644 index 77e0c86..0000000 --- a/beginnerscorner/glade/pygladeObj3/start.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/python -import sys -import gtk -import gtk.glade -import gnome.ui - -""" In this Aplication ist Glade used in Mode GtkBuilder, 2.16 """ - -class mainwindowGTK: - """ This is the main Window of the aplication """ - - def __init__(self): - # Window Open - self.gladefile = "main.glade" - self.builder = gtk.Builder() - self.builder.add_from_file(self.gladefile) - self.builder.connect_signals(self) - self.builder.get_object("window1").show() - - def run(self): - try: - gtk.main() - except KeyboardInterrupt: - pass - - def quit(self): - gtk.main_quit() - - - def btnInfo_clicked(self, *args): - # aendert den Text im Label1 - hilfe = self.builder.get_object('label1') - hilfe.set_label('Jo') - - - def on_window1_delete_event(self, *args): - self.quit() - -if __name__ == "__main__": - """ instantiate Class/Program an GTK """ - mawi = mainwindowGTK() - mawi.run() diff --git a/beginnerscorner/tests/99bottlesofbeer.py b/beginnerscorner/tests/99bottlesofbeer.py deleted file mode 100644 index 436a0e2..0000000 --- a/beginnerscorner/tests/99bottlesofbeer.py +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/python -a,t="\n%s bottles of beer on the wall","\nTake one down, pass it around" -for d in range(99,0,-1):print(a%d*2)[:-12]+t+a%(d-1 or'No') diff --git a/beginnerscorner/tests/array.py b/beginnerscorner/tests/array.py deleted file mode 100644 index 7f01608..0000000 --- a/beginnerscorner/tests/array.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/python - -a = [[1,2,3,4,5],[6,7,8,9,10]] -print a -for i in a: - print i - for p in i: - print p - -print "Mittels Koordinaten:" -print a[1][3] - -b = [] - -b.append(5) -b.append(4) -c = [] -c.append(b) - -b=[] -b.append("t") -b.append("s") - -c.append(b) - -print c diff --git a/beginnerscorner/tests/arrayTest.py b/beginnerscorner/tests/arrayTest.py deleted file mode 100644 index cd24c2d..0000000 --- a/beginnerscorner/tests/arrayTest.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/python - -import gc - -class tC(object): - def __init__(self): - self.name = 'nx' - self.val = '' - for i in range(100): - self.val += 'ASDF' - -def testArray(): - iAr = [] - - raw_input('go') - - for i in range(50000): - iAr.append(tC()) - print i - - raw_input('clear') - print len(iAr) - del iAr -testArray() -#iAr = None -#pop() / remove(iten) -#del iAr[1:49998] -#print len(iAr) -print "gc " + str(gc.get_count()) -gc.collect() -raw_input('done') -print "gc " + str(gc.get_count()) diff --git a/beginnerscorner/tests/arrays.py b/beginnerscorner/tests/arrays.py deleted file mode 100644 index 4cd791c..0000000 --- a/beginnerscorner/tests/arrays.py +++ /dev/null @@ -1,15 +0,0 @@ - - -size = 10 -#foorayOne = [[0]*size]*size -foorayOne = [] - - - -for x in range(0, size): - foorayOne.append([]) - for y in range(0, size): - foorayOne[x].append(0) - foorayOne[x][y] = x*y - -print foorayOne diff --git a/beginnerscorner/tests/count.py b/beginnerscorner/tests/count.py deleted file mode 100644 index 0675cfb..0000000 --- a/beginnerscorner/tests/count.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/python - -print '\n# 10 times' -for i in range(10): - print i - -print '\n# from, to, steps' -test = range(5, 10 ,2) -print test - -print '\n# reversed' -test.reverse() -print test - -for i in range(9, -1, -1): - print i diff --git a/beginnerscorner/tests/dodoCrypt.py b/beginnerscorner/tests/dodoCrypt.py deleted file mode 100644 index c80cd91..0000000 --- a/beginnerscorner/tests/dodoCrypt.py +++ /dev/null @@ -1,58 +0,0 @@ -# Verscchluesselungsarray schreiben -ascii = 65 - -a = chr(ascii) -y = [] -for i in range(26): - - ip = chr(i + 65) - x = [] - for p in range(26): - if i+p+65 <= 90: - x.append(chr(i+p+65)) - else: - x.append(chr(i+p+65-26)) - - y.append(x) - - -# Frage Key -key = raw_input('Gib bitte die Spalte an: \n') -# Frage text -text = raw_input('Gib bitte die Zeile an: \n') - - -# Jeder Buchstabe des Keys ist =q -#for currentkeychar in key: - #print q - -#Mit dem ersten Buchstaben aus dem Text -# Textstelle bekommt den Wer null -textstelle = 0 -for w in text: - - #print w - arraystelle = 0 - - #Suche in der Spalte nach dem Keybuchstaben mit selben Index - for n in y[0]: - - if n == w: - #print wrong - #l = 0 - keystelle = 0 - while keystelle != 25: - if y[keystelle][arraystelle] == key[textstelle]: - - #print wrong2 - - print y[keystelle][0] - - keystelle += 1 - - #l += 1 - - arraystelle += 1 - textstelle += 1 - - diff --git a/beginnerscorner/tests/encoding/unicode.py b/beginnerscorner/tests/encoding/unicode.py deleted file mode 100644 index d704daf..0000000 --- a/beginnerscorner/tests/encoding/unicode.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python -s = u"\u221E" -print('sign: ' + s) -print ord(u'\u221E') -print unichr(ord(u'\u221E')) -print "to UTF8:" + unichr(8734).encode('utf-8') diff --git a/beginnerscorner/tests/exeption/simpleExceptionHandling.py b/beginnerscorner/tests/exeption/simpleExceptionHandling.py deleted file mode 100644 index 7b7a586..0000000 --- a/beginnerscorner/tests/exeption/simpleExceptionHandling.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/python - -hasOnlyNumbers = True -while hasOnlyNumbers == True: - tmpInput = "" - try: - tmpInput = raw_input("Enter a Number: ") - if tmpInput.isdigit() == True: - print("Number: " + tmpInput) - tmpCalc = 0 / int(tmpInput) - else: - raise RuntimeError("idiot!") - - except RuntimeError as err: - print("You are doing it WRONG! " + str(err)) - hasOnlyNumbers = False - except Exception as ex: - print("OtherException: " + str(ex)) - #hasOnlyNumbers = False - -raw_input("End of Program!") diff --git a/beginnerscorner/tests/exeption/simpleExeption.py b/beginnerscorner/tests/exeption/simpleExeption.py deleted file mode 100644 index 62b33e7..0000000 --- a/beginnerscorner/tests/exeption/simpleExeption.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/python3 -# Einfachste Form einer Exeption - - -def throws(): - raise RuntimeError('this is the error message') - -def main(): - throws() - -if __name__ == '__main__': - main() diff --git a/beginnerscorner/tests/exeption/simpleExeption2.py b/beginnerscorner/tests/exeption/simpleExeption2.py deleted file mode 100644 index 9fafb62..0000000 --- a/beginnerscorner/tests/exeption/simpleExeption2.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python3 -import sys - -def throws(): - raise RuntimeError('this is the error message') - -def main(): - try: - throws() - return 0 -# Unterschied Python3 Pyhton2.7 -# except Exception, err: - - - except RuntimeError as err: - sys.stderr.write('ERROR: %s\n' % str(err)) - return 1 - -if __name__ == '__main__': - sys.exit(main()) diff --git a/beginnerscorner/tests/fileFoo/pathfoo.py b/beginnerscorner/tests/fileFoo/pathfoo.py deleted file mode 100644 index a92b574..0000000 --- a/beginnerscorner/tests/fileFoo/pathfoo.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python -import sys, os - -print 'sys.argv[0] =', sys.argv[0] -pathname = os.path.dirname(sys.argv[0]) -print 'path =', pathname -print 'full path =', os.path.abspath(pathname) diff --git a/beginnerscorner/tests/fileFoo/read.py b/beginnerscorner/tests/fileFoo/read.py deleted file mode 100644 index 57eb544..0000000 --- a/beginnerscorner/tests/fileFoo/read.py +++ /dev/null @@ -1,3 +0,0 @@ -datei = open('test.txt','r') -datei.read() -datei.close() diff --git a/beginnerscorner/tests/fileFoo/test.txt b/beginnerscorner/tests/fileFoo/test.txt deleted file mode 100644 index edc9131..0000000 --- a/beginnerscorner/tests/fileFoo/test.txt +++ /dev/null @@ -1,2 +0,0 @@ -test -Hello World!Hello! \ No newline at end of file diff --git a/beginnerscorner/tests/fileFoo/write.py b/beginnerscorner/tests/fileFoo/write.py deleted file mode 100644 index e440b2c..0000000 --- a/beginnerscorner/tests/fileFoo/write.py +++ /dev/null @@ -1,5 +0,0 @@ -# schreibt Hello an die Datei test.txt hinten an ( 'a' fuer anhaengen und 'w' fuer schreiben/neu ) - -datei = open('test.txt', 'a') -datei.write('Hello!') -datei.close() diff --git a/beginnerscorner/tests/format.py b/beginnerscorner/tests/format.py deleted file mode 100644 index b43b88d..0000000 --- a/beginnerscorner/tests/format.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python - -flo = 0.123456 - -print " myval: {:.3}".format(flo) + " formated" - diff --git a/beginnerscorner/tests/getIp.py b/beginnerscorner/tests/getIp.py deleted file mode 100644 index c094f63..0000000 --- a/beginnerscorner/tests/getIp.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python -# Quelle: http://fabaff.blogspot.de/2007/07/ip-adresse-und-python.html - -deviceName = 'wlan0' # eth0, ath0..... - -import socket - -print '############ V1 ############' - -# System name -sys_name = socket.gethostname() -# IP adress -ip_addr = socket.gethostbyname(sys_name) - -print ip_addr - -print '############ V2 ############' - -import os - -ip_adress = os.system('cat /proc/net/arp | grep '+ deviceName +' | cut -c -15') -print ip_adress - -print '############ V3 ############' - -#import socket -import fcntl -import struct - -def get_ip_address(ifname): - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - return socket.inet_ntoa(fcntl.ioctl( - s.fileno(), - 0x8915, # SIOCGIFADDR - struct.pack('256s', ifname[:15]) - )[20:24]) - -print get_ip_address(deviceName) #('ath0') - -# Quelle: http://houseoflaudanum.com/navigate/snippets/discovering-local-ip-addresses-in-python/ -print '############ V4 ############' - -#import socket - -hostname = socket.gethostname() -address = socket.gethostbyname("%s.local" % hostname) -addr = address #, port -print addr, address, hostname -print 'short method:', socket.gethostbyname("%s.local" % socket.gethostname()) diff --git a/beginnerscorner/tests/getWebPage.py b/beginnerscorner/tests/getWebPage.py deleted file mode 100644 index 87b3d5a..0000000 --- a/beginnerscorner/tests/getWebPage.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python -import sys -from urllib import urlopen -if len(sys.argv) > 1: - print urlopen(sys.argv[1]).read() -else: - print 'give me a page to show!' diff --git a/beginnerscorner/tests/import.py b/beginnerscorner/tests/import.py deleted file mode 100644 index 2703f04..0000000 --- a/beginnerscorner/tests/import.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python - -''' -import importlib -my_module = importlib.import_module('os') -help(my_module) -''' - -moduleNames = ['os'] -#moduleNames -#['sys', 'os', 're', 'unittest'] -module = map(__import__, moduleNames) -help(module[0]) -print module diff --git a/beginnerscorner/tests/import/imp_class.py b/beginnerscorner/tests/import/imp_class.py deleted file mode 100644 index e732e18..0000000 --- a/beginnerscorner/tests/import/imp_class.py +++ /dev/null @@ -1,12 +0,0 @@ -import random -import imp_var - -class matrix(object): - def printMatrix(self, lines): - for i in range(lines): - row = '' - - for rw in range(imp_var.matrixRows): - row += str(random.randint(0,1)) - - print row diff --git a/beginnerscorner/tests/import/imp_var.py b/beginnerscorner/tests/import/imp_var.py deleted file mode 100644 index 3c6f230..0000000 --- a/beginnerscorner/tests/import/imp_var.py +++ /dev/null @@ -1,3 +0,0 @@ - -varDict = {'key1':'val1', 'key2':'val2'} -matrixRows = 44 diff --git a/beginnerscorner/tests/import/start.py b/beginnerscorner/tests/import/start.py deleted file mode 100644 index cf90afc..0000000 --- a/beginnerscorner/tests/import/start.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/python - -print '############ imp_class ############' -import imp_class -imp_class.matrixRows = 2 # has NO effect to the import in the matrix-class! -mt = imp_class.matrix() -mt.printMatrix(23) - -print '############ imp_var ############' -import imp_var - -print imp_var.varDict -imp_var.varDict['key3'] = 'key3' -print imp_var.varDict - -print '############ from imp_var import varDict ############' -from imp_var import varDict - -print varDict -varDict['key4'] = 'key4' -print varDict - - diff --git a/beginnerscorner/tests/inherit.py b/beginnerscorner/tests/inherit.py deleted file mode 100644 index 84baeda..0000000 --- a/beginnerscorner/tests/inherit.py +++ /dev/null @@ -1,36 +0,0 @@ -class class1(object): - testText1 = 'fooo' - testText2 = 'bar' - - def __init__(self): - pass - - def printText(self): - print self.testText1, self.testText2 - -class class2(class1): - testText3 = 'TXT 3' - - def __init__(self): - self.testText2 = 'fail' - self.testText4 = 'TXT 4' - - def createNewGlobal(self): - self.testText5 = '555555' - - def printTextChild(self): - print self.testText1, self.testText2, self.testText3, self.testText4, self.testText5 - - -c1 = class1() -print 'c1.printText():' -c1.printText() - -print '' - -c2 = class2() -print 'c2.printText():' -c2.printText() -c2.createNewGlobal() -print 'c2.printTextChild()' -c2.printTextChild() diff --git a/beginnerscorner/tests/inputConvert.py b/beginnerscorner/tests/inputConvert.py deleted file mode 100644 index 6b5f3a5..0000000 --- a/beginnerscorner/tests/inputConvert.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python - -isOk = bool(int(raw_input('Boolean: '))) -print "Bool: " + str(isOk) - diff --git a/beginnerscorner/tests/matrix.py b/beginnerscorner/tests/matrix.py deleted file mode 100644 index 122a4b1..0000000 --- a/beginnerscorner/tests/matrix.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/python -import time - -txt = "The MATRIX has you!" -space = " " -col = "\x1b[32m" -print col -while True: - print space + txt, - if len(space) > 100: - space = " " - else: - space = space + " " - time.sleep(0.001) diff --git a/beginnerscorner/tests/matrix2.py b/beginnerscorner/tests/matrix2.py deleted file mode 100644 index c9388d1..0000000 --- a/beginnerscorner/tests/matrix2.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -import sys -import time - -fulltxt="" -txt = "The MATRIX has you!" -space = " " -col = "\x1b[32m" -print col -while True: - if len(space) > 1024: - fulltxt=txt - space="" - fulltxt = space + txt - print fulltxt - time.sleep(0.1) - #while len(space)<(len(fulltxt)/2): - space += " " - #print txt, " " - #sys.stdout.write(txt) diff --git a/beginnerscorner/tests/mpd/mpdSpam.py b/beginnerscorner/tests/mpd/mpdSpam.py deleted file mode 100644 index e69de29..0000000 diff --git a/beginnerscorner/tests/mpd/mpdTest.py b/beginnerscorner/tests/mpd/mpdTest.py deleted file mode 100644 index f5e20a4..0000000 --- a/beginnerscorner/tests/mpd/mpdTest.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# IMPORTS -from mpd import (MPDClient, CommandError) -from random import choice -from socket import error as SocketError -from sys import exit - - -## SETTINGS -## -HOST = 'hyperion' -PORT = '6600' -PASSWORD = False -### - - -client = MPDClient() - -try: - client.connect(host=HOST, port=PORT) -except SocketError: - exit(1) - -if PASSWORD: - try: - client.password(PASSWORD) - except CommandError: - exit(1) - -print client.status() -print client.playlistinfo()[0] -print client.__dict__ -#client.add(choice(client.list('file'))) -client.disconnect() - -# VIM MODLINE -# vim: ai ts=4 sw=4 sts=4 expandtab diff --git a/beginnerscorner/tests/multiplexer/Mclient.py b/beginnerscorner/tests/multiplexer/Mclient.py deleted file mode 100644 index 6723818..0000000 --- a/beginnerscorner/tests/multiplexer/Mclient.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/python -import socket -import sys - -print """ Client zum multiplexenden Server""" -print '\exit = close connection' - -# len prueft die Anzahl der Elemente im array -if len(sys.argv) > 1: - ip = sys.argv[1] -else: - ip = "localhost" - -if len(sys.argv) > 2: - port = int(sys.argv[2]) -else: - port = 9999 - -while True: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((ip, port)) - - try: - nachricht = raw_input("Nachricht: ") - s.send(unicode(nachricht, "utf-8")) - #Command-Part - if nachricht == "\exit": - break; - finally: - s.close() - diff --git a/beginnerscorner/tests/multiplexer/MclientDual.py b/beginnerscorner/tests/multiplexer/MclientDual.py deleted file mode 100644 index e6c055d..0000000 --- a/beginnerscorner/tests/multiplexer/MclientDual.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/python -import socket -import sys - -print "Client zum multiplexenden Server - Sender" - -# len prueft die Anzahl der Elemente im array -if len(sys.argv) > 1: - ip = sys.argv[1] -else: - ip = "localhost" - -if len(sys.argv) > 2: - port = int(sys.argv[2]) -else: - port = 9999 - -s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -try: - s.connect((ip, port)) - while True: - nachricht = raw_input("Nachricht: ") - s.send(unicode(nachricht, "utf-8")) -finally: - s.close() - diff --git a/beginnerscorner/tests/multiplexer/MclientDualR.py b/beginnerscorner/tests/multiplexer/MclientDualR.py deleted file mode 100644 index 329bd5f..0000000 --- a/beginnerscorner/tests/multiplexer/MclientDualR.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python -import socket -import sys - -print "Client zum multiplexenden Server - Reciever" -print "!BUG! Bei Server-Fail, CPU=100%" -print "BE CAREFUL WITH THAT!" - -# len prueft die Anzahl der Elemente im array -if len(sys.argv) > 1: - ip = sys.argv[1] -else: - ip = "localhost" - -if len(sys.argv) > 2: - port = int(sys.argv[2]) -else: - port = 9999 - -s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -try: - s.connect((ip, port)) - keepRecieving = True - while keepRecieving == True: - nachricht = s.recv(1024) - nachricht = nachricht.decode() - - if nachricht == '\leave': - keepRecieving = False - elif nachricht: - keepRecieving = True - #else: - # keepRecieving = False - print nachricht.decode() -finally: - s.close() - diff --git a/beginnerscorner/tests/multiplexer/MclientDualRcpuFix.py b/beginnerscorner/tests/multiplexer/MclientDualRcpuFix.py deleted file mode 100644 index f50af91..0000000 --- a/beginnerscorner/tests/multiplexer/MclientDualRcpuFix.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python -import socket -import sys -import select - -def makeNumberFromCharCode(code): - return (ord(code[0]) << 24) | (ord(code[1]) << 16) | (ord(code[2]) << 8) | ord(code[3]) - -print "Client zum multiplexenden Server - Reciever" -print "!BUG! Bei Server-Fail, CPU=100%" -print "BE CAREFUL WITH THAT!" - -# len prueft die Anzahl der Elemente im array -if len(sys.argv) > 1: - ip = sys.argv[1] -else: - ip = "localhost" - -if len(sys.argv) > 2: - port = int(sys.argv[2]) -else: - port = 9999 - -s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -noMessageCount = 0 -try: - s.connect((ip, port)) - keepRecieving = True - while keepRecieving == True: - #r, w, e=select([s],[],[s], 0) - #print r,'|',w,'|',e - nachricht = s.recv(1024) - - if nachricht == '\leave': - keepRecieving = False - elif nachricht: - print 'recieved MESSAGE' - keepRecieving = True - elif nachricht == False: - print 'recieved FALSE' - keepRecieving = False - elif nachricht == '': - print 'EMPTY!' - keepRecieving = False - #elif nachricht - #print makeNumberFromCharCode(nachricht) - nachricht = nachricht.decode() - print 'msg', nachricht.decode() -except socket.error: - print 'yay' - if e[0] in (errno.EWOULDBLOCK, errno.EAGAIN): # since this is a non-blocking socket.. - #return # no error - print 'nofoo' - else: - # error - print 'CLOSE error' - socket.close() -finally: - s.close() - diff --git a/beginnerscorner/tests/multiplexer/MclientDualStarter.sh b/beginnerscorner/tests/multiplexer/MclientDualStarter.sh deleted file mode 100644 index 0564580..0000000 --- a/beginnerscorner/tests/multiplexer/MclientDualStarter.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -#DIR = "$( cd "$( dirname "$0")" && pwd )" - - -echo DIR - -#python DIR+"MclientDualR.py" & -#./MclientDual.py - -#if [ "$TERM" = "xterm" ] ; then -# export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}\007"' -#else -# unset PROMPT_COMMAND -#fi diff --git a/beginnerscorner/tests/multiplexer/Mserver.py b/beginnerscorner/tests/multiplexer/Mserver.py deleted file mode 100644 index f469c03..0000000 --- a/beginnerscorner/tests/multiplexer/Mserver.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python -import socket -import select -import sys - -print """Beispiel fuer einen einfachen multiplexenden Server mittels sockets""" - -if len(sys.argv) > 1: - port = int(sys.argv[1]) -else: - port = 10007 - -server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -server.bind(("", port)) - -server.listen(1) - -clients = [] - -try: - while True: - lesen, schreiben, oob = select.select([server] + clients, [], []) - - for sock in lesen: - if sock is server: - client, addr = server.accept() - clients.append(client) - print("+++ Client (0) verbunden", format(addr[0])) - else: - nachricht = sock.recv(1024) - ip = sock.getpeername()[0] - # first commands! - if nachricht == "\exit": - print("+++ " + format(ip) + " exits") - elif nachricht: - #print("[(0)] [1]".format(ip, nachricht.decode())) - print ip + " " + nachricht.decode() - else: - print("+++ Verbindung zu [0] beendet".format(ip)) - - sock.close() - clients.remove(sock) - -finally: - for c in clients: - c.close() - server.close() - diff --git a/beginnerscorner/tests/multiplexer/Mserver.py.back b/beginnerscorner/tests/multiplexer/Mserver.py.back deleted file mode 100644 index 802ffaa..0000000 --- a/beginnerscorner/tests/multiplexer/Mserver.py.back +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python -import socket -import select - -"""Beispiel fuer einen einfachen multiplexenden Server mittels sockets""" - -server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -server.bind(("", 9999)) - -server.listen(1) - -clients = [] - -try: - while True: - lesen, schreiben, oob = select.select([server] + clients, [], []) - - for sock in lesen: - client, addr = server.accept() - clients.append(client) - print("+++ Client (0) verbunden", format(addr[0])) - else: - nachricht = sock.recv(1024) - ip = sock.getpeername()[0] - if nachricht: - print("[(0)] [1]".format(ip,nachricht,decode())) - else: - print("+++ Verbindung zu [0]beendet", format(ip) - sock.close() - clients.remove(sock) - -finally: - for c in clients: - c.close() - server.close() diff --git a/beginnerscorner/tests/multiplexer/MserverDual.py b/beginnerscorner/tests/multiplexer/MserverDual.py deleted file mode 100644 index c860228..0000000 --- a/beginnerscorner/tests/multiplexer/MserverDual.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/python -import socket -import select -import sys - -print "Beispiel fuer einen einfachen multiplexenden Server mittels sockets" - -if len(sys.argv) > 1: - port = int(sys.argv[1]) -else: - port = 9999 - -server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -server.bind(("", port)) - -server.listen(1) - -clients = [] - -try: - while True: - lesen, schreiben, oob = select.select([server] + clients, [], []) - - for sock in lesen: - if sock is server: - client, addr = server.accept() - clients.append(client) - print("+++ Client (0) verbunden", format(addr[0])) - else: - nachricht = sock.recv(1024) - ip = sock.getpeername()[0] - if nachricht: - #print("[(0)] [1]".format(ip, nachricht.decode())) - print ip + " " + nachricht.decode() - for c in clients: - c.send(nachricht) - else: - print("+++ Verbindung zu [0] beendet".format(ip)) - sock.close() - clients.remove(sock) -finally: - for c in clients: - c.close() - -server.close() - diff --git a/beginnerscorner/tests/myClock.py b/beginnerscorner/tests/myClock.py deleted file mode 100644 index 69e4996..0000000 --- a/beginnerscorner/tests/myClock.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/python - -import os -import time -import datetime - -# 1. the year as a four-digit number, e.g. 2007 -# 2. the month (1, 2, , 12) -# 3. the day of the month (1, 2, , 31) -# 4. hour (0, 1, , 23) -# 5. minutes (0, 1, , 59) -# 6. seconds (0, 1, , 61 where 60 and 61 are used for leap seconds) -# 7. week day (0=Monday, 1=Tuesday, , 6=Sunday) -# 8. day of the year (1, 2, , 366) -# 9. daylight saving time information (0, 1, or -1) - -while True: - locTime = time.localtime() - os.system('clear') - - lineHolder = str(locTime[3]) + '| ' - for i in range(locTime[3]): - lineHolder += '#' - print lineHolder - - lineHolder = str(locTime[4]) + '| ' - for i in range(locTime[4]): - lineHolder += '#' - print lineHolder - - lineHolder = str(locTime[5]) + '| ' - for i in range(locTime[5]): - lineHolder += '#' - print lineHolder - - time.sleep(1) diff --git a/beginnerscorner/tests/packetSniffer.py b/beginnerscorner/tests/packetSniffer.py deleted file mode 100644 index 6cd5c65..0000000 --- a/beginnerscorner/tests/packetSniffer.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -import socket, sys -from optparse import OptionParser -def scan_server(address, port): - s = socket.socket() - print "Attempting to connect to %s on port %s." %(address, port) - try: - s.connect((address, port)) - print "Connected to server %s on port %s." %(address, port) - return True - except socket.error, e: - print "Connecting to %s on port %s failed with the following error: %s" %(address, port, e) - return False - -if __name__ == '__main__': -#if True == True: - print 'go:' - parser = OptionParser() - parser.add_option("-a", "--address", dest="address", default="localhost", help="ADDRESS for server", metavar="ADDRESS") - parser.add_option("-p", "--port", dest="port", help="PORT for server", metavar="PORT") - (options, args) = parser.parse_args() - if options.port == 'all': - print 'checking all ports...' - for x in range(1,6 5536): - print 'checking port %s on %s' %(x, options.address) - check = scan_server(options.address, x) - print 'scan_server returned %s' %(check) - else: - options.port = int(options.port) - print 'options: %s, args: %s' %(options, args) - check = scan_server(options.address, options.port) - print 'scan_server returned %s' %(check) - sys.exit(not check) diff --git a/beginnerscorner/tests/path.py b/beginnerscorner/tests/path.py deleted file mode 100644 index 7b94ade..0000000 --- a/beginnerscorner/tests/path.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/python - -import os - -print 'os.path.pathsep: '+os.path.pathsep -print 'os.path.sep: '+os.path.sep -print 'os.path.curdir'+os.path.curdir - -#print os.__dict__ diff --git a/beginnerscorner/tests/python-switch.py b/beginnerscorner/tests/python-switch.py deleted file mode 100644 index dd804bb..0000000 --- a/beginnerscorner/tests/python-switch.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/python -#-*- coding:utf8 -*- - -# Benutzen eines Dictionary um gewissermaßen Switchfunktion aus C# zu haben -# Da Funktion in Switch nur als Funktion aber nicht ausgeführte Funktion funkioniert -# lambda benutzen, -def y(): - print("hallo") - -d = { - "a": lambda x: x**2, - "b": y, -} - -print d["a"](8) -d["b"]() - - - -# sehr schnell wemm viele Vergleiche Richtung 1000 und mehr - - diff --git a/beginnerscorner/tests/randomnes.py b/beginnerscorner/tests/randomnes.py deleted file mode 100644 index b1ca42a..0000000 --- a/beginnerscorner/tests/randomnes.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python -import time - -rangeInt = 1024 * 1024 -rangeIntTmp = raw_input("How many bytes (enter for 1 MB):") -if rangeIntTmp != '': - rangeInt = int(rangeIntTmp) - -targetFile = "/dev/null" -print "FULLPATH to target file" -print "be careful! overwrites existing files without warning!" -targetFileTmp = raw_input("(just enter for '/dev/null'): ") -if targetFileTmp != "": - targetFile = targetFileTmp - -fRandom = open("/dev/urandom", "r") -fTarget = open(targetFile, "w") - -timerStart = time.time() - -try: - for i in range(rangeInt): - # Do stuff with byte. - byte = fRandom.read(1) - fTarget.write(byte) - # !DANGEROUS! Could interact with console! - #print str(byte) -except Exception, e: - print "Error: ", str(e) -finally: - fRandom.close() - fTarget.close() - -print "########### fin" -print "duration: " + str(time.time() - timerStart) diff --git a/beginnerscorner/tests/regex.py b/beginnerscorner/tests/regex.py deleted file mode 100644 index 8097363..0000000 --- a/beginnerscorner/tests/regex.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -import re -from urllib import urlopen - -content = urlopen('http://www.quasco.de').read() - -pattern1 = '\s*(?i)href\s*=\s*(\"([^"]*\")|\'[^\']*\'|([^\'">\s]+))' -pattern2 = "\s*(?i)href\s*=\s*(\\\"([^\"]*\\\")|'[^']*'|([^'\">\s]+))" -pattern3 = "\\s*(?i)href\\s*=\\s*(\"([^\"]*\")|'[^']*'|([^'\">\\s]+))" -pattern4 = "/(.*)<\/a>/" -pattern5 = "([\d\w-.]+?\.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|pro)(\b|\W(?2") -dataRows = cursor.fetchall() - -for data in dataRows: - print(data) - -print dataRows[0] - -print '--------------------' - -# ne kleine selectabfrage (in "sicher") -cursor.execute("SELECT vorname, name FROM user WHERE personalNummer>:personalNummer", {"personalNummer": 2}) -dataRows = cursor.fetchall() - -for data in dataRows: - print(data) - -print dataRows[0] - - -connection.close() \ No newline at end of file diff --git a/beginnerscorner/tests/testEric/.eric4project/TestEric.e4q b/beginnerscorner/tests/testEric/.eric4project/TestEric.e4q deleted file mode 100644 index f7f1878..0000000 --- a/beginnerscorner/tests/testEric/.eric4project/TestEric.e4q +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/beginnerscorner/tests/testEric/.eric4project/TestEric.e4t b/beginnerscorner/tests/testEric/.eric4project/TestEric.e4t deleted file mode 100644 index 17f4946..0000000 --- a/beginnerscorner/tests/testEric/.eric4project/TestEric.e4t +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/beginnerscorner/tests/testEric/TestEric.e4p b/beginnerscorner/tests/testEric/TestEric.e4p deleted file mode 100644 index caf3553..0000000 --- a/beginnerscorner/tests/testEric/TestEric.e4p +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - Python - Console - Kleiner Test der IDE Eric python - 0.1 - Björn Leppin - bjoern@oerb.de - - __init__.py - main.py - start.py - - - - - - - - - - - main - - main - - None - - - - - - - - \ No newline at end of file diff --git a/beginnerscorner/tests/testEric/__init__.py b/beginnerscorner/tests/testEric/__init__.py deleted file mode 100644 index 8b13789..0000000 --- a/beginnerscorner/tests/testEric/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/beginnerscorner/tests/testEric/main b/beginnerscorner/tests/testEric/main deleted file mode 100644 index f1a5f82..0000000 --- a/beginnerscorner/tests/testEric/main +++ /dev/null @@ -1,3 +0,0 @@ - -import start -print "hallo" diff --git a/beginnerscorner/tests/testEric/main.glade b/beginnerscorner/tests/testEric/main.glade deleted file mode 100644 index 327ebe7..0000000 --- a/beginnerscorner/tests/testEric/main.glade +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - True - - - True - True - - - True - _Datei - True - - - True - True - - - gtk-new - True - True - True - - - - - gtk-open - True - True - True - - - - - gtk-save - True - True - True - - - - - gtk-save-as - True - True - True - - - - - True - - - - - gtk-quit - True - True - True - - - - - - - - - True - _Bearbeiten - True - - - True - True - - - gtk-cut - True - True - True - - - - - gtk-copy - True - True - True - - - - - gtk-paste - True - True - True - - - - - gtk-delete - True - True - True - - - - - - - - - True - _Ansicht - True - - - - - True - _Hilfe - True - - - True - True - - - gtk-about - True - True - True - - - - - - - - - - False - 0 - - - - - True - - - False - 1 - - - - - True - True - - - 2 - - - - - True - 2 - - - False - 3 - - - - - - diff --git a/beginnerscorner/tests/testEric/main.py b/beginnerscorner/tests/testEric/main.py deleted file mode 100644 index 3bd3bae..0000000 --- a/beginnerscorner/tests/testEric/main.py +++ /dev/null @@ -1,3 +0,0 @@ - -import __init__ -print "hallo" diff --git a/beginnerscorner/tests/testEric/start.py b/beginnerscorner/tests/testEric/start.py deleted file mode 100644 index 791d514..0000000 --- a/beginnerscorner/tests/testEric/start.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/python -import sys -import gtk -import gtk.glade -import gnome.ui - -""" In this Aplication ist Glade used in Mode GtkBuilder, 2.16 """ - -class mainwindowGTK: - """ This is the main Window of the aplication """ - - def __init__(self): - # Window Open - self.gladefile = "main.glade" - self.builder = gtk.Builder() - self.builder.add_from_file(self.gladefile) - self.builder.connect_signals(self) - self.window1 = self.builder.get_object("window1") - self.window1.show() - - def run(self): - try: - gtk.main() - except KeyboardInterrupt: - pass - - def quit(self): - gtk.main_quit() - - - def btnInfo_clicked(self, *args): - # Ueberschriften Container instantiieren - self.idColumn = gtk.TreeViewColumn('ID') - self.nameColumn = gtk.TreeViewColumn('Name') - self.vornameColumn = gtk.TreeViewColumn('Vorname') - - # Ueberschriften Container beschriften - self.idColumn.Title = "ID" - self.nameColumn.Title = "Name" - self.vornameColumn.Title = "Vorname" - - # instantiiert einen CellRenderer um die Daten Anzuzeigen - cell0 = gtk.CellRendererText() - cell1 = gtk.CellRendererText() - cell2 = gtk.CellRendererText() - - # Cells in die Columns packen und Daten anzeigen - self.idColumn.pack_start(cell0, True) - self.nameColumn.pack_start(cell1, True) - self.vornameColumn.pack_start(cell2, True) - - self.idColumn.set_attributes(cell0, text=0) - self.nameColumn.set_attributes(cell1, text=1) - self.vornameColumn.set_attributes(cell2, text=2) - - # treeview1 aus dem Glade.Gtk objekt Builder instantiieren - self.treeview1 = self.builder.get_object('treeview1') - - # Ueberschriften Container dem TreeView1 Anfuegen - self.treeview1.append_column(self.idColumn) - self.treeview1.append_column(self.nameColumn) - self.treeview1.append_column(self.vornameColumn) - - # gtk Liststore instantiieren, der die Daten uebernehmen soll - self.listStore1 = gtk.ListStore(int, str, str) - - # Daten in den Liststore geben - self.listStore1.append([0,"Leppin","Bjoern"]) - self.listStore1.append([1,"Pollmeier","Klaus"]) - - # ListStore in TreeView anzeigen - self.treeview1.set_model(self.listStore1) - - - - - def on_window1_delete_event(self, *args): - self.quit() - -if __name__ == "__main__": - """ instantiate Class/Program an GTK """ - mawi = mainwindowGTK() - mawi.run() diff --git a/beginnerscorner/tests/threading/Tclient.py b/beginnerscorner/tests/threading/Tclient.py deleted file mode 100644 index dcb6139..0000000 --- a/beginnerscorner/tests/threading/Tclient.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/python -import socket -import threading -SIZE =4 -class client(threading.Thread): - def __init__(self,c): - threading.Thread.__init__(self) - self.conn = c - self.stopIt = False - - def mrecv(self): - data = self.conn.recv(SIZE) - self.conn.send('OK') - return self.conn.recv(int(data)) - - def run(self): - while not self.stopIt: - msg = self.mrecv() - print 'recieved-> ',msg - -soc1 = socket.socket(socket.AF_INET,socket.SOCK_STREAM) -soc1.connect(('127.0.0.1',5432)) -soc1.send('WILL SEND') # telling server we will send data from here - -soc2 = socket.socket(socket.AF_INET,socket.SOCK_STREAM) -soc2.connect(('127.0.0.1',5432)) -soc2.send('WILL RECV') # telling server we will recieve data from here - -def msend(conn,msg): - if len(msg)<=999 and len(msg)>0: - conn.send(str(len(msg))) - if conn.recv(2) == 'OK': - conn.send(msg) - else: - conn.send(str(999)) - if conn.recv(2) == 'OK': - conn.send(msg[:999]) - msend(conn,msg[1000:]) # calling recursive -thr = client(soc2) -thr.start() -try: - while 1: - msend(soc1,raw_input()) -except: - print 'closing' -thr.stopIt=True -msend(soc1,'bye!!') # for stoping the thread -thr.conn.close() -soc1.close() -soc2.close() diff --git a/beginnerscorner/tests/threading/TclientEasy.py b/beginnerscorner/tests/threading/TclientEasy.py deleted file mode 100644 index 5be7b6a..0000000 --- a/beginnerscorner/tests/threading/TclientEasy.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/python -#from: -#http://www.python-forum.de/viewtopic.php?p=36000& - -#from Tkinter import * - - -# Echo client program -import socket - -class chat: - def __init__(self): - HOST = 'localhost' # The remote host - PORT = 9999 # The same port as used by the server - self.chatter = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #socket-Obj erstellen - self.chatter.connect((HOST, PORT)) #zu server verbinden - - def senden(self,inhalt): - self.chatter.send(inhalt) #Daten zu server senden - - def empfangen(self): - self.data = self.chatter.recv(4096) #Daten von Server empfangen - self.chatter.close() - return self.data - -def inserttext(event): - print "-------" - ch.senden(EntryEing.get()) - - stri = ch.empfangen() - print stri - - print "-----stri-----" - - text.insert("end",stri + "\n") - text.see(END) - - -while True: - ch = chat() - ch.senden(raw_input("Nachricht: ")) - print ch.empfangen() - -exit("done") - -#unused code behind.... - -#root = Tk() -ch = chat() - - -#scroll = Scrollbar(root) -#scroll.place(x=200,y= 0,width=200) - -#text = Text(root,yscrollcommand=scroll.set) -#text.place(x=0,y=10,width=200,height=250) - -#scroll.config(command=text.yview) - -#EntryEing = Entry(root) -#EntryEing.place(x=0,y= 280,width=200) -#EntryEing.bind("",inserttext) - -#root.minsize(230,300) -mainloop() diff --git a/beginnerscorner/tests/threading/Tserver.py b/beginnerscorner/tests/threading/Tserver.py deleted file mode 100644 index e454d2e..0000000 --- a/beginnerscorner/tests/threading/Tserver.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/python -import socket -import threading -import time - -SIZE = 4 - -soc = socket.socket(socket.AF_INET,socket.SOCK_STREAM) -soc.bind(('127.0.0.1',5432)) -soc.listen(5) - -class CThread(threading.Thread): - def __init__(self,c): - threading.Thread.__init__(self) - self.conn = c - self.stopIt=False - - def mrecv(self): - data = self.conn.recv(SIZE) - self.conn.send('OK') - msg = self.conn.recv(int(data)) - return msg - - def run(self): - while not self.stopIt: - msg = self.mrecv() - print 'recieved-> ',msg - -def setConn(con1,con2): - dict={} - state = con1.recv(9) - con2.recv(9) - if state =='WILL RECV': - dict['send'] = con1 # server will send data to reciever - dict['recv'] = con2 - else: - dict['recv'] = con1 # server will recieve data from sender - dict['send'] = con2 - return dict - -def msend(conn,msg): - if len(msg)<=999 and len(msg)>0: - conn.send(str(len(msg))) - if conn.recv(2) == 'OK': - conn.send(msg) - else: - conn.send(str(999)) - if conn.recv(2) == 'OK': - conn.send(msg[:999]) - msend(conn,msg[1000:]) # calling recursive - - -(c1,a1) = soc.accept() -(c2,a2) = soc.accept() -dict = setConn(c1,c2) -thr = CThread(dict['recv']) -thr.start() -try: - while 1: - msend(dict['send'],raw_input()) -except: - print 'closing' -thr.stopIt=True -msend(dict['send'],'bye!!!')# for stoping the thread -thr.conn.close() -soc.close() diff --git a/beginnerscorner/tests/threading/TserverEasy.py b/beginnerscorner/tests/threading/TserverEasy.py deleted file mode 100644 index ac6e8aa..0000000 --- a/beginnerscorner/tests/threading/TserverEasy.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/python - -# Echo server program -import socket -import thread - -HOST = 'localhost' # Symbolic name meaning the local host -PORT = 9999 # Arbitrary non-privileged port -s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #erstellen Server -s.bind((HOST, PORT)) #server auf localhost, Port 50007 laufen lassen -s.listen(5) #Server maximal 5 Client akzeptieren lassen... warten... - -allDatas = [] - -def handclient(conn,addr):#,allDatas): - while 1: - global allDatas - data = conn.recv(4096) - if not data: break - #allDatas = allDatas + data + "\n" - allDatas.append(data) - if len(allDatas) > 5: - #del allDatas[0] - allDatas.pop(0) - sendString = "" - for item in allDatas: - sendString = sendString + item + "\n" - conn.send(sendString) #Daten von Server zu Client senden - print data - print addr - print conn - conn.close() - - -def starter(): - while 1: - conn, addr = s.accept() - thread.start_new(handclient,(conn,addr))#,allDatas)) - -starter() - -s.close() diff --git a/beginnerscorner/tests/threading/functionMultithread.py b/beginnerscorner/tests/threading/functionMultithread.py deleted file mode 100644 index d05d40a..0000000 --- a/beginnerscorner/tests/threading/functionMultithread.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -#http://docs.python.org/2/library/queue.html -from multiprocessing import Process, Queue -import time -import random - -def my_function(q, x): - doSleep = random.randint(1,11) - print doSleep - time.sleep(doSleep) - q.put( str(x + 100) + ' slept:' + str(doSleep) ) - -if __name__ == '__main__': - queue = Queue() - - for i in range(11): - p = Process(target=my_function, args=(queue, i)) - p.start() - #p.join() # this deadlocks - - try: - while True: - result = queue.get(True, 11) - print result - except Exception as e: #Queue.Empty: - print 'nothing left', e diff --git a/beginnerscorner/tests/threading/threadTest.py b/beginnerscorner/tests/threading/threadTest.py deleted file mode 100644 index d33efa5..0000000 --- a/beginnerscorner/tests/threading/threadTest.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python -import time -import threading - -class MultiThread(threading.Thread): - def __init__(self, count): - threading.Thread.__init__(self) - self.count = count - - def run(self): - time.sleep(0.5 + self.count) - print 'fin ' + str(self.count) - -counts = 4 -myThreads = [] -for i in range(counts): - thread = MultiThread(i) - myThreads.append(thread) - thread.start() - time.sleep(0.300) - -# wait for all threads to finish -for t in myThreads: - print 'before join' - t.join() - print 'after join' - -print 'fin main' diff --git a/beginnerscorner/tests/time.py b/beginnerscorner/tests/time.py deleted file mode 100644 index 8f68245..0000000 --- a/beginnerscorner/tests/time.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python -import time - -timeClock = time.clock() -print 'clock: ', timeClock - -print time.strftime("%d %m %Y %H:%M:%S ") - -#mail-header-format -#Date: Mon, 4 Dec 2006 15:51:37 +0100' + '\n' -print time.strftime("%a, %d %b %Y %H:%M:%S") - - -pingTimerLast = time.time() - -print 'clock: ', time.clock() - -for i in range(10000): - print 'i+clock: ', i, time.clock() - print str(time.time()) - print str(time.time() - pingTimerLast) - -print 'timeClock: ', time.clock() - diff --git a/beginnerscorner/tests/time_delay.py b/beginnerscorner/tests/time_delay.py deleted file mode 100644 index 95c90d0..0000000 --- a/beginnerscorner/tests/time_delay.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/python -import time -import datetime -# -# str(datetime.timedelta(seconds=666)) - -print time.strftime("%d %m %Y %H:%M:%S ") - -inputTmp = raw_input("Enter Delay (in mins, def 0): ") -if inputTmp != '': - execTime = int(inputTmp) * 60 - -actualTime = time.time() -targetTime = actualTime + execTime -while actualTime < targetTime: - actualTime = time.time() - print str(targetTime - actualTime) - print str(datetime.timedelta(seconds=(targetTime - actualTime))) - time.sleep(1) - -print "End!!1!" diff --git a/beginnerscorner/tests/time_file.py b/beginnerscorner/tests/time_file.py deleted file mode 100644 index fd97ca3..0000000 --- a/beginnerscorner/tests/time_file.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -import time, os - -timerStart = time.time() -for aFile in os.listdir('.'): - mTime = time.ctime(os.path.getmtime(aFile)) - mTimeLocal = time.localtime(os.path.getmtime(aFile)) - - cTime = time.ctime(os.path.getctime(aFile)) - cTimeLocal = time.localtime(os.path.getctime(aFile)) - - print '############', aFile , '############' - print 'mtime:', mTime, 'local:', time.strftime('%d_%m_%Y' , mTimeLocal), mTimeLocal - print 'ctime:', cTime, 'local:', time.strftime('%d_%m_%Y' , cTimeLocal), cTimeLocal - - -print 'mtime = last changed' -print 'ctime = last access' -print 'duration:', str(time.time() - timerStart) - diff --git a/beginnerscorner/tests/time_stopwatch.py b/beginnerscorner/tests/time_stopwatch.py deleted file mode 100644 index 2cbf83a..0000000 --- a/beginnerscorner/tests/time_stopwatch.py +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env python -# -*- Mode: Python; coding: utf-8 - -import time - - -startTime = time.time() - -tmp = raw_input("press enter to stop") - -print time.time() - startTime diff --git a/beginnerscorner/tests/types.py b/beginnerscorner/tests/types.py deleted file mode 100644 index edb3207..0000000 --- a/beginnerscorner/tests/types.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python - -imText = 'foo' -imInt = 7 - -print imText + str(imInt) - diff --git a/beginnerscorner/tests/vars.py b/beginnerscorner/tests/vars.py deleted file mode 100644 index d7c583e..0000000 --- a/beginnerscorner/tests/vars.py +++ /dev/null @@ -1,4 +0,0 @@ -line = "Hallo" -for i in line: - print i -print line[2] diff --git a/beginnerscorner/tests/webserver/header.html b/beginnerscorner/tests/webserver/header.html deleted file mode 100644 index d6eb039..0000000 --- a/beginnerscorner/tests/webserver/header.html +++ /dev/null @@ -1,6 +0,0 @@ -HTTP/1.1 200 OK -Server: PyServ/0.0.1 (Unix) Python/2.x -Content-Language: de -Connection: close -Content-Type: text/html - diff --git a/beginnerscorner/tests/webserver/server.py b/beginnerscorner/tests/webserver/server.py deleted file mode 100644 index e29dc89..0000000 --- a/beginnerscorner/tests/webserver/server.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/python - -import socket -import select -import sys -import urllib - -port = 8080 - -#172.22.26.158 GET /favicon.ico HTTP/1.1 -#Host: 172.22.26.127 -#User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1 -#Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 -#Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 -#Accept-Encoding: gzip, deflate -#Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 -#Connection: keep-alive - - -server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -server.bind(("", port)) -server.listen(1) -clients = [] -try: - while True: - lesen, schreiben, oob = select.select([server] + clients, [], []) - - for sock in lesen: - if sock is server: - client, addr = server.accept() - clients.append(client) - print("+++ Client (0) verbunden", format(addr[0])) - else: - nachricht = sock.recv(1024) - ip = sock.getpeername()[0] - # first commands! - if nachricht == '\exit': - print("+++ " + format(ip) + " exits") - elif nachricht: - #print("[(0)] [1]".format(ip, nachricht.decode())) - print ip + " " + nachricht#.decode() - f = open('header.html', "r") - text = f.read() - f.close() - sock.send(text) - web = urllib.urlopen("http://blog.fefe.de") - # Read from the object, storing the page's contents in 's'. - webString = web.read() - web.close() - webString = webString.replace("Fefe","bison") - sock.send(webString) - else: - print("+++ Verbindung zu [0] beendet".format(ip)) - - sock.close() - clients.remove(sock) -#http://172.22.26.127/google -#GET /google HTTP/1.1 - - -finally: - for c in clients: - c.close() - server.close() - diff --git a/beginnerscorner/tests/xml/beispielObjDeclaration.xml b/beginnerscorner/tests/xml/beispielObjDeclaration.xml deleted file mode 100644 index 898e6bf..0000000 --- a/beginnerscorner/tests/xml/beispielObjDeclaration.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - 1 - 1 - - id - 1 - 0 - - - 2 - 2 - - name - 0 - 1 - - - 3 - 2 - - vorname - 0 - 1 - - diff --git a/beginnerscorner/tests/xml/test.py b/beginnerscorner/tests/xml/test.py deleted file mode 100644 index 3b6136a..0000000 --- a/beginnerscorner/tests/xml/test.py +++ /dev/null @@ -1,32 +0,0 @@ - -#!/usr/bin/python3 -import xml.dom.minidom as dom - -def knoten_auslesen(knoten): - return eval("%s('%s')" % (knoten.getAttribute("typ"), knoten.firstChild.data.strip())) - -def lade_dict(dateiname): - d=() - baum = dom.parse(dateiname) - idnr = [] - name = [] - - - for eintrag in baum.firstChild.childNodes: - if eintrag.nodeName == "eintrag": - schluessel = wert = None - for knoten in eintrag.childNodes: - if knoten.nodeName == "id": - idnr = knoten_auslesen(knoten) - print(idnr) - elif knoten.nodeName == "name": - name = knoten_auslesen(knoten) - print(name) - return (idnr , name) - - -data = None -data = lade_dict("beispielObjDeclaration.xml") -print("#################################") -for d in data: - print(d) diff --git a/beginnerscorner/tests/xml/testAuto.xml b/beginnerscorner/tests/xml/testAuto.xml deleted file mode 100644 index ea8a762..0000000 --- a/beginnerscorner/tests/xml/testAuto.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - Vorname - - - - - - 1 - - - diff --git a/beginnerscorner/tests/xml/testXMLcreator.py b/beginnerscorner/tests/xml/testXMLcreator.py deleted file mode 100644 index 1f65de4..0000000 --- a/beginnerscorner/tests/xml/testXMLcreator.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python3 -# Beispiel zum schreiben eines XML-Baums - -import xml.dom.minidom as dom - -def erstelle_eintrag(idnr, name): - # Definition der Baumelemente - tag_eintrag = dom.Element("eintrag") - tag_idnr = dom.Element("id") - tag_name = dom.Element("name") - - # Typpruefung der datenelemente und typinfo schreiben in den Baum - tag_idnr.setAttribute("typ", type(idnr).__name__) - tag_name.setAttribute("typ", type(name).__name__) - - - text = dom.Text() - text.data = str(idnr) - tag_idnr.appendChild(text) - - text = dom.Text() - text.data = str(name) - tag_name.appendChild(text) - - # Eintrag wird in Baum gefuegt - tag_eintrag.appendChild(tag_idnr) - tag_eintrag.appendChild(tag_name) - return tag_eintrag - -def schreibe_dict(d, dateiname): - # Uebernimmt das Dictionary und Schreibt die Elemente in den Baum - baum = dom.Document() - tag_dict = dom.Element("dictionary") - - # fuehgt ein weiteres element in den Baum je schleifendurchlauf - for idnr, name in d.items(): - tag_eintrag = erstelle_eintrag(idnr, name) - tag_dict.appendChild(tag_eintrag) - - # fuegt den Hauptzweig mit allen Elementen in den XML Baum - baum.appendChild(tag_dict) - - # schreibt die XMLdaten in die datei - with open(dateiname, "w") as f: - baum.writexml(f, "", "\t", "\n") - -# Aufruf der Funktionen -# dictionary leermachen -dictdate = {} -# Werte an dictionary uebergeben -dictdata = { "idnr" : 1 , "name" : "Vorname" } -# XML Funktion schreiben mit dem im dictdata Dictionary enthaltenen Daten -schreibe_dict(dictdata, "testAuto.xml") - -#print(erstelle_eintrag(1,"Vorname")) diff --git a/beginnerscorner/tests/zlibCompression.py b/beginnerscorner/tests/zlibCompression.py deleted file mode 100644 index 8e9736e..0000000 --- a/beginnerscorner/tests/zlibCompression.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python -import sys -import zlib - -def ByteToHex( byteStr ): - #Convert a byte string to it's hex string representation e.g. for output. - ret = ''.join( [ "%02X" % ord( x ) for x in byteStr ] ).strip() - return ret.lower() - -if len(sys.argv) == 0: - print '1st Parameter: string to compress' - print '2nd Parameter (optional) Compression level 0-9' - -else: - - if len(sys.argv) > 1: - cstring = sys.argv[1] - - lvl = 9 # fastes level, 9 slowest, best compression - if len(sys.argv) > 2: - lvl = int(sys.argv[2]) - - compressed = zlib.compress(cstring, lvl) - hexCompressed = ByteToHex(compressed) - print 'UnCompressed: ' + str(len(cstring)) - print 'Compressed: ' + str(len(compressed)) - print 'Compressed Hex: ' + str(len(hexCompressed)) - diff --git a/fonts/copse-regular-webfont.eot b/fonts/copse-regular-webfont.eot new file mode 100644 index 0000000..af1f5e6 Binary files /dev/null and b/fonts/copse-regular-webfont.eot differ diff --git a/fonts/copse-regular-webfont.svg b/fonts/copse-regular-webfont.svg new file mode 100644 index 0000000..1e920b5 --- /dev/null +++ b/fonts/copse-regular-webfont.svg @@ -0,0 +1,247 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2010 Daniel Rhatigansparkyultrasparkyorg with Reserved Font Name Copse +Designer : Daniel Rhatigan +Foundry : Daniel Rhatigan + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/copse-regular-webfont.ttf b/fonts/copse-regular-webfont.ttf new file mode 100644 index 0000000..434b208 Binary files /dev/null and b/fonts/copse-regular-webfont.ttf differ diff --git a/fonts/copse-regular-webfont.woff b/fonts/copse-regular-webfont.woff new file mode 100644 index 0000000..a9a0450 Binary files /dev/null and b/fonts/copse-regular-webfont.woff differ diff --git a/fonts/quattrocentosans-bold-webfont.eot b/fonts/quattrocentosans-bold-webfont.eot new file mode 100644 index 0000000..c041ed9 Binary files /dev/null and b/fonts/quattrocentosans-bold-webfont.eot differ diff --git a/fonts/quattrocentosans-bold-webfont.svg b/fonts/quattrocentosans-bold-webfont.svg new file mode 100644 index 0000000..fb162e9 --- /dev/null +++ b/fonts/quattrocentosans-bold-webfont.svg @@ -0,0 +1,247 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2011 Pablo Impallari wwwimpallaricomimpallarigmailcomCopyright c 2011 Igino Marini wwwikerncommailiginomarinicomCopyright c 2011 Brenda Gallo gbrenda1987gmailcomwith Reserved Font Name Quattrocento Sans +Designer : Pablo Impallari +Foundry : Pablo Impallari Igino Marini Brenda Gallo +Foundry URL : wwwimpallaricom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/quattrocentosans-bold-webfont.ttf b/fonts/quattrocentosans-bold-webfont.ttf new file mode 100644 index 0000000..7389c87 Binary files /dev/null and b/fonts/quattrocentosans-bold-webfont.ttf differ diff --git a/fonts/quattrocentosans-bold-webfont.woff b/fonts/quattrocentosans-bold-webfont.woff new file mode 100644 index 0000000..fc14168 Binary files /dev/null and b/fonts/quattrocentosans-bold-webfont.woff differ diff --git a/fonts/quattrocentosans-bolditalic-webfont.eot b/fonts/quattrocentosans-bolditalic-webfont.eot new file mode 100644 index 0000000..7c1aa7a Binary files /dev/null and b/fonts/quattrocentosans-bolditalic-webfont.eot differ diff --git a/fonts/quattrocentosans-bolditalic-webfont.svg b/fonts/quattrocentosans-bolditalic-webfont.svg new file mode 100644 index 0000000..9070a8b --- /dev/null +++ b/fonts/quattrocentosans-bolditalic-webfont.svg @@ -0,0 +1,248 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2011 Pablo Impallari wwwimpallaricomimpallarigmailcomCopyright c 2011 Igino Marini wwwikerncommailiginomarinicomCopyright c 2011 Brenda Gallo gbrenda1987gmailcomwith Reserved Font Name Quattrocento Sans +Designer : Pablo Impallari +Foundry : Pablo Impallari Igino Marini Brenda Gallo +Foundry URL : wwwimpallaricom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/quattrocentosans-bolditalic-webfont.ttf b/fonts/quattrocentosans-bolditalic-webfont.ttf new file mode 100644 index 0000000..9766a17 Binary files /dev/null and b/fonts/quattrocentosans-bolditalic-webfont.ttf differ diff --git a/fonts/quattrocentosans-bolditalic-webfont.woff b/fonts/quattrocentosans-bolditalic-webfont.woff new file mode 100644 index 0000000..c436da0 Binary files /dev/null and b/fonts/quattrocentosans-bolditalic-webfont.woff differ diff --git a/fonts/quattrocentosans-italic-webfont.eot b/fonts/quattrocentosans-italic-webfont.eot new file mode 100644 index 0000000..379b383 Binary files /dev/null and b/fonts/quattrocentosans-italic-webfont.eot differ diff --git a/fonts/quattrocentosans-italic-webfont.svg b/fonts/quattrocentosans-italic-webfont.svg new file mode 100644 index 0000000..b613779 --- /dev/null +++ b/fonts/quattrocentosans-italic-webfont.svg @@ -0,0 +1,247 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2011 Pablo Impallari wwwimpallaricomimpallarigmailcomCopyright c 2011 Igino Marini wwwikerncommailiginomarinicomCopyright c 2011 Brenda Gallo gbrenda1987gmailcomwith Reserved Font Name Quattrocento Sans +Designer : Pablo Impallari +Foundry : Pablo Impallari Igino Marini Brenda Gallo +Foundry URL : wwwimpallaricom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/quattrocentosans-italic-webfont.ttf b/fonts/quattrocentosans-italic-webfont.ttf new file mode 100644 index 0000000..c7ba47a Binary files /dev/null and b/fonts/quattrocentosans-italic-webfont.ttf differ diff --git a/fonts/quattrocentosans-italic-webfont.woff b/fonts/quattrocentosans-italic-webfont.woff new file mode 100644 index 0000000..3798881 Binary files /dev/null and b/fonts/quattrocentosans-italic-webfont.woff differ diff --git a/fonts/quattrocentosans-regular-webfont.eot b/fonts/quattrocentosans-regular-webfont.eot new file mode 100644 index 0000000..346db6f Binary files /dev/null and b/fonts/quattrocentosans-regular-webfont.eot differ diff --git a/fonts/quattrocentosans-regular-webfont.svg b/fonts/quattrocentosans-regular-webfont.svg new file mode 100644 index 0000000..3470924 --- /dev/null +++ b/fonts/quattrocentosans-regular-webfont.svg @@ -0,0 +1,247 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2011 Pablo Impallari wwwimpallaricomimpallarigmailcomCopyright c 2011 Igino Marini wwwikerncommailiginomarinicomCopyright c 2011 Brenda Gallo gbrenda1987gmailcomwith Reserved Font Name Quattrocento Sans +Designer : Pablo Impallari +Foundry : Pablo Impallari Igino Marini Brenda Gallo +Foundry URL : wwwimpallaricom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/quattrocentosans-regular-webfont.ttf b/fonts/quattrocentosans-regular-webfont.ttf new file mode 100644 index 0000000..e414670 Binary files /dev/null and b/fonts/quattrocentosans-regular-webfont.ttf differ diff --git a/fonts/quattrocentosans-regular-webfont.woff b/fonts/quattrocentosans-regular-webfont.woff new file mode 100644 index 0000000..09ed324 Binary files /dev/null and b/fonts/quattrocentosans-regular-webfont.woff differ diff --git a/images/background.png b/images/background.png new file mode 100644 index 0000000..b63b420 Binary files /dev/null and b/images/background.png differ diff --git a/images/body-background.png b/images/body-background.png new file mode 100644 index 0000000..d6a152f Binary files /dev/null and b/images/body-background.png differ diff --git a/images/bullet.png b/images/bullet.png new file mode 100644 index 0000000..2b7dc9a Binary files /dev/null and b/images/bullet.png differ diff --git a/images/hr.gif b/images/hr.gif new file mode 100644 index 0000000..a64b56c Binary files /dev/null and b/images/hr.gif differ diff --git a/images/octocat-logo.png b/images/octocat-logo.png new file mode 100644 index 0000000..28a3ad1 Binary files /dev/null and b/images/octocat-logo.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..797adde --- /dev/null +++ b/index.html @@ -0,0 +1,56 @@ + + + + + + Pythonfoo by pythonfoo + + + + + + + + + + +
+

Pythonfoo

+

The Main Info git to the pythonfoo Group in Duesseldorf Germany (chaosdorf.de)

+
+ +
+ +
+ +
+

Welcome to the Pythonfoo Github pages

+ +

This is the content Page of the Pythonfoo-Meeting in the Chaosdorf. Chaosdorf is an Erfa to the Chaos Computer Club and has his rooms at Hüttenstr. 25 in Düsseldorf Germany.

+ +

www.chaosdorf.de

+
+ +
+ + + + \ No newline at end of file diff --git a/javascripts/main.js b/javascripts/main.js new file mode 100644 index 0000000..c57e54c --- /dev/null +++ b/javascripts/main.js @@ -0,0 +1,53 @@ +var sectionHeight = function() { + var total = $(window).height(), + $section = $('section').css('height','auto'); + + if ($section.outerHeight(true) < total) { + var margin = $section.outerHeight(true) - $section.height(); + $section.height(total - margin - 20); + } else { + $section.css('height','auto'); + } +} + +$(window).resize(sectionHeight); + +$(document).ready(function(){ + $("section h1, section h2").each(function(){ + $("nav ul").append("
  • " + $(this).text() + "
  • "); + $(this).attr("id",$(this).text().toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g,'')); + $("nav ul li:first-child a").parent().addClass("active"); + }); + + $("nav ul li").on("click", "a", function(event) { + var position = $($(this).attr("href")).offset().top - 190; + $("html, body").animate({scrollTop: position}, 400); + $("nav ul li a").parent().removeClass("active"); + $(this).parent().addClass("active"); + event.preventDefault(); + }); + + sectionHeight(); + + $('img').load(sectionHeight); +}); + +fixScale = function(doc) { + + var addEvent = 'addEventListener', + type = 'gesturestart', + qsa = 'querySelectorAll', + scales = [1, 1], + meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : []; + + function fix() { + meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1]; + doc.removeEventListener(type, fix, true); + } + + if ((meta = meta[meta.length - 1]) && addEvent in doc) { + fix(); + scales = [.25, 1.6]; + doc[addEvent](type, fix, true); + } +}; \ No newline at end of file diff --git a/objektorientierung/pong/start.py b/objektorientierung/pong/start.py deleted file mode 100644 index d0d7d82..0000000 --- a/objektorientierung/pong/start.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/var/bin/python - -############# Pong SFML WindowManager ############################## - -# This is an Example created for the Pythonfoo Workshop at Chaosdorf -# Chaosdorf.de -# in 2012 by Oerb -# -# Include the PySFML extension - -from lib import game - -class main(object): - def __init__(self): - gamevar = game.pongGame() - -if __name__== "__main__": - start = main() diff --git a/params.json b/params.json new file mode 100644 index 0000000..6a26874 --- /dev/null +++ b/params.json @@ -0,0 +1 @@ +{"name":"Pythonfoo","tagline":"The Main Info git to the pythonfoo Group in Duesseldorf Germany (chaosdorf.de)","body":"### Welcome to the Pythonfoo Github pages\r\nThis is the content Page of the Pythonfoo-Meeting in the Chaosdorf. Chaosdorf is an Erfa to the Chaos Computer Club and has his rooms at Hüttenstr. 25 in Düsseldorf Germany. \r\n\r\nwww.chaosdorf.de","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file diff --git a/stylesheets/normalize.css b/stylesheets/normalize.css new file mode 100644 index 0000000..bc2ba93 --- /dev/null +++ b/stylesheets/normalize.css @@ -0,0 +1,459 @@ +/* normalize.css 2012-02-07T12:37 UTC - http://github.com/necolas/normalize.css */ +/* ============================================================================= + HTML5 display definitions + ========================================================================== */ +/* + * Corrects block display not defined in IE6/7/8/9 & FF3 + */ +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +nav, +section, +summary { + display: block; +} + +/* + * Corrects inline-block display not defined in IE6/7/8/9 & FF3 + */ +audio, +canvas, +video { + display: inline-block; + *display: inline; + *zoom: 1; +} + +/* + * Prevents modern browsers from displaying 'audio' without controls + */ +audio:not([controls]) { + display: none; +} + +/* + * Addresses styling for 'hidden' attribute not present in IE7/8/9, FF3, S4 + * Known issue: no IE6 support + */ +[hidden] { + display: none; +} + +/* ============================================================================= + Base + ========================================================================== */ +/* + * 1. Corrects text resizing oddly in IE6/7 when body font-size is set using em units + * http://clagnut.com/blog/348/#c790 + * 2. Prevents iOS text size adjust after orientation change, without disabling user zoom + * www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/ + */ +html { + font-size: 100%; + /* 1 */ + -webkit-text-size-adjust: 100%; + /* 2 */ + -ms-text-size-adjust: 100%; + /* 2 */ +} + +/* + * Addresses font-family inconsistency between 'textarea' and other form elements. + */ +html, +button, +input, +select, +textarea { + font-family: sans-serif; +} + +/* + * Addresses margins handled incorrectly in IE6/7 + */ +body { + margin: 0; +} + +/* ============================================================================= + Links + ========================================================================== */ +/* + * Addresses outline displayed oddly in Chrome + */ +a:focus { + outline: thin dotted; +} + +/* + * Improves readability when focused and also mouse hovered in all browsers + * people.opera.com/patrickl/experiments/keyboard/test + */ +a:hover, +a:active { + outline: 0; +} + +/* ============================================================================= + Typography + ========================================================================== */ +/* + * Addresses font sizes and margins set differently in IE6/7 + * Addresses font sizes within 'section' and 'article' in FF4+, Chrome, S5 + */ +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +h2 { + font-size: 1.5em; + margin: 0.83em 0; +} + +h3 { + font-size: 1.17em; + margin: 1em 0; +} + +h4 { + font-size: 1em; + margin: 1.33em 0; +} + +h5 { + font-size: 0.83em; + margin: 1.67em 0; +} + +h6 { + font-size: 0.75em; + margin: 2.33em 0; +} + +/* + * Addresses styling not present in IE7/8/9, S5, Chrome + */ +abbr[title] { + border-bottom: 1px dotted; +} + +/* + * Addresses style set to 'bolder' in FF3+, S4/5, Chrome +*/ +b, +strong { + font-weight: bold; +} + +blockquote { + margin: 1em 40px; +} + +/* + * Addresses styling not present in S5, Chrome + */ +dfn { + font-style: italic; +} + +/* + * Addresses styling not present in IE6/7/8/9 + */ +mark { + background: #ff0; + color: #000; +} + +/* + * Addresses margins set differently in IE6/7 + */ +p, +pre { + margin: 1em 0; +} + +/* + * Corrects font family set oddly in IE6, S4/5, Chrome + * en.wikipedia.org/wiki/User:Davidgothberg/Test59 + */ +pre, +code, +kbd, +samp { + font-family: monospace, serif; + _font-family: 'courier new', monospace; + font-size: 1em; +} + +/* + * 1. Addresses CSS quotes not supported in IE6/7 + * 2. Addresses quote property not supported in S4 + */ +/* 1 */ +q { + quotes: none; +} + +/* 2 */ +q:before, +q:after { + content: ''; + content: none; +} + +small { + font-size: 75%; +} + +/* + * Prevents sub and sup affecting line-height in all browsers + * gist.github.com/413930 + */ +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* ============================================================================= + Lists + ========================================================================== */ +/* + * Addresses margins set differently in IE6/7 + */ +dl, +menu, +ol, +ul { + margin: 1em 0; +} + +dd { + margin: 0 0 0 40px; +} + +/* + * Addresses paddings set differently in IE6/7 + */ +menu, +ol, +ul { + padding: 0 0 0 40px; +} + +/* + * Corrects list images handled incorrectly in IE7 + */ +nav ul, +nav ol { + list-style: none; + list-style-image: none; +} + +/* ============================================================================= + Embedded content + ========================================================================== */ +/* + * 1. Removes border when inside 'a' element in IE6/7/8/9, FF3 + * 2. Improves image quality when scaled in IE7 + * code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/ + */ +img { + border: 0; + /* 1 */ + -ms-interpolation-mode: bicubic; + /* 2 */ +} + +/* + * Corrects overflow displayed oddly in IE9 + */ +svg:not(:root) { + overflow: hidden; +} + +/* ============================================================================= + Figures + ========================================================================== */ +/* + * Addresses margin not present in IE6/7/8/9, S5, O11 + */ +figure { + margin: 0; +} + +/* ============================================================================= + Forms + ========================================================================== */ +/* + * Corrects margin displayed oddly in IE6/7 + */ +form { + margin: 0; +} + +/* + * Define consistent border, margin, and padding + */ +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/* + * 1. Corrects color not being inherited in IE6/7/8/9 + * 2. Corrects text not wrapping in FF3 + * 3. Corrects alignment displayed oddly in IE6/7 + */ +legend { + border: 0; + /* 1 */ + padding: 0; + white-space: normal; + /* 2 */ + *margin-left: -7px; + /* 3 */ +} + +/* + * 1. Corrects font size not being inherited in all browsers + * 2. Addresses margins set differently in IE6/7, FF3+, S5, Chrome + * 3. Improves appearance and consistency in all browsers + */ +button, +input, +select, +textarea { + font-size: 100%; + /* 1 */ + margin: 0; + /* 2 */ + vertical-align: baseline; + /* 3 */ + *vertical-align: middle; + /* 3 */ +} + +/* + * Addresses FF3/4 setting line-height on 'input' using !important in the UA stylesheet + */ +button, +input { + line-height: normal; + /* 1 */ +} + +/* + * 1. Improves usability and consistency of cursor style between image-type 'input' and others + * 2. Corrects inability to style clickable 'input' types in iOS + * 3. Removes inner spacing in IE7 without affecting normal text inputs + * Known issue: inner spacing remains in IE6 + */ +button, +input[type="button"], +input[type="reset"], +input[type="submit"] { + cursor: pointer; + /* 1 */ + -webkit-appearance: button; + /* 2 */ + *overflow: visible; + /* 3 */ +} + +/* + * Re-set default cursor for disabled elements + */ +button[disabled], +input[disabled] { + cursor: default; +} + +/* + * 1. Addresses box sizing set to content-box in IE8/9 + * 2. Removes excess padding in IE8/9 + * 3. Removes excess padding in IE7 + Known issue: excess padding remains in IE6 + */ +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; + /* 1 */ + padding: 0; + /* 2 */ + *height: 13px; + /* 3 */ + *width: 13px; + /* 3 */ +} + +/* + * 1. Addresses appearance set to searchfield in S5, Chrome + * 2. Addresses box-sizing set to border-box in S5, Chrome (include -moz to future-proof) + */ +input[type="search"] { + -webkit-appearance: textfield; + /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; + /* 2 */ + box-sizing: content-box; +} + +/* + * Removes inner padding and search cancel button in S5, Chrome on OS X + */ +input[type="search"]::-webkit-search-decoration, +input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; +} + +/* + * Removes inner padding and border in FF3+ + * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/ + */ +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/* + * 1. Removes default vertical scrollbar in IE6/7/8/9 + * 2. Improves readability and alignment in all browsers + */ +textarea { + overflow: auto; + /* 1 */ + vertical-align: top; + /* 2 */ +} + +/* ============================================================================= + Tables + ========================================================================== */ +/* + * Remove most spacing between table cells + */ +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css new file mode 100644 index 0000000..62fd970 --- /dev/null +++ b/stylesheets/pygment_trac.css @@ -0,0 +1,70 @@ +.highlight .hll { background-color: #404040 } +.highlight { color: #d0d0d0 } +.highlight .c { color: #999999; font-style: italic } /* Comment */ +.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.highlight .g { color: #d0d0d0 } /* Generic */ +.highlight .k { color: #6ab825; font-weight: normal } /* Keyword */ +.highlight .l { color: #d0d0d0 } /* Literal */ +.highlight .n { color: #d0d0d0 } /* Name */ +.highlight .o { color: #d0d0d0 } /* Operator */ +.highlight .x { color: #d0d0d0 } /* Other */ +.highlight .p { color: #d0d0d0 } /* Punctuation */ +.highlight .cm { color: #999999; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #cd2828; font-weight: normal } /* Comment.Preproc */ +.highlight .c1 { color: #999999; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #e50808; font-weight: normal; background-color: #520000 } /* Comment.Special */ +.highlight .gd { color: #d22323 } /* Generic.Deleted */ +.highlight .ge { color: #d0d0d0; font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #d22323 } /* Generic.Error */ +.highlight .gh { color: #ffffff; font-weight: normal } /* Generic.Heading */ +.highlight .gi { color: #589819 } /* Generic.Inserted */ +.highlight .go { color: #cccccc } /* Generic.Output */ +.highlight .gp { color: #aaaaaa } /* Generic.Prompt */ +.highlight .gs { color: #d0d0d0; font-weight: normal } /* Generic.Strong */ +.highlight .gu { color: #ffffff; text-decoration: underline } /* Generic.Subheading */ +.highlight .gt { color: #d22323 } /* Generic.Traceback */ +.highlight .kc { color: #6ab825; font-weight: normal } /* Keyword.Constant */ +.highlight .kd { color: #6ab825; font-weight: normal } /* Keyword.Declaration */ +.highlight .kn { color: #6ab825; font-weight: normal } /* Keyword.Namespace */ +.highlight .kp { color: #6ab825 } /* Keyword.Pseudo */ +.highlight .kr { color: #6ab825; font-weight: normal } /* Keyword.Reserved */ +.highlight .kt { color: #6ab825; font-weight: normal } /* Keyword.Type */ +.highlight .ld { color: #d0d0d0 } /* Literal.Date */ +.highlight .m { color: #3677a9 } /* Literal.Number */ +.highlight .s { color: #ff8 } /* Literal.String */ +.highlight .na { color: #bbbbbb } /* Name.Attribute */ +.highlight .nb { color: #24909d } /* Name.Builtin */ +.highlight .nc { color: #447fcf; text-decoration: underline } /* Name.Class */ +.highlight .no { color: #40ffff } /* Name.Constant */ +.highlight .nd { color: #ffa500 } /* Name.Decorator */ +.highlight .ni { color: #d0d0d0 } /* Name.Entity */ +.highlight .ne { color: #bbbbbb } /* Name.Exception */ +.highlight .nf { color: #447fcf } /* Name.Function */ +.highlight .nl { color: #d0d0d0 } /* Name.Label */ +.highlight .nn { color: #447fcf; text-decoration: underline } /* Name.Namespace */ +.highlight .nx { color: #d0d0d0 } /* Name.Other */ +.highlight .py { color: #d0d0d0 } /* Name.Property */ +.highlight .nt { color: #6ab825;} /* Name.Tag */ +.highlight .nv { color: #40ffff } /* Name.Variable */ +.highlight .ow { color: #6ab825; font-weight: normal } /* Operator.Word */ +.highlight .w { color: #666666 } /* Text.Whitespace */ +.highlight .mf { color: #3677a9 } /* Literal.Number.Float */ +.highlight .mh { color: #3677a9 } /* Literal.Number.Hex */ +.highlight .mi { color: #3677a9 } /* Literal.Number.Integer */ +.highlight .mo { color: #3677a9 } /* Literal.Number.Oct */ +.highlight .sb { color: #ff8 } /* Literal.String.Backtick */ +.highlight .sc { color: #ff8 } /* Literal.String.Char */ +.highlight .sd { color: #ff8 } /* Literal.String.Doc */ +.highlight .s2 { color: #ff8 } /* Literal.String.Double */ +.highlight .se { color: #ff8 } /* Literal.String.Escape */ +.highlight .sh { color: #ff8 } /* Literal.String.Heredoc */ +.highlight .si { color: #ff8 } /* Literal.String.Interpol */ +.highlight .sx { color: #ffa500 } /* Literal.String.Other */ +.highlight .sr { color: #ff8 } /* Literal.String.Regex */ +.highlight .s1 { color: #ff8 } /* Literal.String.Single */ +.highlight .ss { color: #ff8 } /* Literal.String.Symbol */ +.highlight .bp { color: #24909d } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #40ffff } /* Name.Variable.Class */ +.highlight .vg { color: #40ffff } /* Name.Variable.Global */ +.highlight .vi { color: #40ffff } /* Name.Variable.Instance */ +.highlight .il { color: #3677a9 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/stylesheets/styles.css b/stylesheets/styles.css new file mode 100644 index 0000000..980ee2b --- /dev/null +++ b/stylesheets/styles.css @@ -0,0 +1,1010 @@ +/* +Leap Day for GitHub Pages +by Matt Graham +*/ +@font-face { + font-family: 'Quattrocento Sans'; + src: url("../fonts/quattrocentosans-bold-webfont.eot"); + src: url("../fonts/quattrocentosans-bold-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/quattrocentosans-bold-webfont.woff") format("woff"), url("../fonts/quattrocentosans-bold-webfont.ttf") format("truetype"), url("../fonts/quattrocentosans-bold-webfont.svg#QuattrocentoSansBold") format("svg"); + font-weight: bold; + font-style: normal; +} + +@font-face { + font-family: 'Quattrocento Sans'; + src: url("../fonts/quattrocentosans-bolditalic-webfont.eot"); + src: url("../fonts/quattrocentosans-bolditalic-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/quattrocentosans-bolditalic-webfont.woff") format("woff"), url("../fonts/quattrocentosans-bolditalic-webfont.ttf") format("truetype"), url("../fonts/quattrocentosans-bolditalic-webfont.svg#QuattrocentoSansBoldItalic") format("svg"); + font-weight: bold; + font-style: italic; +} + +@font-face { + font-family: 'Quattrocento Sans'; + src: url("../fonts/quattrocentosans-italic-webfont.eot"); + src: url("../fonts/quattrocentosans-italic-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/quattrocentosans-italic-webfont.woff") format("woff"), url("../fonts/quattrocentosans-italic-webfont.ttf") format("truetype"), url("../fonts/quattrocentosans-italic-webfont.svg#QuattrocentoSansItalic") format("svg"); + font-weight: normal; + font-style: italic; +} + +@font-face { + font-family: 'Quattrocento Sans'; + src: url("../fonts/quattrocentosans-regular-webfont.eot"); + src: url("../fonts/quattrocentosans-regular-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/quattrocentosans-regular-webfont.woff") format("woff"), url("../fonts/quattrocentosans-regular-webfont.ttf") format("truetype"), url("../fonts/quattrocentosans-regular-webfont.svg#QuattrocentoSansRegular") format("svg"); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: 'Copse'; + src: url("../fonts/copse-regular-webfont.eot"); + src: url("../fonts/copse-regular-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/copse-regular-webfont.woff") format("woff"), url("../fonts/copse-regular-webfont.ttf") format("truetype"), url("../fonts/copse-regular-webfont.svg#CopseRegular") format("svg"); + font-weight: normal; + font-style: normal; +} + +/* normalize.css 2012-02-07T12:37 UTC - http://github.com/necolas/normalize.css */ +/* ============================================================================= + HTML5 display definitions + ========================================================================== */ +/* + * Corrects block display not defined in IE6/7/8/9 & FF3 + */ +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +nav, +section, +summary { + display: block; +} + +/* + * Corrects inline-block display not defined in IE6/7/8/9 & FF3 + */ +audio, +canvas, +video { + display: inline-block; + *display: inline; + *zoom: 1; +} + +/* + * Prevents modern browsers from displaying 'audio' without controls + */ +audio:not([controls]) { + display: none; +} + +/* + * Addresses styling for 'hidden' attribute not present in IE7/8/9, FF3, S4 + * Known issue: no IE6 support + */ +[hidden] { + display: none; +} + +/* ============================================================================= + Base + ========================================================================== */ +/* + * 1. Corrects text resizing oddly in IE6/7 when body font-size is set using em units + * http://clagnut.com/blog/348/#c790 + * 2. Prevents iOS text size adjust after orientation change, without disabling user zoom + * www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/ + */ +html { + font-size: 100%; + /* 1 */ + -webkit-text-size-adjust: 100%; + /* 2 */ + -ms-text-size-adjust: 100%; + /* 2 */ +} + +/* + * Addresses font-family inconsistency between 'textarea' and other form elements. + */ +html, +button, +input, +select, +textarea { + font-family: sans-serif; +} + +/* + * Addresses margins handled incorrectly in IE6/7 + */ +body { + margin: 0; +} + +/* ============================================================================= + Links + ========================================================================== */ +/* + * Addresses outline displayed oddly in Chrome + */ +a:focus { + outline: thin dotted; +} + +/* + * Improves readability when focused and also mouse hovered in all browsers + * people.opera.com/patrickl/experiments/keyboard/test + */ +a:hover, +a:active { + outline: 0; +} + +/* ============================================================================= + Typography + ========================================================================== */ +/* + * Addresses font sizes and margins set differently in IE6/7 + * Addresses font sizes within 'section' and 'article' in FF4+, Chrome, S5 + */ +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +h2 { + font-size: 1.5em; + margin: 0.83em 0; +} + +h3 { + font-size: 1.17em; + margin: 1em 0; +} + +h4 { + font-size: 1em; + margin: 1.33em 0; +} + +h5 { + font-size: 0.83em; + margin: 1.67em 0; +} + +h6 { + font-size: 0.75em; + margin: 2.33em 0; +} + +/* + * Addresses styling not present in IE7/8/9, S5, Chrome + */ +abbr[title] { + border-bottom: 1px dotted; +} + +/* + * Addresses style set to 'bolder' in FF3+, S4/5, Chrome +*/ +b, +strong { + font-weight: bold; +} + +blockquote { + margin: 1em 40px; +} + +/* + * Addresses styling not present in S5, Chrome + */ +dfn { + font-style: italic; +} + +/* + * Addresses styling not present in IE6/7/8/9 + */ +mark { + background: #ff0; + color: #000; +} + +/* + * Addresses margins set differently in IE6/7 + */ +p, +pre { + margin: 1em 0; +} + +/* + * Corrects font family set oddly in IE6, S4/5, Chrome + * en.wikipedia.org/wiki/User:Davidgothberg/Test59 + */ +pre, +code, +kbd, +samp { + font-family: monospace, serif; + _font-family: 'courier new', monospace; + font-size: 1em; +} + +/* + * 1. Addresses CSS quotes not supported in IE6/7 + * 2. Addresses quote property not supported in S4 + */ +/* 1 */ +q { + quotes: none; +} + +/* 2 */ +q:before, +q:after { + content: ''; + content: none; +} + +small { + font-size: 75%; +} + +/* + * Prevents sub and sup affecting line-height in all browsers + * gist.github.com/413930 + */ +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* ============================================================================= + Lists + ========================================================================== */ +/* + * Addresses margins set differently in IE6/7 + */ +dl, +menu, +ol, +ul { + margin: 1em 0; +} + +dd { + margin: 0 0 0 40px; +} + +/* + * Addresses paddings set differently in IE6/7 + */ +menu, +ol, +ul { + padding: 0 0 0 40px; +} + +/* + * Corrects list images handled incorrectly in IE7 + */ +nav ul, +nav ol { + list-style: none; + list-style-image: none; +} + +/* ============================================================================= + Embedded content + ========================================================================== */ +/* + * 1. Removes border when inside 'a' element in IE6/7/8/9, FF3 + * 2. Improves image quality when scaled in IE7 + * code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/ + */ +img { + border: 0; + /* 1 */ + -ms-interpolation-mode: bicubic; + /* 2 */ +} + +/* + * Corrects overflow displayed oddly in IE9 + */ +svg:not(:root) { + overflow: hidden; +} + +/* ============================================================================= + Figures + ========================================================================== */ +/* + * Addresses margin not present in IE6/7/8/9, S5, O11 + */ +figure { + margin: 0; +} + +/* ============================================================================= + Forms + ========================================================================== */ +/* + * Corrects margin displayed oddly in IE6/7 + */ +form { + margin: 0; +} + +/* + * Define consistent border, margin, and padding + */ +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/* + * 1. Corrects color not being inherited in IE6/7/8/9 + * 2. Corrects text not wrapping in FF3 + * 3. Corrects alignment displayed oddly in IE6/7 + */ +legend { + border: 0; + /* 1 */ + padding: 0; + white-space: normal; + /* 2 */ + *margin-left: -7px; + /* 3 */ +} + +/* + * 1. Corrects font size not being inherited in all browsers + * 2. Addresses margins set differently in IE6/7, FF3+, S5, Chrome + * 3. Improves appearance and consistency in all browsers + */ +button, +input, +select, +textarea { + font-size: 100%; + /* 1 */ + margin: 0; + /* 2 */ + vertical-align: baseline; + /* 3 */ + *vertical-align: middle; + /* 3 */ +} + +/* + * Addresses FF3/4 setting line-height on 'input' using !important in the UA stylesheet + */ +button, +input { + line-height: normal; + /* 1 */ +} + +/* + * 1. Improves usability and consistency of cursor style between image-type 'input' and others + * 2. Corrects inability to style clickable 'input' types in iOS + * 3. Removes inner spacing in IE7 without affecting normal text inputs + * Known issue: inner spacing remains in IE6 + */ +button, +input[type="button"], +input[type="reset"], +input[type="submit"] { + cursor: pointer; + /* 1 */ + -webkit-appearance: button; + /* 2 */ + *overflow: visible; + /* 3 */ +} + +/* + * Re-set default cursor for disabled elements + */ +button[disabled], +input[disabled] { + cursor: default; +} + +/* + * 1. Addresses box sizing set to content-box in IE8/9 + * 2. Removes excess padding in IE8/9 + * 3. Removes excess padding in IE7 + Known issue: excess padding remains in IE6 + */ +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; + /* 1 */ + padding: 0; + /* 2 */ + *height: 13px; + /* 3 */ + *width: 13px; + /* 3 */ +} + +/* + * 1. Addresses appearance set to searchfield in S5, Chrome + * 2. Addresses box-sizing set to border-box in S5, Chrome (include -moz to future-proof) + */ +input[type="search"] { + -webkit-appearance: textfield; + /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; + /* 2 */ + box-sizing: content-box; +} + +/* + * Removes inner padding and search cancel button in S5, Chrome on OS X + */ +input[type="search"]::-webkit-search-decoration, +input[type="search"]::-webkit-search-cancel-button { + -webkit-appearance: none; +} + +/* + * Removes inner padding and border in FF3+ + * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/ + */ +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/* + * 1. Removes default vertical scrollbar in IE6/7/8/9 + * 2. Improves readability and alignment in all browsers + */ +textarea { + overflow: auto; + /* 1 */ + vertical-align: top; + /* 2 */ +} + +/* ============================================================================= + Tables + ========================================================================== */ +/* + * Remove most spacing between table cells + */ +table { + border-collapse: collapse; + border-spacing: 0; +} + +body { + font: 14px/22px "Quattrocento Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #666; + font-weight: 300; + margin: 0px; + padding: 0px 0 20px 0px; + background: url(../images/body-background.png) #eae6d1; +} + +h1, h2, h3, h4, h5, h6 { + color: #333; + margin: 0 0 10px; +} + +p, ul, ol, table, pre, dl { + margin: 0 0 20px; +} + +h1, h2, h3 { + line-height: 1.1; +} + +h1 { + font-size: 28px; +} + +h2 { + font-size: 24px; + color: #393939; +} + +h3, h4, h5, h6 { + color: #666666; +} + +h3 { + font-size: 18px; + line-height: 24px; +} + +a { + color: #3399cc; + font-weight: 400; + text-decoration: none; +} + +a small { + font-size: 11px; + color: #666; + margin-top: -0.6em; + display: block; +} + +ul { + list-style-image: url("../images/bullet.png"); +} + +strong { + font-weight: bold; + color: #333; +} + +.wrapper { + width: 650px; + margin: 0 auto; + position: relative; +} + +section img { + max-width: 100%; +} + +blockquote { + border-left: 1px solid #ffcc00; + margin: 0; + padding: 0 0 0 20px; + font-style: italic; +} + +code { + font-family: "Lucida Sans", Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; + font-size: 13px; + color: #efefef; + text-shadow: 0px 1px 0px #000; + margin: 0 4px; + padding: 2px 6px; + background: #333; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + -o-border-radius: 2px; + -ms-border-radius: 2px; + -khtml-border-radius: 2px; + border-radius: 2px; +} + +pre { + padding: 8px 15px; + background: #333333; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + -o-border-radius: 3px; + -ms-border-radius: 3px; + -khtml-border-radius: 3px; + border-radius: 3px; + border: 1px solid #c7c7c7; + overflow: auto; + overflow-y: hidden; +} +pre code { + margin: 0px; + padding: 0px; +} + +table { + width: 100%; + border-collapse: collapse; +} + +th { + text-align: left; + padding: 5px 10px; + border-bottom: 1px solid #e5e5e5; + color: #444; +} + +td { + text-align: left; + padding: 5px 10px; + border-bottom: 1px solid #e5e5e5; + border-right: 1px solid #ffcc00; +} +td:first-child { + border-left: 1px solid #ffcc00; +} + +hr { + border: 0; + outline: none; + height: 11px; + background: transparent url("../images/hr.gif") center center repeat-x; + margin: 0 0 20px; +} + +dt { + color: #444; + font-weight: 700; +} + +header { + padding: 25px 20px 40px 20px; + margin: 0; + position: fixed; + top: 0; + left: 0; + right: 0; + width: 100%; + text-align: center; + background: url(../images/background.png) #4276b6; + -moz-box-shadow: 1px 0px 2px rgba(0, 0, 0, 0.75); + -webkit-box-shadow: 1px 0px 2px rgba(0, 0, 0, 0.75); + -o-box-shadow: 1px 0px 2px rgba(0, 0, 0, 0.75); + box-shadow: 1px 0px 2px rgba(0, 0, 0, 0.75); + z-index: 99; + -webkit-font-smoothing: antialiased; + min-height: 76px; +} +header h1 { + font: 40px/48px "Copse", "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #f3f3f3; + text-shadow: 0px 2px 0px #235796; + margin: 0px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; +} +header p { + color: #d8d8d8; + text-shadow: rgba(0, 0, 0, 0.2) 0 1px 0; + font-size: 18px; + margin: 0px; +} + +#banner { + z-index: 100; + left: 0; + right: 50%; + height: 50px; + margin-right: -382px; + position: fixed; + top: 115px; + background: #ffcc00; + border: 1px solid #f0b500; + -moz-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25); + -webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25); + -o-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25); + box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25); + -moz-border-radius: 0px 2px 2px 0px; + -webkit-border-radius: 0px 2px 2px 0px; + -o-border-radius: 0px 2px 2px 0px; + -ms-border-radius: 0px 2px 2px 0px; + -khtml-border-radius: 0px 2px 2px 0px; + border-radius: 0px 2px 2px 0px; + padding-right: 10px; +} +#banner .button { + border: 1px solid #dba500; + background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffe788), color-stop(100%, #ffce38)); + background: -webkit-linear-gradient(#ffe788, #ffce38); + background: -moz-linear-gradient(#ffe788, #ffce38); + background: -o-linear-gradient(#ffe788, #ffce38); + background: -ms-linear-gradient(#ffe788, #ffce38); + background: linear-gradient(#ffe788, #ffce38); + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + -o-border-radius: 2px; + -ms-border-radius: 2px; + -khtml-border-radius: 2px; + border-radius: 2px; + -moz-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.4), 0px 1px 1px rgba(0, 0, 0, 0.1); + -webkit-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.4), 0px 1px 1px rgba(0, 0, 0, 0.1); + -o-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.4), 0px 1px 1px rgba(0, 0, 0, 0.1); + box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.4), 0px 1px 1px rgba(0, 0, 0, 0.1); + background-color: #FFE788; + margin-left: 5px; + padding: 10px 12px; + margin-top: 6px; + line-height: 14px; + font-size: 14px; + color: #333; + font-weight: bold; + display: inline-block; + text-align: center; +} +#banner .button:hover { + background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffe788), color-stop(100%, #ffe788)); + background: -webkit-linear-gradient(#ffe788, #ffe788); + background: -moz-linear-gradient(#ffe788, #ffe788); + background: -o-linear-gradient(#ffe788, #ffe788); + background: -ms-linear-gradient(#ffe788, #ffe788); + background: linear-gradient(#ffe788, #ffe788); + background-color: #ffeca0; +} +#banner .fork { + position: fixed; + left: 50%; + margin-left: -325px; + padding: 10px 12px; + margin-top: 6px; + line-height: 14px; + font-size: 14px; + background-color: #FFE788; +} +#banner .downloads { + float: right; + margin: 0 45px 0 0; +} +#banner .downloads span { + float: left; + line-height: 52px; + font-size: 90%; + color: #9d7f0d; + text-transform: uppercase; + text-shadow: rgba(255, 255, 255, 0.2) 0 1px 0; +} +#banner ul { + list-style: none; + height: 40px; + padding: 0; + float: left; + margin-left: 10px; +} +#banner ul li { + display: inline; +} +#banner ul li a.button { + background-color: #FFE788; +} +#banner #logo { + position: absolute; + height: 36px; + width: 36px; + right: 7px; + top: 7px; + display: block; + background: url(../images/octocat-logo.png); +} + +section { + width: 590px; + padding: 30px 30px 50px 30px; + margin: 20px 0; + margin-top: 190px; + position: relative; + background: #fbfbfb; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + -o-border-radius: 3px; + -ms-border-radius: 3px; + -khtml-border-radius: 3px; + border-radius: 3px; + border: 1px solid #cbcbcb; + -moz-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.09), inset 0px 0px 2px 2px rgba(255, 255, 255, 0.5), inset 0 0 5px 5px rgba(255, 255, 255, 0.4); + -webkit-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.09), inset 0px 0px 2px 2px rgba(255, 255, 255, 0.5), inset 0 0 5px 5px rgba(255, 255, 255, 0.4); + -o-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.09), inset 0px 0px 2px 2px rgba(255, 255, 255, 0.5), inset 0 0 5px 5px rgba(255, 255, 255, 0.4); + box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.09), inset 0px 0px 2px 2px rgba(255, 255, 255, 0.5), inset 0 0 5px 5px rgba(255, 255, 255, 0.4); +} + +small { + font-size: 12px; +} + +nav { + width: 230px; + position: fixed; + top: 220px; + left: 50%; + margin-left: -580px; + text-align: right; +} +nav ul { + list-style: none; + list-style-image: none; + font-size: 14px; + line-height: 24px; +} +nav ul li { + padding: 5px 0px; + line-height: 16px; +} +nav ul li.tag-h1 { + font-size: 1.2em; +} +nav ul li.tag-h1 a { + font-weight: bold; + color: #333; +} +nav ul li.tag-h2 + .tag-h1 { + margin-top: 10px; +} +nav ul a { + color: #666; +} +nav ul a:hover { + color: #999; +} + +footer { + width: 180px; + position: fixed; + left: 50%; + margin-left: -530px; + bottom: 20px; + text-align: right; + line-height: 16px; +} + +@media print, screen and (max-width: 1060px) { + div.wrapper { + width: auto; + margin: 0; + } + + nav { + display: none; + } + + header, section, footer { + float: none; + } + header h1, section h1, footer h1 { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; + } + + #banner { + width: 100%; + } + #banner .downloads { + margin-right: 60px; + } + #banner #logo { + margin-right: 15px; + } + + section { + border: 1px solid #e5e5e5; + border-width: 1px 0; + padding: 20px auto; + margin: 190px auto 20px; + max-width: 600px; + } + + footer { + text-align: center; + margin: 20px auto; + position: relative; + left: auto; + bottom: auto; + width: auto; + } +} +@media print, screen and (max-width: 720px) { + body { + word-wrap: break-word; + } + + header { + padding: 20px 20px; + margin: 0; + } + header h1 { + font-size: 32px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; + } + header p { + display: none; + } + + #banner { + top: 80px; + } + #banner .fork { + float: left; + display: inline-block; + margin-left: 0px; + position: fixed; + left: 20px; + } + + section { + margin-top: 130px; + margin-bottom: 0px; + width: auto; + } + + header ul, header p.view { + position: static; + } +} +@media print, screen and (max-width: 480px) { + header { + position: relative; + padding: 5px 0px; + min-height: 0px; + } + header h1 { + font-size: 24px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; + } + + section { + margin-top: 5px; + } + + #banner { + display: none; + } + + header ul { + display: none; + } +} +@media print { + body { + padding: 0.4in; + font-size: 12pt; + color: #444; + } +} +@media print, screen and (max-height: 680px) { + footer { + text-align: center; + margin: 20px auto; + position: relative; + left: auto; + bottom: auto; + width: auto; + } +} +@media print, screen and (max-height: 480px) { + nav { + display: none; + } + + footer { + text-align: center; + margin: 20px auto; + position: relative; + left: auto; + bottom: auto; + width: auto; + } +}