Changeset 126:4319998fc9b5 for imapclient
- Timestamp:
- 01/25/10 13:26:30 (2 years ago)
- Branch:
- default
- Location:
- imapclient
- Files:
-
- 2 modified
-
imapclient.py (modified) (2 diffs)
-
response_parser.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
imapclient/imapclient.py
r121 r126 15 15 'RECENT'] 16 16 17 from response_parser import parse_fetch_response 17 from response_parser import parse_response, parse_fetch_response 18 18 19 19 20 # System flags … … 205 206 206 207 @param folder: The folder name. 207 @return: Number of messages in the folder. 208 @rtype: long int 208 @return: A dictionary containing the SELECT response 209 values. At least the EXISTS, FLAGS and RECENT keys are 210 guaranteed to exist. Example: 211 {'EXISTS': 3, 212 'FLAGS': ('\\Answered', '\\Flagged', '\\Deleted', ... ), 213 'RECENT': 0, 214 'PERMANENTFLAGS': ('\\Answered', '\\Flagged', '\\Deleted', ... ), 215 'READ-WRITE': True, 216 'UIDNEXT': 11, 217 'UIDVALIDITY': 1239278212} 209 218 """ 210 219 typ, data = self._imap.select(self._encode_folder_name(folder)) 211 220 self._checkok('select', typ, data) 212 return long(data[0]) 221 return self._process_select_response(self._imap.untagged_responses) 222 223 224 def _process_select_response(self, resp): 225 out = {} 226 for key, value in resp.iteritems(): 227 key = key.upper() 228 if key == 'OK': 229 continue 230 elif key in ('EXISTS', 'RECENT', 'UIDNEXT', 'UIDVALIDITY'): 231 value = int(value[0]) 232 elif key in ('FLAGS', 'PERMANENTFLAGS'): 233 value = parse_response(value)[0] 234 elif key == 'READ-WRITE': 235 value = True 236 237 out[key] = value 238 return out 213 239 214 240 -
imapclient/response_parser.py
r123 r126 162 162 163 163 CTRL_CHARS = ''.join([chr(ch) for ch in range(32)]) 164 ATOM_SPECIALS = r'()%*"' + CTRL_CHARS164 SPECIALS = r'()%"' + CTRL_CHARS 165 165 ALL_CHARS = [chr(ch) for ch in range(256)] 166 ATOM_NON_SPECIALS = [ch for ch in ALL_CHARS if ch not in ATOM_SPECIALS]166 NON_SPECIALS = [ch for ch in ALL_CHARS if ch not in SPECIALS] 167 167 168 168 def __init__(self, resp_chunks): … … 174 174 self.lex.quotes = '"' 175 175 self.lex.commenters = '' 176 self.lex.wordchars = self. ATOM_NON_SPECIALS176 self.lex.wordchars = self.NON_SPECIALS 177 177 178 178 def __iter__(self):
