How to use the gitdb.util.file_contents_ro_filepath function in gitdb

To help you get started, we’ve selected a few gitdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gitpython-developers / gitdb / gitdb / db / loose.py View on Github external
def _map_loose_object(self, sha):
        """
        :return: memory map of that file to allow random read access
        :raise BadObject: if object could not be located"""
        db_path = self.db_path(self.object_path(bin_to_hex(sha)))
        try:
            return file_contents_ro_filepath(db_path, flags=self._fd_open_flags)
        except OSError as e:
            if e.errno != ENOENT:
                # try again without noatime
                try:
                    return file_contents_ro_filepath(db_path)
                except OSError as new_e:
                    raise BadObject(sha) from new_e
                # didn't work because of our flag, don't try it again
                self._fd_open_flags = 0
            else:
                raise BadObject(sha) from e
            # END handle error
github gitpython-developers / GitPython / git / refs / log.py View on Github external
def _read_from_file(self):
        try:
            fmap = file_contents_ro_filepath(self._path, stream=True, allow_mmap=True)
        except OSError:
            # it is possible and allowed that the file doesn't exist !
            return
        # END handle invalid log

        try:
            self._deserialize(fmap)
        finally:
            fmap.close()
        # END handle closing of handle
github gitpython-developers / gitdb / gitdb / db / loose.py View on Github external
def _map_loose_object(self, sha):
        """
        :return: memory map of that file to allow random read access
        :raise BadObject: if object could not be located"""
        db_path = self.db_path(self.object_path(bin_to_hex(sha)))
        try:
            return file_contents_ro_filepath(db_path, flags=self._fd_open_flags)
        except OSError as e:
            if e.errno != ENOENT:
                # try again without noatime
                try:
                    return file_contents_ro_filepath(db_path)
                except OSError as new_e:
                    raise BadObject(sha) from new_e
                # didn't work because of our flag, don't try it again
                self._fd_open_flags = 0
            else:
                raise BadObject(sha) from e
            # END handle error
github gitpython-developers / gitdb / gitdb / ref / log.py View on Github external
def _read_from_file(self):
		fmap = file_contents_ro_filepath(self._path, stream=False, allow_mmap=True)
		try:
			self._deserialize(fmap)
		finally:
			fmap.close()
		#END handle closing of handle
github gitpython-developers / gitdb / gitdb / ref / log.py View on Github external
def iter_entries(cls, stream):
		"""
		:return: Iterator yielding RefLogEntry instances, one for each line read 
			sfrom the given stream.
		:param stream: file-like object containing the revlog in its native format
			or basestring instance pointing to a file to read"""
		new_entry = RefLogEntry.from_line
		if isinstance(stream, basestring):
			stream = file_contents_ro_filepath(stream)
		#END handle stream type
		while True:
			line = stream.readline()
			if not line:
				return
			yield new_entry(line.strip())
		#END endless loop
github gitpython-developers / GitPython / git / refs / log.py View on Github external
    @classmethod
    def iter_entries(cls, stream):
        """
        :return: Iterator yielding RefLogEntry instances, one for each line read
            sfrom the given stream.
        :param stream: file-like object containing the revlog in its native format
            or basestring instance pointing to a file to read"""
        new_entry = RefLogEntry.from_line
        if isinstance(stream, basestring):
            stream = file_contents_ro_filepath(stream)
        # END handle stream type
        while True:
            line = stream.readline()
            if not line:
                return
            yield new_entry(line.strip())
        # END endless loop