Ejemplo n.º 1
0
def worldcup_danh_sach_tran_dau():
    matches = []
    for key in BET_INFO.list_keys():
        match = {}
        match['team1'] = BET_INFO.get(key % 'team_1')
        match['team2'] = BET_INFO.get(key % 'team_2')
        match['date'] = BET_INFO.get(key % 'date')

        t = [int(x) for x in str(match['date']).split('/')]
        if date_format(t[2], t[1], t[0]) > date_format.today():
            match['time'] = BET_INFO.get(key % 'hour')
            s = match['date'] + match['time']
            matches.append([match, s])
        else:
            pass
    _data = sorted(matches, key=itemgetter(1))

    data = {}
    data['matches'] = []
    for row in _data:
        data['matches'].append(row[0])

    template_file = open(
        "/home/Workspace/FootballInfo2010/templates/worlcup_danh_sach_tran_dau.json"
    )
    template_file = template_file.read()
    template = load_template(template_file, 'spitfire_tmpl_o4')
    data = template(search_list=[data]).main()
    return data
Ejemplo n.º 2
0
def worldcup_danh_sach_tran_dau():
  matches = []
  for key in BET_INFO.list_keys():
    match = {}
    match['team1'] = BET_INFO.get(key % 'team_1')
    match['team2'] = BET_INFO.get(key % 'team_2')
    match['date'] = BET_INFO.get(key % 'date')

    t = [int(x) for x in str(match['date']).split('/')]
    if date_format(t[2], t[1], t[0]) > date_format.today():
      match['time'] = BET_INFO.get(key % 'hour')
      s = match['date'] + match['time']
      matches.append([match, s])
    else:
      pass
  _data = sorted(matches, key=itemgetter(1))

  data = {}
  data['matches'] = []
  for row in _data:
    data['matches'].append(row[0])

  template_file = open("/home/Workspace/FootballInfo2010/templates/worlcup_danh_sach_tran_dau.json")
  template_file = template_file.read()
  template = load_template(template_file, 'spitfire_tmpl_o4')
  data = template(search_list=[data]).main()
  return data
Ejemplo n.º 3
0
def chi_tiet_ty_le_ca_cuoc(href):
    match = href
    key = match + ': %s'

    date = BET_INFO.get(key % 'date')
    hour = BET_INFO.get(key % 'hour')

    team_1 = BET_INFO.get(key % 'team_1')
    team_2 = BET_INFO.get(key % 'team_2')

    ah_team_1 = BET_INFO.get(key % "ah_team_1")
    ah_team_2 = BET_INFO.get(key % "ah_team_2")
    ah = BET_INFO.get(key % "ah")

    ou_team_1 = BET_INFO.get(key % "ou_team_1")
    ou_team_2 = BET_INFO.get(key % "ou_team_2")
    ou = BET_INFO.get(key % "ou")

    ah1st_team_1 = BET_INFO.get(key % "ah1st_team_1")
    ah1st_team_2 = BET_INFO.get(key % "ah1st_team_2")
    ah1st = BET_INFO.get(key % "ah1st")

    ou1st_team_1 = BET_INFO.get(key % "ou1st_team_1")
    ou1st_team_2 = BET_INFO.get(key % "ou1st_team_2")
    ou1st = BET_INFO.get(key % "ou1st")
    data = {
        'date': date,
        'time': hour,
        'team_1': team_1,
        'team_2': team_2,
        'ah': ah,
        'ah_team_1': ah_team_1,
        'ah_team_2': ah_team_2,
        'ou': ou,
        'ou_team_1': ou_team_1,
        'ou_team_2': ou_team_2,
        'ah1st': ah1st,
        'ah1st_team_1': ah1st_team_1,
        'ah1st_team_2': ah1st_team_2,
        'ou1st': ou1st,
        'ou1st_team_1': ou1st_team_1,
        'ou1st_team_2': ou1st_team_2
    }
    template_file = open(
        "/home/Workspace/FootballInfo2010/templates/worldcup_chi_tiet_ty_le_ca_cuoc.json"
    )
    template_file = template_file.read()
    template = load_template(template_file, 'spitfire_tmpl_o4')
    data = template(search_list=[data]).main()
    return data
