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
6997fc57
Commit
6997fc57
authored
Jul 27, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Continue on errors when syncing with github
parent
05add581
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
common/lib/xmodule/xmodule/raw_module.py
+2
-1
common/lib/xmodule/xmodule/xml_module.py
+10
-9
No files found.
common/lib/xmodule/xmodule/raw_module.py
View file @
6997fc57
...
@@ -6,6 +6,7 @@ import logging
...
@@ -6,6 +6,7 @@ import logging
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
class
RawDescriptor
(
MakoModuleDescriptor
,
XmlDescriptor
):
class
RawDescriptor
(
MakoModuleDescriptor
,
XmlDescriptor
):
"""
"""
Module that provides a raw editing view of its data and children
Module that provides a raw editing view of its data and children
...
@@ -33,7 +34,7 @@ class RawDescriptor(MakoModuleDescriptor, XmlDescriptor):
...
@@ -33,7 +34,7 @@ class RawDescriptor(MakoModuleDescriptor, XmlDescriptor):
line
,
offset
=
err
.
position
line
,
offset
=
err
.
position
msg
=
(
"Unable to create xml for problem {loc}. "
msg
=
(
"Unable to create xml for problem {loc}. "
"Context: '{context}'"
.
format
(
"Context: '{context}'"
.
format
(
context
=
lines
[
line
-
1
][
offset
-
40
:
offset
+
40
],
context
=
lines
[
line
-
1
][
offset
-
40
:
offset
+
40
],
loc
=
self
.
location
))
loc
=
self
.
location
))
log
.
exception
(
msg
)
log
.
exception
(
msg
)
self
.
system
.
error_handler
(
msg
)
self
.
system
.
error_handler
(
msg
)
...
...
common/lib/xmodule/xmodule/xml_module.py
View file @
6997fc57
from
collections
import
MutableMapping
from
collections
import
MutableMapping
from
xmodule.x_module
import
XModuleDescriptor
from
xmodule.x_module
import
XModuleDescriptor
from
xmodule.modulestore
import
Location
from
lxml
import
etree
from
lxml
import
etree
import
copy
import
copy
import
logging
import
logging
...
@@ -13,6 +14,7 @@ log = logging.getLogger(__name__)
...
@@ -13,6 +14,7 @@ log = logging.getLogger(__name__)
# but the actual improvement wasn't measured (and it was implemented late at night).
# but the actual improvement wasn't measured (and it was implemented late at night).
# We should check if it hurts, and whether there's a better way of doing lazy loading
# We should check if it hurts, and whether there's a better way of doing lazy loading
class
LazyLoadingDict
(
MutableMapping
):
class
LazyLoadingDict
(
MutableMapping
):
"""
"""
A dictionary object that lazily loads its contents from a provided
A dictionary object that lazily loads its contents from a provided
...
@@ -173,6 +175,9 @@ class XmlDescriptor(XModuleDescriptor):
...
@@ -173,6 +175,9 @@ class XmlDescriptor(XModuleDescriptor):
url identifiers
url identifiers
"""
"""
xml_object
=
etree
.
fromstring
(
xml_data
)
xml_object
=
etree
.
fromstring
(
xml_data
)
# VS[compat] -- just have the url_name lookup once translation is done
slug
=
xml_object
.
get
(
'url_name'
,
xml_object
.
get
(
'slug'
))
location
=
Location
(
'i4x'
,
org
,
course
,
xml_object
.
tag
,
slug
)
def
metadata_loader
():
def
metadata_loader
():
metadata
=
{}
metadata
=
{}
...
@@ -210,25 +215,21 @@ class XmlDescriptor(XModuleDescriptor):
...
@@ -210,25 +215,21 @@ class XmlDescriptor(XModuleDescriptor):
with
system
.
resources_fs
.
open
(
filepath
)
as
file
:
with
system
.
resources_fs
.
open
(
filepath
)
as
file
:
definition_xml
=
cls
.
file_to_xml
(
file
)
definition_xml
=
cls
.
file_to_xml
(
file
)
except
(
ResourceNotFoundError
,
etree
.
XMLSyntaxError
):
except
(
ResourceNotFoundError
,
etree
.
XMLSyntaxError
):
msg
=
'Unable to load file contents at path
%
s
'
%
filepath
msg
=
'Unable to load file contents at path
%
s
for item
%
s'
%
(
filepath
,
location
.
url
())
log
.
exception
(
msg
)
log
.
exception
(
msg
)
system
.
error_handler
(
msg
)
system
.
error_handler
(
msg
)
# if error_handler didn't reraise, work around problem.
# if error_handler didn't reraise, work around problem.
return
{
'data'
:
'Error loading file contents at path
%
s'
%
filepath
}
error_elem
=
etree
.
Element
(
'error'
)
error_elem
.
text
=
msg
return
{
'data'
:
etree
.
tostring
(
error_elem
)}
cls
.
clean_metadata_from_xml
(
definition_xml
)
cls
.
clean_metadata_from_xml
(
definition_xml
)
return
cls
.
definition_from_xml
(
definition_xml
,
system
)
return
cls
.
definition_from_xml
(
definition_xml
,
system
)
# VS[compat] -- just have the url_name lookup once translation is done
slug
=
xml_object
.
get
(
'url_name'
,
xml_object
.
get
(
'slug'
))
return
cls
(
return
cls
(
system
,
system
,
LazyLoadingDict
(
definition_loader
),
LazyLoadingDict
(
definition_loader
),
location
=
[
'i4x'
,
location
=
location
,
org
,
course
,
xml_object
.
tag
,
slug
],
metadata
=
LazyLoadingDict
(
metadata_loader
),
metadata
=
LazyLoadingDict
(
metadata_loader
),
)
)
...
...
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