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

Source Code for Module Skype4Py.profile

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