Reads a `Fenics/Dolfin` file format. Return an ``Actor(vtkActor)`` object.
495126
def loadDolfin(filename, c="gold", alpha=0.5, wire=None, bc=None):
    """"""
    if not os.path.exists(filename):
        colors.printc("~noentry Error in loadDolfin: Cannot find", filename, c=1)
        return None
    import xml.etree.ElementTree as et

    if filename.endswith(".gz"):
        import gzip

        inF = gzip.open(filename, "rb")
        outF = open("/tmp/filename.xml", "wb")
        outF.write(inF.read())
        outF.close()
        inF.close()
        tree = et.parse("/tmp/filename.xml")
    else:
        tree = et.parse(filename)
    coords, connectivity = [], []
    for mesh in tree.getroot():
        for elem in mesh:
            for e in elem.findall("vertex"):
                x = float(e.get("x"))
                y = float(e.get("y"))
                ez = e.get("z")
                if ez is None:
                    coords.append([x, y])
                else:
                    z = float(ez)
                    coords.append([x, y, z])

            tets = elem.findall("tetrahedron")
            if not len(tets):
                tris = elem.findall("triangle")
                for e in tris:
                    v0 = int(e.get("v0"))
                    v1 = int(e.get("v1"))
                    v2 = int(e.get("v2"))
                    connectivity.append([v0, v1, v2])
            else:
                for e in tets:
                    v0 = int(e.get("v0"))
                    v1 = int(e.get("v1"))
                    v2 = int(e.get("v2"))
                    v3 = int(e.get("v3"))
                    connectivity.append([v0, v1, v2, v3])

    poly = buildPolyData(coords, connectivity)
    return Actor(poly, c, alpha, True, bc)
582582
def read_examples(input_files, batch_size, shuffle, num_epochs=None):
  """"""
  files = []
  for e in input_files:
    for path in e.split(','):
      files.extend(file_io.get_matching_files(path))
  thread_count = multiprocessing.cpu_count()

  # The minimum number of instances in a queue from which examples are drawn
  # randomly. The larger this number, the more randomness at the expense of
  # higher memory requirements.
  min_after_dequeue = 1000

  # When batching data, the queue's capacity will be larger than the batch_size
  # by some factor. The recommended formula is (num_threads + a small safety
  # margin). For now, we use a single thread for reading, so this can be small.
  queue_size_multiplier = thread_count + 3

  # Convert num_epochs == 0 -> num_epochs is None, if necessary
  num_epochs = num_epochs or None

  # Build a queue of the filenames to be read.
  filename_queue = tf.train.string_input_producer(files, num_epochs, shuffle)

  example_id, encoded_example = tf.TextLineReader().read_up_to(
      filename_queue, batch_size)

  if shuffle:
    capacity = min_after_dequeue + queue_size_multiplier * batch_size
    return tf.train.shuffle_batch(
        [example_id, encoded_example],
        batch_size,
        capacity,
        min_after_dequeue,
        enqueue_many=True,
        num_threads=thread_count)

  else:
    capacity = queue_size_multiplier * batch_size
    return tf.train.batch(
        [example_id, encoded_example],
        batch_size,
        capacity=capacity,
        enqueue_many=True,
        num_threads=thread_count)
1211889
def __read(self, i: int) -> bytes:
        """"""
        b = self.data[self.idx: self.idx + i]
        self.idx += i
        if len(b) != i:
            raise bencodepy.DecodingError(
                "Incorrect byte length returned between indexes of {0} and {1}. Possible unexpected End of File."
                    .format(str(self.idx), str(self.idx - i)))
        return b
997274
def read(self, path, ext=None, start=None, stop=None, recursive=False, npartitions=None):
        
        from .utils import connection_with_anon, connection_with_gs

        path = addextension(path, ext)
        scheme, bucket_name, keylist = self.getfiles(
            path, start=start, stop=stop, recursive=recursive)

        if not keylist:
            raise FileNotFoundError("No objects found for '%s'" % path)

        credentials = self.credentials

        self.nfiles = len(keylist)

        if spark and isinstance(self.engine, spark):

            def getsplit(kvIter):
                if scheme == 's3' or scheme == 's3n':
                    conn = connection_with_anon(credentials)
                    bucket = conn.get_bucket(bucket_name)
                elif scheme == 'gs':
                    conn = boto.storage_uri(bucket_name, 'gs')
                    bucket = conn.get_bucket()
                else:
                    raise NotImplementedError("No file reader implementation for URL scheme " + scheme)

                for kv in kvIter:
                    idx, keyname = kv
                    key = bucket.get_key(keyname)
                    buf = key.get_contents_as_string()
                    yield idx, buf, keyname

            npartitions = min(npartitions, self.nfiles) if npartitions else self.nfiles
            rdd = self.engine.parallelize(enumerate(keylist), npartitions)
            return rdd.mapPartitions(getsplit)

        else:

            if scheme == 's3' or scheme == 's3n':
                conn = connection_with_anon(credentials)
                bucket = conn.get_bucket(bucket_name)
            elif scheme == 'gs':
                conn = connection_with_gs(bucket_name)
                bucket = conn.get_bucket()
            else:
                raise NotImplementedError("No file reader implementation for URL scheme " + scheme)

            def getsplit(kv):
                idx, keyName = kv
                key = bucket.get_key(keyName)
                buf = key.get_contents_as_string()
                return idx, buf, keyName

            return [getsplit(kv) for kv in enumerate(keylist)]
