Changeset 3525


Ignore:
Timestamp:
30 Jun 2008, 14:35:08 (16 years ago)
Author:
uli
Message:

Remove Python2.5 stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/trunk/src/waeup/catalog.py

    r3521 r3525  
    1 from __future__ import with_statement
    21import sys
    32import csv
     
    4140    def render(self):
    4241        t = [0]
    43         with accum_time(t):
    44             src = os.path.join(os.path.dirname(__file__), 'tests',
    45                                'results2.csv')
    46             inputfile = file(src, "r")
    47             num = 0
    48             headers, rows = readFile(inputfile)
    49             for i in rows:
    50                 s = Student(i)
    51                 self.context[str(num)] = s
    52                 num += 1
     42        src = os.path.join(os.path.dirname(__file__), 'tests',
     43                           'results2.csv')
     44        inputfile = file(src, "r")
     45        num = 0
     46        headers, rows = readFile(inputfile)
     47        for i in rows:
     48             s = Student(i)
     49             self.context[str(num)] = s
     50             num += 1
    5351        return "%s new Students added in %s" % (num, t[0])
    5452
     
    6260        return "\n".join(result)
    6361
    64 import contextlib, time
    65 
    6662class ExportStudents(grok.View):
    6763    grok.context(University)
     
    6965    def render(self):
    7066        t = [0]
    71         with accum_time(t):
    72             result = []
    73             for s in self.context.values():
    74                 result.append(s.getCsv())
    75             writeFile(result)
     67        result = []
     68        for s in self.context.values():
     69             result.append(s.getCsv())
     70        writeFile(result)
    7671        return "yeah %s" % t[0]
    7772       
     
    9186    writer.writerows(data)
    9287
    93 @contextlib.contextmanager
    94 def accum_time(L):
    95   """
    96   Add time used inside a with block to the value of L[0].
    97   """
    98   start = time.clock()
    99   try:
    100     yield
    101   finally:
    102     end = time.clock()
    103     L[0] += end - start
Note: See TracChangeset for help on using the changeset viewer.