Hello community,

here is the log from the commit of package python-flake8 for openSUSE:Factory 
checked in at 2014-01-14 19:53:30
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-flake8 (Old)
 and      /work/SRC/openSUSE:Factory/.python-flake8.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-flake8"

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-flake8/python-flake8.changes      
2013-10-25 11:15:53.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.python-flake8.new/python-flake8.changes 
2014-01-14 19:53:31.000000000 +0100
@@ -1,0 +2,14 @@
+Mon Jan 13 13:54:22 UTC 2014 - dmuel...@suse.com
+
+- update to 2.1.0:
+  - Add FLAKE8_LAZY and FLAKE8_IGNORE environment variable support to git and
+    mercurial hooks
+  - Force git and mercurial hooks to repsect configuration in setup.cfg
+  - Only check staged files if that is specified
+  - Fix hook file permissions
+  - Fix the git hook on python 3
+  - Ignore non-python files when running the git hook
+  - Ignore .tox directories by default
+  - Flake8 now reports the column number for PyFlakes messages
+
+-------------------------------------------------------------------

Old:
----
  flake8-2.0.tar.gz

New:
----
  flake8-2.1.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-flake8.spec ++++++
--- /var/tmp/diff_new_pack.JaDFhi/_old  2014-01-14 19:53:31.000000000 +0100
+++ /var/tmp/diff_new_pack.JaDFhi/_new  2014-01-14 19:53:31.000000000 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-flake8
 #
-# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           python-flake8
-Version:        2.0
+Version:        2.1.0
 Release:        0
 Summary:        Modular source code checker: pep8, pyflakes and co
 License:        MIT
@@ -28,6 +28,7 @@
 BuildRequires:  python-setuptools
 # Test requirements:
 BuildRequires:  python-mccabe >= 0.2
+BuildRequires:  python-mock
 BuildRequires:  python-nose
 BuildRequires:  python-pep8 >= 1.4.3
 BuildRequires:  python-pyflakes >= 0.6.1

++++++ flake8-2.0.tar.gz -> flake8-2.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/CHANGES.rst new/flake8-2.1.0/CHANGES.rst
--- old/flake8-2.0/CHANGES.rst  2013-02-23 23:32:05.000000000 +0100
+++ new/flake8-2.1.0/CHANGES.rst        2013-10-26 22:23:15.000000000 +0200
@@ -1,7 +1,20 @@
 CHANGES
 =======
 
-2.0.0 - 2013-02-xx
+2.1.0 - 2013-10-26
+------------------
+
+- Add FLAKE8_LAZY and FLAKE8_IGNORE environment variable support to git and
+  mercurial hooks
+- Force git and mercurial hooks to repsect configuration in setup.cfg
+- Only check staged files if that is specified
+- Fix hook file permissions
+- Fix the git hook on python 3
+- Ignore non-python files when running the git hook
+- Ignore .tox directories by default
+- Flake8 now reports the column number for PyFlakes messages
+
+2.0.0 - 2013-02-23
 ------------------
 
 - Pyflakes errors are prefixed by an ``F`` instead of an ``E``
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/CONTRIBUTORS.txt 
new/flake8-2.1.0/CONTRIBUTORS.txt
--- old/flake8-2.0/CONTRIBUTORS.txt     2013-02-23 15:32:11.000000000 +0100
+++ new/flake8-2.1.0/CONTRIBUTORS.txt   2013-06-23 05:46:34.000000000 +0200
@@ -19,3 +19,4 @@
 - Marc Labbé
 - Bruno Miguel Custódio
 - Florent Xicluna
+- Austin Morton
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/LICENSE new/flake8-2.1.0/LICENSE
--- old/flake8-2.0/LICENSE      2013-02-23 15:32:11.000000000 +0100
+++ new/flake8-2.1.0/LICENSE    2013-07-05 16:23:02.000000000 +0200
@@ -1,6 +1,7 @@
 == Flake8 License (MIT) ==
 
-Copyright (C) 2011 Tarek Ziade <ta...@ziade.org>
+Copyright (C) 2011-2013 Tarek Ziade <ta...@ziade.org>
+Copyright (C) 2012-2013 Ian Cordasco <graffatcolmin...@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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/MANIFEST.in new/flake8-2.1.0/MANIFEST.in
--- old/flake8-2.0/MANIFEST.in  2013-02-23 15:32:11.000000000 +0100
+++ new/flake8-2.1.0/MANIFEST.in        2013-06-23 05:46:34.000000000 +0200
@@ -1,4 +1,4 @@
 include *.rst
 include CONTRIBUTORS.txt
 include LICENSE
-recursive-include scripts flake8.*
+recursive-include flake8 *
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/PKG-INFO new/flake8-2.1.0/PKG-INFO
--- old/flake8-2.0/PKG-INFO     2013-02-23 23:36:37.000000000 +0100
+++ new/flake8-2.1.0/PKG-INFO   2013-10-26 22:24:46.000000000 +0200
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
 Name: flake8
-Version: 2.0
+Version: 2.1.0
 Summary: the modular source code checker: pep8, pyflakes and co
 Home-page: http://bitbucket.org/tarek/flake8
 Author: Ian Cordasco
@@ -65,6 +65,13 @@
         anything that goes beyond 10 is too complex.
         See https://en.wikipedia.org/wiki/Cyclomatic_complexity.
         
