示例#1
0
def convertJS(params, files):
  from jshydra.abp_rewrite import doRewrite

  for item in params['metadata'].items('convert_js'):
    file, sources = item
    baseDir = os.path.dirname(item.source)

    # Make sure the file is inside an included directory
    if '/' in file and not files.isIncluded(file):
      continue

    sourceFiles = re.split(r'\s+', sources)
    args = []
    try:
      argsStart = sourceFiles.index('--arg')
      args = sourceFiles[argsStart + 1:]
      sourceFiles = sourceFiles[0:argsStart]
    except ValueError:
      pass

    # Source files of the conversion shouldn't be part of the build
    for sourceFile in sourceFiles:
      if sourceFile in files:
        del files[sourceFile]

    sourceFiles = map(lambda f: os.path.abspath(os.path.join(baseDir, f)), sourceFiles)
    files[file] = doRewrite(sourceFiles, args)
def convertJS(params, files):
    from jshydra.abp_rewrite import doRewrite

    for item in params['metadata'].items('convert_js'):
        file, sources = item
        baseDir = os.path.dirname(item.source)

        # Make sure the file is inside an included directory
        if '/' in file and not files.isIncluded(file):
            continue

        sourceFiles = sources.split()
        args = []
        try:
            argsStart = sourceFiles.index('--arg')
            args = sourceFiles[argsStart + 1:]
            sourceFiles = sourceFiles[0:argsStart]
        except ValueError:
            pass

        # Source files of the conversion shouldn't be part of the build
        for sourceFile in sourceFiles:
            if sourceFile in files:
                del files[sourceFile]

        sourceFiles = map(lambda f: os.path.abspath(os.path.join(baseDir, f)),
                          sourceFiles)
        files[file] = doRewrite(sourceFiles, args)
示例#3
0
def script_as_string(path, sourceURL, backcompat):
    if backcompat:
        from jshydra.abp_rewrite import doRewrite
        data = doRewrite([os.path.abspath(path)], []).decode("utf-8")
    else:
        with io.open(path, "r", encoding="utf-8") as handle:
            data = handle.read()
    data += "\n//# sourceURL=%s" % sourceURL
    return js_encode(data)
示例#4
0
def script_as_string(path, sourceURL, backcompat):
  if backcompat:
    from jshydra.abp_rewrite import doRewrite
    data = doRewrite([os.path.abspath(path)], []).decode("utf-8")
  else:
    with io.open(path, "r", encoding="utf-8") as handle:
      data = handle.read()
  data += "\n//# sourceURL=%s" % sourceURL
  return js_encode(data)