Package Skype4Py :: Module profile
[frames] | no frames]

Source Code for Module Skype4Py.profile

  1  """Current user profile. 
  2  """ 
  3  __docformat__ = 'restructuredtext en' 
  4   
  5   
  6  import weakref 
  7   
  8  from utils import * 
  9   
 10   
11 -class Profile(object):
12 """Represents the profile of currently logged in user. Access using 13 `skype.Skype.CurrentUserProfile`. 14 """ 15
16 - def __init__(self, Skype):
17 """__init__. 18 19 :Parameters: 20 Skype : `Skype` 21 Skype object. 22 """ 23 self._SkypeRef = weakref.ref(Skype)
24
25 - def _Property(self, PropName, Set=None):
26 return self._Skype._Property('PROFILE', '', PropName, Set)
27
28 - def _Get_Skype(self):
29 skype = self._SkypeRef() 30 if skype: 31 return skype 32 raise Exception()
33 34 _Skype = property(_Get_Skype) 35
36 - def _GetAbout(self):
37 return self._Property('ABOUT')
38
39 - def _SetAbout(self, Value):
40 self._Property('ABOUT', Value)
41 42 About = property(_GetAbout, _SetAbout, 43 doc=""""About" field of the profile. 44 45 :type: unicode 46 """) 47
48 - def _GetBalance(self):
49 return int(self._Property('PSTN_BALANCE'))
50 51 Balance = property(_GetBalance, 52 doc="""Skype credit balance. Note that the precision of profile balance value is currently 53 fixed at 2 decimal places, regardless of currency or any other settings. Use `BalanceValue` 54 to get the balance expressed in currency. 55 56 :type: int 57 58 :see: `BalanceCurrency`, `BalanceToText`, `BalanceValue` 59 """) 60
61 - def _GetBalanceCurrency(self):
62 return self._Property('PSTN_BALANCE_CURRENCY')
63 64 BalanceCurrency = property(_GetBalanceCurrency, 65 doc="""Skype credit balance currency. 66 67 :type: unicode 68 69 :see: `Balance`, `BalanceToText`, `BalanceValue` 70 """) 71
72 - def _GetBalanceToText(self):
73 return (u'%s %.2f' % (self.BalanceCurrency, self.BalanceValue)).strip()
74 75 BalanceToText = property(_GetBalanceToText, 76 doc="""Skype credit balance as properly formatted text with currency. 77 78 :type: unicode 79 80 :see: `Balance`, `BalanceCurrency`, `BalanceValue` 81 """) 82
83 - def _GetBalanceValue(self):
84 return float(self._Property('PSTN_BALANCE')) / 100
85 86 BalanceValue = property(_GetBalanceValue, 87 doc="""Skype credit balance expressed in currency. 88 89 :type: float 90 91 :see: `Balance`, `BalanceCurrency`, `BalanceToText` 92 """) 93
94 - def _GetBirthday(self):
95 value = self._Property('BIRTHDAY') 96 if len(value) == 8: 97 from datetime import date 98 from time import strptime 99 return date(*strptime(value, '%Y%m%d')[:3])
100
101 - def _SetBirthday(self, Value):
102 if Value: 103 self._Property('BIRTHDAY', Value.strftime('%Y%m%d')) 104 else: 105 self._Property('BIRTHDAY', 0)
106 107 Birthday = property(_GetBirthday, _SetBirthday, 108 doc=""""Birthday" field of the profile. 109 110 :type: datetime.date 111 """) 112
113 - def _GetCallApplyCF(self):
114 return (self._Property('CALL_APPLY_CF') == 'TRUE')
115
116 - def _SetCallApplyCF(self, Value):
117 self._Property('CALL_APPLY_CF', cndexp(Value, 'TRUE', 'FALSE'))
118 119 CallApplyCF = property(_GetCallApplyCF, _SetCallApplyCF, 120 doc="""Tells if call forwarding is enabled in the profile. 121 122 :type: bool 123 """) 124
125 - def _GetCallForwardRules(self):
126 return str(self._Property('CALL_FORWARD_RULES'))
127
128 - def _SetCallForwardRules(self, Value):
129 self._Property('CALL_FORWARD_RULES', Value)
130 131 CallForwardRules = property(_GetCallForwardRules, _SetCallForwardRules, 132 doc="""Call forwarding rules of the profile. 133 134 :type: str 135 """) 136
137 - def _GetCallNoAnswerTimeout(self):
138 return int(self._Property('CALL_NOANSWER_TIMEOUT'))
139
140 - def _SetCallNoAnswerTimeout(self, Value):
141 self._Property('CALL_NOANSWER_TIMEOUT', Value)
142 143 CallNoAnswerTimeout = property(_GetCallNoAnswerTimeout, _SetCallNoAnswerTimeout, 144 doc="""Number of seconds a call will ring without being answered before it 145 stops ringing. 146 147 :type: int 148 """) 149
150 - def _GetCallSendToVM(self):
151 return (self._Property('CALL_SEND_TO_VM') == 'TRUE')
152
153 - def _SetCallSendToVM(self, Value):
154 self._Property('CALL_SEND_TO_VM', cndexp(Value, 'TRUE', 'FALSE'))
155 156 CallSendToVM = property(_GetCallSendToVM, _SetCallSendToVM, 157 doc="""Tells whether calls will be sent to the voicemail. 158 159 :type: bool 160 """) 161
162 - def _GetCity(self):
163 return self._Property('CITY')
164
165 - def _SetCity(self, Value):
166 self._Property('CITY', Value)
167 168 City = property(_GetCity, _SetCity, 169 doc=""""City" field of the profile. 170 171 :type: unicode 172 """) 173
174 - def _GetCountry(self):
175 return chop(self._Property('COUNTRY'))[0]
176
177 - def _SetCountry(self, Value):
178 self._Property('COUNTRY', Value)
179 180 Country = property(_GetCountry, _SetCountry, 181 doc=""""Country" field of the profile. 182 183 :type: unicode 184 """) 185
186 - def _GetFullName(self):
187 return self._Property('FULLNAME')
188
189 - def _SetFullName(self, Value):
190 self._Property('FULLNAME', Value)
191 192 FullName = property(_GetFullName, _SetFullName, 193 doc=""""Full name" field of the profile. 194 195 :type: unicode 196 """) 197
198 - def _GetHomepage(self):
199 return self._Property('HOMEPAGE')
200
201 - def _SetHomepage(self, Value):
202 self._Property('HOMEPAGE', Value)
203 204 Homepage = property(_GetHomepage, _SetHomepage, 205 doc=""""Homepage" field of the profile. 206 207 :type: unicode 208 """) 209
210 - def _GetIPCountry(self):
211 return str(self._Property('IPCOUNTRY'))
212 213 IPCountry = property(_GetIPCountry, 214 doc="""ISO country code queried by IP address. 215 216 :type: str 217 """) 218
219 - def _GetLanguages(self):
220 return [str(x) for x in split(self._Property('LANGUAGES'))]
221
222 - def _SetLanguages(self, Value):
223 self._Property('LANGUAGES', ' '.join(Value))
224 225 Languages = property(_GetLanguages, _SetLanguages, 226 doc=""""ISO language codes of the profile. 227 228 :type: list of str 229 """) 230
231 - def _GetMoodText(self):
232 return self._Property('MOOD_TEXT')
233
234 - def _SetMoodText(self, Value):
235 self._Property('MOOD_TEXT', Value)
236 237 MoodText = property(_GetMoodText, _SetMoodText, 238 doc=""""Mood text" field of the profile. 239 240 :type: unicode 241 """) 242
243 - def _GetPhoneHome(self):
244 return self._Property('PHONE_HOME')
245
246 - def _SetPhoneHome(self, Value):
247 self._Property('PHONE_HOME', Value)
248 249 PhoneHome = property(_GetPhoneHome, _SetPhoneHome, 250 doc=""""Phone home" field of the profile. 251 252 :type: unicode 253 """) 254
255 - def _GetPhoneMobile(self):
256 return self._Property('PHONE_MOBILE')
257
258 - def _SetPhoneMobile(self, Value):
259 self._Property('PHONE_MOBILE', Value)
260 261 PhoneMobile = property(_GetPhoneMobile, _SetPhoneMobile, 262 doc=""""Phone mobile" field of the profile. 263 264 :type: unicode 265 """) 266
267 - def _GetPhoneOffice(self):
268 return self._Property('PHONE_OFFICE')
269
270 - def _SetPhoneOffice(self, Value):
271 self._Property('PHONE_OFFICE', Value)
272 273 PhoneOffice = property(_GetPhoneOffice, _SetPhoneOffice, 274 doc=""""Phone office" field of the profile. 275 276 :type: unicode 277 """) 278
279 - def _GetProvince(self):
280 return self._Property('PROVINCE')
281
282 - def _SetProvince(self, Value):
283 self._Property('PROVINCE', Value)
284 285 Province = property(_GetProvince, _SetProvince, 286 doc=""""Province" field of the profile. 287 288 :type: unicode 289 """) 290
291 - def _GetRichMoodText(self):
292 return self._Property('RICH_MOOD_TEXT')
293
294 - def _SetRichMoodText(self, Value):
295 self._Property('RICH_MOOD_TEXT', Value)
296 297 RichMoodText = property(_GetRichMoodText, _SetRichMoodText, 298 doc="""Rich mood text of the profile. 299 300 :type: unicode 301 302 :see: https://developer.skype.com/Docs/ApiDoc/SET_PROFILE_RICH_MOOD_TEXT 303 """) 304
305 - def _GetSex(self):
306 return str(self._Property('SEX'))
307
308 - def _SetSex(self, Value):
309 self._Property('SEX', Value)
310 311 Sex = property(_GetSex, _SetSex, 312 doc=""""Sex" field of the profile. 313 314 :type: `enums`.usex* 315 """) 316
317 - def _GetTimezone(self):
318 return int(self._Property('TIMEZONE'))
319
320 - def _SetTimezone(self, Value):
321 self._Property('TIMEZONE', Value)
322 323 Timezone = property(_GetTimezone, _SetTimezone, 324 doc="""Timezone of the current profile in minutes from GMT. 325 326 :type: int 327 """) 328
329 - def _GetValidatedSmsNumbers(self):
330 return [str(x) for x in split(self._Property('SMS_VALIDATED_NUMBERS'), ', ')]
331 332 ValidatedSmsNumbers = property(_GetValidatedSmsNumbers, 333 doc="""List of phone numbers the user has registered for usage in reply-to 334 field of SMS messages. 335 336 :type: list of str 337 """)
338