當前位置: 首頁>>代碼示例>>Python>>正文


Python epylint.py_run方法代碼示例

本文整理匯總了Python中pylint.epylint.py_run方法的典型用法代碼示例。如果您正苦於以下問題:Python epylint.py_run方法的具體用法?Python epylint.py_run怎麽用?Python epylint.py_run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pylint.epylint的用法示例。


在下文中一共展示了epylint.py_run方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: process_python

# 需要導入模塊: from pylint import epylint [as 別名]
# 或者: from pylint.epylint import py_run [as 別名]
def process_python(self, path):
        """Process a python file."""
        (pylint_stdout, pylint_stderr) = epylint.py_run(
            ' '.join([str(path)] + self.pylint_opts), return_std=True)
        emap = {}
        err = pylint_stderr.read()
        if len(err):
            print(err)
        for line in pylint_stdout:
            sys.stderr.write(line)
            key = line.split(':')[-1].split('(')[0].strip()
            if key not in self.pylint_cats:
                continue
            if key not in emap:
                emap[key] = 1
            else:
                emap[key] += 1
        self.python_map[str(path)] = emap 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:20,代碼來源:lint.py

示例2: process_python

# 需要導入模塊: from pylint import epylint [as 別名]
# 或者: from pylint.epylint import py_run [as 別名]
def process_python(self, path):
        """Process a python file."""
        (pylint_stdout, pylint_stderr) = epylint.py_run(
            ' '.join([str(path)] + self.pylint_opts), return_std=True)
        emap = {}
        print pylint_stderr.read()
        for line in pylint_stdout:
            sys.stderr.write(line)
            key = line.split(':')[-1].split('(')[0].strip()
            if key not in self.pylint_cats:
                continue
            if key not in emap:
                emap[key] = 1
            else:
                emap[key] += 1
        sys.stderr.write('\n')
        self.python_map[str(path)] = emap 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:19,代碼來源:lint.py

示例3: process_python

# 需要導入模塊: from pylint import epylint [as 別名]
# 或者: from pylint.epylint import py_run [as 別名]
def process_python(self, path):
        """Process a python file."""
        (pylint_stdout, pylint_stderr) = epylint.py_run(
            ' '.join([str(path)] + self.pylint_opts), return_std=True)
        emap = {}
        print(pylint_stderr.read())
        for line in pylint_stdout:
            sys.stderr.write(line)
            key = line.split(':')[-1].split('(')[0].strip()
            if key not in self.pylint_cats:
                continue
            if key not in emap:
                emap[key] = 1
            else:
                emap[key] += 1
        sys.stderr.write('\n')
        self.python_map[str(path)] = emap 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:19,代碼來源:lint.py

示例4: lint_code

# 需要導入模塊: from pylint import epylint [as 別名]
# 或者: from pylint.epylint import py_run [as 別名]
def lint_code(self, code):
        self.counter += 1
        path = self.path + "/{}.py".format(self.counter)
        with open(path, "w") as codefile:
            codefile.write(code)

        future = await self.bot.loop.run_in_executor(None, lint.py_run, path, "return_std=True")

        if future:
            (pylint_stdout, pylint_stderr) = future
        else:
            (pylint_stdout, pylint_stderr) = None, None

        # print(pylint_stderr)
        # print(pylint_stdout)

        return pylint_stdout, pylint_stderr 
開發者ID:bobloy,項目名稱:Fox-V3,代碼行數:19,代碼來源:coglint.py

示例5: _test_script

