From d9a552a8640b7561cc8f000d8f2b99ba7f8e28ca Mon Sep 17 00:00:00 2001 From: bernimoses Date: Fri, 14 Feb 2014 11:39:57 +0100 Subject: [PATCH 1/3] Fixed SyntaxErrors. --- run.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/run.py b/run.py index c22cc03..3aa32f1 100755 --- a/run.py +++ b/run.py @@ -1,9 +1,10 @@ #!/usr/bin/env python + +from __future__ import print_function + import os import sys import time -from __future__ import print_function - # make sure it's running the mincss here and not anything installed sys.path.insert(0, os.path.dirname(__file__)) from mincss.processor import Processor @@ -44,7 +45,7 @@ def run(args): before_name = 'before_' + link.href.split('/')[-1] with open(os.path.join(output_dir, before_name), 'w') as f: f.write(link.before.encode('utf-8')) - print("Files written to", output_dir + print("Files written to", output_dir) print() print( '(from %d to %d saves %d)' % From 9424e0c98ade9efe799f712e0b7adb7390870990 Mon Sep 17 00:00:00 2001 From: bernimoses Date: Fri, 14 Feb 2014 11:40:10 +0100 Subject: [PATCH 2/3] Fixed UnicodeEncodeError. --- run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.py b/run.py index 3aa32f1..922c165 100755 --- a/run.py +++ b/run.py @@ -41,7 +41,7 @@ def run(args): #print(link.after) orig_name = link.href.split('/')[-1] with open(os.path.join(output_dir, orig_name), 'w') as f: - f.write(link.after) + f.write(link.after.encode('utf-8')) before_name = 'before_' + link.href.split('/')[-1] with open(os.path.join(output_dir, before_name), 'w') as f: f.write(link.before.encode('utf-8')) From 2f5c13f7f1917999f281fe88331919a7e0cdcf7d Mon Sep 17 00:00:00 2001 From: bernimoses Date: Tue, 11 Jul 2017 13:49:10 +0200 Subject: [PATCH 3/3] Use codecs.open instead of open. --- run.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/run.py b/run.py index fc90558..93e3682 100755 --- a/run.py +++ b/run.py @@ -3,6 +3,7 @@ import os import sys import time +import codecs # make sure it's running the mincss here and not anything installed @@ -40,11 +41,11 @@ def run(args): #print("AFTER ".ljust(79, '-')) #print(link.after) orig_name = link.href.split('/')[-1] - with open(os.path.join(output_dir, orig_name), 'w') as f: - f.write(link.after.encode('utf-8')) + with codecs.open(os.path.join(output_dir, orig_name), 'w') as f: + f.write(link.after) before_name = 'before_' + link.href.split('/')[-1] - with open(os.path.join(output_dir, before_name), 'w') as f: - f.write(link.before.encode('utf-8')) + with codecs.open(os.path.join(output_dir, before_name), 'w') as f: + f.write(link.before) print("Files written to", output_dir) print() print(