+        Questions or Feedback
+        =====================
+        
+        If you have questions you'd like to ask the developers, or feedback 
you'd like
+        to provide, feel free to use the mailing list: code-qual...@python.org 
We
+        would love to hear from you. Additionally, if you have a feature you'd 
like to
+        suggest, the mailing list would be the best place for it.
         
         .. _links:
         
@@ -79,7 +86,20 @@
         CHANGES
         =======
         
-        2.0.0 - 2013-02-xx
+        2.1.0 - 2013-10-26
+        ------------------
+        
+        - Add FLAKE8_LAZY and FLAKE8_IGNORE environment variable support to 
git and
+          mercurial hooks
+        - Force git and mercurial hooks to repsect configuration in setup.cfg
+        - Only check staged files if that is specified
+        - Fix hook file permissions
+        - Fix the git hook on python 3
+        - Ignore non-python files when running the git hook
+        - Ignore .tox directories by default
+        - Flake8 now reports the column number for PyFlakes messages
+        
+        2.0.0 - 2013-02-23
         ------------------
         
         - Pyflakes errors are prefixed by an ``F`` instead of an ``E``
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/README.rst new/flake8-2.1.0/README.rst
--- old/flake8-2.0/README.rst   2013-02-23 15:32:11.000000000 +0100
+++ new/flake8-2.1.0/README.rst 2013-07-05 16:23:02.000000000 +0200
@@ -57,6 +57,13 @@
 anything that goes beyond 10 is too complex.
 See https://en.wikipedia.org/wiki/Cyclomatic_complexity.
 
+Questions or Feedback
+=====================
+
+If you have questions you'd like to ask the developers, or feedback you'd like
+to provide, feel free to use the mailing list: code-qual...@python.org We
+would love to hear from you. Additionally, if you have a feature you'd like to
+suggest, the mailing list would be the best place for it.
 
 .. _links:
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8/__init__.py 
new/flake8-2.1.0/flake8/__init__.py
--- old/flake8-2.0/flake8/__init__.py   2013-02-23 15:32:11.000000000 +0100
+++ new/flake8-2.1.0/flake8/__init__.py 2013-10-26 22:24:19.000000000 +0200
@@ -1,2 +1 @@
-
-__version__ = '2.0'
+__version__ = '2.1.0'
Files old/flake8-2.0/flake8/__init__.pyc and 
new/flake8-2.1.0/flake8/__init__.pyc differ
Files old/flake8-2.0/flake8/__pycache__/__init__.cpython-32.pyc and 
new/flake8-2.1.0/flake8/__pycache__/__init__.cpython-32.pyc differ
Files old/flake8-2.0/flake8/__pycache__/_pyflakes.cpython-32.pyc and 
new/flake8-2.1.0/flake8/__pycache__/_pyflakes.cpython-32.pyc differ
Files old/flake8-2.0/flake8/__pycache__/engine.cpython-32.pyc and 
new/flake8-2.1.0/flake8/__pycache__/engine.cpython-32.pyc differ
Files old/flake8-2.0/flake8/__pycache__/main.cpython-32.pyc and 
new/flake8-2.1.0/flake8/__pycache__/main.cpython-32.pyc differ
Files old/flake8-2.0/flake8/__pycache__/util.cpython-32.pyc and 
new/flake8-2.1.0/flake8/__pycache__/util.cpython-32.pyc differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8/_pyflakes.py 
new/flake8-2.1.0/flake8/_pyflakes.py
--- old/flake8-2.0/flake8/_pyflakes.py  2013-02-23 15:32:11.000000000 +0100
+++ new/flake8-2.1.0/flake8/_pyflakes.py        2013-07-05 16:23:02.000000000 
+0200
@@ -44,4 +44,5 @@
 
     def run(self):
         for m in self.messages:
-            yield m.lineno, 0, (m.flake8_msg % m.message_args), m.__class__
+            col = getattr(m, 'col', 0)
+            yield m.lineno, col, (m.flake8_msg % m.message_args), m.__class__
Files old/flake8-2.0/flake8/_pyflakes.pyc and 
new/flake8-2.1.0/flake8/_pyflakes.pyc differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8/engine.py 
new/flake8-2.1.0/flake8/engine.py
--- old/flake8-2.0/flake8/engine.py     2013-02-23 15:32:11.000000000 +0100
+++ new/flake8-2.1.0/flake8/engine.py   2013-06-23 05:46:34.000000000 +0200
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 import re
+import platform
 
 import pep8
 
