comparison browser_side/jid.py @ 274:886b47896f3c

browser_side: better PEP8 compliance
author souliane <souliane@mailoo.org>
date Thu, 21 Nov 2013 16:05:14 +0100
parents 9763dec220ed
children 6ce8515ee8f5
comparison
equal deleted inserted replaced
273:11718798ab8a 274:886b47896f3c
18 You should have received a copy of the GNU Affero General Public License 18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """ 20 """
21 21
22 22
23 23 class JID(object):
24 class JID:
25 """This class help manage JID (Node@Domaine/Resource)""" 24 """This class help manage JID (Node@Domaine/Resource)"""
26 25
27 def __init__(self, jid): 26 def __init__(self, jid):
28 self.__raw = str(jid) 27 self.__raw = str(jid)
29 self.__parse() 28 self.__parse()
30 29
31 def __parse(self): 30 def __parse(self):
32 """find node domaine and resource""" 31 """find node domaine and resource"""
33 node_end=self.__raw.find('@') 32 node_end = self.__raw.find('@')
34 if node_end<0: 33 if node_end < 0:
35 node_end=0 34 node_end = 0
36 domain_end=self.__raw.find('/') 35 domain_end = self.__raw.find('/')
37 if domain_end<1: 36 if domain_end < 1:
38 domain_end=len(self.__raw) 37 domain_end = len(self.__raw)
39 self.node=self.__raw[:node_end] 38 self.node = self.__raw[:node_end]
40 self.domain=self.__raw[(node_end+1) if node_end else 0:domain_end] 39 self.domain = self.__raw[(node_end + 1) if node_end else 0:domain_end]
41 self.resource=self.__raw[domain_end+1:] 40 self.resource = self.__raw[domain_end + 1:]
42 if not node_end: 41 if not node_end:
43 self.bare=self.__raw 42 self.bare = self.__raw
44 else: 43 else:
45 self.bare=self.node+'@'+self.domain 44 self.bare = self.node + '@' + self.domain
46 45
47 def __str__(self): 46 def __str__(self):
48 return self.__raw.__str__() 47 return self.__raw.__str__()
49 48
50 def is_valid(self): 49 def is_valid(self):