Skip to content

Commit 6975cb1

Browse files
Apply black formatting
1 parent 6e07763 commit 6975cb1

33 files changed

+411
-393
lines changed

static_precompiler/compilers/babel.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
from . import base
55
from .. import exceptions, utils
66

7-
__all__ = (
8-
"Babel",
9-
)
7+
__all__ = ("Babel",)
108

119

1210
class Babel(base.BaseCompiler):

static_precompiler/compilers/base.py

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
logger = logging.getLogger("static_precompiler")
1212

1313

14-
__all__ = (
15-
"BaseCompiler",
16-
)
14+
__all__ = ("BaseCompiler",)
1715

1816

1917
class BaseCompiler(object):
@@ -24,7 +22,7 @@ class BaseCompiler(object):
2422
output_extension = None
2523

2624
def is_supported(self, source_path):
27-
""" Return True iff provided source file type is supported by this precompiler.
25+
"""Return True iff provided source file type is supported by this precompiler.
2826
2927
:param source_path: relative path to a source file
3028
:type source_path: str
@@ -35,7 +33,7 @@ def is_supported(self, source_path):
3533

3634
# noinspection PyMethodMayBeStatic
3735
def get_full_source_path(self, source_path):
38-
""" Return the full path to the given source file.
36+
"""Return the full path to the given source file.
3937
Check if the source file exists.
4038
The returned path is OS-dependent.
4139
@@ -63,7 +61,7 @@ def get_full_source_path(self, source_path):
6361
return full_path
6462

6563
def get_output_filename(self, source_filename):
66-
""" Return the name of compiled file based on the name of source file.
64+
"""Return the name of compiled file based on the name of source file.
6765
6866
:param source_filename: name of a source file
6967
:type source_filename: str
@@ -73,7 +71,7 @@ def get_output_filename(self, source_filename):
7371
return "{0}.{1}".format(os.path.splitext(source_filename)[0], self.output_extension)
7472

7573
def get_output_path(self, source_path):
76-
""" Get relative path to compiled file based for the given source file.
74+
"""Get relative path to compiled file based for the given source file.
7775
The returned path is in posix format.
7876
7977
:param source_path: relative path to a source file
@@ -87,7 +85,7 @@ def get_output_path(self, source_path):
8785
return posixpath.join(settings.OUTPUT_DIR, source_dir, output_filename)
8886

8987
def get_full_output_path(self, source_path):
90-
""" Get full path to compiled file based for the given source file.
88+
"""Get full path to compiled file based for the given source file.
9189
The returned path is OS-dependent.
9290
9391
:param source_path: relative path to a source file
@@ -98,7 +96,7 @@ def get_full_output_path(self, source_path):
9896
return os.path.join(settings.ROOT, utils.normalize_path(self.get_output_path(source_path)))
9997

10098
def get_source_mtime(self, source_path):
101-
""" Get the modification time of the source file.
99+
"""Get the modification time of the source file.
102100
103101
:param source_path: relative path to a source file
104102
:type source_path: str
@@ -108,7 +106,7 @@ def get_source_mtime(self, source_path):
108106
return mtime.get_mtime(self.get_full_source_path(source_path))
109107

110108
def get_output_mtime(self, source_path):
111-
""" Get the modification time of the compiled file.
109+
"""Get the modification time of the compiled file.
112110
Return None of compiled file does not exist.
113111
114112
:param source_path: relative path to a source file
@@ -122,7 +120,7 @@ def get_output_mtime(self, source_path):
122120
return mtime.get_mtime(full_output_path)
123121

124122
def should_compile(self, source_path, from_management=False):
125-
""" Return True iff provided source file should be compiled.
123+
"""Return True iff provided source file should be compiled.
126124
127125
:param source_path: relative path to a source file
128126
:type source_path: str
@@ -151,7 +149,7 @@ def should_compile(self, source_path, from_management=False):
151149
return False
152150

153151
def get_source(self, source_path):
154-
""" Get the source code to be compiled.
152+
"""Get the source code to be compiled.
155153
156154
:param source_path: relative path to a source file
157155
:type source_path: str
@@ -161,7 +159,7 @@ def get_source(self, source_path):
161159
return utils.read_file(self.get_full_source_path(source_path))
162160

163161
def compile(self, source_path, from_management=False, verbosity=0):
164-
""" Compile the given source path and return relative path to the compiled file.
162+
"""Compile the given source path and return relative path to the compiled file.
165163
Raise ValueError is the source file type is not supported.
166164
May raise a StaticCompilationError if something goes wrong with compilation.
167165
:param source_path: relative path to a source file
@@ -173,9 +171,7 @@ def compile(self, source_path, from_management=False, verbosity=0):
173171
174172
"""
175173
if not self.is_supported(source_path):
176-
raise ValueError("'{0}' file type is not supported by '{1}'".format(
177-
source_path, self.__class__.__name__
178-
))
174+
raise ValueError("'{0}' file type is not supported by '{1}'".format(source_path, self.__class__.__name__))
179175

180176
compiled_path = self.get_output_path(source_path)
181177

@@ -196,21 +192,21 @@ def compile(self, source_path, from_management=False, verbosity=0):
196192
return compiled_path
197193

198194
def compile_lazy(self, source_path):
199-
""" Return a lazy object which, when translated to string, compiles the specified source path and returns
200-
the path to the compiled file.
201-
Raise ValueError is the source file type is not supported.
202-
May raise a StaticCompilationError if something goes wrong with compilation.
203-
:param source_path: relative path to a source file
204-
:type source_path: str
195+
"""Return a lazy object which, when translated to string, compiles the specified source path and returns
196+
the path to the compiled file.
197+
Raise ValueError is the source file type is not supported.
198+
May raise a StaticCompilationError if something goes wrong with compilation.
199+
:param source_path: relative path to a source file
200+
:type source_path: str
205201
206-
:returns: str
202+
:returns: str
207203
"""
208204
return encoding.force_text(self.compile(source_path))
209205

