Ejemplo n.º 1
0
def build_src():
    i = HtmlInterpreter()
    
    for d in os.walk('src'):
        spath = d[0]
        tpath = 'web' + spath[3:]        
        if not os.path.exists(tpath):
            os.mkdir(tpath)
            
        for f in d[2]:
            if f.endswith('.sp'):
                fpath = os.path.join(spath, f)
                t = os.path.join(tpath, f[:-3])
                s = Shorp()
                s.add(fpath)
                s.interpreter = i
                
                with open(t, 'w') as fh:
                    fh.write(s.run())
            else:
                fpath = os.path.join(spath, f)
                t = os.path.join(tpath, f)
                shutil.copy2(fpath, t)
Ejemplo n.º 2
0
 def get(self):
     shorp = Shorp()
     shorp.interpreter = HtmlInterpreter('lib/shorp/html/html.rule.sp')
     shorp.add(self.request.get('src'))
     self.response.out.write(shorp.run())
Ejemplo n.º 3
0
from shorp.jquerymobile.interpreter import JqmInterpreter
from shorp.template.template import TemplateInterpreter
from shorp.core.rule import MixInterpreter


VERSION = '20100418'
LOG_FILENAME = 'shorp.log'
logger = logging.getLogger('main')

DIR_PATH = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))

if __name__ == '__main__':    
    sys.path.append(DIR_PATH)
        
    logging.basicConfig(filename=LOG_FILENAME,lever=logging.DEBUG)
    
    ti = TemplateInterpreter("tpl.rule.sp")
    hi = HtmlInterpreter()
    
    #i = MixInterpreter([('ti', ti),('hi', hi)], { 'title':'ti' })
    
    s = Shorp()
    s.add('html.sp')
    s.interpreter = ti
    content = s.run()
    print content
    s = Shorp()
    s.add(content)
    s.interpreter = hi
    print s.run()
    
Ejemplo n.º 4
0
 def appendrule(self, rule):
     shorp = Shorp()
     shorp.add(rule)
     self.rule.addChilds(shorp.parse().getChilds(), '+')