[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r36830 - in trunk: . build/generator/util build/win32 subversion/tests/cmdline tools/bdb www

From: Greg Stein <gstein_at_gmail.com>
Date: Sun, 29 Mar 2009 05:17:10 +0100

Excellent! After your last commit, I was going to suggest using
isinstance rather than fetching a type() ... you beat me to it :-)

Cheers,
-g

On Sat, Mar 28, 2009 at 23:25, Arfrever Frehtes Taifersar Arahesis
<Arfrever.FTA_at_gmail.com> wrote:
> Author: arfrever
> Date: Sat Mar 28 15:25:27 2009
> New Revision: 36830
>
> Log:
> Use isinstance() for type comparisons.
>
> * build/generator/util/executable.py:
> * build/win32/make_dist.py:
> * gen-make.py:
> * subversion/tests/cmdline/svnadmin_tests.py:
> * subversion/tests/cmdline/svndumpfilter_tests.py:
> * tools/bdb/skel.py:
> * www/toctool.py: Use isinstance() for type comparisons.
>
> Modified:
>   trunk/build/generator/util/executable.py
>   trunk/build/win32/make_dist.py
>   trunk/gen-make.py
>   trunk/subversion/tests/cmdline/svnadmin_tests.py
>   trunk/subversion/tests/cmdline/svndumpfilter_tests.py
>   trunk/tools/bdb/skel.py
>   trunk/www/toctool.py
>
> Modified: trunk/build/generator/util/executable.py
> URL: http://svn.collab.net/viewvc/svn/trunk/build/generator/util/executable.py?pathrev=36830&r1=36829&r2=36830
> ==============================================================================
> --- trunk/build/generator/util/executable.py    Sat Mar 28 15:12:38 2009        (r36829)
> +++ trunk/build/generator/util/executable.py    Sat Mar 28 15:25:27 2009        (r36830)
> @@ -26,9 +26,9 @@ def output(cmd, strip=None):
>   """Run a command and collect all output"""
>   # Check that cmd is in PATH (otherwise we'd get a generic OSError later)
>   import distutils.spawn
> -  if type(cmd) == str:
> +  if isinstance(cmd, str):
>     cmdname = cmd
> -  elif type(cmd) == list:
> +  elif isinstance(cmd, list):
>     cmdname = cmd[0]
>   if distutils.spawn.find_executable(cmdname) is None:
>     return None
>
> Modified: trunk/build/win32/make_dist.py
> URL: http://svn.collab.net/viewvc/svn/trunk/build/win32/make_dist.py?pathrev=36830&r1=36829&r2=36830
> ==============================================================================
> --- trunk/build/win32/make_dist.py      Sat Mar 28 15:12:38 2009        (r36829)
> +++ trunk/build/win32/make_dist.py      Sat Mar 28 15:25:27 2009        (r36830)
> @@ -443,7 +443,7 @@ def _make_dist(cfg):
>       action = _disttree[reldir]
>       if action is None:
>         continue
> -      if type(action) == tuple:
> +      if isinstance(action, tuple):
>         for subaction in action:
>           subaction.run(dir, cfg)
>       else:
>
> Modified: trunk/gen-make.py
> URL: http://svn.collab.net/viewvc/svn/trunk/gen-make.py?pathrev=36830&r1=36829&r2=36830
> ==============================================================================
> --- trunk/gen-make.py   Sat Mar 28 15:12:38 2009        (r36829)
> +++ trunk/gen-make.py   Sat Mar 28 15:25:27 2009        (r36830)
> @@ -55,7 +55,7 @@ def main(fname, gentype, verfname=None,
>     gen_keys = sorted(generator.__dict__.keys())
>     for name in gen_keys:
>       value = generator.__dict__[name]
> -      if type(value) == list:
> +      if isinstance(value, list):
>         print(name + ": ")
>         for i in value:
>           print("  " + _objinfo(i))
> @@ -63,7 +63,7 @@ def main(fname, gentype, verfname=None,
>
>
>  def _objinfo(o):
> -  if type(o) == str:
> +  if isinstance(o, str):
>     return repr(o)
>   else:
>     t = o.__class__.__name__
>
> Modified: trunk/subversion/tests/cmdline/svnadmin_tests.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svnadmin_tests.py?pathrev=36830&r1=36829&r2=36830
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svnadmin_tests.py    Sat Mar 28 15:12:38 2009        (r36829)
> +++ trunk/subversion/tests/cmdline/svnadmin_tests.py    Sat Mar 28 15:25:27 2009        (r36830)
> @@ -83,7 +83,7 @@ def load_and_verify_dumpstream(sbox, exp
>   using the array of wc.States passed in revs. VARARGS are optional
>   arguments passed to the 'load' command"""
>
> -  if type(dump) is str:
> +  if isinstance(dump, str):
>     dump = [ dump ]
>
>   exit_code, output, errput = svntest.main.run_command_stdin(
>
> Modified: trunk/subversion/tests/cmdline/svndumpfilter_tests.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svndumpfilter_tests.py?pathrev=36830&r1=36829&r2=36830
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svndumpfilter_tests.py       Sat Mar 28 15:12:38 2009        (r36829)
> +++ trunk/subversion/tests/cmdline/svndumpfilter_tests.py       Sat Mar 28 15:25:27 2009        (r36830)
> @@ -42,7 +42,7 @@ Item = svntest.wc.StateItem
>  def filter_and_return_output(dump, *varargs):
>   """Filter the array of lines passed in 'dump' and return the output"""
>
> -  if type(dump) is str:
> +  if isinstance(dump, str):
>     dump = [ dump ]
>
>   ## TODO: Should we need to handle errput and exit_code?
>
> Modified: trunk/tools/bdb/skel.py
> URL: http://svn.collab.net/viewvc/svn/trunk/tools/bdb/skel.py?pathrev=36830&r1=36829&r2=36830
> ==============================================================================
> --- trunk/tools/bdb/skel.py     Sat Mar 28 15:12:38 2009        (r36829)
> +++ trunk/tools/bdb/skel.py     Sat Mar 28 15:25:27 2009        (r36830)
> @@ -52,7 +52,7 @@ _ok_implicit = re.compile(r'^[A-Za-z]([^
>  def unparse(struc):
>   accum = []
>   for ent in struc:
> -    if type(ent) == str:
> +    if isinstance(ent, str):
>       if len(ent) > 0 and _ok_implicit.match(ent[0]):
>         accum.append(ent)
>       else:
> @@ -66,7 +66,7 @@ def unparse(struc):
>  class Rev:
>   def __init__(self, skelstring="(revision null)"):
>     sk = parse(skelstring)
> -    if len(sk) == 2 and sk[0] == "revision" and type(sk[1]) == str:
> +    if len(sk) == 2 and sk[0] == "revision" and isinstance(sk[1], str):
>       self.txn = sk[1]
>     else:
>       raise ValueError("Invalid revision skel: %s" % skelstring)
> @@ -112,9 +112,9 @@ class Copy:
>  class Node:
>   def __init__(self,skelstring="((file null null 1 0) null null)"):
>     sk = parse(skelstring)
> -    if (len(sk) == 3 or (len(sk) == 4 and type(sk[3]) == str)) \
> -        and type(sk[0]) == list and type(sk[1]) == str \
> -        and type(sk[2]) == str and sk[0][0] in ("file", "dir") \
> +    if (len(sk) == 3 or (len(sk) == 4 and isinstance(sk[3], str))) \
> +        and isinstance(sk[0], list) and isinstance(sk[1], str) \
> +        and isinstance(sk[2], str) and sk[0][0] in ("file", "dir") \
>         and type(sk[0][1]) == type(sk[0][2]) == type(sk[0][3]) == str:
>           self.kind = sk[0][0]
>           self.createpath = sk[0][1]
> @@ -180,9 +180,9 @@ class Rep:
>   def __init__(self, skelstring="((fulltext 0  (md5 16 \0\0\0\0\0\0\0\0" \
>           "\0\0\0\0\0\0\0\0)) null)"):
>     sk = parse(skelstring)
> -    if type(sk[0]) == list and len(sk[0]) == 3 \
> -        and type(sk[0][1]) == str \
> -        and type(sk[0][2]) == list and len(sk[0][2]) == 2 \
> +    if isinstance(sk[0], list) and len(sk[0]) == 3 \
> +        and isinstance(sk[0][1], str) \
> +        and isinstance(sk[0][2], list) and len(sk[0][2]) == 2 \
>         and type(sk[0][2][0]) == type(sk[0][2][1]) == str:
>           self.kind = sk[0][0]
>           self.txn = sk[0][1]
>
> Modified: trunk/www/toctool.py
> URL: http://svn.collab.net/viewvc/svn/trunk/www/toctool.py?pathrev=36830&r1=36829&r2=36830
> ==============================================================================
> --- trunk/www/toctool.py        Sat Mar 28 15:12:38 2009        (r36829)
> +++ trunk/www/toctool.py        Sat Mar 28 15:25:27 2009        (r36830)
> @@ -31,7 +31,7 @@ class Index:
>   def prettyString(self):
>     out = []
>     def step(ilevel, node):
> -      if type(node) == list:
> +      if isinstance(node, list):
>         for subnode in node:
>           step(ilevel+1, subnode)
>       else:
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=1462015
>

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1465789
Received on 2009-03-29 06:17:33 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.