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
| import datetime | |
| import functools | |
| from typing import Callable, Optional | |
| def timed_cache(timedelta: datetime.timedelta, | |
| maxsize: Optional[int] = 128, | |
| typed: Optional[bool] = False) -> Callable: | |
| """Timeout is applied to the whole cache.""" | |
| def decorator(func): |
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 collections import namedtuple | |
| CreditCondition = namedtuple( | |
| 'CreditCondition', | |
| ['property_value', | |
| 'initial_payment', | |
| 'loan_months', | |
| 'interest_rate']) |
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 pprint import pprint | |
| from sqlalchemy import create_engine | |
| from sqlalchemy import Column, Integer, ForeignKey, Sequence, String | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.orm import backref, relationship, sessionmaker | |
| engine = create_engine('sqlite:///:memory:') | |
| Session = sessionmaker(bind=engine) |
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 update_remains_period(actor, start, end, company_object): | |
| """ | |
| Обновить остатки топлива за период. | |
| """ | |
| fuel_infos = FuelInfo.objects.filter(active=True, boiler=company_object) | |
| for date in get_period_dates(start, end): | |
| for fuel_info in fuel_infos: | |
| # Запись, которую нужно обновить | |
| record = None | |
| try: |
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
| #!/usr/bin/env python | |
| # –*– encoding: UTF-8 –*– | |
| '''ftp_updown.py: connection to FTP and up & down function''' | |
| __author__ = 'frantisekrehor.cz' | |
| __email__ = 'hi@frantisekrehor.cz' | |
| #================================================================ | |
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
| # The contents of this file are subject to the Common Public Attribution | |
| # License Version 1.0. (the "License"); you may not use this file except in | |
| # compliance with the License. You may obtain a copy of the License at | |
| # http://code.reddit.com/LICENSE. The License is based on the Mozilla Public | |
| # License Version 1.1, but Sections 14 and 15 have been added to cover use of | |
| # software over a computer network and provide for limited attribution for the | |
| # Original Developer. In addition, Exhibit A has been modified to be consistent | |
| # with Exhibit B. | |
| # | |
| # Software distributed under the License is distributed on an "AS IS" basis, |
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 fabric.api import local | |
| import pip | |
| def freeze (): | |
| local("pip freeze > requirements.txt") | |
| local("git add requirements.txt") | |
| local("git commit -v") | |
| def upgrade (): | |
| for dist in pip.get_installed_distributions(): |
NewerOlder