docstring_tokens stringlengths 0 76.5k | code_tokens stringlengths 75 1.81M | label_window listlengths 4 2.12k | html_url stringlengths 74 116 | file_name stringlengths 3 311 |
|---|---|---|---|---|
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
$ flask run
| <mask>
<mask> $ export FLASK_ENV=development
<mask> $ flask run
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_ENV=development
<mask> > flask run
</s> Adding Fish commands to docs | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/quickstart.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP hello
$ export FLASK_ENV=development
$ flask run
| <mask> $ flask run
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
</s> Adding Fish commands to docs | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/server.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP flaskr
$ flask init-db
| <mask> $ flask init-db
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
<mask> > set FLASK_APP=flaskr
</s> Adding Fish commands to docs | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/tutorial/deploy.rst |
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP flaskr
$ set -x FLASK_ENV development
$ flask run
| <mask> $ export FLASK_ENV=development
<mask> $ flask run
<mask>
<mask> .. group-tab:: CMD
<mask>
<mask> .. code-block:: text
<mask>
</s> Adding Fish commands to docs | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/afe77feef351c2752bb9d4a93b65e11215633e06 | docs/tutorial/factory.rst |
<mask> security reasons only objects are supported toplevel. For more
<mask> information about this, have a look at :ref:`json-security`.
<mask>
<mask> .. versionadded:: 0.2
<mask>
<mask> .. versionadded:: 0.9
<mask> If the ``padded`` argument is true, the JSON object will be padded
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b04827283ea36cc456367f1ac4e0700b90b71283 | flask/helpers.py | |
<mask> callback-function name.
<mask> """
<mask> if __debug__:
<mask> _assert_have_json()
<mask>
<mask> padded = kwargs.get('padded', False)
<mask> if 'padded' in kwargs:
<mask> del kwargs['padded']
<mask>
<mask> if padded:
<mask> if isinstance(padded, st... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b04827283ea36cc456367f1ac4e0700b90b71283 | flask/helpers.py | |
<mask> return flask.jsonify(**d)
<mask> @app.route('/dict')
<mask> def return_dict():
<mask> return flask.jsonify(d)
<mask> @app.route("/unpadded")
<mask> def return_padded_false():
<mask> return flask.jsonify(d, padded=False)
<mask> @a... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b04827283ea36cc456367f1ac4e0700b90b71283 | flask/testsuite/helpers.py | |
for url in '/kw', '/dict': | <mask> @app.route("/padded_custom")
<mask> def return_padded_json_custom_callback():
<mask> return flask.jsonify(d, padded='my_func_name')
<mask> c = app.test_client()
<mask> for url in '/kw', '/dict', '/unpadded':
<mask> rv = c.get(url)
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b04827283ea36cc456367f1ac4e0700b90b71283 | flask/testsuite/helpers.py |
<mask> for url in '/kw', '/dict', '/unpadded':
<mask> rv = c.get(url)
<mask> self.assert_equal(rv.mimetype, 'application/json')
<mask> self.assert_equal(flask.json.loads(rv.data), d)
<mask> for get_arg in 'callback=funcName', 'jsonp=funcName':
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b04827283ea36cc456367f1ac4e0700b90b71283 | flask/testsuite/helpers.py | |
same process. A warning will be shown if old configuration is
detected that needs to be moved. :issue:`2866` | <mask> - :attr:`Flask.logger` takes the same name as
<mask> :attr:`Flask.name` (the value passed as
<mask> ``Flask(import_name)``. This reverts 1.0's behavior of always
<mask> logging to ``"flask.app"``, in order to support multiple apps in the
<mask> same process. This may require adjusting logg... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b08e35e4ab525c207144e42af1b678a78abe09cb | CHANGES.rst |
import warnings | <mask>
<mask> import logging
<mask> import sys
<mask>
<mask> from werkzeug.local import LocalProxy
<mask>
<mask> from .globals import request
<mask>
<mask>
</s> show warning for old logger config </s> remove same process. This may require adjusting logging configuration.
:issue:`2866`.
</s> add ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b08e35e4ab525c207144e42af1b678a78abe09cb | src/flask/logging.py |
def _has_config(logger):
"""Decide if a logger has direct configuration applied by checking
its properties against the defaults.
:param logger: The :class:`~logging.Logger` to inspect.
"""
return (
logger.level != logging.NOTSET
or logger.handlers
or logger.filters
o... | <mask> )
<mask>
<mask>
<mask> def create_logger(app):
<mask> """Get the the Flask apps's logger and configure it if needed.
<mask>
<mask> The logger name will be the same as
<mask> :attr:`app.import_name <flask.Flask.name>`.
<mask>
</s> show warning for old logger config </s> remove if app... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b08e35e4ab525c207144e42af1b678a78abe09cb | src/flask/logging.py |
# 1.1.0 changes name of logger, warn if config is detected for old
# name and not new name
for old_name in ("flask.app", "flask"):
old_logger = logging.getLogger(old_name)
if _has_config(old_logger) and not _has_config(logger):
warnings.warn(
"'app.logger' is nam... | <mask> :func:`~flask.logging.wsgi_errors_stream` with a basic format.
<mask> """
<mask> logger = logging.getLogger(app.name)
<mask>
<mask> if app.debug and logger.level == logging.NOTSET:
<mask> logger.setLevel(logging.DEBUG)
<mask>
<mask> if not has_level_handler(logger):
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b08e35e4ab525c207144e42af1b678a78abe09cb | src/flask/logging.py |
- Adam Byrtek | <mask>
<mask> Patches and Suggestions
<mask> ```````````````````````
<mask>
<mask> - Adam Zapletal
<mask> - Ali Afshar
<mask> - Chris Edgemon
<mask> - Chris Grindstaff
<mask> - Christopher Grebs
</s> Use proper exception type and update changelog </s> remove raise RuntimeError('Client cannot pro... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b099999c6cb5c3563dc4fbe45f3101116aab0d3f | AUTHORS |
- Added `json` keyword argument to :meth:`flask.testing.FlaskClient.open`
(and related ``get``, ``post``, etc.), which makes it more convenient to
send JSON requests from the test client. | <mask> - Mimetype guessing for ``send_file`` has been removed, as per issue ``#104``.
<mask> See pull request ``#1849``.
<mask> - Make ``flask.safe_join`` able to join multiple paths like ``os.path.join``
<mask> (pull request ``#1730``).
<mask>
<mask> Version 0.11.2
<mask> --------------
<mask>
</s> Use ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b099999c6cb5c3563dc4fbe45f3101116aab0d3f | CHANGES |
raise ValueError('Client cannot provide both `json` and `data`') | <mask> path += '?' + url.query
<mask>
<mask> if json is not None:
<mask> if 'data' in kwargs:
<mask> raise RuntimeError('Client cannot provide both `json` and `data`')
<mask> kwargs['data'] = json_dumps(json)
<mask>
<mask> # Only set Content-Type when no... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b099999c6cb5c3563dc4fbe45f3101116aab0d3f | flask/testing.py |
- refactored internal request dispatching. | <mask> - :meth:`~flask.Flask.add_url_rule` can now also register a
<mask> view function.
<mask> - server listens on 127.0.0.1 by default now to fix issues with chrome.
<mask> - added external URL support.
<mask> - added support for :func:`~flask.send_file`
<mask> - module support and internal request handling r... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b0ab127015186e1a2918221ffad8d79ca346faf5 | CHANGES |
- sessions can be set to be permanent now on a per-session basis.
- better error reporting on missing secret keys.
- added support for Google Appengine. | <mask> - added external URL support.
<mask> - added support for :func:`~flask.send_file`
<mask> - module support and internal request handling refactoring
<mask> to better support pluggable applications.
<mask>
<mask> Version 0.1
<mask> -----------
<mask>
<mask> First public preview release.
</s> Added lo... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b0ab127015186e1a2918221ffad8d79ca346faf5 | CHANGES |
release:
python setup.py release sdist upload
| <mask> python tests/flask_tests.py
<mask>
<mask> clean-pyc:
<mask> find . -name '*.pyc' -exec rm -f {} +
<mask> find . -name '*.pyo' -exec rm -f {} +
<mask> find . -name '*~' -exec rm -f {} +
<mask>
</s> Added logo with new slogan </s> remove 'Development Status :: 3 - Alpha',
</s> add 'D... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b0ab127015186e1a2918221ffad8d79ca346faf5 | Makefile |
'Development Status :: 4 - Beta', | <mask> 'Werkzeug>=0.6.1',
<mask> 'Jinja2>=2.4'
<mask> ],
<mask> classifiers=[
<mask> 'Development Status :: 3 - Alpha',
<mask> 'Environment :: Web Environment',
<mask> 'Intended Audience :: Developers',
<mask> 'License :: OSI Approved :: BSD License',
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b0ab127015186e1a2918221ffad8d79ca346faf5 | setup.py |
self.view_functions.update(module.view_functions) | <mask> """
<mask> options.setdefault('url_prefix', module.url_prefix)
<mask> options.setdefault('subdomain', module.subdomain)
<mask> state = _ModuleSetupState(self, **options)
<mask> for func in module._register_events:
<mask> func(state)
<mask>
<mask> d... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b0ca7e5af15ef2218b9726aba1d8948a409dedb9 | flask/app.py |
def endpoint(self, endpoint):
"""A decorator to register a function as an endpoint.
Example::
@app.endpoint('example.endpoint')
def example():
return "example"
:param endpoint: the name of the endpoint
"""
def decorator(f):
... | <mask> self.add_url_rule(rule, None, f, **options)
<mask> return f
<mask> return decorator
<mask>
<mask> def errorhandler(self, code):
<mask> """A decorator that is used to register a function give a given
<mask> error code. Example::
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b0ca7e5af15ef2218b9726aba1d8948a409dedb9 | flask/app.py |
self.view_functions = {} | <mask> _PackageBoundObject.__init__(self, import_name)
<mask> self.name = name
<mask> self.url_prefix = url_prefix
<mask> self.subdomain = subdomain
<mask> self._register_events = [_register_module(self, static_path)]
<mask>
<mask> def route(self, rule, **options):
<... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b0ca7e5af15ef2218b9726aba1d8948a409dedb9 | flask/module.py |
def endpoint(self, endpoint):
"""Like :meth:`Flask.endpoint` but for a module."""
def decorator(f):
self.view_functions[endpoint] = f
return f
return decorator
| <mask> self._record(register_rule)
<mask>
<mask> def before_request(self, f):
<mask> """Like :meth:`Flask.before_request` but for a module. This function
<mask> is only executed before each request that is handled by a function of
<mask> that module.
<mask> """
<mas... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b0ca7e5af15ef2218b9726aba1d8948a409dedb9 | flask/module.py |
- ``config.from_file`` can use ``text=False`` to indicate that the parser wants a
binary file instead. :issue:`4989` | <mask> :issue:`4993`
<mask> - Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``.
<mask> :pr:`4947`
<mask> - Ensure subdomains are applied with nested blueprints. :issue:`4834`
<mask>
<mask>
<mask> Version 2.2.3
<mask> -------------
<mask>
</s> add text parameter to ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b10b6d4af1127fdfb0a74221af0c020ced71fece | CHANGES.rst |
text: bool = True, | <mask> self,
<mask> filename: str,
<mask> load: t.Callable[[t.IO[t.Any]], t.Mapping],
<mask> silent: bool = False,
<mask> ) -> bool:
<mask> """Update the values in the config from a file that is loaded
<mask> using the ``load`` parameter. The loaded data is pas... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b10b6d4af1127fdfb0a74221af0c020ced71fece | src/flask/config.py |
import tomllib
app.config.from_file("config.toml", load=tomllib.load, text=False) | <mask>
<mask> import json
<mask> app.config.from_file("config.json", load=json.load)
<mask>
<mask> import toml
<mask> app.config.from_file("config.toml", load=toml.load)
<mask>
<mask> :param filename: The path to the data file. This can be an
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b10b6d4af1127fdfb0a74221af0c020ced71fece | src/flask/config.py |
:param text: Open the file in text or binary mode. | <mask> implements a ``read`` method.
<mask> :param silent: Ignore the file if it doesn't exist.
<mask> :return: ``True`` if the file was loaded successfully.
<mask>
<mask> .. versionchanged:: 2.3
<mask> The ``text`` parameter was added.
<mask>
</s> add text para... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b10b6d4af1127fdfb0a74221af0c020ced71fece | src/flask/config.py |
.. versionchanged:: 2.3
The ``text`` parameter was added.
| <mask> :param text: Open the file in text or binary mode.
<mask> :return: ``True`` if the file was loaded successfully.
<mask>
<mask> .. versionadded:: 2.0
<mask> """
<mask> filename = os.path.join(self.root_path, filename)
<mask>
<mask> try:
</s> add text para... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b10b6d4af1127fdfb0a74221af0c020ced71fece | src/flask/config.py |
with open(filename, "r" if text else "rb") as f: | <mask> """
<mask> filename = os.path.join(self.root_path, filename)
<mask>
<mask> try:
<mask> with open(filename) as f:
<mask> obj = load(f)
<mask> except OSError as e:
<mask> if silent and e.errno in (errno.ENOENT, errno.EISDIR):
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b10b6d4af1127fdfb0a74221af0c020ced71fece | src/flask/config.py |
def test_config_from_file_json(): | <mask> app.config.from_object(__name__)
<mask> common_object_test(app)
<mask>
<mask>
<mask> def test_config_from_file():
<mask> app = flask.Flask(__name__)
<mask> current_dir = os.path.dirname(os.path.abspath(__file__))
<mask> app.config.from_file(os.path.join(current_dir, "static", "confi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b10b6d4af1127fdfb0a74221af0c020ced71fece | tests/test_config.py |
def test_config_from_file_toml():
tomllib = pytest.importorskip("tomllib", reason="tomllib added in 3.11")
app = flask.Flask(__name__)
current_dir = os.path.dirname(os.path.abspath(__file__))
app.config.from_file(
os.path.join(current_dir, "static", "config.toml"), tomllib.load, text=False
)... | <mask> common_object_test(app)
<mask>
<mask>
<mask> def test_from_prefixed_env(monkeypatch):
<mask> monkeypatch.setenv("FLASK_STRING", "value")
<mask> monkeypatch.setenv("FLASK_BOOL", "true")
<mask> monkeypatch.setenv("FLASK_INT", "1")
<mask> monkeypatch.setenv("FLASK_FLOAT", "1.2")
</s> ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b10b6d4af1127fdfb0a74221af0c020ced71fece | tests/test_config.py |
- The ``Scaffold`` class provides a common API for the ``Flask`` and
``Blueprint`` classes. ``Blueprint`` information is stored in
attributes just like ``Flask``, rather than opaque lambda functions.
This is intended to improve consistency and maintainability.
:issue:`3215` | <mask> For example, this allows setting the ``Content-Type`` for
<mask> ``jsonify()``. Use ``response.headers.extend()`` if extending is
<mask> desired. :issue:`3628`
<mask>
<mask>
<mask> Version 1.1.x
<mask> -------------
</s> extract common Flask/Blueprint API to Scaffold base class
Co-authored... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146a13f633b0e2e26e3b8383b3db0feb563bc83 | CHANGES.rst |
<mask> import os
<mask> import sys
<mask> from datetime import timedelta
<mask> from functools import update_wrapper
<mask> from itertools import chain
<mask> from threading import Lock
<mask>
<mask> from werkzeug.datastructures import Headers
<mask> from werkzeug.datastructures import ImmutableDict
</s> ext... | [
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146a13f633b0e2e26e3b8383b3db0feb563bc83 | src/flask/app.py | |
<mask> #:
<mask> #: .. versionadded:: 0.8
<mask> self.before_first_request_funcs = []
<mask>
<mask> #: A dictionary with lists of functions that should be called after
<mask> #: each request. The key of the dictionary is the name of the blueprint
<mask> #: this f... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
... | https://github.com/pallets/flask/commit/b146a13f633b0e2e26e3b8383b3db0feb563bc83 | src/flask/app.py | |
<mask> """
<mask> self.teardown_appcontext_funcs.append(f)
<mask> return f
<mask>
<mask> @setupmethod
<mask> def context_processor(self, f):
<mask> """Registers a template context processor function."""
<mask> self.template_context_processors[None].append(f)
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146a13f633b0e2e26e3b8383b3db0feb563bc83 | src/flask/app.py | |
from .scaffold import _endpoint_from_view_func
from .scaffold import _sentinel
from .scaffold import Scaffold | <mask> from functools import update_wrapper
<mask>
<mask> from .helpers import _endpoint_from_view_func
<mask> from .helpers import _PackageBoundObject
<mask>
<mask> # a singleton sentinel value for parameter defaults
<mask> _sentinel = object()
<mask>
<mask>
<mask> class BlueprintSetupState:
<mask> ... | [
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146a13f633b0e2e26e3b8383b3db0feb563bc83 | src/flask/blueprints.py |
<mask> )
<mask> self.name = name
<mask> self.url_prefix = url_prefix
<mask> self.subdomain = subdomain
<mask> self.static_folder = static_folder
<mask> self.static_url_path = static_url_path
<mask> self.deferred_functions = []
<mask> if url_default... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146a13f633b0e2e26e3b8383b3db0feb563bc83 | src/flask/blueprints.py | |
def _is_setup_finished(self):
return self.warn_on_modifications and self._got_registered_once
| <mask> url_defaults = {}
<mask> self.url_values_defaults = url_defaults
<mask> self.cli_group = cli_group
<mask>
<mask> def record(self, func):
<mask> """Registers a function that is called when the blueprint is
<mask> registered on the application. This function... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146a13f633b0e2e26e3b8383b3db0feb563bc83 | src/flask/blueprints.py |
<mask> lambda s: s.app.teardown_request_funcs.setdefault(None, []).append(f)
<mask> )
<mask> return f
<mask>
<mask> def context_processor(self, f):
<mask> """Like :meth:`Flask.context_processor` but for a blueprint. This
<mask> function is only executed for reque... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146a13f633b0e2e26e3b8383b3db0feb563bc83 | src/flask/blueprints.py | |
<mask> return f
<mask>
<mask> return decorator
<mask>
<mask> def url_value_preprocessor(self, f):
<mask> """Registers a function as URL value preprocessor for this
<mask> blueprint. It's called before the view functions are called and
<mask> can modify the url ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep"... | https://github.com/pallets/flask/commit/b146a13f633b0e2e26e3b8383b3db0feb563bc83 | src/flask/blueprints.py | |
try:
import simplejson as json
except ImportError:
import json | <mask> --------------
<mask>
<mask> .. autofunction:: jsonify
<mask>
<mask> .. data:: json
<mask>
<mask> If JSON support is picked up, this will be the module that Flask is
<mask> using to parse and serialize JSON. So instead of doing this yourself::
<mask>
<mask> try:
</s> Added wrapper... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146d8277ab90cf6d43ea54113383076e4fd0318 | docs/api.rst |
You can instead just do this:: | <mask> .. autofunction:: jsonify
<mask>
<mask> .. data:: json
<mask>
<mask> If JSON support is picked up, this will be the module that Flask is
<mask> using to parse and serialize JSON. So instead of doing this yourself::
<mask>
<mask> try:
<mask> import simplejson as json
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146d8277ab90cf6d43ea54113383076e4fd0318 | docs/api.rst |
The :func:`~htmlsafe_dumps` function of this json module is also available
as filter called ``|tojson`` in Jinja2. Note that inside `script`
tags no escaping must take place, so make sure to disable escaping
with ``|safe`` if you intend to use it inside `script` tags: | <mask> You can instead just do this::
<mask>
<mask> from flask import json
<mask>
<mask> For usage examples, read the :mod:`json` documentation.
<mask>
<mask> The :func:`~json.dumps` function of this json module is also available
<mask> as filter called ``|tojson`` in Jinja2. Note th... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146d8277ab90cf6d43ea54113383076e4fd0318 | docs/api.rst |
.. autofunction:: dumps | <mask> as filter called ``|tojson`` in Jinja2. Note that inside `script`
<mask> tags no escaping must take place, so make sure to disable escaping
<mask> with ``|safe`` if you intend to use it inside `script` tags:
<mask>
<mask> .. sourcecode:: html+jinja
<mask>
<mask> <script type=tex... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146d8277ab90cf6d43ea54113383076e4fd0318 | docs/api.rst |
# We're not exposing the actual json module but a convenient wrapper around
# it.
from . import json
# This was the only thing that flask used to export at one point and it had
# a more generic name.
jsonify = json.jsonify | <mask> from .signals import signals_available, template_rendered, request_started, \
<mask> request_finished, got_request_exception, request_tearing_down, \
<mask> appcontext_tearing_down
<mask>
<mask> # only import json if it's available
<mask> from .helpers import json
<mask>
<mask> # backwards co... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146d8277ab90cf6d43ea54113383076e4fd0318 | flask/__init__.py |
<mask> from werkzeug.routing import BuildError
<mask> from werkzeug.urls import url_quote
<mask> from functools import update_wrapper
<mask>
<mask> # Use the same json implementation as itsdangerous on which we
<mask> # depend anyways.
<mask> from itsdangerous import simplejson as json
<mask>
<mask>
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b146d8277ab90cf6d43ea54113383076e4fd0318 | flask/helpers.py | |
- Clearer error message when ``after_this_request`` is used outside a | <mask> tracebacks when importing the application. :issue:`4307`
<mask> - ``app.json_encoder`` and ``json_decoder`` are only passed to
<mask> ``dumps`` and ``loads`` if they have custom behavior. This improves
<mask> performance, mainly on PyPy. :issue:`4349`
<mask> - Fix error message for ``after_t... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b1a00ebc4c6f15055ddf15ecb17243a089f52a60 | CHANGES.rst |
"This decorator can only be used when a request context is"
" active, such as within a view function." | <mask> """
<mask> top = _request_ctx_stack.top
<mask> if top is None:
<mask> raise RuntimeError(
<mask> "This decorator can only be used at local scopes "
<mask> "when a request context is on the stack. For instance within "
<mask> "view functions."
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b1a00ebc4c6f15055ddf15ecb17243a089f52a60 | src/flask/ctx.py |
<mask> "This decorator can only be used at local scopes "
<mask> "when a request context is on the stack. For instance within "
<mask> "view functions."
<mask> )
<mask> top._after_request_functions.append(f)
<mask>
<mask> return f
<mask>
<mask>
<mask> def... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b1a00ebc4c6f15055ddf15ecb17243a089f52a60 | src/flask/ctx.py | |
top._after_request_functions.append(f) | <mask> " active, such as within a view function."
<mask> )
<mask>
<mask> return f
<mask>
<mask>
<mask> def copy_current_request_context(f: t.Callable) -> t.Callable:
</s> update error message for after_this_request and copy_current_request_context </s> remove top._after_request_fu... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b1a00ebc4c6f15055ddf15ecb17243a089f52a60 | src/flask/ctx.py |
"This decorator can only be used when a request context is"
" active, such as within a view function." | <mask> """
<mask> top = _request_ctx_stack.top
<mask> if top is None:
<mask> raise RuntimeError(
<mask> "This decorator can only be used at local scopes "
<mask> "when a request context is on the stack. For instance within "
<mask> "view functions."
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b1a00ebc4c6f15055ddf15ecb17243a089f52a60 | src/flask/ctx.py |
from . import json | <mask> from werkzeug.utils import import_string
<mask> from ._compat import string_types
<mask>
<mask>
<mask> class ConfigAttribute(object):
<mask> """Makes an attribute forward to the config"""
</s> Add ability to config from a JSON file | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b290bf4079bc325d6b13f9043afb17c4aee48df0 | flask/config.py |
def test_config_from_json(self):
app = flask.Flask(__name__)
current_dir = os.path.dirname(os.path.abspath(__file__))
app.config.from_json(os.path.join(current_dir, 'static', 'config.json'))
self.common_object_test(app)
| <mask> app.config.from_object(__name__)
<mask> self.common_object_test(app)
<mask>
<mask> def test_config_from_class(self):
<mask> class Base(object):
<mask> TEST_KEY = 'foo'
<mask> class Test(Base):
</s> Add ability to config from a JSON file | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b290bf4079bc325d6b13f9043afb17c4aee48df0 | flask/testsuite/config.py |
def test_config_missing_json(self):
app = flask.Flask(__name__)
try:
app.config.from_json('missing.json')
except IOError as e:
msg = str(e)
self.assert_true(msg.startswith('[Errno 2] Unable to load configuration '
... | <mask> else:
<mask> self.assert_true(0, 'expected config')
<mask> self.assert_false(app.config.from_pyfile('missing.cfg', silent=True))
<mask>
<mask> def test_session_lifetime(self):
<mask> app = flask.Flask(__name__)
<mask> app.config['PERMANENT_SESSION_LIFETIME'... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b290bf4079bc325d6b13f9043afb17c4aee48df0 | flask/testsuite/config.py |
appcontext_tearing_down, message_flashed | <mask>
<mask> # the signals
<mask> from .signals import signals_available, template_rendered, request_started, \
<mask> request_finished, got_request_exception, request_tearing_down, \
<mask> appcontext_tearing_down
<mask>
<mask> # We're not exposing the actual json module but a convenient wrapper ar... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b2aae044ca9c9875c594d57a3bd92bd80d8d56ff | flask/__init__.py |
from .signals import message_flashed | <mask> from jinja2 import FileSystemLoader
<mask>
<mask> from .globals import session, _request_ctx_stack, _app_ctx_stack, \
<mask> current_app, request
<mask>
<mask>
<mask> # sentinel
</s> Flash messages signals
If we send a signal when a template is rendered why not when a message
is flashed? One rea... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b2aae044ca9c9875c594d57a3bd92bd80d8d56ff | flask/helpers.py |
message_flashed.send(current_app._get_current_object(),
message=message, category=category) | <mask> # implementations that use external storage for keeping their keys/values.
<mask> flashes = session.get('_flashes', [])
<mask> flashes.append((category, message))
<mask> session['_flashes'] = flashes
<mask>
<mask>
<mask> def get_flashed_messages(with_categories=False, category_filter=[])... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b2aae044ca9c9875c594d57a3bd92bd80d8d56ff | flask/helpers.py |
from __future__ import with_statement
| <mask> :license: BSD, see LICENSE for more details.
<mask> """
<mask> import flask
<mask> import unittest
<mask> from flask.testsuite import FlaskTestCase
<mask>
<mask>
</s> Flash messages signals
If we send a signal when a template is rendered why not when a message
is flashed? One real world use case i... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b2aae044ca9c9875c594d57a3bd92bd80d8d56ff | flask/testsuite/signals.py |
"""Ensure that we register only exceptions as handler keys""" | <mask> return decorator
<mask>
<mask> @staticmethod
<mask> def _get_exc_class_and_code(exc_class_or_code):
<mask> """ensure that we register only exceptions as handler keys"""
<mask> if isinstance(exc_class_or_code, integer_types):
<mask> exc_class = default_exception... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b31252db55cfac4605ad917d34eaa55fff248a38 | flask/app.py |
def find_superclass(handler_map):
if not handler_map: | <mask> If neither blueprint nor App has a suitable handler registered, returns None
<mask> """
<mask> exc_class, code = self._get_exc_class_and_code(type(e))
<mask>
<mask> def find_superclass(d):
<mask> if not d:
<mask> return None
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b31252db55cfac4605ad917d34eaa55fff248a38 | flask/app.py |
for superclass in exc_class.__mro__: | <mask>
<mask> def find_superclass(d):
<mask> if not d:
<mask> return None
<mask> for superclass in exc_class.mro():
<mask> if superclass is BaseException:
<mask> return None
<mask> handler = d.get(superc... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b31252db55cfac4605ad917d34eaa55fff248a38 | flask/app.py |
handler = handler_map.get(superclass) | <mask> return None
<mask> for superclass in exc_class.mro():
<mask> if superclass is BaseException:
<mask> return None
<mask> handler = d.get(superclass)
<mask> if handler is not None:
<mask> d[exc... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b31252db55cfac4605ad917d34eaa55fff248a38 | flask/app.py |
handler_map[exc_class] = handler # cache for next time exc_class is raised | <mask> if superclass is BaseException:
<mask> return None
<mask> handler = d.get(superclass)
<mask> if handler is not None:
<mask> d[exc_class] = handler # cache for next time exc_class is raised
<mask> re... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b31252db55cfac4605ad917d34eaa55fff248a38 | flask/app.py |
TOXENV: py,codecov | <mask> environment:
<mask> global:
<mask> TOXENV: py
<mask>
<mask> matrix:
<mask> - PYTHON: C:\Python36
<mask> - PYTHON: C:\Python27
<mask>
</s> update test envs
use pypy3
fix travis osx env
cache pip on appveyor
codecov on appveyor </s> remove - PYTHON: C:\Python36
- PYTHON: C:\Pytho... | [
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b34c7174e75db5ab43ff3d76a1c7027126e8c9b3 | .appveyor.yml |
- PYTHON: C:\Python36-x64
- PYTHON: C:\Python27-x64 | <mask> global:
<mask> TOXENV: py
<mask>
<mask> matrix:
<mask> - PYTHON: C:\Python36
<mask> - PYTHON: C:\Python27
<mask>
<mask> init:
<mask> - SET PATH=%PYTHON%;%PATH%
<mask>
<mask> install:
</s> update test envs
use pypy3
fix travis osx env
cache pip on appveyor
codecov on appveyor </s>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b34c7174e75db5ab43ff3d76a1c7027126e8c9b3 | .appveyor.yml |
- python -m pip install -U tox | <mask> init:
<mask> - SET PATH=%PYTHON%;%PATH%
<mask>
<mask> install:
<mask> - python -m pip install -U pip setuptools wheel tox
<mask>
<mask> build: false
<mask>
<mask> test_script:
<mask> - python -m tox
</s> update test envs
use pypy3
fix travis osx env
cache pip on appveyor
codecov on appveyor <... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b34c7174e75db5ab43ff3d76a1c7027126e8c9b3 | .appveyor.yml |
- python: pypy3 | <mask> - python: 3.4
<mask> env: TOXENV=py,codecov
<mask> - python: 2.7
<mask> env: TOXENV=py,simplejson,devel,lowest,codecov
<mask> - python: pypy
<mask> env: TOXENV=py,codecov
<mask> - python: nightly
<mask> env: TOXENV=py
<mask> - os: osx
<mask> language: g... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b34c7174e75db5ab43ff3d76a1c7027126e8c9b3 | .travis.yml |
env: TOXENV=py3,py2,codecov
cache:
pip: false
directories:
- $HOME/Library/Caches/Homebrew
- $HOME/Library/Caches/pip | <mask> - python: nightly
<mask> env: TOXENV=py
<mask> - os: osx
<mask> language: generic
<mask> env: TOXENV=py
<mask> allow_failures:
<mask> - python: nightly
<mask> env: TOXENV=py
<mask> - os: osx
<mask> language: generic
</s> update test envs
use pypy3
fix tr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b34c7174e75db5ab43ff3d76a1c7027126e8c9b3 | .travis.yml |
- python: pypy3 | <mask> - $HOME/Library/Caches/Homebrew
<mask> - $HOME/Library/Caches/pip
<mask> allow_failures:
<mask> - python: nightly
<mask> - os: osx
<mask> fast_finish: true
<mask>
<mask> before_install:
<mask> - |
</s> update test envs
use pypy3
fix travis osx env
cache pip on appveyo... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b34c7174e75db5ab43ff3d76a1c7027126e8c9b3 | .travis.yml |
<mask> language: generic
<mask> env: TOXENV=py
<mask> allow_failures:
<mask> - python: nightly
<mask> env: TOXENV=py
<mask> - os: osx
<mask> language: generic
<mask> env: TOXENV=py
<mask> fast_finish: true
<mask>
</s> update test envs
use pypy3
fix travis osx env
ca... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b34c7174e75db5ab43ff3d76a1c7027126e8c9b3 | .travis.yml | |
<mask> allow_failures:
<mask> - python: nightly
<mask> env: TOXENV=py
<mask> - os: osx
<mask> language: generic
<mask> env: TOXENV=py
<mask> fast_finish: true
<mask>
<mask> before_install:
<mask> - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
<mask> brew update;
</s> upda... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b34c7174e75db5ab43ff3d76a1c7027126e8c9b3 | .travis.yml | |
- |
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
brew upgrade python
brew install python@2;
export PATH="/usr/local/opt/python/libexec/bin:${PATH}" | <mask> env: TOXENV=py
<mask> fast_finish: true
<mask>
<mask> before_install:
<mask> - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
<mask> brew update;
<mask> brew install python3 redis memcached;
<mask> virtualenv -p python3 ~/py-env;
<mask> . ~/py-env/bin/activate;
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b34c7174e75db5ab43ff3d76a1c7027126e8c9b3 | .travis.yml |
passenv = CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* | <mask> coverage report
<mask> coverage html
<mask>
<mask> [testenv:codecov]
<mask> passenv = CI TRAVIS TRAVIS_*
<mask> deps = codecov
<mask> skip_install = true
<mask> commands =
<mask> coverage combine
<mask> coverage report
</s> update test envs
use pypy3
fix travis osx env
cache pip on ap... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b34c7174e75db5ab43ff3d76a1c7027126e8c9b3 | tox.ini |
<mask> def __init__(self, app, environ):
<mask> self.app = app
<mask> self.request = app.request_class(environ)
<mask> self.url_adapter = app.create_url_adapter(self.request)
<mask> self.session = app.open_session(self.request)
<mask> if self.session is None:
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b3fc9eb36b8021ad966be57532a5fa5ae4231e13 | flask/ctx.py | |
self.session = None | <mask> self.url_adapter = app.create_url_adapter(self.request)
<mask> self.g = _RequestGlobals()
<mask> self.flashes = None
<mask>
<mask> try:
<mask> url_rule, self.request.view_args = \
<mask> self.url_adapter.match(return_rule=True)
<mask> ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b3fc9eb36b8021ad966be57532a5fa5ae4231e13 | flask/ctx.py |
# Open the session at the moment that the request context is
# available. This allows a custom open_session method to use the
# request context (e.g. flask-sqlalchemy).
self.session = self.app.open_session(self.request)
if self.session is None:
self.session = _NullSes... | <mask> _request_ctx_stack.push(self)
<mask>
<mask> def pop(self):
<mask> """Pops the request context."""
<mask> _request_ctx_stack.pop()
<mask>
<mask> def __enter__(self):
</s> Open the session after the request context is pushed on the stack instead of in the constructor. This... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b3fc9eb36b8021ad966be57532a5fa5ae4231e13 | flask/ctx.py |
if isinstance(app, Flask): | <mask>
<mask> # Search for the most common names first.
<mask> for attr_name in 'app', 'application':
<mask> app = getattr(module, attr_name, None)
<mask> if app is not None and isinstance(app, Flask):
<mask> return app
<mask>
<mask> # Otherwise find the only object tha... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b4eb6534d52e86af3979b06734e5779f6bb9a4f6 | flask/cli.py |
if callable(app_factory): | <mask>
<mask> # Search for app factory callables.
<mask> for attr_name in 'create_app', 'make_app':
<mask> app_factory = getattr(module, attr_name, None)
<mask> if app_factory is not None and callable(app_factory):
<mask> try:
<mask> app = app_factory()
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b4eb6534d52e86af3979b06734e5779f6bb9a4f6 | flask/cli.py |
if isinstance(app, Flask): | <mask> app_factory = getattr(module, attr_name, None)
<mask> if app_factory is not None and callable(app_factory):
<mask> try:
<mask> app = app_factory()
<mask> if app is not None and isinstance(app, Flask):
<mask> return app
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b4eb6534d52e86af3979b06734e5779f6bb9a4f6 | flask/cli.py |
raise NoAppException(
'Auto-detected "{callable}()" in module "{module}", but '
'could not call it without specifying arguments.'
.format(callable=attr_name,
module=module.__name__))
raise NoAppException(
... | <mask> app = app_factory()
<mask> if app is not None and isinstance(app, Flask):
<mask> return app
<mask> except TypeError:
<mask> raise NoAppException('Auto-detected "%s()" in module "%s", '
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b4eb6534d52e86af3979b06734e5779f6bb9a4f6 | flask/cli.py |
r'\(__name__\s*(?:,\s*(?:name\s*=\s*)?(%s))?' % | <mask> _url_for_re = re.compile(r'\b(url_for\()(%s)' % _string_re_part)
<mask> _render_template_re = re.compile(r'\b(render_template\()(%s)' % _string_re_part)
<mask> _after_request_re = re.compile(r'((?:@\S+\.(?:app_)?))(after_request)(\b\s*$)(?m)')
<mask> _module_constructor_re = re.compile(r'([a-zA-Z0-9_][a-zA-Z... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b4ffa4d9ac9cd652e94a97fa633f021d2f934582 | scripts/flask-07-upgrade.py |
this_file = os.path.realpath(__file__).rstrip('c') | <mask> make_diff(filename, contents, new_contents)
<mask>
<mask>
<mask> def walk_path(path):
<mask> for dirpath, dirnames, filenames in os.walk(path):
<mask> dirnames[:] = [x for x in dirnames if not x.startswith('.')]
<mask> for filename in filenames:
<mask> filename = os.... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b4ffa4d9ac9cd652e94a97fa633f021d2f934582 | scripts/flask-07-upgrade.py |
if os.path.realpath(filename) == this_file:
continue | <mask> for filename in filenames:
<mask> filename = os.path.join(dirpath, filename)
<mask> if filename.endswith('.py'):
<mask> yield filename, 'python'
<mask> # skip files that are diffs. These might be false positives
<mask> # when run mult... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b4ffa4d9ac9cd652e94a97fa633f021d2f934582 | scripts/flask-07-upgrade.py |
mod3 = Module(__name__, name='somemod', subdomain='meh') | <mask>
<mask> mod = Module(__name__)
<mask> mod2 = Module(__name__, 'testmod2')
<mask>
<mask> app = Flask(__name__)
<mask> app.register_module(mod)
<mask> app.register_module(mod2)
</s> Allow name to be specified as the first parameter but with an explict name. </s> remove ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b4ffa4d9ac9cd652e94a97fa633f021d2f934582 | scripts/testproj/test.py |
.. versionadded:: 0.10
The `_scheme` parameter was added.
| <mask> that this is for building URLs outside the current application, and not for
<mask> handling 404 NotFound errors.
<mask>
<mask> .. versionadded:: 0.9
<mask> The `_anchor` and `_method` parameters were added.
<mask>
<mask> .. versionadded:: 0.9
<mask> Calls :meth:`Flask.hand... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b5069d07a24a3c3a54fb056aa6f4076a0e7088c7 | flask/helpers.py |
:param _scheme: a string specifying the desired URL scheme. The `_external`
parameter must be set to `True` or a `ValueError` is raised. | <mask> :param _external: if set to `True`, an absolute URL is generated. Server
<mask> address can be changed via `SERVER_NAME` configuration variable which
<mask> defaults to `localhost`.
<mask> :param _anchor: if provided this is added as anchor to the URL.
<mask> :param _method: if provi... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b5069d07a24a3c3a54fb056aa6f4076a0e7088c7 | flask/helpers.py |
scheme = values.pop('_scheme', None) | <mask> external = values.pop('_external', True)
<mask>
<mask> anchor = values.pop('_anchor', None)
<mask> method = values.pop('_method', None)
<mask> appctx.app.inject_url_defaults(endpoint, values)
<mask>
<mask> if scheme is not None:
<mask> if not external:
<mask> ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b5069d07a24a3c3a54fb056aa6f4076a0e7088c7 | flask/helpers.py |
if scheme is not None:
if not external:
raise ValueError('When specifying _scheme, _external must be True')
url_adapter.url_scheme = scheme
| <mask> scheme = values.pop('_scheme', None)
<mask> appctx.app.inject_url_defaults(endpoint, values)
<mask> try:
<mask> rv = url_adapter.build(endpoint, values, method=method,
<mask> force_external=external)
<mask> except BuildError, error:
<mask> # W... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b5069d07a24a3c3a54fb056aa6f4076a0e7088c7 | flask/helpers.py |
- :func:`send_file` encodes filenames as ASCII instead of Latin-1
(ISO-8859-1). This fixes compatibility with Gunicorn, which is
stricter about header encodings than PEP 3333. (`#2766`_)
.. _#2766: https://github.com/pallets/flask/issues/2766
| <mask> -------------
<mask>
<mask> Unreleased
<mask>
<mask>
<mask> Version 1.0.2
<mask> -------------
<mask>
<mask> Released on May 2nd 2018
</s> encode filenames as ascii instead of latin-1
latin-1 is allowed by pep3333, but that breaks gunicorn </s> remove 'NFKD', attachment_filename... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b51ab3ff2c4af7e592e649e0e97657154b79c11f | CHANGES.rst |
.. versionchanged:: 1.0.3
Filenames are encoded with ASCII instead of Latin-1 for broader
compatibility with WSGI servers.
| <mask> .. _RFC 2231: https://tools.ietf.org/html/rfc2231#section-4
<mask>
<mask> :param filename_or_fp: the filename of the file to send.
<mask> This is relative to the :attr:`~Flask.root_path`
<mask> if a relative path is specified.
<mask> ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b51ab3ff2c4af7e592e649e0e97657154b79c11f | flask/helpers.py |
attachment_filename = attachment_filename.encode('ascii') | <mask> raise TypeError('filename unavailable, required for '
<mask> 'sending as attachment')
<mask>
<mask> try:
<mask> attachment_filename = attachment_filename.encode('latin-1')
<mask> except UnicodeEncodeError:
<mask> filenames = ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b51ab3ff2c4af7e592e649e0e97657154b79c11f | flask/helpers.py |
'NFKD', attachment_filename).encode('ascii', 'ignore'), | <mask> attachment_filename = attachment_filename.encode('latin-1')
<mask> except UnicodeEncodeError:
<mask> filenames = {
<mask> 'filename': unicodedata.normalize(
<mask> 'NFKD', attachment_filename).encode('latin-1', 'ignore'),
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b51ab3ff2c4af7e592e649e0e97657154b79c11f | flask/helpers.py |
content_disposition = rv.headers['Content-Disposition']
assert 'filename=%s' % ascii in content_disposition
if utf8:
assert "filename*=UTF-8''" + utf8 in content_disposition
else:
assert "filename*=UTF-8''" not in content_disposition | <mask> ))
<mask> def test_attachment_filename_encoding(self, filename, ascii, utf8):
<mask> rv = flask.send_file('static/index.html', as_attachment=True, attachment_filename=filename)
<mask> rv.close()
<mask>
<mask> def test_static_file(self, app, req_ctx):
<mask> # default c... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b51ab3ff2c4af7e592e649e0e97657154b79c11f | tests/test_helpers.py |
@app.route('/key') | <mask> assert rv.data == b'E2'
<mask>
<mask>
<mask> def test_trapping_of_bad_request_key_errors(app, client):
<mask> @app.route('/fail')
<mask> def fail():
<mask> flask.request.form['missing_key']
<mask>
<mask> rv = client.get('/fail')
<mask> assert rv.status_code == 400
</s> t... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b573a86977161b93152dddb5bfc43195335b3c59 | tests/test_basic.py |
rv = client.get('/abort')
assert rv.status_code == 400 | <mask> rv = client.get('/key')
<mask> assert rv.status_code == 400
<mask> assert b'missing_key' not in rv.data
<mask>
<mask> app.debug = True
<mask> with pytest.raises(KeyError) as e:
<mask> client.get("/key")
<mask> assert e.errisinstance(BadRequest)
<mask> assert 'missing... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b573a86977161b93152dddb5bfc43195335b3c59 | tests/test_basic.py |
app.debug = True | <mask> rv = client.get('/fail')
<mask> assert rv.status_code == 400
<mask> assert b'missing_key' not in rv.data
<mask>
<mask> app.config['TRAP_BAD_REQUEST_ERRORS'] = True
<mask>
<mask> with pytest.raises(KeyError) as e:
<mask> client.get("/fail")
<mask>
<mask> assert e.erris... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b573a86977161b93152dddb5bfc43195335b3c59 | tests/test_basic.py |
client.get("/key") | <mask>
<mask> app.config['TRAP_BAD_REQUEST_ERRORS'] = True
<mask>
<mask> with pytest.raises(KeyError) as e:
<mask> client.get("/fail")
<mask>
<mask> assert e.errisinstance(BadRequest)
<mask> assert 'missing_key' in e.value.description
<mask>
<mask>
<mask> def test_trapping_of_all... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b573a86977161b93152dddb5bfc43195335b3c59 | tests/test_basic.py |
rv = client.get('/abort')
assert rv.status_code == 400
app.debug = False
app.config['TRAP_BAD_REQUEST_ERRORS'] = True
with pytest.raises(KeyError):
client.get('/key')
with pytest.raises(BadRequest):
client.get('/abort') | <mask> client.get("/key")
<mask> assert e.errisinstance(BadRequest)
<mask> assert 'missing_key' in e.value.description
<mask>
<mask>
<mask> def test_trapping_of_all_http_exceptions(app, client):
<mask> app.config['TRAP_HTTP_EXCEPTIONS'] = True
<mask>
<mask> @app.route('/fail')
</s> ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b573a86977161b93152dddb5bfc43195335b3c59 | tests/test_basic.py |
- Removed error handler caching because it caused unexpected results for some
exception inheritance hierarchies. Register handlers explicitly for each
exception if you don't want to traverse the MRO. (`#2362`_) | <mask> (`#2358`_)
<mask> - Extract JSON handling to a mixin applied to both the request and response
<mask> classes used by Flask. This adds the ``is_json`` and ``get_json`` methods to
<mask> the response to make testing JSON response much easier. (`#2358`_)
<mask>
<mask> .. _#1489: https://github.com/pall... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/b5f4c5215022a01823675038bc246dd1d771a543 | CHANGES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.