Reads the captions file.
189926
def read(self, file):
        """"""
        content = self._read_content(file)
        self._validate(content)
        self._parse(content)

        return self
1288123
def read(parts):
    
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    with codecs.open(os.path.join(cur_dir, *parts), "rb", "utf-8") as f:
        return f.read()
766476
def reads(s, filename, loader, implicit_tuple, allow_errors):
  """"""
  try:
    the_context.filename = filename
    the_context.loader = loader

    grammar = make_grammar(allow_errors=allow_errors)
    root = grammar.start_tuple if implicit_tuple else grammar.start

    return root.parseWithTabs().parseString(s, parseAll=True)[0]
  except (p.ParseException, p.ParseSyntaxException) as e:
    loc = SourceLocation(s, find_offset(s, e.lineno, e.col))
    raise exceptions.ParseError(the_context.filename, loc, e.msg)
1036001
def _read(self):
        
        filepos = self._fp.tell()
        if filepos < 1:
            return ""
        destpos = max(filepos - self._chunk_size, 0)
        self._fp.seek(destpos)
        buf = self._fp.read(filepos - destpos)
        self._fp.seek(destpos)
        return buf
309957
def read_stats(self):
        

        stats_with_captions = OrderedDict()
        for stat_name in self.stats_captions.keys():
            stats_with_captions[stat_name] = self.read_stat(self.stats_captions[stat_name], stat_name)
        return stats_with_captions
1235157
def read
      text = @filetype.read
      if text.nil?
        raise IniParseError, _("Cannot read nonexistent file %{file}") % { file: @file.inspect }
      end
      parse(text)
    end
46784
def read(self, *files, **params):
        
        for f in files:
            try:
                with io.open(f, encoding='utf-8') as ff:
                    NS_LOGGER.info('Read from `{0}`'.format(ff.name))
                    self.parse(ff.read(), **params)
            except (IOError, TypeError, SyntaxError, io.UnsupportedOperation):
                if not self.silent_read:
                    NS_LOGGER.error('Reading error `{0}`'.format(ff.name))
                    raise
197357
private static void readFully(final DataInput input, final short[] shorts) throws IOException {
        if (input instanceof ImageInputStream) {
            // Optimization for ImageInputStreams, read all in one go
            ((ImageInputStream) input).readFully(shorts, 0, shorts.length);
        }
        else {
            for (int i = 0; i < shorts.length; i++) {
                shorts[i] = input.readShort();
            }
        }
    }
371090
protected InputStream readFiles() throws IOException {
    BufferedInputStream input = new BufferedInputStream(openFile(), BUFFER_SIZE);
    input.mark(100);
    try {
      return new XZInputStream(input);
    } catch (IOException e) {
      input.reset();
    }
    try {
      return new CompressorStreamFactory().createCompressorInputStream(input);
    } catch (CompressorException e) {
      input.reset();
    }
    try {
      return new ArchiveStreamFactory().createArchiveInputStream(input);
    } catch (ArchiveException e) {
      input.reset();
    }
    return input;
  }
1197118
def read(self):
        

        try:
            while 1:
                token = self.tok.get(True, True).unescape()
                if token.is_eof():
                    if not self.current_file is None:
                        self.current_file.close()
                    if len(self.saved_state) > 0:
                        (self.tok,
                         self.current_origin,
                         self.last_name,
                         self.current_file,
                         self.ttl) = self.saved_state.pop(-1)
                        continue
                    break
                elif token.is_eol():
                    continue
                elif token.is_comment():
                    self.tok.get_eol()
                    continue
                elif token.value[0] == '$':
                    u = token.value.upper()
                    if u == '$TTL':
                        token = self.tok.get()
                        if not token.is_identifier():
                            raise dns.exception.SyntaxError("bad $TTL")
                        self.ttl = dns.ttl.from_text(token.value)
                        self.tok.get_eol()
                    elif u == '$ORIGIN':
                        self.current_origin = self.tok.get_name()
                        self.tok.get_eol()
                        if self.zone.origin is None:
                            self.zone.origin = self.current_origin
                    elif u == '$INCLUDE' and self.allow_include:
                        token = self.tok.get()
                        if not token.is_quoted_string():
                            raise dns.exception.SyntaxError("bad filename in $INCLUDE")
                        filename = token.value
                        token = self.tok.get()
                        if token.is_identifier():
                            new_origin = dns.name.from_text(token.value, \
                                                            self.current_origin)
                            self.tok.get_eol()
                        elif not token.is_eol_or_eof():
                            raise dns.exception.SyntaxError("bad origin in $INCLUDE")
                        else:
                            new_origin = self.current_origin
                        self.saved_state.append((self.tok,
                                                 self.current_origin,
                                                 self.last_name,
                                                 self.current_file,
                                                 self.ttl))
                        self.current_file = file(filename, 'r')
                        self.tok = dns.tokenizer.Tokenizer(self.current_file,
                                                           filename)
                        self.current_origin = new_origin
                    else:
                        raise dns.exception.SyntaxError("Unknown master file directive '" + u + "'")
                    continue
                self.tok.unget(token)
                self._rr_line()
        except dns.exception.SyntaxError, detail:
            (filename, line_number) = self.tok.where()
            if detail is None:
                detail = "syntax error"
            raise dns.exception.SyntaxError("%s:%d: %s" % (filename, line_number, detail))

        # Now that we're done reading, do some basic checking of the zone.
        if self.check_origin:
            self.zone.check_origin()
