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
4cb6eb6e
Commit
4cb6eb6e
authored
Jun 20, 2013
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pylint violations in xmodule static_content.py
parent
501830c9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
common/lib/xmodule/xmodule/static_content.py
+28
-3
No files found.
common/lib/xmodule/xmodule/static_content.py
View file @
4cb6eb6e
...
@@ -20,22 +20,27 @@ LOG = logging.getLogger(__name__)
...
@@ -20,22 +20,27 @@ LOG = logging.getLogger(__name__)
def
write_module_styles
(
output_root
):
def
write_module_styles
(
output_root
):
"""Write all registered XModule css, sass, and scss files to output root."""
return
_write_styles
(
'.xmodule_display'
,
output_root
,
_list_modules
())
return
_write_styles
(
'.xmodule_display'
,
output_root
,
_list_modules
())
def
write_module_js
(
output_root
):
def
write_module_js
(
output_root
):
"""Write all registered XModule js and coffee files to output root."""
return
_write_js
(
output_root
,
_list_modules
())
return
_write_js
(
output_root
,
_list_modules
())
def
write_descriptor_styles
(
output_root
):
def
write_descriptor_styles
(
output_root
):
"""Write all registered XModuleDescriptor css, sass, and scss files to output root."""
return
_write_styles
(
'.xmodule_edit'
,
output_root
,
_list_descriptors
())
return
_write_styles
(
'.xmodule_edit'
,
output_root
,
_list_descriptors
())
def
write_descriptor_js
(
output_root
):
def
write_descriptor_js
(
output_root
):
"""Write all registered XModuleDescriptor js and coffee files to output root."""
return
_write_js
(
output_root
,
_list_descriptors
())
return
_write_js
(
output_root
,
_list_descriptors
())
def
_list_descriptors
():
def
_list_descriptors
():
"""Return a list of all registered XModuleDescriptor classes."""
return
[
return
[
desc
for
desc
in
[
desc
for
desc
in
[
desc
for
(
_
,
desc
)
in
XModuleDescriptor
.
load_classes
()
desc
for
(
_
,
desc
)
in
XModuleDescriptor
.
load_classes
()
...
@@ -44,6 +49,7 @@ def _list_descriptors():
...
@@ -44,6 +49,7 @@ def _list_descriptors():
def
_list_modules
():
def
_list_modules
():
"""Return a list of all registered XModule classes."""
return
[
return
[
desc
.
module_class
desc
.
module_class
for
desc
for
desc
...
@@ -51,9 +57,10 @@ def _list_modules():
...
@@ -51,9 +57,10 @@ def _list_modules():
]
]
def
_ensure_dir
(
dir_
):
def
_ensure_dir
(
directory
):
"""Ensure that `directory` exists."""
try
:
try
:
os
.
makedirs
(
dir
_
)
os
.
makedirs
(
dir
ectory
)
except
OSError
as
exc
:
except
OSError
as
exc
:
if
exc
.
errno
==
errno
.
EEXIST
:
if
exc
.
errno
==
errno
.
EEXIST
:
pass
pass
...
@@ -131,6 +138,19 @@ def _write_js(output_root, classes):
...
@@ -131,6 +138,19 @@ def _write_js(output_root, classes):
def
_write_files
(
output_root
,
contents
,
generated_suffix_map
=
None
):
def
_write_files
(
output_root
,
contents
,
generated_suffix_map
=
None
):
"""
Write file contents to output root.
Any files not listed in contents that exists in output_root will be deleted,
unless it matches one of the patterns in `generated_suffix_map`.
output_root (path): The root directory to write the file contents in
contents (dict): A map from filenames to file contents to be written to the output_root
generated_suffix_map (dict): Optional. Maps file suffix to generated file suffix.
For any file in contents, if the suffix matches a key in `generated_suffix_map`,
then the same filename with the suffix replaced by the value from `generated_suffix_map`
will be ignored
"""
_ensure_dir
(
output_root
)
_ensure_dir
(
output_root
)
to_delete
=
set
(
file
.
basename
()
for
file
in
output_root
.
files
())
-
set
(
contents
.
keys
())
to_delete
=
set
(
file
.
basename
()
for
file
in
output_root
.
files
())
-
set
(
contents
.
keys
())
...
@@ -146,7 +166,12 @@ def _write_files(output_root, contents, generated_suffix_map=None):
...
@@ -146,7 +166,12 @@ def _write_files(output_root, contents, generated_suffix_map=None):
for
filename
,
file_content
in
contents
.
iteritems
():
for
filename
,
file_content
in
contents
.
iteritems
():
output_file
=
output_root
/
filename
output_file
=
output_root
/
filename
if
not
output_file
.
isfile
()
or
output_file
.
read_md5
()
!=
hashlib
.
md5
(
file_content
)
.
digest
():
not_file
=
not
output_file
.
isfile
()
# not_file is included to short-circuit this check, because
# read_md5 depends on the file already existing
write_file
=
not_file
or
output_file
.
read_md5
()
!=
hashlib
.
md5
(
file_content
)
.
digest
()
# pylint: disable=E1121
if
write_file
:
LOG
.
debug
(
"Writing
%
s"
,
output_file
)
LOG
.
debug
(
"Writing
%
s"
,
output_file
)
output_file
.
write_bytes
(
file_content
)
output_file
.
write_bytes
(
file_content
)
else
:
else
:
...
...
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