Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

hacking in dojo support.

  • Loading branch information...
commit 8ebf16487a0ac52027baeee56d14fada8575269e 1 parent 9ba3f53
authored April 28, 2011

Showing 1 changed file with 29 additions and 1 deletion. Show diff stats Hide diff stats

  1. 30  django/src/depender/core.py
30  django/src/depender/core.py
@@ -436,13 +436,41 @@ def _force_unicode(data):
436 436
   except UnicodeDecodeError:
437 437
     data = unicode(data, "latin1")
438 438
   return data
439  
-          
  439
+
  440
+def _dojo_parse(data, filename):
  441
+  data = re.sub(r'\/\/.*?\n', '', data)
  442
+  deps = {
  443
+    'requires': [], 'provides': []
  444
+  }
  445
+  dojo_provision = get_dojo_provision(filename)
  446
+  if not dojo_provision:
  447
+    return
  448
+
  449
+  deps['provides'] = re.findall(r'dojo.provide\("(.*?)"\);', data)
  450
+  if len(deps['provides']) > 0:
  451
+    if dojo_provision not in deps['provides']:
  452
+      deps['provides'].append(dojo_provision)
  453
+  else:
  454
+    deps['provides'] = [dojo_provision]
  455
+  deps['requires'] = re.findall(r'dojo.require\("(.*?)"\);', data)
  456
+
  457
+  return deps
  458
+
  459
+def get_dojo_provision(filename):
  460
+  # total hack
  461
+  if filename.find('dojo-1.6/') != -1:
  462
+   return re.sub(r'\.js$', '', re.sub('/', '.', filename.split('dojo-1.6/')[-1]))
  463
+
440 464
 def _parse_js_file(filename):
441 465
   """Find yaml section in javascript file."""
442 466
   data = _force_unicode(file(filename).read())
443 467
 
444 468
   m = YAML_SECTION.match(data)
445 469
   if not m:
  470
+    m = _dojo_parse(data, filename)
  471
+    if m:
  472
+      return m
  473
+  if not m:
446 474
     raise Exception("Could not succesfully find YAML section in %r." % filename)
447 475
     return None
448 476
   try:  

0 notes on commit 8ebf164

Please sign in to comment.
Something went wrong with that request. Please try again.