|
a/bottle.py |
|
b/bottle.py |
|
... |
|
... |
307 |
def float_filter(self, conf):
|
307 |
def float_filter(self, conf):
|
308 |
return r'-?[\d.]+', float, lambda x: str(float(x))
|
308 |
return r'-?[\d.]+', float, lambda x: str(float(x))
|
309 |
|
309 |
|
310 |
def path_filter(self, conf):
|
310 |
def path_filter(self, conf):
|
311 |
return r'.*?', None, None
|
311 |
return r'.*?', None, None
|
312 |
|
312 |
|
313 |
def add_filter(self, name, func):
|
313 |
def add_filter(self, name, func):
|
314 |
''' Add a filter. The provided function is called with the configuration
|
314 |
''' Add a filter. The provided function is called with the configuration
|
315 |
string as parameter and must return a (regexp, to_python, to_url) tuple.
|
315 |
string as parameter and must return a (regexp, to_python, to_url) tuple.
|
316 |
The first element is a string, the last two are callables or None. '''
|
316 |
The first element is a string, the last two are callables or None. '''
|
317 |
self.filters[name] = func
|
317 |
self.filters[name] = func
|
318 |
|
318 |
|
319 |
def parse_rule(self, rule):
|
319 |
def parse_rule(self, rule):
|
320 |
''' Parses a rule into a (name, filter, conf) token stream. If mode is
|
320 |
''' Parses a rule into a (name, filter, conf) token stream. If mode is
|
321 |
None, name contains a static rule part. '''
|
321 |
None, name contains a static rule part. '''
|
322 |
offset, prefix = 0, ''
|
322 |
offset, prefix = 0, ''
|
323 |
for match in self.rule_syntax.finditer(rule):
|
323 |
for match in self.rule_syntax.finditer(rule):
|
|
... |
|
... |
2463 |
if not exists(path) or mtime(path) > lmtime:
|
2463 |
if not exists(path) or mtime(path) > lmtime:
|
2464 |
self.status = 'reload'
|
2464 |
self.status = 'reload'
|
2465 |
thread.interrupt_main()
|
2465 |
thread.interrupt_main()
|
2466 |
break
|
2466 |
break
|
2467 |
time.sleep(self.interval)
|
2467 |
time.sleep(self.interval)
|
2468 |
|
2468 |
|
2469 |
def __enter__(self):
|
2469 |
def __enter__(self):
|
2470 |
self.start()
|
2470 |
self.start()
|
2471 |
|
2471 |
|
2472 |
def __exit__(self, exc_type, exc_val, exc_tb):
|
2472 |
def __exit__(self, exc_type, exc_val, exc_tb):
|
2473 |
if not self.status: self.status = 'exit' # silent exit
|
2473 |
if not self.status: self.status = 'exit' # silent exit
|
2474 |
self.join()
|
2474 |
self.join()
|
2475 |
return issubclass(exc_type, KeyboardInterrupt)
|
2475 |
return issubclass(exc_type, KeyboardInterrupt)
|
2476 |
|
2476 |
|