Fix more pep8 issues in code I touched recently.
authorJelmer Vernooń≥ <jelmer@samba.org>
Mon, 2 Jun 2014 00:53:01 +0000 (02:53 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 14 Oct 2014 04:44:06 +0000 (06:44 +0200)
Signed-Off-By: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Change-Id: I35f3204bdf5d00b3280d703427ded2fa2163a6f7

buildtools/wafsamba/samba3.py
buildtools/wafsamba/wafsamba.py
python/samba/drs_utils.py
python/samba/provision/backend.py
python/samba/schema.py
python/samba/tests/dns.py
python/samba/tests/samba3sam.py
python/samba/tests/source.py
selftest/tests.py

index 571954de169fa80b5a4755bf513dbe5fcb72c01d..ffe678416edfb457a92b200530c9b3c2bc7193e0 100644 (file)
@@ -6,16 +6,17 @@ from optparse import SUPPRESS_HELP
 from samba_utils import os_path_relpath, TO_LIST
 from samba_autoconf import library_flags
 
+
 def SAMBA3_ADD_OPTION(opt, option, help=(), dest=None, default=True,
                       with_name="with", without_name="without"):
     if default is None:
-        default_str="auto"
+        default_str = "auto"
     elif default is True:
-        default_str="yes"
+        default_str = "yes"
     elif default is False:
-        default_str="no"
+        default_str = "no"
     else:
-        default_str=str(default)
+        default_str = str(default)
 
     if help == ():
         help = ("Build with %s support (default=%s)" % (option, default_str))
index b36b47bbcb40f13db7e25705de125aab98004d73..b68b9d2dbf94ad60d1687568e516430ca90da520 100644 (file)
@@ -726,7 +726,8 @@ sys.path.insert(1, "%s")""" % (task.env["PYTHONARCHDIR"], task.env["PYTHONDIR"])
     lineno = 0
     for line in source_file:
         newline = line
-        if lineno == 0 and task.env["PYTHON_SPECIFIED"] is True and line[:2] == "#!":
+        if (lineno == 0 and task.env["PYTHON_SPECIFIED"] is True and
+                line[:2] == "#!"):
             newline = replacement_shebang
         elif pattern in line:
             newline = line.replace(pattern, replacement)
index 38accdd6ab0bf0009c969ec7cc9a97ccd741af99..87c9a8655769a2139f88cd8dd3666f70048a6a6b 100644 (file)
@@ -222,7 +222,8 @@ class drs_Replicate(object):
                                   drsuapi.DRSUAPI_DRS_GET_ANC |
                                   drsuapi.DRSUAPI_DRS_NEVER_SYNCED)
             if rodc:
-                req8.replica_flags |= drsuapi.DRSUAPI_DRS_SPECIAL_SECRET_PROCESSING
+                req8.replica_flags |= (
+                    drsuapi.DRSUAPI_DRS_SPECIAL_SECRET_PROCESSING)
             else:
                 req8.replica_flags |= drsuapi.DRSUAPI_DRS_WRIT_REP
         req8.max_object_count = 402
index cffdea7218ed7652095b63ac1c00192ea1833c0d..17572efc76bfa349305021f6e05a03f61ab4c514 100644 (file)
@@ -369,13 +369,16 @@ class OpenLDAPBackend(LDAPBackend):
                 memberof_config += read_and_sub_file(
                     setup_path("memberof.conf"), {
                         "MEMBER_ATTR": att,
-                        "MEMBEROF_ATTR" : lnkattr[att] })
+                        "MEMBEROF_ATTR": lnkattr[att]})
 
-        refint_config = read_and_sub_file(setup_path("refint.conf"),
-                                      { "LINK_ATTRS" : refint_attributes})
+        refint_config = read_and_sub_file(
+            setup_path("refint.conf"), {"LINK_ATTRS": refint_attributes})
 
         attrs = ["linkID", "lDAPDisplayName"]
-        res = self.schema.ldb.search(expression="(&(objectclass=attributeSchema)(searchFlags:1.2.840.113556.1.4.803:=1))", base=self.names.schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
+        res = self.schema.ldb.search(
+            expression="(&(objectclass=attributeSchema)"
+                       "(searchFlags:1.2.840.113556.1.4.803:=1))",
+            base=self.names.schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
         index_config = ""
         for i in range(0, len(res)):
             index_attr = res[i]["lDAPDisplayName"][0]
@@ -734,7 +737,10 @@ class FDSBackend(LDAPBackend):
             f.close()
 
         attrs = ["lDAPDisplayName"]
-        res = self.schema.ldb.search(expression="(&(objectclass=attributeSchema)(searchFlags:1.2.840.113556.1.4.803:=1))", base=self.names.schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
+        res = self.schema.ldb.search(
+            expression="(&(objectclass=attributeSchema)"
+                       "(searchFlags:1.2.840.113556.1.4.803:=1))",
+            base=self.names.schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
 
         for i in range(0, len(res)):
             attr = res[i]["lDAPDisplayName"][0]
index 4e6381306caee8cef04e5f2cac82aa29d2d40e8e..839d681825ad359c7531045c72dfd430c078d2cf 100644 (file)
@@ -156,12 +156,19 @@ dn: @INDEXLIST
 
 
 # Return a hash with the forward attribute as a key and the back as the value
-def get_linked_attributes(schemadn,schemaldb):
+def get_linked_attributes(schemadn, schemaldb):
     attrs = ["linkID", "lDAPDisplayName"]
-    res = schemaldb.search(expression="(&(linkID=*)(!(linkID:1.2.840.113556.1.4.803:=1))(objectclass=attributeSchema)(attributeSyntax=2.5.5.1))", base=schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
+    res = schemaldb.search(
+        expression="(&(linkID=*)"
+                   "(!(linkID:1.2.840.113556.1.4.803:=1))"
+                   "(objectclass=attributeSchema)"
+                   "(attributeSyntax=2.5.5.1))",
+        base=schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
     attributes = {}
     for i in range(0, len(res)):
-        expression = "(&(objectclass=attributeSchema)(linkID=%d)(attributeSyntax=2.5.5.1))" % (int(res[i]["linkID"][0])+1)
+        expression = ("(&(objectclass=attributeSchema)(linkID=%d)"
+                      "(attributeSyntax=2.5.5.1))" %
+                      (int(res[i]["linkID"][0])+1))
         target = schemaldb.searchone(basedn=schemadn,
                                      expression=expression,
                                      attribute="lDAPDisplayName",
index 303e93a02830d9ca18b9c586042f8b3f630d3970..34edf6b66e63ae0cd19dbf346e89d9ea93e56129 100644 (file)
@@ -127,13 +127,14 @@ class DNSTest(TestCase):
         N = 0
         result = ''
         while src:
-           s,src = src[:length],src[length:]
-           hexa = ' '.join(["%02X"%ord(x) for x in s])
-           s = s.translate(FILTER)
-           result += "%04X   %-*s   %s\n" % (N, length*3, hexa, s)
-           N+=length
+            s, src = src[:length], src[length:]
+            hexa = ' '.join(["%02X" % ord(x) for x in s])
+            s = s.translate(FILTER)
+            result += "%04X   %-*s   %s\n" % (N, length*3, hexa, s)
+            N += length
         return result
 
+
 class TestSimpleQueries(DNSTest):
 
     def test_one_a_query(self):
index 7cd656670a7b8d6089c605785a388e536b9a63be..d4347cd52c8c83f1c45fa069370a253587edf93a 100644 (file)
@@ -186,12 +186,12 @@ class Samba3SamTestCase(MapBaseTestCase):
 
     def test_s3sam_modify(self):
         # Adding a record that will be fallbacked
-        self.ldb.add({"dn": "cn=Foo",
+        self.ldb.add({
+            "dn": "cn=Foo",
             "foo": "bar",
             "blah": "Blie",
             "cn": "Foo",
-            "showInAdvancedViewOnly": "TRUE"}
-            )
+            "showInAdvancedViewOnly": "TRUE"})
 
         # Checking for existence of record (local)
         # TODO: This record must be searched in the local database, which is
index 2612ae68cf5b4a7aac885a6ea29b625a75d078b2..3910acd85d6ef1f42984d5275ace713100188dd1 100644 (file)
@@ -98,10 +98,9 @@ class TestSource(TestCase):
                 incorrect.append((fname, 'no copyright line found\n'))
 
         if incorrect:
-            help_text = ["Some files have missing or incorrect copyright"
-                         " statements.",
-                         "",
-                        ]
+            help_text = [
+                "Some files have missing or incorrect copyright"
+                " statements.", ""]
             for fname, comment in incorrect:
                 help_text.append(fname)
                 help_text.append((' ' * 4) + comment)
@@ -230,18 +229,19 @@ class TestSource(TestCase):
         'E203',      # whitespace before ':'
         'E222',      # multiple spaces after operator
         'E301',      # expected 1 blank line, found 0
-        'E211',      # whitespace before '('
-        'E701',      # multiple statements on one line (colon)
         ]
 
     def test_pep8(self):
         pep8.process_options()
-        pep8.options.repeat = True
         pep8_errors = []
+        pep8_error_count = {}
         pep8_warnings = []
         for fname, text in get_source_file_contents():
             def report_error(line_number, offset, text, check):
                 code = text[:4]
+                if code not in pep8_error_count:
+                    pep8_error_count[code] = 0
+                pep8_error_count[code] += 1
                 if code in self.pep8_ignore:
                     code = 'W' + code[1:]
                 text = code + text[4:]
@@ -259,6 +259,5 @@ class TestSource(TestCase):
             d = {}
             for (fname, line_no, offset, text, check) in pep8_errors:
                 d.setdefault(fname, []).append(line_no - 1)
-            self.fail(self._format_message(d,
-                'There were %d PEP8 errors:' % len(pep8_errors)))
-
+            self.fail(self._format_message(
+                d, 'There were %d PEP8 errors:' % len(pep8_errors)))
index 88a08c9724da91fd2366fb7c2fe934b727439ad4..a6a5186e82322afc4309aeb6e484b9dc47eb941b 100644 (file)
@@ -58,13 +58,36 @@ planpythontestsuite("none", "samba.tests.samdb")
 planpythontestsuite("none", "samba.tests.hostconfig")
 planpythontestsuite("none", "samba.tests.messaging")
 planpythontestsuite("none", "samba.tests.samba3sam")
-planpythontestsuite("none", "wafsamba.tests.test_suite", extra_path=[os.path.join(samba4srcdir, "..", "buildtools"), os.path.join(samba4srcdir, "..", "buildtools", "wafadmin")])
-plantestsuite("samba4.blackbox.dbcheck.alpha13", "none" , ["PYTHON=%s" % python, os.path.join(bbdir, "dbcheck-oldrelease.sh"), '$PREFIX_ABS/provision', 'alpha13', configuration])
-plantestsuite("samba4.blackbox.dbcheck.release-4-0-0", "none" , ["PYTHON=%s" % python, os.path.join(bbdir, "dbcheck-oldrelease.sh"), '$PREFIX_ABS/provision', 'release-4-0-0', configuration])
-plantestsuite("samba4.blackbox.dbcheck.release-4-1-0rc3", "none" , ["PYTHON=%s" % python, os.path.join(bbdir, "dbcheck-oldrelease.sh"), '$PREFIX_ABS/provision', 'release-4-1-0rc3', configuration])
-plantestsuite("samba4.blackbox.dbcheck.release-4-1-6-partial-object", "none" , ["PYTHON=%s" % python, os.path.join(bbdir, "dbcheck-oldrelease.sh"), '$PREFIX_ABS/provision', 'release-4-1-6-partial-object', configuration])
-plantestsuite("samba4.blackbox.upgradeprovision.alpha13", "none" , ["PYTHON=%s" % python, os.path.join(bbdir, "upgradeprovision-oldrelease.sh"), '$PREFIX_ABS/provision', 'alpha13', configuration])
-plantestsuite("samba4.blackbox.upgradeprovision.release-4-0-0", "none" , ["PYTHON=%s" % python, os.path.join(bbdir, "upgradeprovision-oldrelease.sh"), '$PREFIX_ABS/provision', 'release-4-0-0', configuration])
+planpythontestsuite(
+    "none", "wafsamba.tests.test_suite",
+    extra_path=[os.path.join(samba4srcdir, "..", "buildtools"),
+                os.path.join(samba4srcdir, "..", "buildtools", "wafadmin")])
+plantestsuite(
+    "samba4.blackbox.dbcheck.alpha13", "none",
+    ["PYTHON=%s" % python, os.path.join(bbdir, "dbcheck-oldrelease.sh"),
+     '$PREFIX_ABS/provision', 'alpha13', configuration])
+plantestsuite(
+    "samba4.blackbox.dbcheck.release-4-0-0", "none",
+    ["PYTHON=%s" % python, os.path.join(bbdir, "dbcheck-oldrelease.sh"),
+     '$PREFIX_ABS/provision', 'release-4-0-0', configuration])
+plantestsuite(
+    "samba4.blackbox.dbcheck.release-4-1-0rc3", "none",
+    ["PYTHON=%s" % python, os.path.join(bbdir, "dbcheck-oldrelease.sh"),
+     '$PREFIX_ABS/provision', 'release-4-1-0rc3', configuration])
+plantestsuite(
+    "samba4.blackbox.dbcheck.release-4-1-6-partial-object", "none",
+    ["PYTHON=%s" % python, os.path.join(bbdir, "dbcheck-oldrelease.sh"),
+     '$PREFIX_ABS/provision', 'release-4-1-6-partial-object', configuration])
+plantestsuite(
+    "samba4.blackbox.upgradeprovision.alpha13", "none",
+    ["PYTHON=%s" % python,
+     os.path.join(bbdir, "upgradeprovision-oldrelease.sh"),
+     '$PREFIX_ABS/provision', 'alpha13', configuration])
+plantestsuite(
+    "samba4.blackbox.upgradeprovision.release-4-0-0", "none",
+    ["PYTHON=%s" % python,
+     os.path.join(bbdir, "upgradeprovision-oldrelease.sh"),
+     '$PREFIX_ABS/provision', 'release-4-0-0', configuration])
 planpythontestsuite("none", "samba.tests.upgradeprovision")
 planpythontestsuite("none", "samba.tests.xattr")
 planpythontestsuite("none", "samba.tests.ntacls")