This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pyramid.renderers import render_to_response | |
| from pyramid.view import notfound_view_config | |
| from pyramid.httpexceptions import HTTPFound, HTTPNotFound | |
| from pyramid.interfaces import IRoutesMapper | |
| def find_route(path, request): | |
| q = request.registry.queryUtility | |
| mapper = q(IRoutesMapper) | |
| if mapper is None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #-*- coding: utf-8 -*- | |
| def bitsort(inlist): | |
| tmplist = list([0] * 100) | |
| for item in inlist: | |
| tmplist[item] = 1 | |
| outlist = [i for i, item in enumerate(tmplist) if item == 1] | |
| return outlist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def diff_time(curr_time): | |
| curr_time_obj = datetime.strptime(curr_time, "%a, %d %b %Y %H:%M:%S GMT") | |
| now_obj = datetime.now() | |
| res = curr_time_obj - now_obj | |
| days = int(abs(res.total_seconds()) / (3600 * 24)) | |
| hours = int((abs(res.total_seconds()) - days * 3600 * 24)/3600) | |
| minutes = int((abs(res.total_seconds()) - days * 3600 * 24 - hours * 3600)/60) | |
| ret = u"From now " | |
| if days > 0: | |
| ret += str(days) + "days " |