Ejemplo n.º 4
0
def chi_tiet_ty_le_ca_cuoc(href):
  match = href
  key = match + ': %s'

  date = BET_INFO.get(key % 'date')
  hour = BET_INFO.get(key % 'hour')

  team_1 = BET_INFO.get(key % 'team_1')
  team_2 = BET_INFO.get(key % 'team_2')

  ah_team_1 = BET_INFO.get(key % "ah_team_1")
  ah_team_2 = BET_INFO.get(key % "ah_team_2")
  ah = BET_INFO.get(key % "ah")

  ou_team_1 = BET_INFO.get(key % "ou_team_1")
  ou_team_2 = BET_INFO.get(key % "ou_team_2")
  ou = BET_INFO.get(key % "ou")

  ah1st_team_1 = BET_INFO.get(key % "ah1st_team_1")
  ah1st_team_2 = BET_INFO.get(key % "ah1st_team_2")
  ah1st = BET_INFO.get(key % "ah1st")

  ou1st_team_1 = BET_INFO.get(key % "ou1st_team_1")
  ou1st_team_2 = BET_INFO.get(key % "ou1st_team_2")
  ou1st = BET_INFO.get(key % "ou1st")
  data = {'date': date,
          'time': hour,
          'team_1': team_1,
          'team_2': team_2,
          'ah': ah,
          'ah_team_1': ah_team_1,
          'ah_team_2': ah_team_2,
          'ou': ou,
          'ou_team_1': ou_team_1,
          'ou_team_2': ou_team_2,
          'ah1st': ah1st,
          'ah1st_team_1': ah1st_team_1,
          'ah1st_team_2': ah1st_team_2,
          'ou1st': ou1st,
          'ou1st_team_1': ou1st_team_1,
          'ou1st_team_2': ou1st_team_2}
  template_file = open("/home/Workspace/FootballInfo2010/templates/worldcup_chi_tiet_ty_le_ca_cuoc.json")
  template_file = template_file.read()
  template = load_template(template_file, 'spitfire_tmpl_o4')
  data = template(search_list=[data]).main()
  return data
Ejemplo n.º 5
0
else:
    spitfire_template = SpitfireTemplate.load_template("""\
<!doctype html>
<html>
  <head>
    <title>$cgi.escape($page_title)</title>
  </head>
  <body>
    <div class="header">
      <h1>$cgi.escape($page_title)</h1>
    </div>
    <ul class="navigation">
    #for $href, $caption in [('index.html', 'Index'), ('downloads.html', 'Downloads'), ('products.html', 'Products')]
      <li><a href="$cgi.escape($href)">$cgi.escape($caption)</a></li>
    #end for
    </ul>
    <div class="table">
      <table>
      #for $row in $table
        <tr>
        #for $cell in $row
          <td>$cell</td>
        #end for
        </tr>
      #end for
      </table>
    </div>
  </body>
</html>\
""", 'spitfire_tmpl', spitfire_optimizer, {'enable_filters': False})
    spitfire_context = dict(context, **{'cgi': cgi})
Ejemplo n.º 6
0
#! /usr/bin/python
#! coding: utf-8

from Cheetah.Template import Template

template = """
<?xml version="1.0" encoding="UTF-8"?>
<WorlcupOdds version="$version" last_update="$last_update">
  #for $i in $menu
  <menu href="$i.href">$i.name</menu>
  #end for
</WorlcupOdds>
"""
info = {"version": '1.0', 
        "last_update": "21/5/2010",
        "menu":[{"href": "matches", "name": "Matches"},
                {"href": "results", "name": "Results"}]}

menu ={}
xml = Template(file='templates/menu.xml', searchList=[info, menu])
print xml

from spitfire.compiler import util

template = util.load_template(template, 'spitfire_tmpl_o4')
    
print template(search_list=[info]).main()