# Path: wh.py
# def shlexSplit(str, sep):
#   """
#   shlexSplit(str, sep)
#   
#   split string by separator, observing quotes
#   """
#   if not str:
#     return []
#   lex=shlex(str, posix=True)
#   lex.whitespace=sep
#   lex.commenters=''
#   lex.whitespace_split=True
#   return list(lex)


import ssl
import imaplib
import adm
from wh import shlexSplit
from imap_utf7 import decode as decodeUtf7, encode as encodeUtf7 # @UnusedImport

  def send(self, data):
    return self.callClass.send(self, data)
  
  def shutdown(self):
    return self.callClass.shutdown(self)
  
  def xatomResult(self, cmd, *params):
    typ,dat=self.xatom(cmd, *params)  
    if typ == "OK":
      typ, dat=self._untagged_response(typ, dat, cmd)
    return typ,dat
  
  def GetAnnotations(self, mailbox):
    dat=self.getresult(self.getannotation(mailbox, '"*"', '"value.shared"'))
    if not dat:
      return None
    annotations=Annotations()
    
    for ann in dat:
      # this tries to deal with some imaplib weirdness if non-ascii is returned.
      # usually, ann should be a string, but if the value.shared contains non-ascii
      # a tuple is returned, with the next ann being ")"
      # This is so for imaplib.__version__ == 2.58
      if not ann or ann == ")":
        continue
      if isinstance(ann, str):
        parts=shlexSplit(ann.decode('utf-8'), " ")
        annotations[parts[1]] = parts[-1][:-1]
      elif isinstance(ann, tuple):

# Path: wh.py
# def shlexSplit(str, sep):
#   """
#   shlexSplit(str, sep)
#   
#   split string by separator, observing quotes
#   """
#   if not str:
#     return []
#   lex=shlex(str, posix=True)
#   lex.whitespace=sep
#   lex.commenters=''
#   lex.whitespace_split=True
#   return list(lex)


# Path: modImap/_imap.py
import ssl
import imaplib
import adm
from wh import shlexSplit
from imap_utf7 import decode as decodeUtf7, encode as encodeUtf7 # @UnusedImport


  def send(self, data):
    return self.callClass.send(self, data)
  
  def shutdown(self):
    return self.callClass.shutdown(self)
  
  def xatomResult(self, cmd, *params):
    typ,dat=self.xatom(cmd, *params)  
    if typ == "OK":
      typ, dat=self._untagged_response(typ, dat, cmd)
    return typ,dat
  
  def GetAnnotations(self, mailbox):
    dat=self.getresult(self.getannotation(mailbox, '"*"', '"value.shared"'))
    if not dat:
      return None
    annotations=Annotations()
    
    for ann in dat:
      # this tries to deal with some imaplib weirdness if non-ascii is returned.
      # usually, ann should be a string, but if the value.shared contains non-ascii
      # a tuple is returned, with the next ann being ")"
      # This is so for imaplib.__version__ == 2.58
      if not ann or ann == ")":
        continue
      if isinstance(ann, str):
        parts=shlexSplit(ann.decode('utf-8'), " ")
        annotations[parts[1]] = parts[-1][:-1]
      elif isinstance(ann, tuple):

        parts=shlexSplit(ann[0].decode('utf-8'), " ")