title: Python + getopt - Problems with parsing
body: <p>I have some problems with writing some Gerrit <a href="http://code.google.com/p/gerrit/" rel="nofollow">http://code.google.com/p/gerrit/</a> hooks.</p>
  
  <p><a href="http://gerrit.googlecode.com/svn/documentation/2.2.0/config-hooks.html" rel="nofollow">http://gerrit.googlecode.com/svn/documentation/2.2.0/config-hooks.html</a></p>
  
  <p>If I parse the command line for
  patchset-created --change  --change-url  --project  --branch  --uploader  --commit  --patchset </p>
  
  <pre><code>def main():
  
  if (len(sys.argv) &lt; 2):
      showUsage()
      exit()
  
  if (sys.argv[1] == 'update-projects'):
      updateProjects()
      exit()
  
  need = ['action=', 'change=', 'change-url=', 'commit=', 'project=', 'branch=', 'uploader=',
          'patchset=', 'abandoner=', 'reason=', 'submitter=', 'comment=', 'CRVW=', 'VRIF=' , 'patchset=' , 'restorer=', 'author=']
  print  sys.argv[1:]
  print '-----' 
  optlist, args = getopt.getopt(sys.argv[1:], '', need)
  id = url = hash = who = comment = reason =  codeReview = verified = restorer = ''
  print optlist
  
  for o, a in optlist:
      if o == '--change': id = a
      elif o == '--change-url': url = a
      elif o == '--commit': hash = a
      elif o == '--action': what = a
      elif o == '--uploader': who = a
      elif o == '--submitter': who = a
      elif o == '--abandoner': who = a
      elif o == '--author' : who = a
      elif o == '--branch': branch = a
      elif o == '--comment': comment = a
      elif o == '--CRVW' : codeReview = a
      elif o == '--VRIF' : verified = a
      elif o == '--patchset' : patchset = a
      elif o == '--restorer' : who = a
      elif o == '--reason' : reason = a
  </code></pre>
  
  <p>Command line input:</p>
  
  <pre><code>--change I87f7802d438d5640779daa9ac8196aeb3eec8c2a
  --change-url http://&lt;hostname&gt;:8080/308
  --project private/bar
  --branch master
  --uploader xxxxxxx-xxxxx xxxxxxx (xxxxxxxxxxxxx.xxxxxxx@xxx-xxxx.xx)
  --commit 49aae9befaf27a5fede51b498f0660199f47b899 --patchset 1
  </code></pre>
  
  <p>print  sys.argv[1:]</p>
  
  <pre><code>['--action', 'new',
  '--change','I87f7802d438d5640779daa9ac8196aeb3eec8c2a',
  '--change-url',
  'http://&lt;hostname&gt;:8080/308',
  '--project', 'private/bar',
  '--branch', 'master',
  '--uploader', 'xxxxxxx-xxxxx', 'xxxxxxx', '(xxxxxxxxxxxxx.xxxxxxx@xxx-xxxx.xx)',
  '--commit', '49aae9befaf27a5fede51b498f0660199f47b899',
  '--patchset', '1']
  </code></pre>
  
  <p>print optlist</p>
  
  <pre><code>[('--action', 'new'),
  ('--change', 'I87f7802d438d5640779daa9ac8196aeb3eec8c2a'),
  ('--change-url', 'http://&lt;hostname&gt;:8080/308'),
  ('--project', 'private/bar'),
  ('--branch', 'master'),
  ('--uploader', 'xxxxxxx-xxxxx')]
  </code></pre>
  
  <p>I don't know why the script generates</p>
  
  <pre><code>'--uploader', 'xxxxxxx-xxxxx', 'xxxxxxx', '(xxxxxxxxxxxxx.xxxxxxx@xxx-xxxx.xx)'
  and not
  '--uploader', 'xxxxxxx-xxxxx xxxxxxx (xxxxxxxxxxxxx.xxxxxxx@xxx-xxxx.xx)'
  </code></pre>
  
  <p>because so the script dont't parse --commit  --patchset  ...</p>
  
  <p>When I parse comment-added all things works:</p>
  
  <p>Command line input:</p>
  
  <pre><code>   -change I87f7802d438d5640779daa9ac8196aeb3eec8c2a
     --change-url http://&lt;hostname&gt;.intra:8080/308
     --project private/bar
     --branch master
     --author xxxxxxx-xxxxx xxxxxxx (xxxxxxxxxxxxx.xxxxxxx@xxx-xxxx.xx)
     --commit 49aae9befaf27a5fede51b498f0660199f47b899
     --comment asdf
     --CRVW 0 
     --VRIF 0
  </code></pre>
  
  <p>print sys.argv[1:]</p>
  
  <pre><code>  '--action', 'comment',
      '--change', 'I87f7802d438d5640779daa9ac8196aeb3eec8c2a',
      '--change-url',
      'http://&lt;hostname&gt;:8080/308',
      '--project', 'private/bar',
      '--branch', 'master',
      '--author', 'xxxxxxx-xxxxx xxxxxxx (xxxxxxxxxxxxx.xxxxxxx@xxx-xxxx.xx)', &lt;&lt;&lt; That's right!
      '--commit', '49aae9befaf27a5fede51b498f0660199f47b899',
      '--comment', 'asdf',
      '--CRVW', '0',
      '--VRIF', '0']
  </code></pre>