Skip to content

Commit

Permalink
Fixed remaining pep8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Jun 7, 2014
1 parent f4fffbf commit 6fe71da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
22 changes: 12 additions & 10 deletions Lib/python/std_pair.i
Expand Up @@ -176,18 +176,20 @@ SwigPython_std_pair_setitem (PyObject *a, Py_ssize_t b, PyObject *c)
%define %swig_pair_methods(pair...)
#if !defined(SWIGPYTHON_BUILTIN)
%extend {
%pythoncode {def __len__(self): return 2
def __repr__(self): return str((self.first, self.second))
%pythoncode {def __len__(self):
return 2
def __repr__(self):
return str((self.first, self.second))
def __getitem__(self, index):
if not (index % 2):
return self.first
else:
return self.second
if not (index % 2):
return self.first
else:
return self.second
def __setitem__(self, index, val):
if not (index % 2):
self.first = val
else:
self.second = val}
if not (index % 2):
self.first = val
else:
self.second = val}
}
#endif
%enddef
Expand Down
22 changes: 11 additions & 11 deletions Source/Modules/python.cxx
Expand Up @@ -860,10 +860,10 @@ class PYTHON:public Language {
// Python-2.2 object hack
Printv(f_shadow,
"\n", "def _swig_setattr_nondynamic(self, class_type, name, value, static=1):\n",
tab4, "if (name == \"thisown\"):\n", tab4, tab4, "return self.this.own(value)\n",
tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n",
tab4, "if (name == \"thisown\"):\n", tab8, "return self.this.own(value)\n",
tab4, "if (name == \"this\"):\n", tab8, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n",
#ifdef USE_THISOWN
tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n",
tab4, tab8, "if hasattr(value,\"thisown\"):\n", tab8, tab8, "self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n",
#endif
tab4, tab8, "return\n", tab4, "method = class_type.__swig_setmethods__.get(name, None)\n", tab4, "if method:\n", tab4, tab4, "return method(self, value)\n",
#ifdef USE_THISOWN
Expand All @@ -878,14 +878,14 @@ class PYTHON:public Language {

Printv(f_shadow,
"\n", "def _swig_getattr(self, class_type, name):\n",
tab4, "if (name == \"thisown\"):\n", tab4, tab4, "return self.this.own()\n",
tab4, "if (name == \"thisown\"):\n", tab8, "return self.this.own()\n",
tab4, "method = class_type.__swig_getmethods__.get(name, None)\n",
tab4, "if method:\n", tab4, tab4, "return method(self)\n", tab4, "raise AttributeError(name)\n\n", NIL);
tab4, "if method:\n", tab8, "return method(self)\n", tab4, "raise AttributeError(name)\n\n", NIL);

Printv(f_shadow,
"\n", "def _swig_repr(self):\n",
tab4, "try:\n", tab4, tab4, "strthis = \"proxy of \" + self.this.__repr__()\n",
tab4, "except:\n", tab4, tab4, "strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
tab4, "try:\n", tab8, "strthis = \"proxy of \" + self.this.__repr__()\n",
tab4, "except:\n", tab8, "strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);

if (!classic) {
/* Usage of types.ObjectType is deprecated.
Expand All @@ -895,7 +895,7 @@ class PYTHON:public Language {
// "import types\n",
"try:\n",
// " _object = types.ObjectType\n",
tab4, "_object = object\n", tab4, "_newclass = 1\n", "except AttributeError:\n", tab4, "class _object:\n", tab4, tab4, "pass\n", tab4, "_newclass = 0\n",
tab4, "_object = object\n", tab4, "_newclass = 1\n", "except AttributeError:\n", tab4, "class _object:\n", tab8, "pass\n", tab4, "_newclass = 0\n",
// "del types\n",
"\n\n", NIL);
}
Expand All @@ -905,7 +905,7 @@ class PYTHON:public Language {
#ifdef USE_THISOWN
tab4, tab4, "if hasattr(self, name) or (name in (\"this\", \"thisown\")):\n",
#else
tab4, tab4, "if (name == \"thisown\"): return self.this.own(value)\n", tab4, tab4, "if hasattr(self, name) or (name == \"this\"):\n",
tab4, tab4, "if (name == \"thisown\"):\n", tab8, tab4, "return self.this.own(value)\n", tab4, tab4, "if hasattr(self, name) or (name == \"this\"):\n",
#endif
tab4, tab4, tab4, "set(self, name, value)\n",
tab4, tab4, "else:\n",
Expand Down Expand Up @@ -1637,7 +1637,7 @@ class PYTHON:public Language {
}
// Write the function annotation
if (func_annotation)
Printf(doc, " : '%s'", type_str);
Printf(doc, ": '%s'", type_str);

// Write default value
if (value && !calling) {
Expand Down Expand Up @@ -2012,7 +2012,7 @@ class PYTHON:public Language {
if (ret)
ret = SwigType_str(ret, 0);
}
return (ret && py3) ? NewStringf(" -> \"%s\" ", ret)
return (ret && py3) ? NewStringf(" -> \"%s\"", ret)
: NewString("");
}

Expand Down

0 comments on commit 6fe71da

Please sign in to comment.