210206
compile_lazy = functional.lazy(compile_lazy, str)
211207

212208
def compile_file(self, source_path):
213-
""" Compile the source file. Return the relative path to compiled file.
209+
"""Compile the source file. Return the relative path to compiled file.
214210
May raise a StaticCompilationError if something goes wrong with compilation.
215211
216212
:param source_path: path to the source file
@@ -221,7 +217,7 @@ def compile_file(self, source_path):
221217
raise NotImplementedError
222218

223219
def compile_source(self, source):
224-
""" Compile the source code. May raise a StaticCompilationError
220+
"""Compile the source code. May raise a StaticCompilationError
225221
if something goes wrong with compilation.
226222
227223
:param source: source code
@@ -232,7 +228,7 @@ def compile_source(self, source):
232228
raise NotImplementedError
233229

234230
def find_dependencies(self, source_path):
235-
""" Find the dependencies for the given source file.
231+
"""Find the dependencies for the given source file.
236232
237233
:param source_path: relative path to a source file
238234
:type source_path: str
@@ -242,7 +238,7 @@ def find_dependencies(self, source_path):
242238

243239
# noinspection PyMethodMayBeStatic
244240
def get_dependencies(self, source_path):
245-
""" Get the saved dependencies for the given source file.
241+
"""Get the saved dependencies for the given source file.
246242
247243
:param source_path: relative path to a source file
248244
:type source_path: str
@@ -261,7 +257,7 @@ def get_dependencies(self, source_path):
261257

262258
# noinspection PyMethodMayBeStatic
263259
def get_dependents(self, source_path):
264-
""" Get a list of files that depends on the given source file.
260+
"""Get a list of files that depends on the given source file.
265261
266262
:param source_path: relative path to a source file
267263
:type source_path: str
@@ -280,7 +276,7 @@ def get_dependents(self, source_path):
280276

281277
# noinspection PyMethodMayBeStatic
282278
def update_dependencies(self, source_path, dependencies):
283-
""" Updates the saved dependencies for the given source file.
279+
"""Updates the saved dependencies for the given source file.
284280
285281
:param source_path: relative path to a source file
286282
:type source_path: str
@@ -291,9 +287,7 @@ def update_dependencies(self, source_path, dependencies):
291287
if not dependencies:
292288
models.Dependency.objects.filter(source=source_path).delete()
293289
else:
294-
models.Dependency.objects.filter(
295-
source=source_path
296-
).exclude(
290+
models.Dependency.objects.filter(source=source_path).exclude(
297291
depends_on__in=dependencies,
298292
).delete()
299293
for dependency in dependencies:

static_precompiler/compilers/coffeescript.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
from . import base
44
from .. import exceptions, utils
55

6-
__all__ = (
7-
"CoffeeScript",
8-
)
6+
__all__ = ("CoffeeScript",)
97

108

119
class CoffeeScript(base.BaseCompiler):
@@ -27,10 +25,13 @@ def compile_file(self, source_path):
2725
]
2826
if self.is_sourcemap_enabled:
2927
args.append("-m")
30-
args.extend([
31-
"-o", os.path.dirname(full_output_path),
32-
self.get_full_source_path(source_path),
33-
])
28+
args.extend(
29+
[
30+
"-o",
31+
os.path.dirname(full_output_path),
32+
self.get_full_source_path(source_path),
33+
]
34+
)
3435
return_code, out, errors = utils.run_command(args)
3536

3637
if return_code:

static_precompiler/compilers/handlebars.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33
from . import base
44
from .. import exceptions, utils
55

6-
__all__ = (
7-
"Handlebars",
8-
)
6+
__all__ = ("Handlebars",)
97

108

119
class Handlebars(base.BaseCompiler):
1210

1311
name = "handlebars"
14-
input_extensions = ("hbs", "handlebars", )
12+
input_extensions = (
13+
"hbs",
14+
"handlebars",
15+
)
1516
output_extension = "js"
1617

1718
def is_supported(self, source_path):
1819
return os.path.splitext(source_path)[1].lstrip(".") in self.input_extensions
1920

20-
def __init__(self, executable="handlebars", sourcemap_enabled=False, known_helpers=None,
21-
namespace=None, simple=False):
21+
def __init__(
22+
self, executable="handlebars", sourcemap_enabled=False, known_helpers=None, namespace=None, simple=False
23+
):
2224
self.executable = executable
2325
self.is_sourcemap_enabled = sourcemap_enabled
2426
if known_helpers is None:
@@ -57,8 +59,10 @@ def compile_file(self, source_path):
5759
args = [
5860
self.executable,
5961
self.get_full_source_path(source_path),
60-
"-e", template_extension,
61-
"-f", full_output_path,
62+
"-e",
63+
template_extension,
64+
"-f",
65+
full_output_path,
6266
] + self.get_extra_args()
6367

6468
if self.is_sourcemap_enabled:
@@ -77,7 +81,8 @@ def compile_file(self, source_path):
7781
def compile_source(self, source):
7882
args = [
7983
self.executable,
80-
"-i", "-",
84+
"-i",
85+
"-",
8186
] + self.get_extra_args()
8287

8388
return_code, out, errors = utils.run_command(args, input=source)

0 commit comments

Comments
 (0)