web/propertysheet.py
changeset 5938 9cb13d1b2ce4
parent 5467 57372dbfd114
child 6000 98ca82aae3a1
equal deleted inserted replaced
5937:82cac9383dd8 5938:9cb13d1b2ce4
    21 
    21 
    22 import re
    22 import re
    23 import os
    23 import os
    24 import os.path as osp
    24 import os.path as osp
    25 
    25 
       
    26 class lazystr(object):
       
    27     def __init__(self, string, context):
       
    28         self.string = string
       
    29         self.context = context
       
    30     def __str__(self):
       
    31         return self.string % self.context
       
    32 
    26 
    33 
    27 class PropertySheet(dict):
    34 class PropertySheet(dict):
    28     def __init__(self, cache_directory, **context):
    35     def __init__(self, cache_directory, **context):
    29         self._cache_directory = cache_directory
    36         self._cache_directory = cache_directory
    30         self.context = context
    37         self.context = context
    31         self.reset()
    38         self.reset()
    32         context['sheet'] = self
    39         context['sheet'] = self
       
    40         context['lazystr'] = self.lazystr
    33         self._percent_rgx = re.compile('%(?!\()')
    41         self._percent_rgx = re.compile('%(?!\()')
       
    42 
       
    43     def lazystr(self, str):
       
    44         return lazystr(str, self)
    34 
    45 
    35     def reset(self):
    46     def reset(self):
    36         self.clear()
    47         self.clear()
    37         self._ordered_propfiles = []
    48         self._ordered_propfiles = []
    38         self._propfile_mtime = {}
    49         self._propfile_mtime = {}