Mercurial > libervia-web
annotate browser_side/jid.py @ 301:5943eaa6f422
browser_side (plugin radiocol): set the upload limit to 10 MB instead of 5
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 18 Dec 2013 07:45:53 +0100 |
parents | 886b47896f3c |
children | 6ce8515ee8f5 |
rev | line source |
---|---|
13 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 Libervia: a Salut à Toi frontend | |
165 | 6 Copyright (C) 2011, 2012, 2013 Jérôme Poisson <goffi@goffi.org> |
13 | 7 |
8 This program is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU Affero General Public License as published by | |
10 the Free Software Foundation, either version 3 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU Affero General Public License for more details. | |
17 | |
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/>. | |
20 """ | |
21 | |
22 | |
274
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
23 class JID(object): |
13 | 24 """This class help manage JID (Node@Domaine/Resource)""" |
25 | |
26 def __init__(self, jid): | |
19 | 27 self.__raw = str(jid) |
13 | 28 self.__parse() |
29 | |
30 def __parse(self): | |
31 """find node domaine and resource""" | |
274
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
32 node_end = self.__raw.find('@') |
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
33 if node_end < 0: |
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
34 node_end = 0 |
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
35 domain_end = self.__raw.find('/') |
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
36 if domain_end < 1: |
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
37 domain_end = len(self.__raw) |
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
38 self.node = self.__raw[:node_end] |
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
39 self.domain = self.__raw[(node_end + 1) if node_end else 0:domain_end] |
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
40 self.resource = self.__raw[domain_end + 1:] |
13 | 41 if not node_end: |
274
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
42 self.bare = self.__raw |
13 | 43 else: |
274
886b47896f3c
browser_side: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
165
diff
changeset
|
44 self.bare = self.node + '@' + self.domain |
19 | 45 |
46 def __str__(self): | |
47 return self.__raw.__str__() | |
13 | 48 |
49 def is_valid(self): | |
50 """return True if the jid is xmpp compliant""" | |
51 #FIXME: always return True for the moment | |
52 return True |