[Pkg-mozext-commits] [adblock-plus] 61/87: Issue 3952 - Fix whitespaces for compliance with PEP-8
David Prévot
taffit at moszumanska.debian.org
Sat Apr 30 17:59:08 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit 27f7a14cd4815d228c204c49b55d80a11f26cfac
Author: Sebastian Noack <sebastian at adblockplus.org>
Date: Mon Apr 18 14:23:07 2016 +0200
Issue 3952 - Fix whitespaces for compliance with PEP-8
---
abp_rewrite.py | 38 +++++++++++++++------------
autotest.py | 82 +++++++++++++++++++++++++++++++---------------------------
utils.py | 75 +++++++++++++++++++++++++++--------------------------
3 files changed, 103 insertions(+), 92 deletions(-)
diff --git a/abp_rewrite.py b/abp_rewrite.py
index ad7be1c..85003af 100755
--- a/abp_rewrite.py
+++ b/abp_rewrite.py
@@ -5,26 +5,30 @@
# version 2.0 (the "License"). You can obtain a copy of the License at
# http://mozilla.org/MPL/2.0/.
-import sys, os, subprocess, utils
+import sys
+import os
+import subprocess
+import utils
+
def doRewrite(files, args):
- application = utils.ensureJSShell()
+ application = utils.ensureJSShell()
- env = {
- 'LD_LIBRARY_PATH': os.path.relpath(os.path.dirname(application)),
- }
+ env = {
+ 'LD_LIBRARY_PATH': os.path.relpath(os.path.dirname(application)),
+ }
- baseDir = os.path.dirname(utils.__file__)
- command = [
- application, os.path.join(baseDir, 'jshydra.js'),
- os.path.join(baseDir, 'scripts', 'abprewrite.js'),
- '--arg', ' '.join(args)
- ] + files
- return subprocess.check_output(command, env=env).replace('\r', '')
+ baseDir = os.path.dirname(utils.__file__)
+ command = [
+ application, os.path.join(baseDir, 'jshydra.js'),
+ os.path.join(baseDir, 'scripts', 'abprewrite.js'),
+ '--arg', ' '.join(args)
+ ] + files
+ return subprocess.check_output(command, env=env).replace('\r', '')
if __name__ == '__main__':
- try:
- scriptArgsStart = sys.argv.index('--arg')
- except ValueError:
- scriptArgsStart = len(sys.argv)
- print doRewrite(sys.argv[1:scriptArgsStart], sys.argv[scriptArgsStart + 1:])
+ try:
+ scriptArgsStart = sys.argv.index('--arg')
+ except ValueError:
+ scriptArgsStart = len(sys.argv)
+ print doRewrite(sys.argv[1:scriptArgsStart], sys.argv[scriptArgsStart + 1:])
diff --git a/autotest.py b/autotest.py
index f3e1cef..d7f5710 100755
--- a/autotest.py
+++ b/autotest.py
@@ -5,45 +5,51 @@
# version 2.0 (the "License"). You can obtain a copy of the License at
# http://mozilla.org/MPL/2.0/.
-import sys, os, subprocess, re, difflib, utils
+import sys
+import os
+import subprocess
+import re
+import difflib
+import utils
+
def run_tests():
- application = utils.ensureJSShell()
- env = {
- 'LD_LIBRARY_PATH': os.path.relpath(os.path.dirname(application)),
- }
-
- baseDir = os.path.dirname(utils.__file__)
- testDir = os.path.join(baseDir, 'autotest')
- for file in os.listdir(testDir):
- if not re.search(r'^test_.*\.js$', file):
- continue
-
- file = os.path.join(testDir, file)
- handle = open(file, 'r')
- name = None
- arguments = None
- for line in handle:
- match = re.search(r'^//\s*([A-Za-z]+):\s*(.*?)\s*$', line)
- if match and match.group(1).lower() == 'name':
- name = match.group(2)
- elif match and match.group(1).lower() == 'arguments':
- arguments = match.group(2).split(' ')
- handle.close()
-
- if arguments == None:
- continue
-
- command = [application, os.path.join(baseDir, 'jshydra.js'), file] + arguments
- out = subprocess.check_output(command, stderr=subprocess.STDOUT, env=env).replace('\r', '')
- expected = open(file + '.expected', 'r').read().replace('\r', '')
- if out == expected:
- print '%s passed' % name
- else:
- print '%s failed! Log:' % name
- for line in difflib.unified_diff(expected.split('\n'), out.split('\n'), fromfile=file + '.expected', tofile=file + '.output'):
- print line
- print
+ application = utils.ensureJSShell()
+ env = {
+ 'LD_LIBRARY_PATH': os.path.relpath(os.path.dirname(application)),
+ }
+
+ baseDir = os.path.dirname(utils.__file__)
+ testDir = os.path.join(baseDir, 'autotest')
+ for file in os.listdir(testDir):
+ if not re.search(r'^test_.*\.js$', file):
+ continue
+
+ file = os.path.join(testDir, file)
+ handle = open(file, 'r')
+ name = None
+ arguments = None
+ for line in handle:
+ match = re.search(r'^//\s*([A-Za-z]+):\s*(.*?)\s*$', line)
+ if match and match.group(1).lower() == 'name':
+ name = match.group(2)
+ elif match and match.group(1).lower() == 'arguments':
+ arguments = match.group(2).split(' ')
+ handle.close()
+
+ if arguments == None:
+ continue
+
+ command = [application, os.path.join(baseDir, 'jshydra.js'), file] + arguments
+ out = subprocess.check_output(command, stderr=subprocess.STDOUT, env=env).replace('\r', '')
+ expected = open(file + '.expected', 'r').read().replace('\r', '')
+ if out == expected:
+ print '%s passed' % name
+ else:
+ print '%s failed! Log:' % name
+ for line in difflib.unified_diff(expected.split('\n'), out.split('\n'), fromfile=file + '.expected', tofile=file + '.output'):
+ print line
+ print
if __name__ == '__main__':
- run_tests()
+ run_tests()
diff --git a/utils.py b/utils.py
index dc41390..3c9a752 100644
--- a/utils.py
+++ b/utils.py
@@ -17,47 +17,48 @@ JSSHELL_URL = ("https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly"
"/2015/02/2015-02-25-00-22-19-%s/jsshell-%%s.zip" % JSSHELL_DIR)
JSSHELL_SUPPORTED_PLATFORMS = {
- "win32": "win32",
- "linux2": {
- "i686": "linux-i686",
- "x86_64": "linux-x86_64"
- },
- "darwin": "mac"
+ "win32": "win32",
+ "linux2": {
+ "i686": "linux-i686",
+ "x86_64": "linux-x86_64"
+ },
+ "darwin": "mac"
}
+
def ensureJSShell():
- baseDir = os.path.dirname(__file__)
-
- try:
- build = JSSHELL_SUPPORTED_PLATFORMS[sys.platform]
- if isinstance(build, dict):
- build = build[platform.machine()]
- except KeyError:
- raise Exception('Platform %s (%s) not supported by JS shell' % (
- sys.platform, platform.machine()
- ))
-
- shell_dir = os.path.join(baseDir, JSSHELL_DIR + "-" + build)
- if not os.path.exists(shell_dir):
- os.makedirs(shell_dir)
- if sys.platform == 'win32':
- path = os.path.join(shell_dir, 'js.exe')
- else:
- path = os.path.join(shell_dir, 'js')
-
- if os.path.exists(path):
- return path
+ baseDir = os.path.dirname(__file__)
+
+ try:
+ build = JSSHELL_SUPPORTED_PLATFORMS[sys.platform]
+ if isinstance(build, dict):
+ build = build[platform.machine()]
+ except KeyError:
+ raise Exception('Platform %s (%s) not supported by JS shell' % (
+ sys.platform, platform.machine()
+ ))
- with closing(urllib.urlopen(JSSHELL_URL % build)) as response, \
- zipfile.ZipFile(StringIO(response.read())) as zip:
- zip.extractall(shell_dir)
+ shell_dir = os.path.join(baseDir, JSSHELL_DIR + "-" + build)
+ if not os.path.exists(shell_dir):
+ os.makedirs(shell_dir)
+ if sys.platform == 'win32':
+ path = os.path.join(shell_dir, 'js.exe')
+ else:
+ path = os.path.join(shell_dir, 'js')
- if not os.path.exists(path):
- raise Exception('Downloaded package didn\'t contain JS shell executable')
+ if os.path.exists(path):
+ return path
- try:
- os.chmod(path, 0700)
- except:
- pass
+ with closing(urllib.urlopen(JSSHELL_URL % build)) as response, \
+ zipfile.ZipFile(StringIO(response.read())) as zip:
+ zip.extractall(shell_dir)
- return path
+ if not os.path.exists(path):
+ raise Exception('Downloaded package didn\'t contain JS shell executable')
+
+ try:
+ os.chmod(path, 0700)
+ except:
+ pass
+
+ return path
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list