From 9ce766c18e74e6df3d41b109d5e03d32240d3a92 Mon Sep 17 00:00:00 2001 From: Cody Date: Fri, 1 Jan 2016 19:38:58 +0000 Subject: [PATCH] Explicitely numbered replacement fields --- setup.py | 2 +- tests/app/tests/test_webpack.py | 2 +- webpack_loader/templatetags/webpack_loader.py | 8 ++++---- webpack_loader/utils.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index cc3a0a12..9f27f749 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ description = 'Transparently use webpack with django', author = 'Owais Lone', author_email = 'hello@owaislone.org', - download_url = 'https://github.com/owais/django-webpack-loader/tarball/{}'.format(version), + download_url = 'https://github.com/owais/django-webpack-loader/tarball/{0}'.format(version), url = 'https://github.com/owais/django-webpack-loader', # use the URL to the github repo keywords = ['django', 'webpack', 'assets'], # arbitrary keywords data_files = [("", ["LICENSE"])], diff --git a/tests/app/tests/test_webpack.py b/tests/app/tests/test_webpack.py index 9d395200..3489e03a 100644 --- a/tests/app/tests/test_webpack.py +++ b/tests/app/tests/test_webpack.py @@ -158,7 +158,7 @@ def test_missing_stats_file(self): try: get_assets(get_config(DEFAULT_CONFIG)) except IOError as e: - expected = 'Error reading {}. Are you sure webpack has generated the file and the path is correct?'.format(settings.WEBPACK_LOADER[DEFAULT_CONFIG]['STATS_FILE']) + expected = 'Error reading {0}. Are you sure webpack has generated the file and the path is correct?'.format(settings.WEBPACK_LOADER[DEFAULT_CONFIG]['STATS_FILE']) self.assertIn(expected, str(e)) def test_bad_status_in_production(self): diff --git a/webpack_loader/templatetags/webpack_loader.py b/webpack_loader/templatetags/webpack_loader.py index dbf5cb58..eaea065f 100644 --- a/webpack_loader/templatetags/webpack_loader.py +++ b/webpack_loader/templatetags/webpack_loader.py @@ -10,7 +10,7 @@ def filter_by_extension(bundle, extension): for chunk in bundle: - if chunk['name'].endswith('.{}'.format(extension)): + if chunk['name'].endswith('.{0}'.format(extension)): yield chunk @@ -19,9 +19,9 @@ def render_as_tags(bundle): for chunk in bundle: url = chunk.get('publicPath') or chunk['url'] if chunk['name'].endswith('.js'): - tags.append(''.format(url)) + tags.append(''.format(url)) elif chunk['name'].endswith('.css'): - tags.append(''.format(url)) + tags.append(''.format(url)) return mark_safe('\n'.join(tags)) @@ -39,7 +39,7 @@ def render_bundle(bundle_name, extension=None, config='DEFAULT'): @register.simple_tag def webpack_static(asset_name, config='DEFAULT'): - return "{}{}".format( + return "{0}{1}".format( get_assets(get_config(config)).get( 'publicPath', getattr(settings, 'STATIC_URL') ), diff --git a/webpack_loader/utils.py b/webpack_loader/utils.py index 420322dd..b2f3e5fb 100644 --- a/webpack_loader/utils.py +++ b/webpack_loader/utils.py @@ -58,7 +58,7 @@ def filter_files(files, config): filename = F['name'] ignore = any(regex.match(filename) for regex in config['ignores']) if not ignore: - relpath = '{}{}'.format(config['BUNDLE_DIR_NAME'], filename) + relpath = '{0}{1}'.format(config['BUNDLE_DIR_NAME'], filename) F['url'] = staticfiles_storage.url(relpath) yield F