has_key is deprecated, converting uses to use "in" operator.
authorNathan Yergler <nathan@yergler.net>
Sat, 1 Oct 2011 22:10:41 +0000 (15:10 -0700)
committerNathan Yergler <nathan@yergler.net>
Sat, 1 Oct 2011 22:10:41 +0000 (15:10 -0700)
mediagoblin/auth/views.py
mediagoblin/db/util.py
mediagoblin/gmg_commands/__init__.py
mediagoblin/init/__init__.py
mediagoblin/init/celery/__init__.py
mediagoblin/staticdirect.py
mediagoblin/submit/views.py
mediagoblin/util.py

index afcfcf1e0b003e4ac548aa3f81c45269df11219f..adf2c315847b22efc2ca1d10290d0337c9048178 100644 (file)
@@ -146,7 +146,7 @@ def verify_email(request):
     you are lucky :)
     """
     # If we don't have userid and token parameters, we can't do anything; 404
-    if not request.GET.has_key('userid') or not request.GET.has_key('token'):
+    if not 'userid' in request.GET or not 'token' in request.GET:
         return render_404(request)
 
     user = request.db.User.find_one(
@@ -307,6 +307,6 @@ def _process_for_token(request):
     formdata = {
         'vars': formdata_vars,
         'has_userid_and_token':
-            formdata_vars.has_key('userid') and formdata_vars.has_key('token')}
+            'userid' in formdata_vars and 'token' in formdata_vars}
 
     return formdata
index 38f0233f9daa1c291fe428809fd79f1d7c17f5e2..52e97f6de64e805583261d2f5dd3b212a44eb097 100644 (file)
@@ -148,7 +148,7 @@ class RegisterMigration(object):
     """
     def __init__(self, migration_number, migration_registry=MIGRATIONS):
         assert migration_number > 0, "Migration number must be > 0!"
-        assert not migration_registry.has_key(migration_number), \
+        assert migration_number not in migration_registry, \
             "Duplicate migration numbers detected!  That's not allowed!"
 
         self.migration_number = migration_number
index b3f69ccccad0394ba61c52c3acbca9bf6b8c1a5a..3250c246d4139bc1bd93e8e7657302e6d3539240 100644 (file)
@@ -61,7 +61,7 @@ def main_cli():
 
     subparsers = parser.add_subparsers(help='sub-command help')
     for command_name, command_struct in SUBCOMMAND_MAP.iteritems():
-        if command_struct.has_key('help'):
+        if 'help' in command_struct:
             subparser = subparsers.add_parser(
                 command_name, help=command_struct['help'])
         else:
index f21e2fdd7c1c78514520db06eab50e8e026f0ae3..08a0618d38b5ab127f4620e871b42c0305a71ea4 100644 (file)
@@ -103,10 +103,10 @@ def get_jinja_loader(user_template_path=None):
 
 
 def get_staticdirector(app_config):
-    if app_config.has_key('direct_remote_path'):
+    if 'direct_remote_path' in app_config:
         return staticdirect.RemoteStaticDirect(
             app_config['direct_remote_path'].strip())
