pep8
This commit is contained in:
@@ -4,8 +4,6 @@ css-js-minify wrapper for Pelican
|
||||
"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
|
||||
from .minify import (
|
||||
process_single_css_file,
|
||||
@@ -17,6 +15,7 @@ from pelican import signals
|
||||
CSS_DIR = '/theme/css'
|
||||
JS_DIR = '/theme/js'
|
||||
|
||||
|
||||
def main(pelican):
|
||||
""" Compiler """
|
||||
for file in glob.iglob(pelican.output_path + CSS_DIR + '/**/*.css', recursive=True):
|
||||
@@ -24,10 +23,12 @@ def main(pelican):
|
||||
for file in glob.iglob(pelican.output_path + JS_DIR + '/**/*.js', recursive=True):
|
||||
process_single_js_file(file, overwrite=True)
|
||||
|
||||
|
||||
def register():
|
||||
""" Register """
|
||||
signals.finalized.connect(main)
|
||||
|
||||
|
||||
SUPPORT_JS = """
|
||||
-----------------------------------------------------------------
|
||||
COMPRESSOR:
|
||||
|
||||
@@ -13,8 +13,8 @@ def remove_commented_lines(js):
|
||||
"""Force remove commented out lines from Javascript."""
|
||||
result = ""
|
||||
for line in js.splitlines():
|
||||
line = re.sub(r"/\*.*\*/", "", line) # (/*COMMENT */)
|
||||
line = re.sub(r"//.*", "", line) # (//COMMENT)
|
||||
line = re.sub(r"/\*.*\*/", "", line) # (/*COMMENT */)
|
||||
line = re.sub(r"//.*", "", line) # (//COMMENT)
|
||||
result += '\n'+line
|
||||
return result
|
||||
|
||||
|
||||
@@ -27,11 +27,12 @@ __all__ = ('process_multiple_files', 'prefixer_extensioner',
|
||||
'make_arguments_parser', 'main')
|
||||
|
||||
color = {
|
||||
'cyan' : '\033[1;36m',
|
||||
'end' : '\033[0m',
|
||||
'green' : '\033[1;32m'
|
||||
'cyan': '\033[1;36m',
|
||||
'end': '\033[0m',
|
||||
'green': '\033[1;32m'
|
||||
}
|
||||
|
||||
|
||||
def process_multiple_files(file_path, watch=False, wrap=False, timestamp=False,
|
||||
comments=False, sort=False, overwrite=False,
|
||||
zipy=False, prefix='', add_hash=False):
|
||||
@@ -95,7 +96,9 @@ def process_single_css_file(css_file_path, wrap=False, timestamp=False,
|
||||
zipy=False, prefix='', add_hash=False,
|
||||
output_path=None):
|
||||
"""Process a single CSS file."""
|
||||
print("Processing %sCSS%s file: %s" % (color['cyan'], color['end'], css_file_path))
|
||||
print("Processing %sCSS%s file: %s" % (color['cyan'],
|
||||
color['end'],
|
||||
css_file_path))
|
||||
with open(css_file_path, encoding="utf-8") as css_file:
|
||||
original_css = css_file.read()
|
||||
|
||||
@@ -134,7 +137,9 @@ def process_single_css_file(css_file_path, wrap=False, timestamp=False,
|
||||
def process_single_js_file(js_file_path, timestamp=False, overwrite=False,
|
||||
zipy=False, output_path=None):
|
||||
"""Process a single JS file."""
|
||||
print("Processing %sJS%s file: %s" % (color['green'], color['end'], js_file_path))
|
||||
print("Processing %sJS%s file: %s" % (color['green'],
|
||||
color['end'],
|
||||
js_file_path))
|
||||
with open(js_file_path, encoding="utf-8") as js_file:
|
||||
original_js = js_file.read()
|
||||
print("INPUT: Reading JS file %s" % js_file_path)
|
||||
@@ -173,7 +178,8 @@ def make_arguments_parser():
|
||||
SHA1 HEX-Digest 11 Chars Hash on Filenames is used for Server Cache.
|
||||
CSS Properties are Alpha-Sorted, to help spot cloned ones, Selectors not.
|
||||
Watch works for whole folders, with minimum of ~60 Secs between runs.""")
|
||||
# parser.add_argument('--version', action='version', version=css_js_minify.__version__)
|
||||
# parser.add_argument('--version', action='version',
|
||||
# version=css_js_minify.__version__)
|
||||
parser.add_argument('fullpath', metavar='fullpath', type=str,
|
||||
help='Full path to local file or folder.')
|
||||
parser.add_argument('--wrap', action='store_true',
|
||||
|
||||
Reference in New Issue
Block a user