Merge pull request #3406 from erfanio/f-string-docs

Change docs to use f-strings
This commit is contained in:
David Lord 2019-11-18 19:09:30 -08:00 committed by GitHub
commit 2659f0a5e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 13 deletions

View file

@ -49,16 +49,16 @@ virtual environment::
def deploy():
# figure out the package name and version
dist = local('python setup.py --fullname', capture=True).strip()
filename = '%s.tar.gz' % dist
filename = f'{dist}.tar.gz'
# upload the package to the temporary folder on the server
put('dist/%s' % filename, '/tmp/%s' % filename)
put(f'dist/{filename}', f'/tmp/{filename}')
# install the package in the application's virtualenv with pip
run('/var/www/yourapplication/env/bin/pip install /tmp/%s' % filename)
run(f'/var/www/yourapplication/env/bin/pip install /tmp/{filename}')
# remove the uploaded package
run('rm -r /tmp/%s' % filename)
run(f'rm -r /tmp/{filename}')
# touch the .wsgi file to trigger a reload in mod_wsgi
run('touch /var/www/yourapplication.wsgi')

View file

@ -86,7 +86,7 @@ Here is an example model (put this into :file:`models.py`, e.g.)::
self.email = email
def __repr__(self):
return '<User %r>' % (self.name)
return f'<User {self.name!r}>'
To create the database you can use the `init_db` function:
@ -159,7 +159,7 @@ Here is an example table and model (put this into :file:`models.py`)::
self.email = email
def __repr__(self):
return '<User %r>' % (self.name)
return f'<User {self.name!r}>'
users = Table('users', metadata,
Column('id', Integer, primary_key=True),

View file

@ -82,11 +82,11 @@ Here the code::
from functools import wraps
from flask import request
def cached(timeout=5 * 60, key='view/%s'):
def cached(timeout=5 * 60, key='view/{}'):
def decorator(f):
@wraps(f)
def decorated_function(*args, **kwargs):
cache_key = key % request.path
cache_key = key.format(request.path)
rv = cache.get(cache_key)
if rv is not None:
return rv