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
""" | |
Example function that reads a file and does something with it. | |
""" | |
import re | |
import sys | |
def list_shell_aliases(script): | |
"""Find all command aliases defined in a shell script. | |
Aliases are created though the ``alias`` command:: |
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
#!/bin/sh | |
# Script for setting up virtualenv to work correctly with Google App Engine projects | |
# @author Karol Kuczmarski "Xion" | |
DEFAULT_APPENGINE_SDK_PATH="/opt/google_appengine" | |
DEFAULT_PROJECT_LIB_PATH="./lib" | |
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 Mapping | |
import unittest | |
import warnings | |
from flask import get_template_attribute | |
from myapplication import app | |
class JinjaTestCase(unittest.TestCase): |
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 | |
""" | |
Decorator for fluent interface classes. | |
""" | |
import functools | |
import inspect | |
def chained(method): | |
"""Method decorator to allow chaining.""" |
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 functools | |
import inspect | |
import os | |
import warnings | |
class _DeprecatedDecorator(object): | |
MESSAGE = "%s is @deprecated" | |
def __call__(self, symbol): |
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 imp | |
import inspect | |
import sys | |
__all__ = [] | |
class PassthroughImporter(object): | |
"""Import hook that simulates the standard import flow |
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 | |
""" | |
Experiment with automatic generation of English plurals. | |
""" | |
import os | |
import random | |
def main(): | |
total_count = 0 |
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 inspect | |
def split(iterable, by): | |
"""Generalized split function that works on any iterable.""" | |
separator = by if inspect.isfunction(by) else lambda x: x == by | |
res = [] | |
curr = [] | |
for elem in iterable: | |
if separator(elem): |
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 re | |
from flask import url_for | |
from myflaskapp import app | |
def url_for_ex(endpoint, **values): | |
"""Improved version of standard Flask's :func:`url_for` | |
that accepts an additional, optional ``_strict`` argument. | |
:param _strict: If ``False``, values for the endpoint are not checked |
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
class L(object): | |
def __init__(self, iterable): | |
self.value = iterable | |
def map(self, fn): | |
self.value = map(fn, self.value) | |
return self | |
def join(self, s): | |
self.value = s.join(self.value) | |
return self | |