Moved from php to python

This commit is contained in:
Thomas FORGIONE
2015-04-12 21:13:41 +02:00
parent 35a8522088
commit 925f6bab74
30 changed files with 4886 additions and 124 deletions

1
webtools/.htaccess Normal file
View File

@@ -0,0 +1 @@
Deny from all

46
webtools/Web.py Executable file
View File

@@ -0,0 +1,46 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os
# ROOT_DIR = '/'.join(__file__.split('/')[:-2]) + '/'
ROOT_DIR = '/home/thomas/stage/javascript/web/'
class Element:
def __init__(self, filename = None):
self.children = []
self.open_string = ''
self.close_string = ''
if filename:
self.load(filename)
def load(self, filename):
with open(filename, 'r') as f:
first_part = True
for line in f:
if line[0] == '#':
first_part = False
continue
if first_part:
self.open_string += line
else:
self.close_string += line
self.open_string = self.open_string[:-1]
self.close_string = self.close_string[:-1]
def open(self, format = {}):
print(self.open_string % format)
def close(self, format = {}):
print(self.close_string % format)
def add_child(self, child):
self.children.append(child)
def print(self, format = {}):
self.open()
for i in self.children:
i.print(format)
self.close()