#!/usr/bin/python
#
-# Copyright (C) 2014 Simo Sorce <simo@redhat.com>
-#
-# see file 'COPYING' for use and warranty information
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
+# Copyright (C) 2014 Ipsilon project Contributors, for license see COPYING
from lxml import html
import requests
def first_value(self, rule):
result = self.tree.xpath(rule)
- if type(result) is list:
+ if isinstance(result, list):
if len(result) > 0:
result = result[0]
else:
def all_values(self, rule):
result = self.tree.xpath(rule)
- if type(result) is list:
+ if isinstance(result, list):
return result
return [result]
return values
def handle_login_form(self, idp, page):
- if type(page) != PageTree:
+ if not isinstance(page, PageTree):
raise TypeError("Expected PageTree object")
srv = self.servers[idp]
{'headers': headers, 'data': payload}]
def handle_return_form(self, page):
- if type(page) != PageTree:
+ if not isinstance(page, PageTree):
raise TypeError("Expected PageTree object")
try:
{'headers': headers, 'data': payload}]
def handle_openid_form(self, page):
- if type(page) != PageTree:
+ if not isinstance(page, PageTree):
raise TypeError("Expected PageTree object")
if not page.first_value('//title/text()') == \
{'headers': headers, 'data': payload}]
def handle_openid_consent_form(self, page):
- if type(page) != PageTree:
+ if not isinstance(page, PageTree):
raise TypeError("Expected PageTree object")
try:
args = {}
while True:
- # pylint: disable=star-args
r = self.access(action, url, krb=krb, **args)
if r.status_code == 303 or r.status_code == 302:
if not follow_redirect: