[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Mon Apr 27 15:55:05 MDT 2015
The branch, master has been updated
via af03b57 lib: Use isspace on unsigned char
via 38553a3 Add set date to tdb manpages.
via e9809a6 Drop unused and uninstalled SWIG wrapper for talloc.
via a001b03 pep8: Move to third_party/.
from 0621f07 ctdb-scripts: New configuration variable CTDB_NODE_ADDRESS
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit af03b5752bf91e3db33f5a28b2b86b25666764b6
Author: Volker Lendecke <vl at samba.org>
Date: Sun Apr 26 11:15:01 2015 +0200
lib: Use isspace on unsigned char
Signed-off-by: Volker Lendecke <vl at samba.org>
Bug: https://bugzilla.samba.org/show_bug.cgi?id=11223
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Mon Apr 27 23:54:27 CEST 2015 on sn-devel-104
commit 38553a305fe4021e2bd034bed11eaef18863aa0a
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Apr 26 10:13:05 2015 +0000
Add set date to tdb manpages.
This makes builds reproducible.
Signed-Off-By: Jelmer Vernooij <jelmer at samba.org>
Reveiewed-by: Jeremy Allison <jra at samba.org>
commit e9809a6bb534ec55ed9e887701da94b46a059283
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Apr 26 10:11:33 2015 +0000
Drop unused and uninstalled SWIG wrapper for talloc.
This file was also still incorrectly licensed under the GPLv3.
Signed-off-by: Jelmer Vernooij <jelmer at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit a001b0385412786c50553cfb38c146dfb3646142
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sat Apr 25 15:34:13 2015 +0000
pep8: Move to third_party/.
Also, update to latest upstream version.
Signed-Off-By: Jelmer Vernooij <jelmer at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/pep8/pep8.py | 1959 --------------------
lib/talloc/talloc.i | 31 -
lib/tdb/man/tdbbackup.8.xml | 1 +
lib/tdb/man/tdbdump.8.xml | 1 +
lib/tdb/man/tdbrestore.8.xml | 1 +
lib/tdb/man/tdbtool.8.xml | 1 +
lib/util/tini.c | 19 +-
third_party/pep8/.gitignore | 7 +
third_party/pep8/.travis.yml | 25 +
third_party/pep8/CHANGES.txt | 651 +++++++
third_party/pep8/LICENSE | 24 +
third_party/pep8/MANIFEST.in | 9 +
third_party/pep8/Makefile | 13 +
third_party/pep8/README.rst | 91 +
third_party/pep8/docs/Makefile | 153 ++
third_party/pep8/docs/advanced.rst | 77 +
third_party/pep8/docs/api.rst | 88 +
third_party/pep8/docs/conf.py | 251 +++
third_party/pep8/docs/developer.rst | 96 +
third_party/pep8/docs/index.rst | 69 +
third_party/pep8/docs/intro.rst | 435 +++++
third_party/pep8/docs/make.bat | 190 ++
third_party/pep8/setup.cfg | 7 +
third_party/pep8/setup.py | 56 +
third_party/pep8/testsuite/E10.py | 41 +
third_party/pep8/testsuite/E11.py | 36 +
third_party/pep8/testsuite/E12.py | 376 ++++
third_party/pep8/testsuite/E12not.py | 644 +++++++
third_party/pep8/testsuite/E20.py | 55 +
third_party/pep8/testsuite/E21.py | 14 +
third_party/pep8/testsuite/E22.py | 157 ++
third_party/pep8/testsuite/E23.py | 15 +
third_party/pep8/testsuite/E24.py | 13 +
third_party/pep8/testsuite/E25.py | 36 +
third_party/pep8/testsuite/E26.py | 59 +
third_party/pep8/testsuite/E27.py | 30 +
third_party/pep8/testsuite/E30.py | 90 +
third_party/pep8/testsuite/E30not.py | 134 ++
third_party/pep8/testsuite/E40.py | 38 +
third_party/pep8/testsuite/E50.py | 118 ++
third_party/pep8/testsuite/E70.py | 20 +
third_party/pep8/testsuite/E71.py | 73 +
third_party/pep8/testsuite/E72.py | 51 +
third_party/pep8/testsuite/E73.py | 18 +
third_party/pep8/testsuite/E90.py | 26 +
third_party/pep8/testsuite/W19.py | 145 ++
third_party/pep8/testsuite/W29.py | 21 +
third_party/pep8/testsuite/W39.py | 18 +
third_party/pep8/testsuite/W60.py | 15 +
.../pep8/testsuite}/__init__.py | 0
third_party/pep8/testsuite/latin-1.py | 6 +
third_party/pep8/testsuite/noqa.py | 15 +
third_party/pep8/testsuite/python3.py | 6 +
third_party/pep8/testsuite/support.py | 197 ++
third_party/pep8/testsuite/test_all.py | 63 +
third_party/pep8/testsuite/test_api.py | 389 ++++
third_party/pep8/testsuite/test_shell.py | 189 ++
third_party/pep8/testsuite/test_util.py | 23 +
third_party/pep8/testsuite/utf-8-bom.py | 6 +
third_party/pep8/testsuite/utf-8.py | 52 +
third_party/pep8/tox.ini | 15 +
61 files changed, 5464 insertions(+), 1995 deletions(-)
delete mode 100755 lib/pep8/pep8.py
delete mode 100644 lib/talloc/talloc.i
create mode 100644 third_party/pep8/.gitignore
create mode 100644 third_party/pep8/.travis.yml
create mode 100644 third_party/pep8/CHANGES.txt
create mode 100644 third_party/pep8/LICENSE
create mode 100644 third_party/pep8/MANIFEST.in
create mode 100644 third_party/pep8/Makefile
create mode 100644 third_party/pep8/README.rst
create mode 100644 third_party/pep8/docs/Makefile
create mode 100644 third_party/pep8/docs/advanced.rst
create mode 100644 third_party/pep8/docs/api.rst
create mode 100644 third_party/pep8/docs/conf.py
create mode 100644 third_party/pep8/docs/developer.rst
create mode 100644 third_party/pep8/docs/index.rst
create mode 100644 third_party/pep8/docs/intro.rst
create mode 100644 third_party/pep8/docs/make.bat
create mode 100644 third_party/pep8/setup.cfg
create mode 100644 third_party/pep8/setup.py
create mode 100644 third_party/pep8/testsuite/E10.py
create mode 100644 third_party/pep8/testsuite/E11.py
create mode 100644 third_party/pep8/testsuite/E12.py
create mode 100644 third_party/pep8/testsuite/E12not.py
create mode 100644 third_party/pep8/testsuite/E20.py
create mode 100644 third_party/pep8/testsuite/E21.py
create mode 100644 third_party/pep8/testsuite/E22.py
create mode 100644 third_party/pep8/testsuite/E23.py
create mode 100644 third_party/pep8/testsuite/E24.py
create mode 100644 third_party/pep8/testsuite/E25.py
create mode 100644 third_party/pep8/testsuite/E26.py
create mode 100644 third_party/pep8/testsuite/E27.py
create mode 100644 third_party/pep8/testsuite/E30.py
create mode 100644 third_party/pep8/testsuite/E30not.py
create mode 100644 third_party/pep8/testsuite/E40.py
create mode 100644 third_party/pep8/testsuite/E50.py
create mode 100644 third_party/pep8/testsuite/E70.py
create mode 100644 third_party/pep8/testsuite/E71.py
create mode 100644 third_party/pep8/testsuite/E72.py
create mode 100644 third_party/pep8/testsuite/E73.py
create mode 100644 third_party/pep8/testsuite/E90.py
create mode 100644 third_party/pep8/testsuite/W19.py
create mode 100644 third_party/pep8/testsuite/W29.py
create mode 100644 third_party/pep8/testsuite/W39.py
create mode 100644 third_party/pep8/testsuite/W60.py
copy {buildtools/wafsamba => third_party/pep8/testsuite}/__init__.py (100%)
create mode 100644 third_party/pep8/testsuite/latin-1.py
create mode 100644 third_party/pep8/testsuite/noqa.py
create mode 100644 third_party/pep8/testsuite/python3.py
create mode 100644 third_party/pep8/testsuite/support.py
create mode 100644 third_party/pep8/testsuite/test_all.py
create mode 100644 third_party/pep8/testsuite/test_api.py
create mode 100644 third_party/pep8/testsuite/test_shell.py
create mode 100644 third_party/pep8/testsuite/test_util.py
create mode 100644 third_party/pep8/testsuite/utf-8-bom.py
create mode 100644 third_party/pep8/testsuite/utf-8.py
create mode 100644 third_party/pep8/tox.ini
Changeset truncated at 500 lines:
diff --git a/lib/pep8/pep8.py b/lib/pep8/pep8.py
deleted file mode 100755
index b31a978..0000000
--- a/lib/pep8/pep8.py
+++ /dev/null
@@ -1,1959 +0,0 @@
-#!/usr/bin/env python
-# pep8.py - Check Python source code formatting, according to PEP 8
-# Copyright (C) 2006-2009 Johann C. Rocholl <johann at rocholl.net>
-# Copyright (C) 2009-2014 Florent Xicluna <florent.xicluna at gmail.com>
-#
-# Permission is hereby granted, free of charge, to any person
-# obtaining a copy of this software and associated documentation files
-# (the "Software"), to deal in the Software without restriction,
-# including without limitation the rights to use, copy, modify, merge,
-# publish, distribute, sublicense, and/or sell copies of the Software,
-# and to permit persons to whom the Software is furnished to do so,
-# subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-
-r"""
-Check Python source code formatting, according to PEP 8.
-
-For usage and a list of options, try this:
-$ python pep8.py -h
-
-This program and its regression test suite live here:
-http://github.com/jcrocholl/pep8
-
-Groups of errors and warnings:
-E errors
-W warnings
-100 indentation
-200 whitespace
-300 blank lines
-400 imports
-500 line length
-600 deprecation
-700 statements
-900 syntax error
-"""
-from __future__ import with_statement
-
-__version__ = '1.6.0a0'
-
-import os
-import sys
-import re
-import time
-import inspect
-import keyword
-import tokenize
-from optparse import OptionParser
-from fnmatch import fnmatch
-try:
- from configparser import RawConfigParser
- from io import TextIOWrapper
-except ImportError:
- from ConfigParser import RawConfigParser
-
-DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__'
-DEFAULT_IGNORE = 'E123,E226,E24,E704'
-if sys.platform == 'win32':
- DEFAULT_CONFIG = os.path.expanduser(r'~\.pep8')
-else:
- DEFAULT_CONFIG = os.path.join(os.getenv('XDG_CONFIG_HOME') or
- os.path.expanduser('~/.config'), 'pep8')
-PROJECT_CONFIG = ('setup.cfg', 'tox.ini', '.pep8')
-TESTSUITE_PATH = os.path.join(os.path.dirname(__file__), 'testsuite')
-MAX_LINE_LENGTH = 79
-REPORT_FORMAT = {
- 'default': '%(path)s:%(row)d:%(col)d: %(code)s %(text)s',
- 'pylint': '%(path)s:%(row)d: [%(code)s] %(text)s',
-}
-
-PyCF_ONLY_AST = 1024
-SINGLETONS = frozenset(['False', 'None', 'True'])
-KEYWORDS = frozenset(keyword.kwlist + ['print']) - SINGLETONS
-UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-'])
-ARITHMETIC_OP = frozenset(['**', '*', '/', '//', '+', '-'])
-WS_OPTIONAL_OPERATORS = ARITHMETIC_OP.union(['^', '&', '|', '<<', '>>', '%'])
-WS_NEEDED_OPERATORS = frozenset([
- '**=', '*=', '/=', '//=', '+=', '-=', '!=', '<>', '<', '>',
- '%=', '^=', '&=', '|=', '==', '<=', '>=', '<<=', '>>=', '='])
-WHITESPACE = frozenset(' \t')
-NEWLINE = frozenset([tokenize.NL, tokenize.NEWLINE])
-SKIP_TOKENS = NEWLINE.union([tokenize.INDENT, tokenize.DEDENT])
-# ERRORTOKEN is triggered by backticks in Python 3
-SKIP_COMMENTS = SKIP_TOKENS.union([tokenize.COMMENT, tokenize.ERRORTOKEN])
-BENCHMARK_KEYS = ['directories', 'files', 'logical lines', 'physical lines']
-
-INDENT_REGEX = re.compile(r'([ \t]*)')
-RAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*,')
-RERAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*,.*,\s*\w+\s*$')
-ERRORCODE_REGEX = re.compile(r'\b[A-Z]\d{3}\b')
-DOCSTRING_REGEX = re.compile(r'u?r?["\']')
-EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
-WHITESPACE_AFTER_COMMA_REGEX = re.compile(r'[,;:]\s*(?: |\t)')
-COMPARE_SINGLETON_REGEX = re.compile(r'([=!]=)\s*(None|False|True)')
-COMPARE_NEGATIVE_REGEX = re.compile(r'\b(not)\s+[^[({ ]+\s+(in|is)\s')
-COMPARE_TYPE_REGEX = re.compile(r'(?:[=!]=|is(?:\s+not)?)\s*type(?:s.\w+Type'
- r'|\s*\(\s*([^)]*[^ )])\s*\))')
-KEYWORD_REGEX = re.compile(r'(\s*)\b(?:%s)\b(\s*)' % r'|'.join(KEYWORDS))
-OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)')
-LAMBDA_REGEX = re.compile(r'\blambda\b')
-HUNK_REGEX = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$')
-
-# Work around Python < 2.6 behaviour, which does not generate NL after
-# a comment which is on a line by itself.
-COMMENT_WITH_NL = tokenize.generate_tokens(['#\n'].pop).send(None)[1] == '#\n'
-
-
-##############################################################################
-# Plugins (check functions) for physical lines
-##############################################################################
-
-
-def tabs_or_spaces(physical_line, indent_char):
- r"""Never mix tabs and spaces.
-
- The most popular way of indenting Python is with spaces only. The
- second-most popular way is with tabs only. Code indented with a mixture
- of tabs and spaces should be converted to using spaces exclusively. When
- invoking the Python command line interpreter with the -t option, it issues
- warnings about code that illegally mixes tabs and spaces. When using -tt
- these warnings become errors. These options are highly recommended!
-
- Okay: if a == 0:\n a = 1\n b = 1
- E101: if a == 0:\n a = 1\n\tb = 1
- """
- indent = INDENT_REGEX.match(physical_line).group(1)
- for offset, char in enumerate(indent):
- if char != indent_char:
- return offset, "E101 indentation contains mixed spaces and tabs"
-
-
-def tabs_obsolete(physical_line):
- r"""For new projects, spaces-only are strongly recommended over tabs.
-
- Okay: if True:\n return
- W191: if True:\n\treturn
- """
- indent = INDENT_REGEX.match(physical_line).group(1)
- if '\t' in indent:
- return indent.index('\t'), "W191 indentation contains tabs"
-
-
-def trailing_whitespace(physical_line):
- r"""Trailing whitespace is superfluous.
-
- The warning returned varies on whether the line itself is blank, for easier
- filtering for those who want to indent their blank lines.
-
- Okay: spam(1)\n#
- W291: spam(1) \n#
- W293: class Foo(object):\n \n bang = 12
- """
- physical_line = physical_line.rstrip('\n') # chr(10), newline
- physical_line = physical_line.rstrip('\r') # chr(13), carriage return
- physical_line = physical_line.rstrip('\x0c') # chr(12), form feed, ^L
- stripped = physical_line.rstrip(' \t\v')
- if physical_line != stripped:
- if stripped:
- return len(stripped), "W291 trailing whitespace"
- else:
- return 0, "W293 blank line contains whitespace"
-
-
-def trailing_blank_lines(physical_line, lines, line_number, total_lines):
- r"""Trailing blank lines are superfluous.
-
- Okay: spam(1)
- W391: spam(1)\n
-
- However the last line should end with a new line (warning W292).
- """
- if line_number == total_lines:
- stripped_last_line = physical_line.rstrip()
- if not stripped_last_line:
- return 0, "W391 blank line at end of file"
- if stripped_last_line == physical_line:
- return len(physical_line), "W292 no newline at end of file"
-
-
-def maximum_line_length(physical_line, max_line_length, multiline):
- r"""Limit all lines to a maximum of 79 characters.
-
- There are still many devices around that are limited to 80 character
- lines; plus, limiting windows to 80 characters makes it possible to have
- several windows side-by-side. The default wrapping on such devices looks
- ugly. Therefore, please limit all lines to a maximum of 79 characters.
- For flowing long blocks of text (docstrings or comments), limiting the
- length to 72 characters is recommended.
-
- Reports error E501.
- """
- line = physical_line.rstrip()
- length = len(line)
- if length > max_line_length and not noqa(line):
- # Special case for long URLs in multi-line docstrings or comments,
- # but still report the error when the 72 first chars are whitespaces.
- chunks = line.split()
- if ((len(chunks) == 1 and multiline) or
- (len(chunks) == 2 and chunks[0] == '#')) and \
- len(line) - len(chunks[-1]) < max_line_length - 7:
- return
- if hasattr(line, 'decode'): # Python 2
- # The line could contain multi-byte characters
- try:
- length = len(line.decode('utf-8'))
- except UnicodeError:
- pass
- if length > max_line_length:
- return (max_line_length, "E501 line too long "
- "(%d > %d characters)" % (length, max_line_length))
-
-
-##############################################################################
-# Plugins (check functions) for logical lines
-##############################################################################
-
-
-def blank_lines(logical_line, blank_lines, indent_level, line_number,
- blank_before, previous_logical, previous_indent_level):
- r"""Separate top-level function and class definitions with two blank lines.
-
- Method definitions inside a class are separated by a single blank line.
-
- Extra blank lines may be used (sparingly) to separate groups of related
- functions. Blank lines may be omitted between a bunch of related
- one-liners (e.g. a set of dummy implementations).
-
- Use blank lines in functions, sparingly, to indicate logical sections.
-
- Okay: def a():\n pass\n\n\ndef b():\n pass
- Okay: def a():\n pass\n\n\n# Foo\n# Bar\n\ndef b():\n pass
-
- E301: class Foo:\n b = 0\n def bar():\n pass
- E302: def a():\n pass\n\ndef b(n):\n pass
- E303: def a():\n pass\n\n\n\ndef b(n):\n pass
- E303: def a():\n\n\n\n pass
- E304: @decorator\n\ndef a():\n pass
- """
- if line_number < 3 and not previous_logical:
- return # Don't expect blank lines before the first line
- if previous_logical.startswith('@'):
- if blank_lines:
- yield 0, "E304 blank lines found after function decorator"
- elif blank_lines > 2 or (indent_level and blank_lines == 2):
- yield 0, "E303 too many blank lines (%d)" % blank_lines
- elif logical_line.startswith(('def ', 'class ', '@')):
- if indent_level:
- if not (blank_before or previous_indent_level < indent_level or
- DOCSTRING_REGEX.match(previous_logical)):
- yield 0, "E301 expected 1 blank line, found 0"
- elif blank_before != 2:
- yield 0, "E302 expected 2 blank lines, found %d" % blank_before
-
-
-def extraneous_whitespace(logical_line):
- r"""Avoid extraneous whitespace.
-
- Avoid extraneous whitespace in these situations:
- - Immediately inside parentheses, brackets or braces.
- - Immediately before a comma, semicolon, or colon.
-
- Okay: spam(ham[1], {eggs: 2})
- E201: spam( ham[1], {eggs: 2})
- E201: spam(ham[ 1], {eggs: 2})
- E201: spam(ham[1], { eggs: 2})
- E202: spam(ham[1], {eggs: 2} )
- E202: spam(ham[1 ], {eggs: 2})
- E202: spam(ham[1], {eggs: 2 })
-
- E203: if x == 4: print x, y; x, y = y , x
- E203: if x == 4: print x, y ; x, y = y, x
- E203: if x == 4 : print x, y; x, y = y, x
- """
- line = logical_line
- for match in EXTRANEOUS_WHITESPACE_REGEX.finditer(line):
- text = match.group()
- char = text.strip()
- found = match.start()
- if text == char + ' ':
- # assert char in '([{'
- yield found + 1, "E201 whitespace after '%s'" % char
- elif line[found - 1] != ',':
- code = ('E202' if char in '}])' else 'E203') # if char in ',;:'
- yield found, "%s whitespace before '%s'" % (code, char)
-
-
-def whitespace_around_keywords(logical_line):
- r"""Avoid extraneous whitespace around keywords.
-
- Okay: True and False
- E271: True and False
- E272: True and False
- E273: True and\tFalse
- E274: True\tand False
- """
- for match in KEYWORD_REGEX.finditer(logical_line):
- before, after = match.groups()
-
- if '\t' in before:
- yield match.start(1), "E274 tab before keyword"
- elif len(before) > 1:
- yield match.start(1), "E272 multiple spaces before keyword"
-
- if '\t' in after:
- yield match.start(2), "E273 tab after keyword"
- elif len(after) > 1:
- yield match.start(2), "E271 multiple spaces after keyword"
-
-
-def missing_whitespace(logical_line):
- r"""Each comma, semicolon or colon should be followed by whitespace.
-
- Okay: [a, b]
- Okay: (3,)
- Okay: a[1:4]
- Okay: a[:4]
- Okay: a[1:]
- Okay: a[1:4:2]
- E231: ['a','b']
- E231: foo(bar,baz)
- E231: [{'a':'b'}]
- """
- line = logical_line
- for index in range(len(line) - 1):
- char = line[index]
- if char in ',;:' and line[index + 1] not in WHITESPACE:
- before = line[:index]
- if char == ':' and before.count('[') > before.count(']') and \
- before.rfind('{') < before.rfind('['):
- continue # Slice syntax, no space required
- if char == ',' and line[index + 1] == ')':
- continue # Allow tuple with only one element: (3,)
- yield index, "E231 missing whitespace after '%s'" % char
-
-
-def indentation(logical_line, previous_logical, indent_char,
- indent_level, previous_indent_level):
- r"""Use 4 spaces per indentation level.
-
- For really old code that you don't want to mess up, you can continue to
- use 8-space tabs.
-
- Okay: a = 1
- Okay: if a == 0:\n a = 1
- E111: a = 1
- E114: # a = 1
-
- Okay: for item in items:\n pass
- E112: for item in items:\npass
- E115: for item in items:\n# Hi\n pass
-
- Okay: a = 1\nb = 2
- E113: a = 1\n b = 2
- E116: a = 1\n # b = 2
- """
- c = 0 if logical_line else 3
- tmpl = "E11%d %s" if logical_line else "E11%d %s (comment)"
- if indent_level % 4:
- yield 0, tmpl % (1 + c, "indentation is not a multiple of four")
- indent_expect = previous_logical.endswith(':')
- if indent_expect and indent_level <= previous_indent_level:
- yield 0, tmpl % (2 + c, "expected an indented block")
- elif not indent_expect and indent_level > previous_indent_level:
- yield 0, tmpl % (3 + c, "unexpected indentation")
-
-
-def continued_indentation(logical_line, tokens, indent_level, hang_closing,
- indent_char, noqa, verbose):
- r"""Continuation lines indentation.
-
- Continuation lines should align wrapped elements either vertically
- using Python's implicit line joining inside parentheses, brackets
- and braces, or using a hanging indent.
-
- When using a hanging indent these considerations should be applied:
- - there should be no arguments on the first line, and
- - further indentation should be used to clearly distinguish itself as a
- continuation line.
-
- Okay: a = (\n)
- E123: a = (\n )
-
- Okay: a = (\n 42)
- E121: a = (\n 42)
- E122: a = (\n42)
- E123: a = (\n 42\n )
- E124: a = (24,\n 42\n)
- E125: if (\n b):\n pass
- E126: a = (\n 42)
- E127: a = (24,\n 42)
- E128: a = (24,\n 42)
- E129: if (a or\n b):\n pass
- E131: a = (\n 42\n 24)
- """
- first_row = tokens[0][2][0]
- nrows = 1 + tokens[-1][2][0] - first_row
- if noqa or nrows == 1:
- return
-
- # indent_next tells us whether the next block is indented; assuming
- # that it is indented by 4 spaces, then we should not allow 4-space
- # indents on the final continuation line; in turn, some other
- # indents are allowed to have an extra 4 spaces.
- indent_next = logical_line.endswith(':')
-
- row = depth = 0
- valid_hangs = (4,) if indent_char != '\t' else (4, 8)
- # remember how many brackets were opened on each line
- parens = [0] * nrows
- # relative indents of physical lines
- rel_indent = [0] * nrows
- # for each depth, collect a list of opening rows
- open_rows = [[0]]
- # for each depth, memorize the hanging indentation
- hangs = [None]
- # visual indents
- indent_chances = {}
- last_indent = tokens[0][2]
- visual_indent = None
- # for each depth, memorize the visual indent column
- indent = [last_indent[1]]
- if verbose >= 3:
- print(">>> " + tokens[0][4].rstrip())
-
- for token_type, text, start, end, line in tokens:
-
- newline = row < start[0] - first_row
- if newline:
- row = start[0] - first_row
- newline = not last_token_multiline and token_type not in NEWLINE
-
- if newline:
- # this is the beginning of a continuation line.
- last_indent = start
- if verbose >= 3:
- print("... " + line.rstrip())
-
- # record the initial indent.
- rel_indent[row] = expand_indent(line) - indent_level
-
- # identify closing bracket
- close_bracket = (token_type == tokenize.OP and text in ']})')
-
- # is the indent relative to an opening bracket line?
- for open_row in reversed(open_rows[depth]):
- hang = rel_indent[row] - rel_indent[open_row]
- hanging_indent = hang in valid_hangs
- if hanging_indent:
- break
- if hangs[depth]:
- hanging_indent = (hang == hangs[depth])
- # is there any chance of visual indent?
- visual_indent = (not close_bracket and hang > 0 and
- indent_chances.get(start[1]))
-
- if close_bracket and indent[depth]:
- # closing bracket for visual indent
- if start[1] != indent[depth]:
- yield (start, "E124 closing bracket does not match "
- "visual indentation")
- elif close_bracket and not hang:
- # closing bracket matches indentation of opening bracket's line
- if hang_closing:
- yield start, "E133 closing bracket is missing indentation"
- elif indent[depth] and start[1] < indent[depth]:
- if visual_indent is not True:
- # visual indent is broken
- yield (start, "E128 continuation line "
- "under-indented for visual indent")
- elif hanging_indent or (indent_next and rel_indent[row] == 8):
- # hanging indent is verified
- if close_bracket and not hang_closing:
- yield (start, "E123 closing bracket does not match "
- "indentation of opening bracket's line")
- hangs[depth] = hang
- elif visual_indent is True:
- # visual indent is verified
- indent[depth] = start[1]
- elif visual_indent in (text, str):
- # ignore token lined up with matching one from a previous line
- pass
- else:
- # indent is broken
- if hang <= 0:
--
Samba Shared Repository
More information about the samba-cvs
mailing list