@@ -37,7 +38,10 @@
     """
     (extensions, parser_hooks, options_hooks) = _register_extensions()
     details = ', '.join(['%s: %s' % ext for ext in extensions])
-    parser = pep8.get_parser('flake8', '%s (%s)' % (__version__, details))
+    python_version = get_python_version()
+    parser = pep8.get_parser('flake8', '%s (%s) %s' % (
+        __version__, details, python_version
+    ))
     for opt in ('--repeat', '--testsuite', '--doctest'):
         try:
             parser.remove_option(opt)
@@ -78,3 +82,12 @@
     for options_hook in options_hooks:
         options_hook(options)
     return styleguide
+
+
+def get_python_version():
+    # The implementation isn't all that important.
+    try:
+        impl = platform.python_implementation() + " "
+    except AttributeError:  # Python 2.5
+        impl = ''
+    return '%s%s on %s' % (impl, platform.python_version(), platform.system())
Files old/flake8-2.0/flake8/engine.pyc and new/flake8-2.1.0/flake8/engine.pyc 
differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8/hooks.py 
new/flake8-2.1.0/flake8/hooks.py
--- old/flake8-2.0/flake8/hooks.py      2013-02-23 15:32:11.000000000 +0100
+++ new/flake8-2.1.0/flake8/hooks.py    2013-10-26 21:05:42.000000000 +0200
@@ -2,7 +2,16 @@
 from __future__ import with_statement
 import os
 import sys
+import stat
 from subprocess import Popen, PIPE
+import shutil
+from tempfile import mkdtemp
+try:
+    # The 'demandimport' breaks pyflakes and flake8._pyflakes
+    from mercurial import demandimport
+    demandimport.disable()
+except ImportError:
+    pass
 try:
     from configparser import ConfigParser
 except ImportError:   # Python 2
@@ -14,7 +23,7 @@
 
 def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
     """This is the function used by the git hook.
-    
+
     :param int complexity: (optional), any value > 0 enables complexity
         checking with mccabe
     :param bool strict: (optional), if True, this returns the total number of
@@ -25,15 +34,59 @@
         the files to the index before running a commit, e.g., git commit -a
     :returns: total number of errors if strict is True, otherwise 0
     """
-    gitcmd = "git diff-index --cached --name-only HEAD"
+    gitcmd = "git diff-index --cached --name-only --diff-filter=ACMRTUXB HEAD"
     if lazy:
+        # Catch all files, including those not added to the index
         gitcmd = gitcmd.replace('--cached ', '')
 
+    if hasattr(ignore, 'split'):
+        ignore = ignore.split(',')
+
+    # Returns the exit code, list of files modified, list of error messages
     _, files_modified, _ = run(gitcmd)
 
+    # We only want to pass ignore and max_complexity if they differ from the
+    # defaults so that we don't override a local configuration file
+    options = {}
+    if ignore:
+        options['ignore'] = ignore
+    if complexity > -1:
+        options['max_complexity'] = complexity
+
+    files_modified = [f for f in files_modified if f.endswith('.py')]
+
     flake8_style = get_style_guide(
-        config_file=DEFAULT_CONFIG, ignore=ignore, max_complexity=complexity)
-    report = flake8_style.check_files(files_modified)
+        parse_argv=True,
+        config_file=DEFAULT_CONFIG,
+        **options
+        )
+
+    # Copy staged versions to temporary directory
+    tmpdir = mkdtemp()
+    files_to_check = []
+    try:
+        for file_ in files_modified:
+            # get the staged version of the file
+            gitcmd_getstaged = "git show :%s" % file_
+            _, out, _ = run(gitcmd_getstaged, raw_output=True, decode=False)
+            # write the staged version to temp dir with its full path to
+            # avoid overwriting files with the same name
+            dirname, filename = os.path.split(os.path.abspath(file_))
+            prefix = os.path.commonprefix([dirname, tmpdir])
+            dirname = os.path.relpath(dirname, start=prefix)
+            dirname = os.path.join(tmpdir, dirname)
+            if not os.path.isdir(dirname):
+                os.makedirs(dirname)
+            filename = os.path.join(dirname, filename)
+            # write staged version of file to temporary directory
+            with open(filename, "wb") as fh:
+                fh.write(out)
+            files_to_check.append(filename)
+        # Run the checks
+        report = flake8_style.check_files(files_to_check)
+    # remove temporary directory
+    finally:
+        shutil.rmtree(tmpdir, ignore_errors=True)
 
     if strict:
         return report.total_errors
@@ -49,14 +102,23 @@
     """
     complexity = ui.config('flake8', 'complexity', default=-1)
     strict = ui.configbool('flake8', 'strict', default=True)
+    ignore = ui.config('flake8', 'ignore', default=None)
     config = ui.config('flake8', 'config', default=True)
     if config is True:
         config = DEFAULT_CONFIG
 
     paths = _get_files(repo, **kwargs)
 
-    flake8_style = get_style_guide(
-        config_file=config, max_complexity=complexity)
+    # We only want to pass ignore and max_complexity if they differ from the
+    # defaults so that we don't override a local configuration file
+    options = {}
+    if ignore:
+        options['ignore'] = ignore
+    if complexity > -1:
+        options['max_complexity'] = complexity
+
+    flake8_style = get_style_guide(parse_argv=True, config_file=config,
+                                   **options)
     report = flake8_style.check_files(paths)
 
     if strict:
@@ -65,11 +127,23 @@
     return 0
 
 
-def run(command):
+def run(command, raw_output=False, decode=True):
     p = Popen(command.split(), stdout=PIPE, stderr=PIPE)
     (stdout, stderr) = p.communicate()
-    return (p.returncode, [line.strip() for line in stdout.splitlines()],
-            [line.strip() for line in stderr.splitlines()])
+    # On python 3, subprocess.Popen returns bytes objects which expect
+    # endswith to be given a bytes object or a tuple of bytes but not native
+    # string objects. This is simply less mysterious than using b'.py' in the
+    # endswith method. That should work but might still fail horribly.
+    if hasattr(stdout, 'decode'):
+        if decode:
+            stdout = stdout.decode()
+    if hasattr(stderr, 'decode'):
+        if decode:
+            stderr = stderr.decode()
+    if not raw_output:
+        stdout = [line.strip() for line in stdout.splitlines()]
+        stderr = [line.strip() for line in stderr.splitlines()]
+    return (p.returncode, stdout, stderr)
 
 
 def _get_files(repo, **kwargs):
@@ -85,12 +159,14 @@
 
 
 def find_vcs():
-    if os.path.isdir('.git'):
-        if not os.path.isdir('.git/hooks'):
-            os.mkdir('.git/hooks')
-        return '.git/hooks/pre-commit'
-    elif os.path.isdir('.hg'):
-        return '.hg/hgrc'
+    _, git_dir, _ = run('git rev-parse --git-dir')
+    if git_dir and os.path.isdir(git_dir[0]):
+        if not os.path.isdir(os.path.join(git_dir[0], 'hooks')):
+            os.mkdir(os.path.join(git_dir[0], 'hooks'))
+        return os.path.join(git_dir[0], 'hooks', 'pre-commit')
+    _, hg_dir, _ = run('hg root')
+    if hg_dir and os.path.isdir(hg_dir[0]):
+        return os.path.join(hg_dir[0], '.hg', 'hgrc')
     return ''
 
 
@@ -101,14 +177,25 @@
 
 COMPLEXITY = os.getenv('FLAKE8_COMPLEXITY', 10)
 STRICT = os.getenv('FLAKE8_STRICT', False)
+IGNORE = os.getenv('FLAKE8_IGNORE')
+LAZY = os.getenv('FLAKE8_LAZY', False)
 
 
 if __name__ == '__main__':
