Пример #1
0
def render_xd_classes(js_file_path_or_content, req):
    """
    Renders the cross-domain dojo files
    """
    from google.appengine.ext.webapp import template
    import os, re
    from tic.utils.jsparser import parse
    try:
        nodes = parse(file(js_file_path_or_content).read(), js_file_path_or_content)
    except:
        try:
            nodes = parse(js_file_path_or_content)
        except Exception:
            raise Exception(js_file_path_or_content)

    provide_matcher = re.compile(r'dojo\.provide\([\'"](.*)[\'"]\)')
    require_matcher = re.compile(r'dojo\.require\([\'"](.*)[\'"]\)')
    vars = {'requireList': list(), 'declaration': ""}
    for node in nodes:
        source = node.getSource()
        #dojo.provide statement?
        if provide_matcher.match(source):
            vars['provide'] = provide_matcher.findall(source)[0]

        elif require_matcher.match(source):
            vars['requireList'].append(require_matcher.findall(source)[0])
        else:
            vars['declaration'] += source + ";"

    mimetype = "application/javascript;charset=utf-8"
    req.send_header('Content-Type', mimetype)
    path = os.path.join(os.path.dirname(__file__), 'templates/xd.js')
    req.write(template.render(path, vars))
Пример #2
0
def is_dojo_class(js_file_path_or_content):
    import os, re
    from tic.utils.jsparser import parse
    try:
        nodes = parse(file(js_file_path_or_content).read(), js_file_path_or_content)
    except:
        nodes = parse(js_file_path_or_content)

    provide_matcher = re.compile(r'dojo\.provide\([\'"](.*)[\'"]\)')
    for node in nodes:
        source = node.getSource()
        #dojo.provide statement?
        if provide_matcher.match(source):
            vars['provide'] = provide_matcher.findall(source)[0]
            return True

    return False
Пример #3
0
 def _coverage(self):
     """
     TODOC
     """
     logging.info('Scanning For Js Files')
     jsfile = "/Users/selkhateeb/Development/Projects/tic/src/example/client/entrypoint.js"
     nodes = parse(file(jsfile).read())
     self._recurse(nodes)