Commits

Anonymous committed abfcac6

1.1.2dev: Merged [12083] from 1.0-stable (fix for #11306).

Comments (0)

Files changed (17)

contrib/bugzilla2trac.py

 # mapping, just return string, otherwise return value
 class FieldTranslator(dict):
     def __getitem__(self, item):
-        if not dict.has_key(self, item):
+        if item not in self:
             return item
 
         return dict.__getitem__(self, item)
             if BUG_NO_RE.search(desc):
                 desc = re.sub(BUG_NO_RE, BUG_NO_REPL, desc)
 
-        if PRIORITIES_MAP.has_key(priority):
+        if priority in PRIORITIES_MAP:
             priority = PRIORITIES_MAP[priority]
 
         print "  inserting ticket %s -- %s" % (id, summary)
     def addTicketChange(self, ticket, time, author, field, oldvalue, newvalue):
 
         if field == "owner":
-            if LOGIN_MAP.has_key(oldvalue):
+            if oldvalue in LOGIN_MAP:
                 oldvalue = LOGIN_MAP[oldvalue]
-            if LOGIN_MAP.has_key(newvalue):
+            if newvalue in LOGIN_MAP:
                 newvalue = LOGIN_MAP[newvalue]
 
         if field == "priority":
-            if PRIORITIES_MAP.has_key(oldvalue.lower()):
+            if oldvalue.lower() in PRIORITIES_MAP:
                 oldvalue = PRIORITIES_MAP[oldvalue.lower()]
-            if PRIORITIES_MAP.has_key(newvalue.lower()):
+            if newvalue.lower() in PRIORITIES_MAP:
                 newvalue = PRIORITIES_MAP[newvalue.lower()]
 
         # Doesn't make sense if we go from highest -> highest, for example.
         users = ()
     htpasswd = file("htpasswd", 'w')
     for user in users:
-        if LOGIN_MAP.has_key(user['login_name']):
+        if user['login_name'] in LOGIN_MAP:
             login = LOGIN_MAP[user['login_name']]
         else:
             login = user['login_name']
         for parent in self.config.parents:
             if parent[self.name].contains(key, defaults=False):
                 return True
-        return defaults and Option.registry.has_key((self.name, key))
+        return defaults and (self.name, key) in Option.registry
 
     __contains__ = contains
 

trac/notification.py

         # server.set_debuglevel(True)
         if self.use_tls:
             server.ehlo()
-            if not server.esmtp_features.has_key('starttls'):
+            if 'starttls' not in server.esmtp_features:
                 raise TracError(_("TLS enabled but server does not support " \
                                   "TLS"))
             server.starttls()

trac/tests/notification.py

                     # splits header name from value
                     (h, v) = line.split(':', 1)
                     val = decode_header(v.strip())
-                    if headers.has_key(h):
+                    if h in headers:
                         if isinstance(headers[h], tuple):
                             headers[h] += val
                         else:

trac/ticket/default_workflow.py

             id = 'action_%s_reassign_owner' % action
             selected_owner = req.args.get(id, req.authname)
 
-            if this_action.has_key('set_owner'):
+            if 'set_owner' in this_action:
                 owners = [x.strip() for x in
                           this_action['set_owner'].split(',')]
             elif self.config.getbool('ticket', 'restrict_owner'):
                            "to %(authname)s", current_owner=current_owner,
                            authname=req.authname))
         if 'set_resolution' in operations:
-            if this_action.has_key('set_resolution'):
+            if 'set_resolution' in this_action:
                 resolutions = [x.strip() for x in
                                this_action['set_resolution'].split(',')]
             else:

trac/ticket/notification.py

         width_lr = [width_l, width_r]
         for f in [f for f in fields if f['name'] != 'description']:
             fname = f['name']
-            if not tkt.values.has_key(fname):
+            if fname not in tkt.values:
                 continue
             fval = tkt[fname] or ''
             if fname in tkt.time_fields:

trac/ticket/roadmap.py

             action = 'edit' # rather than 'new' so that it works for POST/save
 
         if req.method == 'POST':
-            if req.args.has_key('cancel'):
+            if 'cancel' in req.args:
                 if milestone.exists:
                     req.redirect(req.href.milestone(milestone.name))
                 else:
         req.perm(milestone.resource).require('MILESTONE_DELETE')
 
         retarget_to = None
