Happily unbroked once again

Tue, 07 May 2013 22:22:22 +0200

author
Andy Buckley <andy@insectnation.org>
date
Tue, 07 May 2013 22:22:22 +0200
changeset 222
3c65cf35a5b5
parent 221
4f6ce5c1904d
child 223
a37f9686a5ff

Happily unbroked once again

pyslha.py file | annotate | diff | comparison | revisions
     1.1 --- a/pyslha.py	Tue May 07 22:18:36 2013 +0200
     1.2 +++ b/pyslha.py	Tue May 07 22:22:22 2013 +0200
     1.3 @@ -197,18 +197,15 @@
     1.4              self.entries[None] = args[0]
     1.5          else:
     1.6              ## Find the first non-integer -- all previous items are indices
     1.7 +            i_first_nonint = -1
     1.8              for i, x in enumerate(args):
     1.9                  if type(x) is not int:
    1.10                      i_first_nonint = i
    1.11                      break
    1.12              if i_first_nonint == 0:
    1.13                  raise AccessError("Attempted to set a block entry with a non-integer(s) index")
    1.14 -            elif i_first_nonint == 1:
    1.15 -                self.entries[args[0]] = args[1:]
    1.16 -            elif i_first_nonint == len(args)-1:
    1.17 -                self.entries[tuple(args[:-1])] = args[-1]
    1.18              else:
    1.19 -                self.entries[tuple(args[:i_first_nonint])] = args[i_first_nonint:]
    1.20 +                self.entries[_autotuple(args[:i_first_nonint])] = _autotuple(args[i_first_nonint:])
    1.21  
    1.22      def has_key(self, key):
    1.23          """Does the block have the given key?"""
    1.24 @@ -236,7 +233,7 @@
    1.25          return self.entries[key]
    1.26  
    1.27      def __setitem__(self, key, value):
    1.28 -        if type(key) is not int and not all(type(x) is int for x in key):
    1.29 +        if key is not None and type(key) is not int and not all(type(x) is int for x in key):
    1.30              raise AccessError("Attempted to set a block entry with a non-integer(s) index")
    1.31          self.entries[key] = value
    1.32  
    1.33 @@ -724,7 +721,7 @@
    1.34      blocks["MINPAR"] = Block("MINPAR")
    1.35      blocks["MINPAR"][3] = TANB
    1.36      blocks["ALPHA"] = Block("ALPHA")
    1.37 -    blocks["ALPHA"][None] = ALPHAH
    1.38 +    blocks["ALPHA"].set_value(ALPHAH)
    1.39      #
    1.40      ## Neutralino mixing matrix
    1.41      blocks["NMIX"] = Block("NMIX")

mercurial