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
7c5d93a5
Commit
7c5d93a5
authored
Feb 13, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commented out debug print statements for possible merge
--HG-- branch : pmitros-mod-template
parent
cc28d828
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
courseware/content_parser.py
+7
-9
No files found.
courseware/content_parser.py
View file @
7c5d93a5
...
@@ -8,8 +8,6 @@ from lxml import etree
...
@@ -8,8 +8,6 @@ from lxml import etree
from
mako.template
import
Template
from
mako.template
import
Template
from
mako.lookup
import
TemplateLookup
from
mako.lookup
import
TemplateLookup
#import courseware.modules
try
:
# This lets us do __name__ == ='__main__'
try
:
# This lets us do __name__ == ='__main__'
from
django.conf
import
settings
from
django.conf
import
settings
from
student.models
import
UserProfile
from
student.models
import
UserProfile
...
@@ -51,7 +49,7 @@ def xpath(xml, query_string, **args):
...
@@ -51,7 +49,7 @@ def xpath(xml, query_string, **args):
We should remove this with the move to lxml.
We should remove this with the move to lxml.
We should also use lxml argument passing. '''
We should also use lxml argument passing. '''
doc
=
etree
.
fromstring
(
xml
)
doc
=
etree
.
fromstring
(
xml
)
print
type
(
doc
)
#
print type(doc)
def
escape
(
x
):
def
escape
(
x
):
# TODO: This should escape the string. For now, we just assume it's made of valid characters.
# TODO: This should escape the string. For now, we just assume it's made of valid characters.
# Couldn't figure out how to escape for lxml in a few quick Googles
# Couldn't figure out how to escape for lxml in a few quick Googles
...
@@ -62,7 +60,7 @@ def xpath(xml, query_string, **args):
...
@@ -62,7 +60,7 @@ def xpath(xml, query_string, **args):
return
x
return
x
args
=
dict
(
((
k
,
escape
(
args
[
k
]))
for
k
in
args
)
)
args
=
dict
(
((
k
,
escape
(
args
[
k
]))
for
k
in
args
)
)
print
args
#
print args
results
=
doc
.
xpath
(
query_string
.
format
(
**
args
))
results
=
doc
.
xpath
(
query_string
.
format
(
**
args
))
return
results
return
results
...
@@ -88,7 +86,7 @@ def item(l, default="", process=lambda x:x):
...
@@ -88,7 +86,7 @@ def item(l, default="", process=lambda x:x):
def
id_tag
(
course
):
def
id_tag
(
course
):
''' Tag all course elements with unique IDs '''
''' Tag all course elements with unique IDs '''
default
_ids
=
{
'video'
:
'youtube'
,
old
_ids
=
{
'video'
:
'youtube'
,
'problem'
:
'filename'
,
'problem'
:
'filename'
,
'sequential'
:
'id'
,
'sequential'
:
'id'
,
'html'
:
'filename'
,
'html'
:
'filename'
,
...
@@ -96,11 +94,11 @@ def id_tag(course):
...
@@ -96,11 +94,11 @@ def id_tag(course):
'tab'
:
'id'
,
'tab'
:
'id'
,
'schematic'
:
'id'
,
'schematic'
:
'id'
,
'book'
:
'id'
}
'book'
:
'id'
}
# TODO:
import
courseware.modules
# a
lt_ids = courseware.modules.get_default_ids()
defau
lt_ids
=
courseware
.
modules
.
get_default_ids
()
# print default_ids, alt
_ids
#print default_ids, old
_ids
# print default_ids == alt
_ids
#print default_ids == old
_ids
# Tag elements with unique IDs
# Tag elements with unique IDs
elements
=
course
.
xpath
(
"|"
.
join
([
'//'
+
c
for
c
in
default_ids
]))
elements
=
course
.
xpath
(
"|"
.
join
([
'//'
+
c
for
c
in
default_ids
]))
...
...
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