-    sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT))
+    sys.exit(git_hook(
+        complexity=COMPLEXITY,
+        strict=STRICT,
+        ignore=IGNORE,
+        lazy=LAZY,
+        ))
 """
 
 
 def _install_hg_hook(path):
+    if not os.path.isfile(path):
+        # Make the file so we can avoid IOError's
+        open(path, 'w+').close()
+
     c = ConfigParser()
     c.readfp(open(path, 'r'))
     if not c.has_section('hooks'):
@@ -129,6 +216,12 @@
     if not c.has_option('flake8', 'strict'):
         c.set('flake8', 'strict', os.getenv('FLAKE8_STRICT', False))
 
+    if not c.has_option('flake8', 'ignore'):
+        c.set('flake8', 'ignore', os.getenv('FLAKE8_IGNORE'))
+
+    if not c.has_option('flake8', 'lazy'):
+        c.set('flake8', 'lazy', os.getenv('FLAKE8_LAZY', False))
+
     c.write(open(path, 'w+'))
 
 
@@ -136,7 +229,7 @@
     vcs = find_vcs()
 
     if not vcs:
-        p = get_parser()
+        p = get_parser()[0]
         sys.stderr.write('Error: could not find either a git or mercurial '
                          'directory. Please re-run this in a proper '
                          'repository.')
@@ -147,7 +240,8 @@
     if 'git' in vcs:
         with open(vcs, 'w+') as fd:
             fd.write(git_hook_file)
-        os.chmod(vcs, 744)
+        # rwxr--r--
+        os.chmod(vcs, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
     elif 'hg' in vcs:
         _install_hg_hook(vcs)
     else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8/hooks.py.orig 
new/flake8-2.1.0/flake8/hooks.py.orig
--- old/flake8-2.0/flake8/hooks.py.orig 1970-01-01 01:00:00.000000000 +0100
+++ new/flake8-2.1.0/flake8/hooks.py.orig       2013-06-23 05:46:34.000000000 
+0200
@@ -0,0 +1,176 @@
+# -*- coding: utf-8 -*-
+from __future__ import with_statement
+import os
+import sys
+from subprocess import Popen, PIPE
+try:
+    from mercurial import demandimport
+    demandimport.disable()
+except ImportError:
+    pass
+
+try:
+    from configparser import ConfigParser
+except ImportError:   # Python 2
+    from ConfigParser import ConfigParser
+
+from flake8.engine import get_parser, get_style_guide
+from flake8.main import DEFAULT_CONFIG
+
+
+def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
+    """This is the function used by the git hook.
+
+    :param int complexity: (optional), any value > 0 enables complexity
+        checking with mccabe
+    :param bool strict: (optional), if True, this returns the total number of
+        errors which will cause the hook to fail
+    :param str ignore: (optional), a comma-separated list of errors and
+        warnings to ignore
+    :param bool lazy: (optional), allows for the instances where you don't add
+        the files to the index before running a commit, e.g., git commit -a
+    :returns: total number of errors if strict is True, otherwise 0
+    """
+    gitcmd = "git diff-index --cached --name-only HEAD"
+    if lazy:
+        # Catch all files, including those not added to the index
+        gitcmd = gitcmd.replace('--cached ', '')
+
+    if hasattr(ignore, 'split'):
+        ignore = ignore.split(',')
+
+    # Returns the exit code, list of files modified, list of error messages
+    _, files_modified, _ = run(gitcmd)
+
+    # Run the checks
+    flake8_style = get_style_guide(
+        config_file=DEFAULT_CONFIG, ignore=ignore, max_complexity=complexity)
+    report = flake8_style.check_files([f for f in files_modified if
+                                       f.endswith('.py')])
+
+    if strict:
+        return report.total_errors
+
+    return 0
+
+
+def hg_hook(ui, repo, **kwargs):
+    """This is the function executed directly by Mercurial as part of the
+    hook. This is never called directly by the user, so the parameters are
+    undocumented. If you would like to learn more about them, please feel free
+    to read the official Mercurial documentation.
+    """
+    complexity = ui.config('flake8', 'complexity', default=-1)
+    strict = ui.configbool('flake8', 'strict', default=True)
+    config = ui.config('flake8', 'config', default=True)
+    if config is True:
+        config = DEFAULT_CONFIG
+
+    paths = _get_files(repo, **kwargs)
+
+    flake8_style = get_style_guide(
+        config_file=config, max_complexity=complexity)
+    report = flake8_style.check_files(paths)
+
+    if strict:
+        return report.total_errors
+
+    return 0
+
+
+def run(command):
+    p = Popen(command.split(), stdout=PIPE, stderr=PIPE)
+    (stdout, stderr) = p.communicate()
+    return (p.returncode, [line.strip() for line in stdout.splitlines()],
+            [line.strip() for line in stderr.splitlines()])
+
+
+def _get_files(repo, **kwargs):
+    seen = set()
+    for rev in range(repo[kwargs['node']], len(repo)):
+        for file_ in repo[rev].files():
+            file_ = os.path.join(repo.root, file_)
+            if file_ in seen or not os.path.exists(file_):
+                continue
+            seen.add(file_)
+            if file_.endswith('.py'):
+                yield file_
+
+
+def find_vcs():
+    if os.path.isdir('.git'):
+        if not os.path.isdir('.git/hooks'):
+            os.mkdir('.git/hooks')
+        return '.git/hooks/pre-commit'
+    elif os.path.isdir('.hg'):
+        return '.hg/hgrc'
+    return ''
+
+
+git_hook_file = """#!/usr/bin/env python
+import sys
+import os
+from flake8.hooks import git_hook
+
+COMPLEXITY = os.getenv('FLAKE8_COMPLEXITY', 10)
+STRICT = os.getenv('FLAKE8_STRICT', False)
+
+
+if __name__ == '__main__':
+    sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT))
+"""
+
+
+def _install_hg_hook(path):
+    if not os.path.isfile(path):
+        # Make the file so we can avoid IOError's
+        open(path, 'w+').close()
+
+    c = ConfigParser()
+    c.readfp(open(path, 'r'))
+    if not c.has_section('hooks'):
+        c.add_section('hooks')
+
+    if not c.has_option('hooks', 'commit'):
+        c.set('hooks', 'commit', 'python:flake8.hooks.hg_hook')
+
+    if not c.has_option('hooks', 'qrefresh'):
+        c.set('hooks', 'qrefresh', 'python:flake8.hooks.hg_hook')
+
+    if not c.has_section('flake8'):
+        c.add_section('flake8')
+
+    if not c.has_option('flake8', 'complexity'):
+        c.set('flake8', 'complexity', str(os.getenv('FLAKE8_COMPLEXITY', 10)))
+
+    if not c.has_option('flake8', 'strict'):
+        c.set('flake8', 'strict', os.getenv('FLAKE8_STRICT', False))
+
+    c.write(open(path, 'w+'))
+
+
+def install_hook():
+    vcs = find_vcs()
+
+    if not vcs:
+        p = get_parser()
+        sys.stderr.write('Error: could not find either a git or mercurial '
+                         'directory. Please re-run this in a proper '
+                         'repository.')
+        p.print_help()
+        sys.exit(1)
+
+    status = 0
+    if 'git' in vcs:
+        with open(vcs, 'w+') as fd:
+            fd.write(git_hook_file)
+        # 0b111100100 == rwxr--r--
+        # Python 2.5 doesn't support 0b syntax so note that the above binary
+        # value is equivalent to 484 in decimal
+        os.chmod(vcs, 484)
+    elif 'hg' in vcs:
+        _install_hg_hook(vcs)
+    else:
+        status = 1
+
+    sys.exit(status)
Files old/flake8-2.0/flake8/hooks.pyc and new/flake8-2.1.0/flake8/hooks.pyc 
differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8/main.py 
new/flake8-2.1.0/flake8/main.py
--- old/flake8-2.0/flake8/main.py       2013-02-23 15:32:11.000000000 +0100
+++ new/flake8-2.1.0/flake8/main.py     2013-10-05 15:25:41.000000000 +0200
@@ -4,7 +4,8 @@
 
 import setuptools
 
-from flake8.engine import get_style_guide
+from flake8.engine import get_parser, get_style_guide
+from flake8.util import is_flag, flag_on
 
 if sys.platform.startswith('win'):
     DEFAULT_CONFIG = os.path.expanduser(r'~\.flake8')
@@ -14,6 +15,8 @@
         'flake8'
     )
 
+EXTRA_IGNORE = ['.tox']
+
 
 def main():
     """Parse options and run checks on Python source."""
@@ -28,6 +31,11 @@
     # Run the checkers
     report = flake8_style.check_files()
 
+    exit_code = print_report(report, flake8_style)
+    raise SystemExit(exit_code > 0)
+
+
+def print_report(report, flake8_style):
     # Print the final report
     options = flake8_style.options
     if options.statistics:
@@ -38,17 +46,19 @@
         if options.count:
             sys.stderr.write(str(report.total_errors) + '\n')
         if not options.exit_zero:
-            raise SystemExit(1)
+            return 1
+    return 0
 
 
 def check_file(path, ignore=(), complexity=-1):
-    """Checks a file using pep8 and pyflakes by default and mccabe 
+    """Checks a file using pep8 and pyflakes by default and mccabe
     optionally.
 
     :param str path: path to the file to be checked
     :param tuple ignore: (optional), error and warning codes to be ignored
     :param int complexity: (optional), enables the mccabe check for values > 0
     """