139337
def read(cls, file):
        """"""
        parser = WebVTTParser().read(file)
        return cls(file=file, captions=parser.captions, styles=parser.styles)
1070561
def read(self):
        
        todos = []
        try:
            todofile = codecs.open(self.path, 'r', encoding="utf-8")
            todos = todofile.readlines()
            todofile.close()
        except IOError:
            pass

        return todos
1318600
def _read(self):
        
        event = self._stick_file.read(self.EVENT_SIZE)
        (tv_sec, tv_usec, type, code, value) = struct.unpack(self.EVENT_FORMAT, event)
        if type == self.EV_KEY:
            return InputEvent(
                timestamp=tv_sec + (tv_usec / 1000000),
                direction={
                    self.KEY_UP:    DIRECTION_UP,
                    self.KEY_DOWN:  DIRECTION_DOWN,
                    self.KEY_LEFT:  DIRECTION_LEFT,
                    self.KEY_RIGHT: DIRECTION_RIGHT,
                    self.KEY_ENTER: DIRECTION_MIDDLE,
                    }[code],
                action={
                    self.STATE_PRESS:   ACTION_PRESSED,
                    self.STATE_RELEASE: ACTION_RELEASED,
                    self.STATE_HOLD:    ACTION_HELD,
                    }[value])
        else:
            return None
707190
function readFile (archive, name, opts, cb) {
  if (typeof opts === 'function') {
    cb = opts
    opts = {}
  }

  return maybe(cb, async function () {
    opts = opts || {}
    if (typeof opts === 'string') {
      opts = { encoding: opts }
    }
    opts.encoding = toValidEncoding(opts.encoding)

    // check that it's a file
    const st = await stat(archive, name)
    if (!st.isFile()) {
      throw new NotAFileError()
    }

    // read the file
    return new Promise((resolve, reject) => {
      archive.readFile(name, opts, (err, data) => {
        if (err) reject(toBeakerError(err, 'readFile'))
        else resolve(data)
      })
    })
  })
}
62858
def _read_data(file_obj, fo_encoding, value_count, bit_width):
    
    vals = []
    if fo_encoding == parquet_thrift.Encoding.RLE:
        seen = 0
        while seen < value_count:
            values = encoding.read_rle_bit_packed_hybrid(file_obj, bit_width)
            if values is None:
                break  # EOF was reached.
            vals += values
            seen += len(values)
    elif fo_encoding == parquet_thrift.Encoding.BIT_PACKED:
        raise NotImplementedError("Bit packing not yet supported")

    return vals
396488
function read(fp, opts, fn) {
  opts = opts || {};
  opts.encoding = opts.encoding || 'utf8';

  if (opts.read) {
    return opts.read(fp, opts);
  } else if (fn) {
    return fn(fp, opts);
  }

  if (endsWith(fp, '.js')) {
    return tryRequire(fp);
  } else {
    var str = tryCatch(fs.readFileSync, fp, opts);
    if (endsWith(fp, '.json')) {
      return tryCatch(JSON.parse, str);
    }
    return str;
  }
}
421817
function readFileSync (args) {
    var file = args.file;
    var next = args.next;

    if (isUnsupportedPath(file.url)) {
      // It's not a filesystem path, so let some other plugin handle it
      return next();
    }

    var filepath = getFileSystemPath(file.url);

    inferFileMetadata(file);
    return fs.readFileSync(filepath);
  }
503496
def _read_file(name, encoding='utf-8'):
    
    with codecs.open(name, encoding=encoding) as f:
        return f.read()
294635
function fileReader(moduleMeta) {
  // Read file from disk and return a module meta
  return pstream(readFile(moduleMeta.path))
    .then(function(text) {
      return {
        source: text
      };
    }, log2console);
}
1301891
def read(filename):
    
    fname = os.path.join(here, filename)
    with codecs.open(fname, encoding='utf-8') as f:
        return f.read()
27988
def read(fname):
    
    fpath = os.path.join(os.path.dirname(__file__), fname)
    with codecs.open(fpath, 'r', 'utf8') as fhandle:
        return fhandle.read().strip()
716096
function readFile(p, encoding) {
    var def = Q.defer();
    fs.readFile(p, encoding, def.makeNodeResolver());
    return def.promise
}
882563
def readProfile(filename):
  
  p    = profile_parser.Parser()
  accu = TermSet()
  file = open(filename,'r')
  s    = file.readline()
  while s!="":
    try:
      accu = p.parse(s,filename)
    except EOFError:
      break
    s = file.readline()

  return accu