# 需要導入模塊: from pylint import epylint [as 別名]
# 或者: from pylint.epylint import py_run [as 別名]
def _test_script(self, script):
        self.assertTrue(os.path.exists(script))
        out, err = lint.py_run("%s -E --extension-pkg-whitelist=numpy,scipy.fftpack --init-hook='import sys; sys.path=[%s]; sys.path.insert(0, \"%s\")'" % (script, ",".join(['"%s"' % p for p in sys.path]), os.path.dirname(BIFROST_DIR)), return_std=True)
        out_lines = out.read().split('\n')
        err_lines = err.read().split('\n')
        out.close()
        err.close()
        
        for line in out_lines:
            #if line.find("Module 'numpy") != -1:
            #    continue
            #if line.find("module 'scipy.fftpack") != -1:
            #    continue
                
            mtch = _LINT_RE.match(line)
            if mtch is not None:
                line_no, type, info = mtch.group('line'), mtch.group('type'), mtch.group('info')
                self.assertEqual(type, None, "%s:%s - %s" % (os.path.basename(script), line_no, info)) 
開發者ID:ledatelescope,項目名稱:bifrost,代碼行數:20,代碼來源:test_scripts.py

示例6: test_pylint

# 需要導入模塊: from pylint import epylint [as 別名]
# 或者: from pylint.epylint import py_run [as 別名]
def test_pylint(self):
        (stdout, _) = lint.py_run('datacats', return_std=True)
        stdout_str = stdout.read().strip()
        self.failIf(stdout_str, stdout_str) 
開發者ID:datacats,項目名稱:datacats,代碼行數:6,代碼來源:test_style.py

示例7: test_pylint

# 需要導入模塊: from pylint import epylint [as 別名]
# 或者: from pylint.epylint import py_run [as 別名]
def test_pylint(self):
        (stdout, _) = lint.py_run('kademlia', return_std=True)
        errors = stdout.read()
        if errors.strip():
            raise LintError(errors)

    # pylint: disable=no-self-use 
開發者ID:bmuller,項目名稱:kademlia,代碼行數:9,代碼來源:test_linting.py

示例8: lint

# 需要導入模塊: from pylint import epylint [as 別名]
# 或者: from pylint.epylint import py_run [as 別名]
def lint(full=False):
    from pylint import epylint

    sources = [Config.root, Config.meka, Config.skmultilearn]
    if full:
        fullReport = 'y'
    else:
        fullReport = 'n'

    config = "--rcfile ./utils/pylint.config --msg-template=\"{C}:{msg_id}:{line:3d},{column:2d}:{msg}({symbol})\" -r %s %s"
    for dir in sources:
        print 'lint %s' %dir
        epylint.py_run(config % (fullReport, dir), script='pylint') 
開發者ID:scikit-multilearn,項目名稱:scikit-multilearn,代碼行數:15,代碼來源:utils.py

示例9: evaluate_pylint

# 需要導入模塊: from pylint import epylint [as 別名]
# 或者: from pylint.epylint import py_run [as 別名]
def evaluate_pylint(text):
    """Create temp files for pylint parsing on user code

    :param text: user code
    :return: dictionary of pylint errors:
        {
            {
                "code":...,
                "error": ...,
                "message": ...,
                "line": ...,
                "error_info": ...,
            }
            ...
        }
    """
    # Open temp file for specific session.
    # IF it doesn't exist (aka the key doesn't exist), create one
    try:
        session["file_name"]
        f = open(session["file_name"], "w")
        for t in text:
            f.write(t)
        f.flush()
    except KeyError as e:
        with tempfile.NamedTemporaryFile(delete=False) as temp:
            session["file_name"] = temp.name
            for t in text:
                temp.write(t.encode("utf-8"))
            temp.flush()

    try:
        ARGS = " -r n --disable=R,C"
        (pylint_stdout, pylint_stderr) = lint.py_run(
            session["file_name"] + ARGS, return_std=True)
    except Exception as e:
        raise Exception(e)

    if pylint_stderr.getvalue():
        raise Exception("Issue with pylint configuration")

    return format_errors(pylint_stdout.getvalue())

# def split_error_gen(error):
#     """Inspired by this Python discussion: https://bugs.python.org/issue17343
#     Uses a generator to split error by token and save some space
#
#         :param error: string to be split
#         :yield: next line split by new line
#     """
#     for e in error.split():
#         yield e 
開發者ID:ethanchewy,項目名稱:PythonBuddy,代碼行數:54,代碼來源:app.py


注:本文中的pylint.epylint.py_run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。