Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
6e3eff30
Commit
6e3eff30
authored
Aug 16, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{} -> {0} etc in .format statements
parent
97538e70
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
25 additions
and
25 deletions
+25
-25
common/djangoapps/static_replace.py
+1
-1
common/lib/xmodule/xmodule/modulestore/xml.py
+3
-3
common/lib/xmodule/xmodule/tests/test_import.py
+1
-1
common/lib/xmodule/xmodule/x_module.py
+1
-1
common/xml_cleanup.py
+4
-4
lms/djangoapps/courseware/access.py
+2
-2
lms/djangoapps/courseware/management/commands/metadata_to_json.py
+1
-1
lms/djangoapps/courseware/module_render.py
+2
-2
lms/djangoapps/courseware/tests/tests.py
+10
-10
No files found.
common/djangoapps/static_replace.py
View file @
6e3eff30
...
@@ -15,7 +15,7 @@ def try_staticfiles_lookup(path):
...
@@ -15,7 +15,7 @@ def try_staticfiles_lookup(path):
try
:
try
:
url
=
staticfiles_storage
.
url
(
path
)
url
=
staticfiles_storage
.
url
(
path
)
except
Exception
as
err
:
except
Exception
as
err
:
log
.
warning
(
"staticfiles_storage couldn't find path {
}: {
}"
.
format
(
log
.
warning
(
"staticfiles_storage couldn't find path {
0}: {1
}"
.
format
(
path
,
str
(
err
)))
path
,
str
(
err
)))
# Just return the original path; don't kill everything.
# Just return the original path; don't kill everything.
url
=
path
url
=
path
...
...
common/lib/xmodule/xmodule/modulestore/xml.py
View file @
6e3eff30
...
@@ -187,11 +187,11 @@ class XMLModuleStore(ModuleStoreBase):
...
@@ -187,11 +187,11 @@ class XMLModuleStore(ModuleStoreBase):
if
not
os
.
path
.
exists
(
policy_path
):
if
not
os
.
path
.
exists
(
policy_path
):
return
{}
return
{}
try
:
try
:
log
.
debug
(
"Loading policy from {}"
.
format
(
policy_path
))
log
.
debug
(
"Loading policy from {
0
}"
.
format
(
policy_path
))
with
open
(
policy_path
)
as
f
:
with
open
(
policy_path
)
as
f
:
return
json
.
load
(
f
)
return
json
.
load
(
f
)
except
(
IOError
,
ValueError
)
as
err
:
except
(
IOError
,
ValueError
)
as
err
:
msg
=
"Error loading course policy from {}"
.
format
(
policy_path
)
msg
=
"Error loading course policy from {
0
}"
.
format
(
policy_path
)
tracker
(
msg
)
tracker
(
msg
)
log
.
warning
(
msg
+
" "
+
str
(
err
))
log
.
warning
(
msg
+
" "
+
str
(
err
))
return
{}
return
{}
...
@@ -238,7 +238,7 @@ class XMLModuleStore(ModuleStoreBase):
...
@@ -238,7 +238,7 @@ class XMLModuleStore(ModuleStoreBase):
url_name
=
course_data
.
get
(
'url_name'
)
url_name
=
course_data
.
get
(
'url_name'
)
if
url_name
:
if
url_name
:
policy_path
=
self
.
data_dir
/
course_dir
/
'policies'
/
'{}.json'
.
format
(
url_name
)
policy_path
=
self
.
data_dir
/
course_dir
/
'policies'
/
'{
0
}.json'
.
format
(
url_name
)
policy
=
self
.
load_policy
(
policy_path
,
tracker
)
policy
=
self
.
load_policy
(
policy_path
,
tracker
)
else
:
else
:
policy
=
{}
policy
=
{}
...
...
common/lib/xmodule/xmodule/tests/test_import.py
View file @
6e3eff30
...
@@ -201,7 +201,7 @@ class ImportTestCase(unittest.TestCase):
...
@@ -201,7 +201,7 @@ class ImportTestCase(unittest.TestCase):
def
check_for_key
(
key
,
node
):
def
check_for_key
(
key
,
node
):
"recursive check for presence of key"
"recursive check for presence of key"
print
"Checking {}"
.
format
(
node
.
location
.
url
())
print
"Checking {
0
}"
.
format
(
node
.
location
.
url
())
self
.
assertTrue
(
key
in
node
.
metadata
)
self
.
assertTrue
(
key
in
node
.
metadata
)
for
c
in
node
.
get_children
():
for
c
in
node
.
get_children
():
check_for_key
(
key
,
c
)
check_for_key
(
key
,
c
)
...
...
common/lib/xmodule/xmodule/x_module.py
View file @
6e3eff30
...
@@ -629,7 +629,7 @@ class XModuleDescriptor(Plugin, HTMLSnippet):
...
@@ -629,7 +629,7 @@ class XModuleDescriptor(Plugin, HTMLSnippet):
try
:
try
:
return
parse_time
(
self
.
metadata
[
key
])
return
parse_time
(
self
.
metadata
[
key
])
except
ValueError
as
e
:
except
ValueError
as
e
:
msg
=
"Descriptor {
} loaded with a bad metadata key '{}': '{
}'"
.
format
(
msg
=
"Descriptor {
0} loaded with a bad metadata key '{1}': '{2
}'"
.
format
(
self
.
location
.
url
(),
self
.
metadata
[
key
],
e
)
self
.
location
.
url
(),
self
.
metadata
[
key
],
e
)
log
.
warning
(
msg
)
log
.
warning
(
msg
)
return
None
return
None
...
...
common/xml_cleanup.py
View file @
6e3eff30
...
@@ -47,12 +47,12 @@ def cleanup(filepath, remove_meta):
...
@@ -47,12 +47,12 @@ def cleanup(filepath, remove_meta):
'ispublic'
,
'xqa_key'
)
'ispublic'
,
'xqa_key'
)
try
:
try
:
print
"Cleaning {}"
.
format
(
filepath
)
print
"Cleaning {
0
}"
.
format
(
filepath
)
with
open
(
filepath
)
as
f
:
with
open
(
filepath
)
as
f
:
parser
=
etree
.
XMLParser
(
remove_comments
=
False
)
parser
=
etree
.
XMLParser
(
remove_comments
=
False
)
xml
=
etree
.
parse
(
filepath
,
parser
=
parser
)
xml
=
etree
.
parse
(
filepath
,
parser
=
parser
)
except
:
except
:
print
"Error parsing file {}"
.
format
(
filepath
)
print
"Error parsing file {
0
}"
.
format
(
filepath
)
return
return
for
node
in
xml
.
iter
(
tag
=
etree
.
Element
):
for
node
in
xml
.
iter
(
tag
=
etree
.
Element
):
...
@@ -67,12 +67,12 @@ def cleanup(filepath, remove_meta):
...
@@ -67,12 +67,12 @@ def cleanup(filepath, remove_meta):
del
attrs
[
'name'
]
del
attrs
[
'name'
]
if
'url_name'
in
attrs
and
'slug'
in
attrs
:
if
'url_name'
in
attrs
and
'slug'
in
attrs
:
print
"WARNING: {
} has both slug and url_name"
print
"WARNING: {
0} has both slug and url_name"
.
format
(
node
)
if
(
'url_name'
in
attrs
and
'filename'
in
attrs
and
if
(
'url_name'
in
attrs
and
'filename'
in
attrs
and
len
(
attrs
)
==
2
and
attrs
[
'url_name'
]
==
attrs
[
'filename'
]):
len
(
attrs
)
==
2
and
attrs
[
'url_name'
]
==
attrs
[
'filename'
]):
# This is a pointer tag in disguise. Get rid of the filename.
# This is a pointer tag in disguise. Get rid of the filename.
print
'turning {
}.{
} into a pointer tag'
.
format
(
node
.
tag
,
attrs
[
'url_name'
])
print
'turning {
0}.{1
} into a pointer tag'
.
format
(
node
.
tag
,
attrs
[
'url_name'
])
del
attrs
[
'filename'
]
del
attrs
[
'filename'
]
if
remove_meta
:
if
remove_meta
:
...
...
lms/djangoapps/courseware/access.py
View file @
6e3eff30
...
@@ -65,7 +65,7 @@ def has_access(user, obj, action):
...
@@ -65,7 +65,7 @@ def has_access(user, obj, action):
# Passing an unknown object here is a coding error, so rather than
# Passing an unknown object here is a coding error, so rather than
# returning a default, complain.
# returning a default, complain.
raise
TypeError
(
"Unknown object type in has_access(): '{}'"
raise
TypeError
(
"Unknown object type in has_access(): '{
0
}'"
.
format
(
type
(
obj
)))
.
format
(
type
(
obj
)))
...
@@ -255,7 +255,7 @@ def _dispatch(table, action, user, obj):
...
@@ -255,7 +255,7 @@ def _dispatch(table, action, user, obj):
action
)
action
)
return
result
return
result
raise
ValueError
(
"Unknown action for object type '{
}': '{
}'"
.
format
(
raise
ValueError
(
"Unknown action for object type '{
0}': '{1
}'"
.
format
(
type
(
obj
),
action
))
type
(
obj
),
action
))
def
_course_staff_group_name
(
location
):
def
_course_staff_group_name
(
location
):
...
...
lms/djangoapps/courseware/management/commands/metadata_to_json.py
View file @
6e3eff30
...
@@ -41,7 +41,7 @@ def import_course(course_dir, verbose=True):
...
@@ -41,7 +41,7 @@ def import_course(course_dir, verbose=True):
course
=
courses
[
0
]
course
=
courses
[
0
]
errors
=
modulestore
.
get_item_errors
(
course
.
location
)
errors
=
modulestore
.
get_item_errors
(
course
.
location
)
if
len
(
errors
)
!=
0
:
if
len
(
errors
)
!=
0
:
sys
.
stderr
.
write
(
'ERRORs during import: {}
\n
'
.
format
(
'
\n
'
.
join
(
map
(
str_of_err
,
errors
))))
sys
.
stderr
.
write
(
'ERRORs during import: {
0
}
\n
'
.
format
(
'
\n
'
.
join
(
map
(
str_of_err
,
errors
))))
return
course
return
course
...
...
lms/djangoapps/courseware/module_render.py
View file @
6e3eff30
...
@@ -327,7 +327,7 @@ def xqueue_callback(request, course_id, userid, id, dispatch):
...
@@ -327,7 +327,7 @@ def xqueue_callback(request, course_id, userid, id, dispatch):
user
,
modulestore
()
.
get_item
(
id
),
depth
=
0
,
select_for_update
=
True
)
user
,
modulestore
()
.
get_item
(
id
),
depth
=
0
,
select_for_update
=
True
)
instance
=
get_module
(
user
,
request
,
id
,
student_module_cache
)
instance
=
get_module
(
user
,
request
,
id
,
student_module_cache
)
if
instance
is
None
:
if
instance
is
None
:
log
.
debug
(
"No module {
} for user {
}--access denied?"
.
format
(
id
,
user
))
log
.
debug
(
"No module {
0} for user {1
}--access denied?"
.
format
(
id
,
user
))
raise
Http404
raise
Http404
instance_module
=
get_instance_module
(
user
,
instance
,
student_module_cache
)
instance_module
=
get_instance_module
(
user
,
instance
,
student_module_cache
)
...
@@ -390,7 +390,7 @@ def modx_dispatch(request, dispatch=None, id=None, course_id=None):
...
@@ -390,7 +390,7 @@ def modx_dispatch(request, dispatch=None, id=None, course_id=None):
if
instance
is
None
:
if
instance
is
None
:
# Either permissions just changed, or someone is trying to be clever
# Either permissions just changed, or someone is trying to be clever
# and load something they shouldn't have access to.
# and load something they shouldn't have access to.
log
.
debug
(
"No module {
} for user {
}--access denied?"
.
format
(
id
,
user
))
log
.
debug
(
"No module {
0} for user {1
}--access denied?"
.
format
(
id
,
user
))
raise
Http404
raise
Http404
instance_module
=
get_instance_module
(
request
.
user
,
instance
,
student_module_cache
)
instance_module
=
get_instance_module
(
request
.
user
,
instance
,
student_module_cache
)
...
...
lms/djangoapps/courseware/tests/tests.py
View file @
6e3eff30
...
@@ -177,7 +177,7 @@ class PageLoader(ActivateLoginTestCase):
...
@@ -177,7 +177,7 @@ class PageLoader(ActivateLoginTestCase):
def
try_enroll
(
self
,
course
):
def
try_enroll
(
self
,
course
):
"""Try to enroll. Return bool success instead of asserting it."""
"""Try to enroll. Return bool success instead of asserting it."""
data
=
self
.
_enroll
(
course
)
data
=
self
.
_enroll
(
course
)
print
'Enrollment in {
} result: {
}'
.
format
(
course
.
location
.
url
(),
data
)
print
'Enrollment in {
0} result: {1
}'
.
format
(
course
.
location
.
url
(),
data
)
return
data
[
'success'
]
return
data
[
'success'
]
def
enroll
(
self
,
course
):
def
enroll
(
self
,
course
):
...
@@ -309,7 +309,7 @@ class TestViewAuth(PageLoader):
...
@@ -309,7 +309,7 @@ class TestViewAuth(PageLoader):
# shouldn't be able to get to the instructor pages
# shouldn't be able to get to the instructor pages
for
url
in
instructor_urls
(
self
.
toy
)
+
instructor_urls
(
self
.
full
):
for
url
in
instructor_urls
(
self
.
toy
)
+
instructor_urls
(
self
.
full
):
print
'checking for 404 on {}'
.
format
(
url
)
print
'checking for 404 on {
0
}'
.
format
(
url
)
self
.
check_for_get_code
(
404
,
url
)
self
.
check_for_get_code
(
404
,
url
)
# Make the instructor staff in the toy course
# Make the instructor staff in the toy course
...
@@ -322,11 +322,11 @@ class TestViewAuth(PageLoader):
...
@@ -322,11 +322,11 @@ class TestViewAuth(PageLoader):
# Now should be able to get to the toy course, but not the full course
# Now should be able to get to the toy course, but not the full course
for
url
in
instructor_urls
(
self
.
toy
):
for
url
in
instructor_urls
(
self
.
toy
):
print
'checking for 200 on {}'
.
format
(
url
)
print
'checking for 200 on {
0
}'
.
format
(
url
)
self
.
check_for_get_code
(
200
,
url
)
self
.
check_for_get_code
(
200
,
url
)
for
url
in
instructor_urls
(
self
.
full
):
for
url
in
instructor_urls
(
self
.
full
):
print
'checking for 404 on {}'
.
format
(
url
)
print
'checking for 404 on {
0
}'
.
format
(
url
)
self
.
check_for_get_code
(
404
,
url
)
self
.
check_for_get_code
(
404
,
url
)
...
@@ -337,7 +337,7 @@ class TestViewAuth(PageLoader):
...
@@ -337,7 +337,7 @@ class TestViewAuth(PageLoader):
# and now should be able to load both
# and now should be able to load both
for
url
in
instructor_urls
(
self
.
toy
)
+
instructor_urls
(
self
.
full
):
for
url
in
instructor_urls
(
self
.
toy
)
+
instructor_urls
(
self
.
full
):
print
'checking for 200 on {}'
.
format
(
url
)
print
'checking for 200 on {
0
}'
.
format
(
url
)
self
.
check_for_get_code
(
200
,
url
)
self
.
check_for_get_code
(
200
,
url
)
...
@@ -413,22 +413,22 @@ class TestViewAuth(PageLoader):
...
@@ -413,22 +413,22 @@ class TestViewAuth(PageLoader):
def
check_non_staff
(
course
):
def
check_non_staff
(
course
):
"""Check that access is right for non-staff in course"""
"""Check that access is right for non-staff in course"""
print
'=== Checking non-staff access for {}'
.
format
(
course
.
id
)
print
'=== Checking non-staff access for {
0
}'
.
format
(
course
.
id
)
for
url
in
instructor_urls
(
course
)
+
dark_student_urls
(
course
):
for
url
in
instructor_urls
(
course
)
+
dark_student_urls
(
course
):
print
'checking for 404 on {}'
.
format
(
url
)
print
'checking for 404 on {
0
}'
.
format
(
url
)
self
.
check_for_get_code
(
404
,
url
)
self
.
check_for_get_code
(
404
,
url
)
for
url
in
light_student_urls
(
course
):
for
url
in
light_student_urls
(
course
):
print
'checking for 200 on {}'
.
format
(
url
)
print
'checking for 200 on {
0
}'
.
format
(
url
)
self
.
check_for_get_code
(
200
,
url
)
self
.
check_for_get_code
(
200
,
url
)
def
check_staff
(
course
):
def
check_staff
(
course
):
"""Check that access is right for staff in course"""
"""Check that access is right for staff in course"""
print
'=== Checking staff access for {}'
.
format
(
course
.
id
)
print
'=== Checking staff access for {
0
}'
.
format
(
course
.
id
)
for
url
in
(
instructor_urls
(
course
)
+
for
url
in
(
instructor_urls
(
course
)
+
dark_student_urls
(
course
)
+
dark_student_urls
(
course
)
+
light_student_urls
(
course
)):
light_student_urls
(
course
)):
print
'checking for 200 on {}'
.
format
(
url
)
print
'checking for 200 on {
0
}'
.
format
(
url
)
self
.
check_for_get_code
(
200
,
url
)
self
.
check_for_get_code
(
200
,
url
)
# First, try with an enrolled student
# First, try with an enrolled student
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment