Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
283 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ mincss.egg-info/ | |
/build/ | ||
/dist/ | ||
simple.js | ||
*.pyc | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
language: python | ||
|
||
python: | ||
- "2.7" | ||
- "3.3" | ||
|
||
install: | ||
- python setup.py --quiet install | ||
|
||
script: | ||
- nosetests | ||
- mincss https://travis-ci.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
include LICENSE | ||
include README.md | ||
include README.rst | ||
include docs/changelog.rst | ||
include requirements.txt | ||
include mincss/download.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
|
||
from . import main | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main.main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from __future__ import print_function | ||
|
||
import io | ||
import os | ||
import time | ||
|
||
from .processor import Processor | ||
|
||
|
||
def run(args): | ||
options = {'debug': args.verbose} | ||
if args.phantomjs_path: | ||
options['phantomjs'] = args.phantomjs_path | ||
elif args.phantomjs: | ||
options['phantomjs'] = True | ||
p = Processor(**options) | ||
t0 = time.time() | ||
p.process(args.url) | ||
t1 = time.time() | ||
print('TOTAL TIME ', t1 - t0) | ||
for inline in p.inlines: | ||
print('ON', inline.url) | ||
print('AT line', inline.line) | ||
print('BEFORE '.ljust(79, '-')) | ||
print(inline.before) | ||
print('AFTER '.ljust(79, '-')) | ||
print(inline.after) | ||
print() | ||
|
||
output_dir = args.outputdir | ||
if not os.path.isdir(output_dir): | ||
os.mkdir(output_dir) | ||
for link in p.links: | ||
print('FOR', link.href) | ||
orig_name = link.href.split('/')[-1] | ||
with io.open(os.path.join(output_dir, orig_name), 'w') as f: | ||
f.write(link.after) | ||
before_name = 'before_' + link.href.split('/')[-1] | ||
with io.open(os.path.join(output_dir, before_name), 'w') as f: | ||
f.write(link.before) | ||
print('Files written to', output_dir) | ||
print() | ||
print( | ||
'(from %d to %d saves %d)' % | ||
(len(link.before), len(link.after), | ||
len(link.before) - len(link.after)) | ||
) | ||
|
||
return 0 | ||
|
||
|
||
def main(): | ||
import argparse | ||
parser = argparse.ArgumentParser() | ||
add = parser.add_argument | ||
add('url', type=str, | ||
help='URL to process') | ||
add('--outputdir', action='store', | ||
default='./output', | ||
help='directory where to put output (default ./output)') | ||
add('-v', '--verbose', action='store_true', | ||
help='increase output verbosity') | ||
add('--phantomjs', action='store_true', | ||
help='Use PhantomJS to download the source') | ||
add('--phantomjs-path', action='store', | ||
default='', | ||
help='Where is the phantomjs executable') | ||
|
||
args = parser.parse_args() | ||
return run(args) |
Oops, something went wrong.