+    ignore = set(ignore).union(EXTRA_IGNORE)
     flake8_style = get_style_guide(
         config_file=DEFAULT_CONFIG, ignore=ignore, max_complexity=complexity)
     return flake8_style.input_file(path)
@@ -61,9 +71,10 @@
     :param tuple ignore: (optional), error and warning codes to be ignored
     :param int complexity: (optional), enables the mccabe check for values > 0
     """
+    ignore = set(ignore).union(EXTRA_IGNORE)
     flake8_style = get_style_guide(
         config_file=DEFAULT_CONFIG, ignore=ignore, max_complexity=complexity)
-    return flake8_style.input_file('-', lines=code.splitlines())
+    return flake8_style.input_file(None, lines=code.splitlines(True))
 
 
 class Flake8Command(setuptools.Command):
@@ -75,22 +86,45 @@
     user_options = []
 
     def initialize_options(self):
-        pass
+        self.option_to_cmds = {}
+        parser = get_parser()[0]
+        for opt in parser.option_list:
+            cmd_name = opt._long_opts[0][2:]
+            option_name = cmd_name.replace('-', '_')
+            self.option_to_cmds[option_name] = cmd_name
+            setattr(self, option_name, None)
 
     def finalize_options(self):
-        pass
+        self.options_dict = {}
+        for (option_name, cmd_name) in self.option_to_cmds.items():
+            if option_name in ['help', 'verbose']:
+                continue
+            value = getattr(self, option_name)
+            if value is None:
+                continue
+            if is_flag(value):
+                value = flag_on(value)
+            self.options_dict[option_name] = value
 
     def distribution_files(self):
         if self.distribution.packages:
+            package_dirs = self.distribution.package_dir or {}
             for package in self.distribution.packages:
-                yield package.replace(".", os.path.sep)
+                pkg_dir = package
+                if package in package_dirs:
+                    pkg_dir = package_dirs[package]
+                elif '' in package_dirs:
+                    pkg_dir = package_dirs[''] + os.path.sep + pkg_dir
+                yield pkg_dir.replace('.', os.path.sep)
 
         if self.distribution.py_modules:
             for filename in self.distribution.py_modules:
                 yield "%s.py" % filename
 
     def run(self):
-        flake8_style = get_style_guide(config_file=DEFAULT_CONFIG)
+        flake8_style = get_style_guide(config_file=DEFAULT_CONFIG,
+                                       **self.options_dict)
         paths = self.distribution_files()
         report = flake8_style.check_files(paths)
-        raise SystemExit(report.total_errors > 0)
+        exit_code = print_report(report, flake8_style)
+        raise SystemExit(exit_code > 0)
Files old/flake8-2.0/flake8/main.pyc and new/flake8-2.1.0/flake8/main.pyc differ
Files old/flake8-2.0/flake8/tests/__init__.pyc and 
new/flake8-2.1.0/flake8/tests/__init__.pyc differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8/tests/test_engine.py 
new/flake8-2.1.0/flake8/tests/test_engine.py
--- old/flake8-2.0/flake8/tests/test_engine.py  1970-01-01 01:00:00.000000000 
+0100
+++ new/flake8-2.1.0/flake8/tests/test_engine.py        2013-07-06 
17:56:20.000000000 +0200
@@ -0,0 +1,81 @@
+from flake8 import engine, util, __version__
+import pep8
+import unittest
+import mock
+
+
+class TestEngine(unittest.TestCase):
+    def setUp(self):
+        self.patches = {}
+
+    def tearDown(self):
+        assert len(self.patches.items()) == 0
+
+    def start_patch(self, patch):
+        self.patches[patch] = mock.patch(patch)
+        return self.patches[patch].start()
+
+    def stop_patches(self):
+        patches = self.patches.copy()
+        for k, v in patches.items():
+            v.stop()
+            del(self.patches[k])
+
+    def test_get_style_guide(self):
+        with mock.patch('flake8.engine._register_extensions') as reg_ext:
+            reg_ext.return_value = ([], [], [])
+            g = engine.get_style_guide()
+            self.assertTrue(isinstance(g, engine.StyleGuide))
+            reg_ext.assert_called_once_with()
+
+    def test_get_style_guide_kwargs(self):
+        m = mock.Mock()
+        with mock.patch('flake8.engine.StyleGuide') as StyleGuide:
+            with mock.patch('flake8.engine.get_parser') as get_parser:
+                get_parser.return_value = (m, [])
+                engine.get_style_guide(foo='bar')
+                get_parser.assert_called_once_with()
+            StyleGuide.assert_called_once_with(**{'parser': m, 'foo': 'bar'})
+
+    def test_register_extensions(self):
+        with mock.patch('pep8.register_check') as register_check:
+            registered_extensions = engine._register_extensions()
+            self.assertTrue(isinstance(registered_extensions[0], 
util.OrderedSet))
+            self.assertTrue(len(registered_extensions[0]) > 0)
+            for i in registered_extensions[1:]:
+                self.assertTrue(isinstance(i, list))
+            register_check.assert_called()
+
+    def test_get_parser(self):
+        # setup
+        re = self.start_patch('flake8.engine._register_extensions')
+        gpv = self.start_patch('flake8.engine.get_python_version')
+        pgp = self.start_patch('pep8.get_parser')
+        m = mock.Mock()
+        re.return_value = ([('pyflakes', '0.7'), ('mccabe', '0.2')], [], [])
+        gpv.return_value = 'Python Version'
+        pgp.return_value = m
+        # actual call we're testing
+        parser, hooks = engine.get_parser()
+        # assertions
+        re.assert_called()
+        gpv.assert_called()
+        pgp.assert_called_once_with(
+            'flake8',
+            '%s (pyflakes: 0.7, mccabe: 0.2) Python Version' % __version__
+            )
+        m.remove_option.assert_called()
+        m.add_option.assert_called()
+        self.assertEqual(parser, m)
+        self.assertEqual(hooks, [])
+        # clean-up
+        self.stop_patches()
+
+    def test_get_python_version(self):
+        self.assertTrue('on' in engine.get_python_version())
+        # Silly test but it will provide 100% test coverage
+        # Also we can never be sure (without reconstructing the string
+        # ourselves) what system we may be testing on.
+
+if __name__ == '__main__':
+    unittest.main()
Files old/flake8-2.0/flake8/tests/test_engine.pyc and 
new/flake8-2.1.0/flake8/tests/test_engine.pyc differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8/tests/test_flakes.py 
new/flake8-2.1.0/flake8/tests/test_flakes.py
--- old/flake8-2.0/flake8/tests/test_flakes.py  2013-02-23 15:32:11.000000000 
+0100
+++ new/flake8-2.1.0/flake8/tests/test_flakes.py        1970-01-01 
01:00:00.000000000 +0100
@@ -1,94 +0,0 @@
-# -*- coding: utf-8 -*-
-import sys
-
-from unittest import TestCase
-from pyflakes.api import check
-
-
-class FlakesTestReporter(object):
-    def __init__(self):
-        self.messages = []
-        self.flakes = self.messages.append
-
-    def unexpectedError(self, filename, msg):
-        self.flakes('[unexpectedError] %s: %s' % (filename, msg))
-
-    def syntaxError(self, filename, msg, lineno, offset, text):
-        self.flakes('[syntaxError] %s:%d: %s' % (filename, lineno, msg))
-
-
-code0 = """
-try:
-    pass
-except ValueError, err:
-    print(err)
-"""
-
-code1 = """
-try:
-    pass
-except ValueError as err:
-    print(err)
-"""
-
-code2 = """
-try:
-    pass
-except ValueError:
-    print("err")
-
-try:
-    pass
-except ValueError:
-    print("err")
-"""
-
-code3 = """
-try:
-    pass
-except (ImportError, ValueError):
-    print("err")
-"""
-
-code_from_import_exception = """
-from foo import SomeException
-try:
-    pass
-except SomeException:
-    print("err")
-"""
-
-code_import_exception = """
-import foo.SomeException
-try:
-    pass
-except foo.SomeException:
-    print("err")
-"""
-
-
-class TestFlake(TestCase):
-
-    def test_exception(self):
-        codes = [code1, code2, code3]
-        if sys.version_info < (2, 6):
-            codes[0] = code0
-        elif sys.version_info < (3,):
-            codes.insert(0, code0)
-        for code in codes:
-            reporter = FlakesTestReporter()
-            warnings = check(code, '(stdin)', reporter)
-            self.assertFalse(reporter.messages)
-            self.assertEqual(warnings, 0)
-
-    def test_from_import_exception_in_scope(self):
-        reporter = FlakesTestReporter()
-        warnings = check(code_from_import_exception, '(stdin)', reporter)
-        self.assertFalse(reporter.messages)
-        self.assertEqual(warnings, 0)
-
-    def test_import_exception_in_scope(self):
-        reporter = FlakesTestReporter()
-        warnings = check(code_import_exception, '(stdin)', reporter)
-        self.assertFalse(reporter.messages)
-        self.assertEqual(warnings, 0)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8/util.py 
new/flake8-2.1.0/flake8/util.py
--- old/flake8-2.0/flake8/util.py       2013-02-23 15:32:11.000000000 +0100
+++ new/flake8-2.1.0/flake8/util.py     2013-06-23 05:46:34.000000000 +0200
@@ -35,3 +35,14 @@
     def add(self, value):
         if value not in self:
             self.append(value)
+
+
+def is_flag(val):
+    """Guess if the value could be an on/off toggle"""
+    val = str(val)
+    return val.upper() in ('1', '0', 'F', 'T', 'TRUE', 'FALSE', 'ON', 'OFF')
+
+
+def flag_on(val):
+    """Return true if flag is on"""
+    return str(val).upper() in ('1', 'T', 'TRUE', 'ON')
Files old/flake8-2.0/flake8/util.pyc and new/flake8-2.1.0/flake8/util.pyc differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8.egg-info/PKG-INFO 
new/flake8-2.1.0/flake8.egg-info/PKG-INFO
--- old/flake8-2.0/flake8.egg-info/PKG-INFO     2013-02-23 23:36:37.000000000 
+0100
+++ new/flake8-2.1.0/flake8.egg-info/PKG-INFO   2013-10-26 22:24:46.000000000 
+0200
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
 Name: flake8
-Version: 2.0
+Version: 2.1.0
 Summary: the modular source code checker: pep8, pyflakes and co
 Home-page: http://bitbucket.org/tarek/flake8
 Author: Ian Cordasco
@@ -65,6 +65,13 @@
         anything that goes beyond 10 is too complex.
         See https://en.wikipedia.org/wiki/Cyclomatic_complexity.
         
+        Questions or Feedback
+        =====================
+        
+        If you have questions you'd like to ask the developers, or feedback 
you'd like
+        to provide, feel free to use the mailing list: code-qual...@python.org 
We
+        would love to hear from you. Additionally, if you have a feature you'd 
like to
+        suggest, the mailing list would be the best place for it.
         
         .. _links:
         
@@ -79,7 +86,20 @@
         CHANGES
         =======
         
-        2.0.0 - 2013-02-xx
+        2.1.0 - 2013-10-26
+        ------------------
+        
+        - Add FLAKE8_LAZY and FLAKE8_IGNORE environment variable support to 
git and
+          mercurial hooks
+        - Force git and mercurial hooks to repsect configuration in setup.cfg
+        - Only check staged files if that is specified
+        - Fix hook file permissions
+        - Fix the git hook on python 3
+        - Ignore non-python files when running the git hook
+        - Ignore .tox directories by default
+        - Flake8 now reports the column number for PyFlakes messages
+        
+        2.0.0 - 2013-02-23
         ------------------
         
         - Pyflakes errors are prefixed by an ``F`` instead of an ``E``
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8.egg-info/SOURCES.txt 
new/flake8-2.1.0/flake8.egg-info/SOURCES.txt
--- old/flake8-2.0/flake8.egg-info/SOURCES.txt  2013-02-23 23:36:37.000000000 
+0100
+++ new/flake8-2.1.0/flake8.egg-info/SOURCES.txt        2013-10-26 
22:24:46.000000000 +0200
@@ -5,18 +5,31 @@
 README.rst
 setup.py
 flake8/__init__.py
+flake8/__init__.pyc
 flake8/_pyflakes.py
+flake8/_pyflakes.pyc
 flake8/engine.py
+flake8/engine.pyc
 flake8/hooks.py
+flake8/hooks.py.orig
+flake8/hooks.pyc
 flake8/main.py
+flake8/main.pyc
 flake8/run.py
 flake8/util.py
+flake8/util.pyc
 flake8.egg-info/PKG-INFO
 flake8.egg-info/SOURCES.txt
 flake8.egg-info/dependency_links.txt
 flake8.egg-info/entry_points.txt
 flake8.egg-info/requires.txt
 flake8.egg-info/top_level.txt
+flake8/__pycache__/__init__.cpython-32.pyc
+flake8/__pycache__/_pyflakes.cpython-32.pyc
+flake8/__pycache__/engine.cpython-32.pyc
+flake8/__pycache__/main.cpython-32.pyc
+flake8/__pycache__/util.cpython-32.pyc
 flake8/tests/__init__.py
-flake8/tests/test_flakes.py
-scripts/flake8.cmd
\ No newline at end of file
+flake8/tests/__init__.pyc
+flake8/tests/test_engine.py
+flake8/tests/test_engine.pyc
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/flake8.egg-info/requires.txt 
new/flake8-2.1.0/flake8.egg-info/requires.txt
--- old/flake8-2.0/flake8.egg-info/requires.txt 2013-02-23 23:36:37.000000000 
+0100
+++ new/flake8-2.1.0/flake8.egg-info/requires.txt       2013-10-26 
22:24:46.000000000 +0200
@@ -1,4 +1,3 @@
-setuptools
-pyflakes >= 0.6.1
-pep8 >= 1.4.3
-mccabe >= 0.2
\ No newline at end of file
+pyflakes >= 0.7.3
+pep8 >= 1.4.6
+mccabe >= 0.2.1
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/scripts/flake8.cmd 
new/flake8-2.1.0/scripts/flake8.cmd
--- old/flake8-2.0/scripts/flake8.cmd   2013-02-22 00:54:24.000000000 +0100
+++ new/flake8-2.1.0/scripts/flake8.cmd 1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-@setlocal enableextensions & python -x %~f0 %* & goto :EOF
-# -*- mode: python -*-
-from flake8.run import main
-
-if __name__ == '__main__':
-    main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-2.0/setup.py new/flake8-2.1.0/setup.py
--- old/flake8-2.0/setup.py     2013-02-23 15:32:11.000000000 +0100
+++ new/flake8-2.1.0/setup.py   2013-10-13 04:28:56.000000000 +0200
@@ -31,10 +31,9 @@
     url="http://bitbucket.org/tarek/flake8";,
     packages=["flake8", "flake8.tests"],
     install_requires=[
-        "setuptools",
-        "pyflakes >= 0.6.1",
-        "pep8 >= 1.4.3",
-        "mccabe >= 0.2",
+        "pyflakes >= 0.7.3",
+        "pep8 >= 1.4.6",
+        "mccabe >= 0.2.1",
     ],
     entry_points={
         'distutils.commands': ['flake8 = flake8.main:Flake8Command'],
@@ -53,6 +52,6 @@
         "Topic :: Software Development :: Libraries :: Python Modules",
         "Topic :: Software Development :: Quality Assurance",
     ],
-    tests_require=['nose'],
+    tests_require=['nose', 'mock'],
     test_suite='nose.collector',
 )

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to