Use 'is None' and 'is not None'
This commit is contained in:
@@ -13,7 +13,7 @@ def query_yes_no(question, default="yes"):
|
|||||||
"""
|
"""
|
||||||
valid = {"yes":True, "y":True, "ye":True,
|
valid = {"yes":True, "y":True, "ye":True,
|
||||||
"no":False, "n":False}
|
"no":False, "n":False}
|
||||||
if default == None:
|
if default is None:
|
||||||
prompt = " [y/n] "
|
prompt = " [y/n] "
|
||||||
elif default == "yes":
|
elif default == "yes":
|
||||||
prompt = " [Y/n] "
|
prompt = " [Y/n] "
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ def get_date_for_press(publish_date):
|
|||||||
|
|
||||||
def press(request):
|
def press(request):
|
||||||
json_articles = cache.get("student_press_json_articles")
|
json_articles = cache.get("student_press_json_articles")
|
||||||
if json_articles == None:
|
if json_articles is None:
|
||||||
if hasattr(settings, 'RSS_URL'):
|
if hasattr(settings, 'RSS_URL'):
|
||||||
content = urllib.urlopen(settings.PRESS_URL).read()
|
content = urllib.urlopen(settings.PRESS_URL).read()
|
||||||
json_articles = json.loads(content)
|
json_articles = json.loads(content)
|
||||||
@@ -301,7 +301,7 @@ def change_enrollment(request):
|
|||||||
action = request.POST.get("enrollment_action", "")
|
action = request.POST.get("enrollment_action", "")
|
||||||
|
|
||||||
course_id = request.POST.get("course_id", None)
|
course_id = request.POST.get("course_id", None)
|
||||||
if course_id == None:
|
if course_id is None:
|
||||||
return HttpResponse(json.dumps({'success': False,
|
return HttpResponse(json.dumps({'success': False,
|
||||||
'error': 'There was an error receiving the course id.'}))
|
'error': 'There was an error receiving the course id.'}))
|
||||||
|
|
||||||
@@ -1203,7 +1203,7 @@ def _get_news(top=None):
|
|||||||
"Return the n top news items on settings.RSS_URL"
|
"Return the n top news items on settings.RSS_URL"
|
||||||
|
|
||||||
feed_data = cache.get("students_index_rss_feed_data")
|
feed_data = cache.get("students_index_rss_feed_data")
|
||||||
if feed_data == None:
|
if feed_data is None:
|
||||||
if hasattr(settings, 'RSS_URL'):
|
if hasattr(settings, 'RSS_URL'):
|
||||||
feed_data = urllib.urlopen(settings.RSS_URL).read()
|
feed_data = urllib.urlopen(settings.RSS_URL).read()
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -524,7 +524,7 @@ class PeerGradingModule(XModule):
|
|||||||
'''
|
'''
|
||||||
Show individual problem interface
|
Show individual problem interface
|
||||||
'''
|
'''
|
||||||
if get == None or get.get('location') == None:
|
if get is None or get.get('location') is None:
|
||||||
if not self.use_for_single_location:
|
if not self.use_for_single_location:
|
||||||
#This is an error case, because it must be set to use a single location to be called without get parameters
|
#This is an error case, because it must be set to use a single location to be called without get parameters
|
||||||
#This is a dev_facing_error
|
#This is a dev_facing_error
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ def course_wiki_redirect(request, course_id):
|
|||||||
if not course_slug:
|
if not course_slug:
|
||||||
log.exception("This course is improperly configured. The slug cannot be empty.")
|
log.exception("This course is improperly configured. The slug cannot be empty.")
|
||||||
valid_slug = False
|
valid_slug = False
|
||||||
if re.match('^[-\w\.]+$', course_slug) == None:
|
if re.match('^[-\w\.]+$', course_slug) is None:
|
||||||
log.exception("This course is improperly configured. The slug can only contain letters, numbers, periods or hyphens.")
|
log.exception("This course is improperly configured. The slug can only contain letters, numbers, periods or hyphens.")
|
||||||
valid_slug = False
|
valid_slug = False
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ def grade(student, request, course, student_module_cache=None, keep_raw_scores=F
|
|||||||
grading_context = course.grading_context
|
grading_context = course.grading_context
|
||||||
raw_scores = []
|
raw_scores = []
|
||||||
|
|
||||||
if student_module_cache == None:
|
if student_module_cache is None:
|
||||||
student_module_cache = StudentModuleCache(course.id, student, grading_context['all_descriptors'])
|
student_module_cache = StudentModuleCache(course.id, student, grading_context['all_descriptors'])
|
||||||
|
|
||||||
totaled_scores = {}
|
totaled_scores = {}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ def get_course_settings(coursename):
|
|||||||
|
|
||||||
|
|
||||||
def is_valid_course(coursename):
|
def is_valid_course(coursename):
|
||||||
return get_course_settings(coursename) != None
|
return get_course_settings(coursename) is not None
|
||||||
|
|
||||||
|
|
||||||
def get_course_property(coursename, property):
|
def get_course_property(coursename, property):
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ def history(request, article_path, page=1, course_id=None):
|
|||||||
|
|
||||||
page_size = 10
|
page_size = 10
|
||||||
|
|
||||||
if page == None:
|
if page is None:
|
||||||
page = 1
|
page = 1
|
||||||
try:
|
try:
|
||||||
p = int(page)
|
p = int(page)
|
||||||
@@ -310,7 +310,7 @@ def revision_feed(request, page=1, namespace=None, course_id=None):
|
|||||||
|
|
||||||
page_size = 10
|
page_size = 10
|
||||||
|
|
||||||
if page == None:
|
if page is None:
|
||||||
page = 1
|
page = 1
|
||||||
try:
|
try:
|
||||||
p = int(page)
|
p = int(page)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class Model(object):
|
|||||||
try:
|
try:
|
||||||
return self.attributes[name]
|
return self.attributes[name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if self.retrieved or self.id == None:
|
if self.retrieved or self.id is None:
|
||||||
raise AttributeError("Field {0} does not exist".format(name))
|
raise AttributeError("Field {0} does not exist".format(name))
|
||||||
self.retrieve()
|
self.retrieve()
|
||||||
return self.__getattr__(name)
|
return self.__getattr__(name)
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ StrPrinter._print_hat = _print_hat
|
|||||||
|
|
||||||
|
|
||||||
def to_latex(x):
|
def to_latex(x):
|
||||||
if x == None: return ''
|
if x is None: return ''
|
||||||
# LatexPrinter._print_dot = _print_dot
|
# LatexPrinter._print_dot = _print_dot
|
||||||
xs = latex(x)
|
xs = latex(x)
|
||||||
xs = xs.replace(r'\XI', 'XI') # workaround for strange greek
|
xs = xs.replace(r'\XI', 'XI') # workaround for strange greek
|
||||||
@@ -278,7 +278,7 @@ class formula(object):
|
|||||||
|
|
||||||
if self.the_sympy: return self.the_sympy
|
if self.the_sympy: return self.the_sympy
|
||||||
|
|
||||||
if xml == None: # root
|
if xml is None: # root
|
||||||
if not self.is_mathml():
|
if not self.is_mathml():
|
||||||
return my_sympify(self.expr)
|
return my_sympify(self.expr)
|
||||||
if self.is_presentation_mathml():
|
if self.is_presentation_mathml():
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<%page args="active_page=None" />
|
<%page args="active_page=None" />
|
||||||
|
|
||||||
<%
|
<%
|
||||||
if active_page == None and active_page_context is not UNDEFINED:
|
if active_page is None and active_page_context is not UNDEFINED:
|
||||||
# If active_page is not passed in as an argument, it may be in the context as active_page_context
|
# If active_page is not passed in as an argument, it may be in the context as active_page_context
|
||||||
active_page = active_page_context
|
active_page = active_page_context
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<%namespace name='static' file='static_content.html'/>
|
<%namespace name='static' file='static_content.html'/>
|
||||||
<h2 class="problem-header">
|
<h2 class="problem-header">
|
||||||
${ problem['name'] }
|
${ problem['name'] }
|
||||||
% if problem['weight'] != 1 and problem['weight'] != None:
|
% if problem['weight'] != 1 and problem['weight'] is not None:
|
||||||
: ${ problem['weight'] } points
|
: ${ problem['weight'] } points
|
||||||
% endif
|
% endif
|
||||||
</h2>
|
</h2>
|
||||||
@@ -30,4 +30,4 @@
|
|||||||
</section>
|
</section>
|
||||||
% endif
|
% endif
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user