Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

hacking in dojo support.

  • Loading branch information...
commit 8ebf16487a0ac52027baeee56d14fada8575269e 1 parent 9ba3f53
@anutron authored
Showing with 29 additions and 1 deletion.
  1. +29 −1 django/src/depender/core.py
View
30 django/src/depender/core.py
@@ -436,13 +436,41 @@ def _force_unicode(data):
except UnicodeDecodeError:
data = unicode(data, "latin1")
return data
-
+
+def _dojo_parse(data, filename):
+ data = re.sub(r'\/\/.*?\n', '', data)
+ deps = {
+ 'requires': [], 'provides': []
+ }
+ dojo_provision = get_dojo_provision(filename)
+ if not dojo_provision:
+ return
+
+ deps['provides'] = re.findall(r'dojo.provide\("(.*?)"\);', data)
+ if len(deps['provides']) > 0:
+ if dojo_provision not in deps['provides']:
+ deps['provides'].append(dojo_provision)
+ else:
+ deps['provides'] = [dojo_provision]
+ deps['requires'] = re.findall(r'dojo.require\("(.*?)"\);', data)
+
+ return deps
+
+def get_dojo_provision(filename):
+ # total hack
+ if filename.find('dojo-1.6/') != -1:
+ return re.sub(r'\.js$', '', re.sub('/', '.', filename.split('dojo-1.6/')[-1]))
+
def _parse_js_file(filename):
"""Find yaml section in javascript file."""
data = _force_unicode(file(filename).read())
m = YAML_SECTION.match(data)
if not m:
+ m = _dojo_parse(data, filename)
+ if m:
+ return m
+ if not m:
raise Exception("Could not succesfully find YAML section in %r." % filename)
return None
try:
Please sign in to comment.
Something went wrong with that request. Please try again.