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 matches(environ, start_response):
  """Lấy danh sách các trận sẽ thi đấu trong Worldcup 2010."""
  matches = []
  for key in BET_INFO.list_keys():
    match = {}
    match['team_1'] = BET_INFO.get(key % 'team_1')
    match['team_2'] = 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['hour'] = BET_INFO.get(key % 'hour')
      match['href'] = "bet_info|%s - %s (%s)" \
                    % (match['team_1'], match['team_2'], match['date'])
      match['href2'] = "odd_details|%s - %s (%s)" \
                     % (match['team_1'], match['team_2'], match['date'])

      matches.append([match, s])
    else:
      pass
  _data = sorted(matches, key=itemgetter(1))
  
  matches = []
  for row in _data:
    matches.append(row[0])
  info['matches'] = matches
  xml = Template(file="templates/matches.xml", searchList=[info])
  xml = str(xml)
  response_headers = [('Content-Type', 'text/xml; charset="UTF-8"'),
                      ('Content-Length', str(len(xml)))]
  start_response(status, response_headers)
  return [xml]