1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
|
Description: Compatibility with Python 3.7
Author: <pylama@c.michael-kaeufl.de>
Acked-By: Mattia Rizzolo <mattia@debian.org>
Bug-Debian: https://bugs.debian.org/904491
Origin: https://github.com/fmv1992/pylama/pull/2/commits/f835653e21e78c9c2577189956601089d8809f6b
--- a/pylama/config.py
+++ b/pylama/config.py
@@ -128,7 +128,7 @@
"--hook", action="store_true", help="Install Git (Mercurial) hook.")
PARSER.add_argument(
- "--async", action="store_true",
+ "--async", action="store_true", dest='async_mode',
help="Enable async mode. Useful for checking a lot of files. "
"Unsupported with pylint.")
@@ -168,6 +168,8 @@
if config:
cfg = get_config(str(options.options), rootdir=rootdir)
for opt, val in cfg.default.items():
+ if opt == 'async':
+ opt = 'async_mode'
LOGGER.info('Find option %s (%s)', opt, val)
passed_value = getattr(options, opt, _Default())
if isinstance(passed_value, _Default):
@@ -199,9 +201,9 @@
if isinstance(value, _Default):
setattr(options, name, process_value(name, value.value))
- if options.async and 'pylint' in options.linters:
+ if options.async_mode and 'pylint' in options.linters:
LOGGER.warning('Can\'t parse code asynchronously with pylint enabled.')
- options.async = False
+ options.async_mode = False
return options
--- a/pylama/main.py
+++ b/pylama/main.py
@@ -7,7 +7,7 @@
from .config import parse_options, CURDIR, setup_logger
from .core import LOGGER, run
-from .async import check_async
+from .async_mode import check_async
def check_path(options, rootdir=None, candidates=None, code=None):
@@ -43,7 +43,7 @@
paths.append(path)
- if options.async:
+ if options.async_mode:
return check_async(paths, options, rootdir)
errors = []
--- a/pylama/async.py
+++ /dev/null
@@ -1,75 +0,0 @@
-"""Support for checking code asynchronously."""
-
-import logging
-import threading
-
-try:
- import Queue
-except ImportError:
- import queue as Queue
-
-
-try:
- import multiprocessing
-
- CPU_COUNT = multiprocessing.cpu_count()
-
-except (ImportError, NotImplementedError):
- CPU_COUNT = 1
-
-from .core import run
-
-
-LOGGER = logging.getLogger('pylama')
-
-
-class Worker(threading.Thread):
- """Get tasks from queue and run."""
-
- def __init__(self, path_queue, result_queue):
- """ Init worker. """
- threading.Thread.__init__(self)
- self.path_queue = path_queue
- self.result_queue = result_queue
-
- def run(self):
- """ Run tasks from queue. """
- while True:
- path, params = self.path_queue.get()
- errors = run(path, **params)
- self.result_queue.put(errors)
- self.path_queue.task_done()
-
-
-def check_async(paths, options, rootdir=None):
- """Check given paths asynchronously.
-
- :return list: list of errors
-
- """
- LOGGER.info('Async code checking is enabled.')
- path_queue = Queue.Queue()
- result_queue = Queue.Queue()
-
- for num in range(CPU_COUNT):
- worker = Worker(path_queue, result_queue)
- worker.setDaemon(True)
- LOGGER.info('Start worker #%s', (num + 1))
- worker.start()
-
- for path in paths:
- path_queue.put((path, dict(options=options, rootdir=rootdir)))
-
- path_queue.join()
-
- errors = []
- while True:
- try:
- errors += result_queue.get(False)
- except Queue.Empty:
- break
-
- return errors
-
-
-# pylama:ignore=W0212,D210,F0001
--- /dev/null
+++ b/pylama/async_mode.py
@@ -0,0 +1,75 @@
+"""Support for checking code asynchronously."""
+
+import logging
+import threading
+
+try:
+ import Queue
+except ImportError:
+ import queue as Queue
+
+
+try:
+ import multiprocessing
+
+ CPU_COUNT = multiprocessing.cpu_count()
+
+except (ImportError, NotImplementedError):
+ CPU_COUNT = 1
+
+from .core import run
+
+
+LOGGER = logging.getLogger('pylama')
+
+
+class Worker(threading.Thread):
+ """Get tasks from queue and run."""
+
+ def __init__(self, path_queue, result_queue):
+ """ Init worker. """
+ threading.Thread.__init__(self)
+ self.path_queue = path_queue
+ self.result_queue = result_queue
+
+ def run(self):
+ """ Run tasks from queue. """
+ while True:
+ path, params = self.path_queue.get()
+ errors = run(path, **params)
+ self.result_queue.put(errors)
+ self.path_queue.task_done()
+
+
+def check_async(paths, options, rootdir=None):
+ """Check given paths asynchronously.
+
+ :return list: list of errors
+
+ """
+ LOGGER.info('Async code checking is enabled.')
+ path_queue = Queue.Queue()
+ result_queue = Queue.Queue()
+
+ for num in range(CPU_COUNT):
+ worker = Worker(path_queue, result_queue)
+ worker.setDaemon(True)
+ LOGGER.info('Start worker #%s', (num + 1))
+ worker.start()
+
+ for path in paths:
+ path_queue.put((path, dict(options=options, rootdir=rootdir)))
+
+ path_queue.join()
+
+ errors = []
+ while True:
+ try:
+ errors += result_queue.get(False)
+ except Queue.Empty:
+ break
+
+ return errors
+
+
+# pylama:ignore=W0212,D210,F0001
|