Changeset 7937
- Timestamp:
- 02/04/07 19:57:25 (22 months ago)
- Location:
- trunk/src/common
- Files:
-
- 7 modified
-
commands.py (modified) (2 diffs)
-
connection_handlers.py (modified) (2 diffs)
-
fuzzyclock.py (modified) (1 diff)
-
helpers.py (modified) (3 diffs)
-
optparser.py (modified) (2 diffs)
-
rst_xhtml_generator.py (modified) (2 diffs)
-
xmpp_stringprep.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/common/commands.py
r7872 r7937 118 118 presencetype = form['presence-type'].value 119 119 if not presencetype in \ 120 ('free-for-chat', 'online', 'away', 'xa', 'dnd', 'offline'):120 ('free-for-chat', 'online', 'away', 'xa', 'dnd', 'offline'): 121 121 self.badRequest(request) 122 122 return False … … 283 283 q = iq.getTag('query') 284 284 q.addChild('identity', attrs = {'type': 'command-node', 285 'category': 'automation',286 'name': cmd.commandname})285 'category': 'automation', 286 'name': cmd.commandname}) 287 287 q.addChild('feature', attrs = {'var': xmpp.NS_COMMANDS}) 288 288 for feature in cmd.commandfeatures: -
trunk/src/common/connection_handlers.py
r7934 r7937 860 860 entry = {} 861 861 for c in info.getChildren(): 862 entry[c.getName()] = c.getData()862 entry[c.getName()] = c.getData() 863 863 dict[name].append(entry) 864 864 elif info.getChildren() == []: … … 867 867 dict[name] = {} 868 868 for c in info.getChildren(): 869 dict[name][c.getName()] = c.getData()869 dict[name][c.getName()] = c.getData() 870 870 return dict 871 871 -
trunk/src/common/fuzzyclock.py
r7756 r7937 35 35 36 36 class FuzzyClock: 37 def __init__(self):38 self.__hour = 039 self.__minute = 040 self.__dayOfWeek = 037 def __init__(self): 38 self.__hour = 0 39 self.__minute = 0 40 self.__dayOfWeek = 0 41 41 42 self.__hourNames = [ _('one'), _('two'), _('three'), _('four'), _('five'), _('six'),43 _('seven'), _('eight'), _('nine'), _('ten'), _('eleven'),44 _('twelve')]42 self.__hourNames = [ _('one'), _('two'), _('three'), _('four'), _('five'), _('six'), 43 _('seven'), _('eight'), _('nine'), _('ten'), _('eleven'), 44 _('twelve')] 45 45 46 #Strings to use for the output. %0 will be replaced with the preceding hour (e.g. "x PAST %0"), %1 with the coming hour (e.g. "x TO %1). '''47 self.__normalFuzzy = [ _("$0 o'clock"), _('five past $0'),48 _('ten past $0'), _('quarter past $0'),49 _('twenty past $0'), _('twenty five past $0'),50 _('half past $0'), _('twenty five to $1'),51 _('twenty to $1'), _('quarter to $1'),52 _('ten to $1'), _('five to $1'), _("$1 o'clock") ]46 #Strings to use for the output. %0 will be replaced with the preceding hour (e.g. "x PAST %0"), %1 with the coming hour (e.g. "x TO %1). ''' 47 self.__normalFuzzy = [ _("$0 o'clock"), _('five past $0'), 48 _('ten past $0'), _('quarter past $0'), 49 _('twenty past $0'), _('twenty five past $0'), 50 _('half past $0'), _('twenty five to $1'), 51 _('twenty to $1'), _('quarter to $1'), 52 _('ten to $1'), _('five to $1'), _("$1 o'clock") ] 53 53 54 #A "singular-form". It is used when talking about hour 055 self.__normalFuzzyOne = [ _("$0 o'clock"), _('five past $0'),56 _('ten past $0'), _('quarter past $0'),57 _('twenty past $0'), _('twenty five past $0'),58 _('half past $0'), _('twenty five to $1'),59 _('twenty to $1'), _('quarter to $1'),60 _('ten to $1'), _('five to $1'),61 _("$1 o'clock") ]54 #A "singular-form". It is used when talking about hour 0 55 self.__normalFuzzyOne = [ _("$0 o'clock"), _('five past $0'), 56 _('ten past $0'), _('quarter past $0'), 57 _('twenty past $0'), _('twenty five past $0'), 58 _('half past $0'), _('twenty five to $1'), 59 _('twenty to $1'), _('quarter to $1'), 60 _('ten to $1'), _('five to $1'), 61 _("$1 o'clock") ] 62 62 63 63 64 self.__dayTime = [ _('Night'), _('Early morning'), _('Morning'), _('Almost noon'),65 _('Noon'), _('Afternoon'), _('Evening'), _('Late evening') ]64 self.__dayTime = [ _('Night'), _('Early morning'), _('Morning'), _('Almost noon'), 65 _('Noon'), _('Afternoon'), _('Evening'), _('Late evening') ] 66 66 67 self.__fuzzyWeek = [ _('Start of week'), _('Middle of week'), _('End of week'),68 _('Weekend!') ]67 self.__fuzzyWeek = [ _('Start of week'), _('Middle of week'), _('End of week'), 68 _('Weekend!') ] 69 69 70 self.setCurrent()70 self.setCurrent() 71 71 72 def setHour(self,hour):73 self.__hour = int(hour)72 def setHour(self,hour): 73 self.__hour = int(hour) 74 74 75 def setMinute(self,minute):76 self.__minute=int(minute)75 def setMinute(self,minute): 76 self.__minute=int(minute) 77 77 78 def setDayOfWeek(self,day):79 self.__dayOfWeek=int(day)78 def setDayOfWeek(self,day): 79 self.__dayOfWeek=int(day) 80 80 81 def setTime(self,time):82 timeArray = time.split(":")83 self.setHour(timeArray[0])84 self.setMinute(timeArray[1])81 def setTime(self,time): 82 timeArray = time.split(":") 83 self.setHour(timeArray[0]) 84 self.setMinute(timeArray[1]) 85 85 86 def setCurrent(self):87 hour=time.strftime("%H")88 minute=time.strftime("%M")89 day=time.strftime("%w")86 def setCurrent(self): 87 hour=time.strftime("%H") 88 minute=time.strftime("%M") 89 day=time.strftime("%w") 90 90 91 self.setTime(hour+":"+minute)92 self.setDayOfWeek(day)91 self.setTime(hour+":"+minute) 92 self.setDayOfWeek(day) 93 93 94 def getFuzzyTime(self, fuzzyness = 1):95 sector = 096 realHour = 094 def getFuzzyTime(self, fuzzyness = 1): 95 sector = 0 96 realHour = 0 97 97 98 if fuzzyness == 1 or fuzzyness == 2:99 if fuzzyness == 1:100 if self.__minute >2:101 sector = (self.__minute - 3) / 5 +1102 else:103 if self.__minute > 6:104 sector = ((self.__minute - 7) / 15 + 1) * 398 if fuzzyness == 1 or fuzzyness == 2: 99 if fuzzyness == 1: 100 if self.__minute >2: 101 sector = (self.__minute - 3) / 5 +1 102 else: 103 if self.__minute > 6: 104 sector = ((self.__minute - 7) / 15 + 1) * 3 105 105 106 newTimeStr = self.__normalFuzzy[sector]107 #$0 or $1?108 deltaHour = int(newTimeStr[newTimeStr.find("$")+1])106 newTimeStr = self.__normalFuzzy[sector] 107 #$0 or $1? 108 deltaHour = int(newTimeStr[newTimeStr.find("$")+1]) 109 109 110 if (self.__hour + deltaHour) % 12 > 0:111 realHour = (self.__hour + deltaHour) % 12 - 1112 else:113 realHour = 12 - ((self.__hour + deltaHour) % 12 + 1)110 if (self.__hour + deltaHour) % 12 > 0: 111 realHour = (self.__hour + deltaHour) % 12 - 1 112 else: 113 realHour = 12 - ((self.__hour + deltaHour) % 12 + 1) 114 114 115 if realHour == 0:116 newTimeStr = self.__normalFuzzyOne[sector]115 if realHour == 0: 116 newTimeStr = self.__normalFuzzyOne[sector] 117 117 118 newTimeStr = newTimeStr.replace("$"+str(deltaHour),119 self.__hourNames[realHour])118 newTimeStr = newTimeStr.replace("$"+str(deltaHour), 119 self.__hourNames[realHour]) 120 120 121 121 122 elif fuzzyness == 3:123 newTimeStr = self.__dayTime[self.__hour / 3]122 elif fuzzyness == 3: 123 newTimeStr = self.__dayTime[self.__hour / 3] 124 124 125 else:126 dayOfWeek = self.__dayOfWeek127 if dayOfWeek == 1:128 newTimeStr = self.__fuzzyWeek[0]129 elif dayOfWeek >= 2 and dayOfWeek <= 4:130 newTimeStr = self.__fuzzyWeek[1]131 elif dayOfWeek == 5:132 newTimeStr = self.__fuzzyWeek[2]133 else:134 newTimeStr = self.__fuzzyWeek[3]125 else: 126 dayOfWeek = self.__dayOfWeek 127 if dayOfWeek == 1: 128 newTimeStr = self.__fuzzyWeek[0] 129 elif dayOfWeek >= 2 and dayOfWeek <= 4: 130 newTimeStr = self.__fuzzyWeek[1] 131 elif dayOfWeek == 5: 132 newTimeStr = self.__fuzzyWeek[2] 133 else: 134 newTimeStr = self.__fuzzyWeek[3] 135 135 136 return newTimeStr136 return newTimeStr -
trunk/src/common/helpers.py
r7852 r7937 621 621 win32api.RegCloseKey(rkey) 622 622 return val 623 623 624 624 def get_my_pictures_path(): 625 625 '''windows-only atm. [Unix lives in the past]''' … … 699 699 (2, 5, 1): 'XP', 700 700 (2, 5, 2): '2003', 701 (2, 6, 0): 'Vista',701 (2, 6, 0): 'Vista', 702 702 } 703 703 if win_version.has_key(ver_format): … … 761 761 .replace('\\', '_').replace('"', "'").replace('|', '_')\ 762 762 .replace('*', '_').replace('<', '_').replace('>', '_') 763 # 48 is the limit763 # 48 is the limit 764 764 if len(filename) > 48: 765 765 extension = filename.split('.')[-1] -
trunk/src/common/optparser.py
r7911 r7937 362 362 if self.old_values.has_key('trayicon_notification_on_new_messages'): 363 363 gajim.config.set('trayicon_notification_on_events', 364 self.old_values['trayicon_notification_on_new_messages'])364 self.old_values['trayicon_notification_on_new_messages']) 365 365 gajim.config.set('version', '0.10.1.7') 366 366 … … 369 369 if self.old_values.has_key('chat_state_notifications'): 370 370 gajim.config.set('outgoing_chat_state_notifications', 371 self.old_values['chat_state_notifications'])371 self.old_values['chat_state_notifications']) 372 372 gajim.config.set('version', '0.10.1.8') 373 373 -
trunk/src/common/rst_xhtml_generator.py
r7099 r7937 29 29 '''Role to make handy references to Jabber Enhancement Proposals (JEP). 30 30 31 Use as :JEP:`71` (or jep, or jep-reference).31 Use as :JEP:`71` (or jep, or jep-reference). 32 32 Modeled after the sample in docutils documentation. 33 33 ''' … … 112 112 test:: 113 113 114 >>> print 1115 1114 >>> print 1 115 1 116 116 117 117 *I* like it. It is for :JEP:`71` -
trunk/src/common/xmpp_stringprep.py
r7270 r7937 33 33 34 34 warnings.warn("Accented and non-Western Jabber IDs will not be properly " 35 "case-folded with this version of Python, resulting in "36 "incorrect protocol-level behavior. It is strongly "37 "recommended you upgrade to Python 2.3.2 or newer if you "38 "intend to use Twisted's Jabber support.")35 "case-folded with this version of Python, resulting in " 36 "incorrect protocol-level behavior. It is strongly " 37 "recommended you upgrade to Python 2.3.2 or newer if you " 38 "intend to use Twisted's Jabber support.") 39 39 40 40 else: … … 98 98 class Profile: 99 99 def __init__(self, mappings=[], normalize=True, prohibiteds=[], 100 check_unassigneds=True, check_bidi=True):100 check_unassigneds=True, check_bidi=True): 101 101 self.mappings = mappings 102 102 self.normalize = normalize … … 184 184 # Prohibited characters. 185 185 prohibiteds = [unichr(n) for n in range(0x00, 0x2c + 1) + 186 range(0x2e, 0x2f + 1) +187 range(0x3a, 0x40 + 1) +188 range(0x5b, 0x60 + 1) +189 range(0x7b, 0x7f + 1) ]186 range(0x2e, 0x2f + 1) + 187 range(0x3a, 0x40 + 1) + 188 range(0x5b, 0x60 + 1) + 189 range(0x7b, 0x7f + 1) ] 190 190 191 191 def prepare(self, string): … … 207 207 def check_prohibiteds(self, string): 208 208 for c in string: 209 if c in self.prohibiteds:210 raise UnicodeError, "Invalid character %s" % repr(c)209 if c in self.prohibiteds: 210 raise UnicodeError, "Invalid character %s" % repr(c) 211 211 212 212 def nameprep(self, label): … … 222 222 case_map = MappingTableFromFunction(lambda c: c.lower()) 223 223 nodeprep = Profile(mappings=[case_map], 224 normalize=False,225 prohibiteds=[LookupTable([u' ', u'"', u'&', u"'", u'/',226 u':', u'<', u'>', u'@'])],227 check_unassigneds=False,228 check_bidi=False)224 normalize=False, 225 prohibiteds=[LookupTable([u' ', u'"', u'&', u"'", u'/', 226 u':', u'<', u'>', u'@'])], 227 check_unassigneds=False, 228 check_bidi=False) 229 229 230 230 resourceprep = Profile(normalize=False, 231 check_unassigneds=False,232 check_bidi=False)233 231 check_unassigneds=False, 232 check_bidi=False) 233 234 234 else: 235 235 C_11 = LookupTableFromFunction(stringprep.in_table_c11) … … 252 252 C_3, C_4, C_5, C_6, C_7, C_8, C_9, 253 253 LookupTable([u'"', u'&', u"'", u'/', 254 u':', u'<', u'>', u'@'])])254 u':', u'<', u'>', u'@'])]) 255 255 256 256 resourceprep = Profile(mappings=[B_1,], 257 prohibiteds=[C_12, C_21, C_22,257 prohibiteds=[C_12, C_21, C_22, 258 258 C_3, C_4, C_5, C_6, C_7, C_8, C_9]) 259 259
