Beispiel #1
0
def load_isolates(items):
  """Parses each .isolate file and returns the merged results.

  It only loads what load_isolate_as_config() can process.

  Return values:
    files: dict(filename, set(OS where this filename is a dependency))
    dirs:  dict(dirame, set(OS where this dirname is a dependency))
    oses:  set(all the OSes referenced)
  """
  # pylint: disable=W0212
  configs = isolate_format.Configs(None, ())
  for item in items:
    item = os.path.abspath(item)
    logging.debug('loading %s' % item)
    if item == '-':
      content = sys.stdin.read()
    else:
      with open(item, 'r') as f:
        content = f.read()
    new_config = isolate_format.load_isolate_as_config(
        os.path.dirname(item),
        isolate_format.eval_content(content),
        isolate_format.extract_comment(content))
    logging.debug('has configs: ' + ','.join(map(repr, new_config._by_config)))
    configs = configs.union(new_config)
  logging.debug('Total configs: ' + ','.join(map(repr, configs._by_config)))
  return configs
Beispiel #2
0
def load_isolates(items):
    """Parses each .isolate file and returns the merged results.

  It only loads what load_isolate_as_config() can process.

  Return values:
    files: dict(filename, set(OS where this filename is a dependency))
    dirs:  dict(dirame, set(OS where this dirname is a dependency))
    oses:  set(all the OSes referenced)
  """
    # pylint: disable=W0212
    configs = isolate_format.Configs(None, ())
    for item in items:
        item = os.path.abspath(item)
        logging.debug('loading %s' % item)
        if item == '-':
            content = sys.stdin.read()
        else:
            with open(item, 'r') as f:
                content = f.read()
        new_config = isolate_format.load_isolate_as_config(
            os.path.dirname(item), isolate_format.eval_content(content),
            isolate_format.extract_comment(content))
        logging.debug('has configs: ' +
                      ','.join(map(repr, new_config._by_config)))
        configs = configs.union(new_config)
    logging.debug('Total configs: ' + ','.join(map(repr, configs._by_config)))
    return configs
 def test_extract_comment(self):
     self.assertEqual('# Foo\n# Bar\n',
                      isolate_format.extract_comment('# Foo\n# Bar\n{}'))
     self.assertEqual('', isolate_format.extract_comment('{}'))
 def test_extract_comment(self):
   self.assertEqual(
       '# Foo\n# Bar\n', isolate_format.extract_comment('# Foo\n# Bar\n{}'))
   self.assertEqual('', isolate_format.extract_comment('{}'))
def load_isolates(items):
    """Parses each .isolate file and returns the merged results.

  It only loads what load_isolate_as_config() can process.

  Return values:
    files: dict(filename, set(OS where this filename is a dependency))
    dirs:  dict(dirame, set(OS where this dirname is a dependency))
    oses:  set(all the OSes referenced)
  """
    # pylint: disable=W0212
    configs = None
    for item in items:
        item = os.path.abspath(item)
        logging.debug("loading %s" % item)
        if item == "-":
            content = sys.stdin.read()
        else:
            with open(item, "r") as f:
                content = f.read()
        new_config = load_isolate_as_config(os.path.dirname(item), eval_content(content), extract_comment(content))
        logging.debug("has configs: " + ",".join(map(repr, new_config._by_config)))
        configs = union(configs, new_config)
    logging.debug("Total configs: " + ",".join(map(repr, configs._by_config)))
    return configs