1221251
protected function read()
    {
        $subSections = [];

        $startObject = $entryCount = $lastLineStart = null;
        $validityChecked = false;
        while (($line = $this->reader->readLine(20)) !== false) {
            if (\strpos($line, 'trailer') !== false) {
                $this->reader->reset($lastLineStart);
                break;
            }

            // jump over if line content doesn't match the expected string
            if (\sscanf($line, '%d %d', $startObject, $entryCount) !== 2) {
                continue;
            }

            $oldPosition = $this->reader->getPosition();
            $position = $oldPosition + $this->reader->getOffset();

            if (!$validityChecked && $entryCount > 0) {
                $nextLine = $this->reader->readBytes(21);
                /* Check the next line for maximum of 20 bytes and not longer
                 * By catching 21 bytes and trimming the length should be still 21.
                 */
                if (\strlen(\trim($nextLine)) !== 21) {
                    throw new CrossReferenceException(
                        'Cross-reference entries are larger than 20 bytes.',
                        CrossReferenceException::ENTRIES_TOO_LARGE
                    );
                }

                /* Check for less than 20 bytes: cut the line to 20 bytes and trim; have to result in exactly 18 bytes.
                 * If it would have less bytes the substring would get the first bytes of the next line which would
                 * evaluate to a 20 bytes long string after trimming.
                 */
                if (\strlen(\trim(\substr($nextLine, 0, 20))) !== 18) {
                    throw new CrossReferenceException(
                        'Cross-reference entries are less than 20 bytes.',
                        CrossReferenceException::ENTRIES_TOO_SHORT
                    );
                }

                $validityChecked = true;
            }

            $subSections[$position] = [$startObject, $entryCount];

            $lastLineStart = $position + $entryCount * 20;
            $this->reader->reset($lastLineStart);
        }

        // reset after the last correct parsed line
        $this->reader->reset($lastLineStart);

        if (\count($subSections) === 0) {
            throw new CrossReferenceException(
                'No entries found in cross-reference.',
                CrossReferenceException::NO_ENTRIES
            );
        }

        $this->subSections = $subSections;
    }
1059947
def reads(s, filename=None, loader=None, implicit_tuple=True, allow_errors=False):
  """"""
  return ast.reads(s,
      filename=filename or '<input>',
      loader=loader or default_loader,
      implicit_tuple=implicit_tuple,
      allow_errors=allow_errors)
