Exemple #1
0
 def do_test(self):
     arglist = ['--exclude=', filepath]
     pep8.process_options(arglist)
     pep8.input_dir(filepath)
     output = pep8.get_statistics()
     print "PEP8 OUTPUT: " + str(output)
     self.assertEqual(len(output), 0)
Exemple #2
0
    def test_pep8(self):
        """ Verify that source code complies with PEP 8 formatting. """
        import pep8

        ignored_codes = [
            "E221",
            "E241",
        ]

        # Setup pep8 processing options.
        pep8_args = [
            "--show-source",
            "--repeat",
            "--ignore=" + ",".join(ignored_codes),
            "ignored",  # Ignored argument, but needed
            #  by pep8.process_options()
        ]
        pep8.process_options(pep8_args)

        # Call pep8 to process local files.
        directory = os.path.split(os.path.abspath(__file__))[0]
        directory = os.path.split(directory)[0]
        pep8.input_dir(directory)
        statistics = pep8.get_statistics()

        filtered_statistics = []
        for line in statistics:
            code = line[8:12]
            if code not in ignored_codes:
                filtered_statistics.append(line)

        self.assertFalse(filtered_statistics)
Exemple #3
0
 def test_pep8(self):
     filepath = settings.INSTALL_DIR
     arglist = ['--exclude=', filepath]
     pep8.process_options(arglist)
     pep8.input_dir(filepath)
     output = pep8.get_statistics()
     self.assertEqual(len(output), 0)
Exemple #4
0
    def test_pep8(self):
        """ Verify that source code complies with PEP 8 formatting. """
        import pep8

        ignored_codes = [
                         "E221",
                         "E241",
                        ]

        # Setup pep8 processing options.
        pep8_args = [
                     "--show-source",
                     "--repeat",
                     "--ignore=" + ",".join(ignored_codes),
                     "ignored",  # Ignored argument, but needed
                                 #  by pep8.process_options()
                    ]
        pep8.process_options(pep8_args)

        # Call pep8 to process local files.
        directory = os.path.split(os.path.abspath(__file__))[0]
        directory = os.path.split(directory)[0]
        pep8.input_dir(directory)
        statistics = pep8.get_statistics()

        filtered_statistics = []
        for line in statistics:
            code = line[8:12]
            if code not in ignored_codes:
                filtered_statistics.append(line)

        self.assertFalse(filtered_statistics)
Exemple #5
0
 def do_test(self):
     #print "PATH:", filepath
     arglist = ['--exclude=lib', filepath]
     pep8.process_options(arglist)
     pep8.input_dir(filepath)
     output = pep8.get_statistics()
     #print "PEP8 OUTPUT: " + str(output)
     self.assertEqual(len(output), 0)
Exemple #6
0
 def closure(self, fullpath=fullpath):
     pep8.process_options([
         '--first', fullpath,
         '--ignore', ','.join(PEP8_IGNORE)],
         )
     pep8.input_file(fullpath)
     if len(pep8.get_statistics()):
         self.fail('PEP8 issue in "%s"' % fullpath)
Exemple #7
0
 def report(self, stream):
     if not self.messages:
         return
     stream.write('\n' + "PEP8:" + '\n')
     output = '\n'.join(self.messages)
     stream.write(output + '\n')
     if self.tissue_statistics:
         stats = '\n'.join(pep8.get_statistics())
         stream.write(stats + '\n')
Exemple #8
0
#!/usr/local/bin/python3.2
import tkinter
from tkinter.filedialog import askopenfilename
import sys

import pep8

if __name__ == "__main__":
    root = tkinter.Tk()
    py_file = askopenfilename(title="Select a Python file to stylecheck ...",
                              initialdir=".")
    if not py_file:
        sys.exit("No file selected")

    pep8.process_options(['-v', '--count', py_file])
    pep8.input_file(py_file)
    if pep8.get_statistics() == []:
        print("Congrats! No style errors were detected.")
Exemple #9
0
Here are the results of the automatic PEP 8 syntax checker:

""")

# backup stdout
stdout = sys.stdout
sys.stdout = StringIO()

# clean up runner options
options, args = process_options()
options.repeat = True
input_dir(path, runner=input_file)
sys.stdout.seek(0)
data = sys.stdout.read()
statistic = get_statistics('')
count = get_count()

if count == 0:
    fh.write("The PEP 8 checker didn't find any issues.\n")
else:
    fh.write("\n")
    fh.write(".. rubric:: Statistic\n")
    fh.write("\n")
    fh.write("======= =====================================================\n")
    fh.write("Count   PEP 8 message string                                 \n")
    fh.write("======= =====================================================\n")
    for stat in statistic:
        fh.write(stat + "\n")
    fh.write("======= =====================================================\n")
    fh.write("\n")
Exemple #10
0
Here are the results of the automatic PEP 8 syntax checker:

""")


# backup stdout
stdout = sys.stdout
sys.stdout = StringIO()

# clean up runner options
options, args = process_options()
options.repeat = True
input_dir(path, runner=input_file)
sys.stdout.seek(0)
data = sys.stdout.read()
statistic = get_statistics('')
count = get_count()

if count == 0:
    fh.write("The PEP 8 checker didn't find any issues.\n")
else:
    fh.write("\n")
    fh.write(".. rubric:: Statistic\n")
    fh.write("\n")
    fh.write("======= =====================================================\n")
    fh.write("Count   PEP 8 message string                                 \n")
    fh.write("======= =====================================================\n")
    for stat in statistic:
        fh.write(stat + "\n")
    fh.write("======= =====================================================\n")
    fh.write("\n")