-    elif app_config.has_key('direct_remote_paths'):
+    elif 'direct_remote_paths' in app_config:
         direct_remote_path_lines = app_config[
             'direct_remote_paths'].strip().splitlines()
         return staticdirect.MultiRemoteStaticDirect(
index 21ce1d395d628eb58a06a8a9d72641506513ccdc..f7ef9f3972344f5dc4a4bb02e31f3b1559603066 100644 (file)
@@ -40,25 +40,25 @@ def setup_celery_from_config(app_config, global_config,
     - set_environ: if set, this will CELERY_CONFIG_MODULE to the
       settings_module
     """
-    if global_config.has_key('celery'):
+    if 'celery' in global_config:
         celery_conf = global_config['celery']
     else:
         celery_conf = {}
-    
+
     celery_settings = {}
 
     # set up mongodb stuff
     celery_settings['CELERY_RESULT_BACKEND'] = 'mongodb'
-    if not celery_settings.has_key('BROKER_BACKEND'):
+    if 'BROKER_BACKEND' not in celery_settings:
         celery_settings['BROKER_BACKEND'] = 'mongodb'
 
     celery_mongo_settings = {}
 
-    if app_config.has_key('db_host'):
+    if 'db_host' in app_config:
         celery_mongo_settings['host'] = app_config['db_host']
         if celery_settings['BROKER_BACKEND'] == 'mongodb':
             celery_settings['BROKER_HOST'] = app_config['db_host']
-    if app_config.has_key('db_port'):
+    if 'db_port' in app_config:
         celery_mongo_settings['port'] = app_config['db_port']
         if celery_settings['BROKER_BACKEND'] == 'mongodb':
             celery_settings['BROKER_PORT'] = app_config['db_port']
index 5817588158f303724a14a31ce6cfedbcd71aa947..c6d2b3745b35c6bb1721731d0b2f0900958aeb6b 100644 (file)
@@ -21,24 +21,24 @@ import urlparse
 # Staticdirect infrastructure.
 # Borrowed largely from cc.engine
 # by Chris Webber & Creative Commons
-# 
+#
 # This needs documentation!
 ####################################
 
 import pkg_resources
 import urlparse
 
+
 class StaticDirect(object):
     def __init__(self):
         self.cache = {}
 
     def __call__(self, filepath):
-        if self.cache.has_key(filepath):
+        if filepath in self.cache:
             return self.cache[filepath]
 
         static_direction = self.cache[filepath] = self.get(filepath)
         return static_direction
-        
 
     def get(self, filepath):
         # should be implemented by the individual staticdirector
index 22a13b6d1681bf67f3b4ae041ef2dbf9c397d48d..d450ca214fe70f5d9fc3175b2a13638627d3339d 100644 (file)
@@ -40,7 +40,7 @@ def submit_start(request):
     submit_form = submit_forms.SubmitStartForm(request.POST)
 
     if request.method == 'POST' and submit_form.validate():
-        if not (request.POST.has_key('file')
+        if not ('file' in request.POST
                 and isinstance(request.POST['file'], FieldStorage)
                 and request.POST['file'].file):
             submit_form.file.errors.append(
index 4132b4975ad41162a0c3cf2bd8bdf72308ddbad7..d6ce59306c8cc2654fc6e9425ea4dd602779fe41 100644 (file)
@@ -89,7 +89,7 @@ def get_jinja_env(template_loader, locale):
 
     # If we have a jinja environment set up with this locale, just
     # return that one.
-    if SETUP_JINJA_ENVS.has_key(locale):
+    if locale in SETUP_JINJA_ENVS:
         return SETUP_JINJA_ENVS[locale]
 
     template_env = jinja2.Environment(
@@ -166,7 +166,7 @@ def setup_user_in_request(request):
     Examine a request and tack on a request.user parameter if that's
     appropriate.
     """
-    if not request.session.has_key('user_id'):
+    if not 'user_id' in request.session:
         request.user = None
         return
 
@@ -356,7 +356,7 @@ def get_locale_from_request(request):
     """
     request_form = request.GET or request.POST
 
-    if request_form.has_key('lang'):
+    if 'lang' in request_form:
         return locale_to_lower_upper(request_form['lang'])
 
     accept_lang_matches = request.accept_language.best_matches()
@@ -364,9 +364,9 @@ def get_locale_from_request(request):
     # Your routing can explicitly specify a target language
     matchdict = request.matchdict or {}
 
-    if matchdict.has_key('locale'):
+    if 'locale' in matchdict:
         target_lang = matchdict['locale']
-    elif request.session.has_key('target_lang'):
+    elif 'target_lang' in request.session:
         target_lang = request.session['target_lang']
     # Pull the first acceptable language
     elif accept_lang_matches:
@@ -393,9 +393,9 @@ HTML_CLEANER = Cleaner(
     annoying_tags=True,
     allow_tags=[
         'div', 'b', 'i', 'em', 'strong', 'p', 'ul', 'ol', 'li', 'a', 'br'],
-    remove_unknown_tags=False, # can't be used with allow_tags
+    remove_unknown_tags=False,  # can't be used with allow_tags
     safe_attrs_only=True,
-    add_nofollow=True, # for now
+    add_nofollow=True,  # for now
     host_whitelist=(),
     whitelist_tags=set([]))
 
@@ -492,7 +492,7 @@ def setup_gettext(locale):
 
     # TODO: fallback nicely on translations from pt_PT to pt if not
     # available, etc.
-    if SETUP_GETTEXTS.has_key(locale):
+    if locale in SETUP_GETTEXTS:
         this_gettext = SETUP_GETTEXTS[locale]
     else:
         this_gettext = gettext.translation(