Small fixups while learning ZODB

While learning ZODB I've found a couple of scripts that were not working. The fixes are here.

Please apply and thanks beforehand,
Kirill
On Tue, Jul 22, 2014 at 07:05:26AM -0700, Tres Seaver wrote:
> > @@ -94,6 +94,7 @@ def report(oid, data, serial, missing):
> >      print()
> >  
> >  def main(path=None):
> > +    global VERBOSE
> 
> Because it is not used as a global, a cleaner fix would be to move the 'VERBOSE = 0' assignment into the 'main()' function.

May I suggest it to be the other way?

Usually in scripts verbose is global for the reason so that all script's
functions could know verbosity level. Yes, currently fsrefs uses VERBOSE
only in main(), but it could possibly in the future make use of it in
report() or other later-introduced functions.

I don't insist though - please feel free to apply attached follow-up
patch with global -> local conversion.

Thanks,
Kirill

---- 8< ----
From: Kirill Smelkov <kirr@nexedi.com>
Date: Tue, 22 Jul 2014 19:25:15 +0400
Subject: [PATCH] scripts/fsrefs: De-globalify verbose

As noted in recent commit, verbose option handling in fsrefs.py was
broken. On review Tres suggested to make VERBOSE a local variable as
currently it is used only in one function main().

Suggested-by: Tres Seaver
---
 src/ZODB/scripts/fsrefs.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/ZODB/scripts/fsrefs.py b/src/ZODB/scripts/fsrefs.py
index 6225e0f..77ec065 100644
--- a/src/ZODB/scripts/fsrefs.py
+++ b/src/ZODB/scripts/fsrefs.py
@@ -70,8 +70,6 @@ from ZODB.utils import u64, oid_repr, get_pickle_metadata
 from ZODB.serialize import get_refs
 from ZODB.POSException import POSKeyError
 
-VERBOSE = 0
-
 # There's a problem with oid.  'data' is its pickle, and 'serial' its
 # serial number.  'missing' is a list of (oid, class, reason) triples,
 # explaining what the problem(s) is(are).
@@ -94,7 +92,7 @@ def report(oid, data, serial, missing):
     print()
 
 def main(path=None):
-    global VERBOSE
+    verbose = 0
     if path is None:
         import sys
         import getopt
@@ -102,7 +100,7 @@ def main(path=None):
         opts, args = getopt.getopt(sys.argv[1:], "v")
         for k, v in opts:
             if k == "-v":
-                VERBOSE += 1
+                verbose += 1
 
         path, = args
 
@@ -128,7 +126,7 @@ def main(path=None):
         except POSKeyError:
             undone[oid] = 1
         except:
-            if VERBOSE:
+            if verbose:
                 traceback.print_exc()
             noload[oid] = 1
 
-- 
2.0.2.796.g90283d9