-        if req.args.has_key('retarget'):
+        if 'retarget' in req.args:
             retarget_to = req.args.get('target') or None
         milestone.delete(retarget_to, req.authname)
         add_notice(req, _('The milestone "%(name)s" has been deleted.',

trac/ticket/tests/notification.py

 from trac.ticket.model import Ticket
 from trac.ticket.notification import TicketNotifyEmail
 from trac.test import EnvironmentStub, Mock, MockPerm
+from trac.tests import compat
 from trac.tests.notification import SMTPThreadedServer, parse_smtp_message, \
                                     smtp_address
 
         xlist = ['summary', 'description', 'comment', 'time', 'changetime']
         # check banner content (field exists, msg value matches ticket value)
         for p in [prop for prop in ticket.values.keys() if prop not in xlist]:
-            self.assertFalse(not props.has_key(p))
+            self.assertIn(p, props)
             # Email addresses might be obfuscated
             if '@' in ticket[p] and '@' in props[p]:
                 self.assertFalse(props[p].split('@')[0] != ticket[p].split('@')[0])

trac/util/__init__.py

         return __import__(module_name, globals(), locals(), [])
     except Exception, e:
         for modname in sys.modules.copy():
-            if not already_imported.has_key(modname):
+            if modname not in already_imported:
                 del(sys.modules[modname])
         raise e
 

trac/versioncontrol/web_ui/browser.py

             rev = None
         format = req.args.get('format')
         order = req.args.get('order', 'name').lower()
-        desc = req.args.has_key('desc')
+        desc = 'desc' in req.args
         xhr = req.get_header('X-Requested-With') == 'XMLHttpRequest'
 
         rm = RepositoryManager(self.env)

trac/web/_fcgi.py

 
         Set multithreaded to False if your application is not MT-safe.
         """
-        if kw.has_key('handler'):
+        if 'handler' in kw:
             del kw['handler'] # Doesn't make sense to let this through
         super(WSGIServer, self).__init__(**kw)
 
 
     def _sanitizeEnv(self, environ):
         """Ensure certain values are present, if required by WSGI."""
-        if not environ.has_key('SCRIPT_NAME'):
+        if 'SCRIPT_NAME' not in environ:
             environ['SCRIPT_NAME'] = ''
-        if not environ.has_key('PATH_INFO'):
+        if 'PATH_INFO' not in environ:
             environ['PATH_INFO'] = ''
 
         # If any of these are missing, it probably signifies a broken
                              ('SERVER_NAME', 'localhost'),
                              ('SERVER_PORT', '80'),
                              ('SERVER_PROTOCOL', 'HTTP/1.0')]:
-            if not environ.has_key(name):
+            if name not in environ:
                 environ['wsgi.errors'].write('%s: missing FastCGI param %s '
                                              'required by WSGI!\n' %
                                              (self.__class__.__name__, name))
         authname = None
         if req.remote_user:
             authname = req.remote_user
-        elif req.incookie.has_key('trac_auth'):
+        elif 'trac_auth' in req.incookie:
             authname = self._get_name_for_cookie(req,
                                                  req.incookie['trac_auth'])
 
                          'nc', 'cnonce']
         # Invalid response?
         for key in required_keys:
-            if not auth.has_key(key):
+            if key not in auth:
                 self.send_auth_request(environ, start_response)
                 return None
         # Unknown user?
         self.check_reload()
-        if not self.hash.has_key(auth['username']):
+        if auth['username'] not in self.hash:
             self.send_auth_request(environ, start_response)
             return None
 
         If the the user does not have a `trac_form_token` cookie a new
         one is generated.
         """
-        if req.incookie.has_key('trac_form_token'):
+        if 'trac_form_token' in req.incookie:
             return req.incookie['trac_form_token'].value
         else:
             req.outcookie['trac_form_token'] = hex_entropy(24)

trac/web/session.py

         super(Session, self).__init__(env, None)
         self.req = req
         if req.authname == 'anonymous':
-            if not req.incookie.has_key(COOKIE_KEY):
+            if COOKIE_KEY not in req.incookie:
                 self.sid = hex_entropy(24)
                 self.bake_cookie()
             else:
                 sid = req.incookie[COOKIE_KEY].value
                 self.get_session(sid)
         else:
-            if req.incookie.has_key(COOKIE_KEY):
+            if COOKIE_KEY in req.incookie:
                 sid = req.incookie[COOKIE_KEY].value
                 self.promote_session(sid)
             self.get_session(req.authname, authenticated=True)

trac/web/tests/session.py

 import unittest
 
 from trac.test import EnvironmentStub, Mock
+from trac.tests import compat
 from trac.web.session import DetachedSession, Session, PURGE_AGE, \
                              UPDATE_INTERVAL, SessionAdmin
 from trac.core import TracError
                    outcookie=outcookie)
         session = Session(self.env, req)
         self.assertEqual('123456', session.sid)
-        self.assertFalse(outcookie.has_key('trac_session'))
+        self.assertNotIn('trac_session', outcookie)
 
     def test_authenticated_session(self):
         """

tracopt/versioncontrol/git/PyGIT.py

             raise GitErrorSha
 
         with self.__commit_msg_lock:
-            if self.__commit_msg_cache.has_key(commit_id):
+            if commit_id in self.__commit_msg_cache:
                 # cache hit
                 result = self.__commit_msg_cache[commit_id]
                 return result[0], dict(result[1])

tracopt/versioncontrol/svn/svn_fs.py

                 action = Changeset.EDIT
                 # identify the most interesting base_path/base_rev
                 # in terms of last changed information (see r2562)
-                if revroots.has_key(base_rev):
+                if base_rev in revroots:
                     b_root = revroots[base_rev]
                 else:
                     b_root = fs.revision_root(self.fs_ptr, base_rev, pool())