200293
private void scanSubtitles() {
		boolean convertFPS = configuration.getConvertFPS();
		subPictures = new SubPicture[subtitleStream.getFrameCount()];
		double factTS = convertFPS ? configuration.getFPSSrc()
				/ configuration.getFpsTrg() : 1.0;

		double fx;
		double fy;
		fx = 1.0;
		fy = 1.0;

		// first run: clone source subpics, apply speedup/down,
		SubPicture picSrc;
		for (int i = 0; i < subPictures.length; i++) {
			picSrc = subtitleStream.getSubPicture(i);
			subPictures[i] = new SubPicture(picSrc);
			long ts = picSrc.getStartTime();
			long te = picSrc.getEndTime();
			// copy time stamps and apply speedup/speeddown
			int delayPTS = configuration.getDelayPTS();
			if (!convertFPS) {
				subPictures[i].setStartTime(ts + delayPTS);
				subPictures[i].setEndTime(te + delayPTS);
			} else {
				subPictures[i].setStartTime((long) (ts * factTS + 0.5)
						+ delayPTS);
				subPictures[i]
						.setEndTime((long) (te * factTS + 0.5) + delayPTS);
			}
			// synchronize to target frame rate
			subPictures[i].setStartTime(SubtitleUtils.syncTimePTS(
					subPictures[i].getStartTime(), configuration.getFpsTrg(),
					configuration.getFpsTrg()));
			subPictures[i].setEndTime(SubtitleUtils.syncTimePTS(
					subPictures[i].getEndTime(), configuration.getFpsTrg(),
					configuration.getFpsTrg()));

			// set forced flag
			SubPicture picTrg = subPictures[i];

			double scaleX;
			double scaleY;
			if (configuration.getConvertResolution()) {
				// adjust image sizes and offsets
				// determine scaling factors
				picTrg.setWidth(configuration.getOutputResolution()
						.getDimensions()[0]);
				picTrg.setHeight(configuration.getOutputResolution()
						.getDimensions()[1]);
				scaleX = (double) picTrg.getWidth() / picSrc.getWidth();
				scaleY = (double) picTrg.getHeight() / picSrc.getHeight();
			} else {
				picTrg.setWidth(picSrc.getWidth());
				picTrg.setHeight(picSrc.getHeight());
				scaleX = 1.0;
				scaleY = 1.0;
			}
			int w = (int) (picSrc.getImageWidth() * scaleX * fx + 0.5);
			if (w < MIN_IMAGE_DIMENSION) {
				w = picSrc.getImageWidth();
			} else if (w > picTrg.getWidth()) {
				w = picTrg.getWidth();
			}

			int h = (int) (picSrc.getImageHeight() * scaleY * fy + 0.5);
			if (h < MIN_IMAGE_DIMENSION) {
				h = picSrc.getImageHeight();
			} else if (h > picTrg.getHeight()) {
				h = picTrg.getHeight();
			}
			picTrg.setImageWidth(w);
			picTrg.setImageHeight(h);

			int xOfs = (int) (picSrc.getXOffset() * scaleX + 0.5);
			int spaceSrc = (int) ((picSrc.getWidth() - picSrc.getImageWidth())
					* scaleX + 0.5);
			int spaceTrg = picTrg.getWidth() - w;
			xOfs += (spaceTrg - spaceSrc) / 2;
			if (xOfs < 0) {
				xOfs = 0;
			} else if (xOfs + w > picTrg.getWidth()) {
				xOfs = picTrg.getWidth() - w;
			}
			picTrg.setOfsX(xOfs);

			int yOfs = (int) (picSrc.getYOffset() * scaleY + 0.5);
			spaceSrc = (int) ((picSrc.getHeight() - picSrc.getImageHeight())
					* scaleY + 0.5);
			spaceTrg = picTrg.getHeight() - h;
			yOfs += (spaceTrg - spaceSrc) / 2;
			if (yOfs + h > picTrg.getHeight()) {
				yOfs = picTrg.getHeight() - h;
			}
			picTrg.setOfsY(yOfs);
		}

		// 2nd run: validate times
		SubPicture picPrev = null;
		SubPicture picNext;
		for (int i = 0; i < subPictures.length; i++) {
			if (i < subPictures.length - 1) {
				picNext = subPictures[i + 1];
			} else {
				picNext = null;
			}
			picSrc = subPictures[i];
			validateTimes(i, subPictures[i], picNext, picPrev);
			picPrev = picSrc;
		}
	}
368387
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
  {
    s.defaultReadObject();
    if (words == null) {
      reset();
      return;
    }
    lastWordIndex = words.length - 1;
    updateLast();
    size = -1;
  }
440402
def _parse_caption(self, node, state):
        
        if node.tag not in ["caption", "figcaption"]:  # captions used in Tables
            return state

        # Add a Caption
        parent = state["parent"][node]
        stable_id = (
            f"{state['document'].name}"
            f"::"
            f"{'caption'}"
            f":"
            f"{state['caption']['idx']}"
        )

        # Set name for Section
        name = node.attrib["name"] if "name" in node.attrib else None

        if isinstance(parent, Table):
            state["context"][node] = Caption(
                document=state["document"],
                table=parent,
                figure=None,
                stable_id=stable_id,
                name=name,
                position=state["caption"]["idx"],
            )
        elif isinstance(parent, Figure):
            state["context"][node] = Caption(
                document=state["document"],
                table=None,
                figure=parent,
                stable_id=stable_id,
                name=name,
                position=state["caption"]["idx"],
            )
        else:
            raise NotImplementedError("Caption must be a child of Table or Figure.")
        state["caption"]["idx"] += 1

        return state
739826
def read_lines(in_file):
    """"""

    with open(in_file, 'r') as inf:
        in_contents = inf.read().split('\n')
    return in_contents
338175
def read_files(*files):
    """"""
    text = ""
    for single_file in files:
        content = read(single_file)
        text = text + content + "\n"
    return text