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
797b7c9d
Commit
797b7c9d
authored
Feb 12, 2013
by
Vasyl Nakvasiuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add static method `ConditionalDescriptor.parse_sources`
parent
0129994e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
25 deletions
+18
-25
common/lib/xmodule/xmodule/conditional_module.py
+18
-25
No files found.
common/lib/xmodule/xmodule/conditional_module.py
View file @
797b7c9d
...
@@ -124,46 +124,39 @@ class ConditionalDescriptor(SequenceDescriptor):
...
@@ -124,46 +124,39 @@ class ConditionalDescriptor(SequenceDescriptor):
show_tag_list
=
List
(
help
=
"Poll answers"
,
scope
=
Scope
.
content
)
show_tag_list
=
List
(
help
=
"Poll answers"
,
scope
=
Scope
.
content
)
def
get_required_module_descriptors
(
self
):
@staticmethod
"""TODO: Returns a list of XModuleDescritpor instances upon which this module depends, but are
def
parse_sources
(
xml_element
,
system
,
return_descriptor
=
False
):
not children of this module"""
result
=
[]
descriptors
=
[]
sources
=
xml_element
.
get
(
'sources'
)
sources
=
self
.
xml_attributes
.
get
(
'sources'
)
if
sources
:
if
sources
:
locations
=
[
location
.
strip
()
for
location
in
sources
.
split
(
';'
)]
locations
=
[
location
.
strip
()
for
location
in
sources
.
split
(
';'
)]
for
location
in
locations
:
for
location
in
locations
:
# Check valid location url.
# Check valid location url.
if
Location
.
is_valid
(
location
):
if
Location
.
is_valid
(
location
):
try
:
try
:
descriptor
=
self
.
system
.
load_item
(
location
)
descriptor
=
system
.
load_item
(
location
)
descriptors
.
append
(
descriptor
)
if
return_descriptor
:
result
.
append
(
descriptor
)
else
:
result
.
append
(
location
)
except
ItemNotFoundError
:
except
ItemNotFoundError
:
log
.
exception
(
"Invalid module by location."
)
log
.
exception
(
"Invalid module by location."
)
return
descriptors
return
result
def
get_required_module_descriptors
(
self
):
"""TODO: Returns a list of XModuleDescritpor instances upon which this module depends, but are
not children of this module"""
return
ConditionalDescriptor
.
parse_sources
(
self
.
xml_attributes
,
self
.
system
,
True
)
@classmethod
@classmethod
def
definition_from_xml
(
cls
,
xml_object
,
system
):
def
definition_from_xml
(
cls
,
xml_object
,
system
):
def
parse_show_tag
(
child
):
"""Return list of valid module urls from <show> tag."""
urls
=
[]
sources
=
child
.
get
(
'sources'
)
if
sources
:
locations
=
[
location
.
strip
()
for
location
in
sources
.
split
(
';'
)]
for
location
in
locations
:
# Check valid location url.
if
Location
.
is_valid
(
location
):
try
:
system
.
load_item
(
location
)
urls
.
append
(
location
)
except
ItemNotFoundError
:
log
.
exception
(
"Invalid descriptor by location."
)
return
urls
children
=
[]
children
=
[]
show_tag_list
=
[]
show_tag_list
=
[]
for
child
in
xml_object
:
for
child
in
xml_object
:
if
child
.
tag
==
'show'
:
if
child
.
tag
==
'show'
:
location
=
parse_show_tag
(
child
)
location
=
ConditionalDescriptor
.
parse_sources
(
child
,
system
)
children
.
extend
(
location
)
children
.
extend
(
location
)
show_tag_list
.
extend
(
location
)
show_tag_list
.
extend
(
location
)
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