Read ``file`` into ``bytes``.
	
	:arg file type: path-like or file-like
	:rtype: bytes
515494
def read_file(file):
	
	if hasattr(file, "read"):
		return file.read()
	if hasattr(file, "read_bytes"):
		return file.read_bytes()
	with open(file, "rb") as f:
		return f.read()
365305
def read_file(self):
        
        file_obj = open(self.file, 'r')
        content = file_obj.read()
        file_obj.close()
        if content:
            content = json.loads(content)
            return content
        else:
            return {}
594058
def get_filelikeobject(filename: str = None,
                       blob: bytes = None) -> BinaryIO:
    
    if not filename and not blob:
        raise ValueError("no filename and no blob")
    if filename and blob:
        raise ValueError("specify either filename or blob")
    if filename:
        return open(filename, 'rb')
    else:
        return io.BytesIO(blob)
501661
def _read_file(self, file):  # type: (str) -> Optional[str]
        
        if not self.setup_file_name:
            return None
        source = None
        if os.path.isfile(file):
            with self.file_opener.open_this(file, "r") as setup_py:
                source = setup_py.read()
        return source
164665
def insert_file(self, file):
        

        if type(file) is bytes:
            file = open(file, 'r')

        self.insert_string(file.read())
1124466
def readfile(filename, binary=False):
    

    if not os.path.isfile(filename):
        return None

    try:
        flags = 'r' if not binary else 'rb'
        with open(filename, flags) as _file:
            return _file.read()

    except (OSError, IOError):
        return None
480187
def read_file(self, path):
        

        self.assert_valid_path(path)

        with open(path, 'rb') as file:
            contents = file.read().decode('UTF-8')

        return contents
257951
def read_bytes(fd, byte_order, dtype, count):
    """"""
    return numpy.fromfile(fd, byte_order+dtype[-1], count).tostring()
1293886
def decode_from_file(path: str) -> Iterable:
    """"""
    with open(path, 'rb') as f:
        b = f.read()
    return decode(b)
475098
def read_file(filename, binary_mode=False):
  
  mode = 'rb' if binary_mode else 'r'
  with open(filename, mode) as f:
    return f.read()
1119335
def read_file(file_path_name):
    
    with io.open(os.path.join(os.path.dirname(__file__), file_path_name), mode='rt', encoding='utf-8') as fd:
        return fd.read()
759445
def ReadFile(self, definitions_registry, path):
    
    with open(path, 'r') as file_object:
      self.ReadFileObject(definitions_registry, file_object)
844576
def read_file(path):
    
    with open(must_exist(path)) as infile:
        r = infile.read()
    return r
526045
def parse_file(self, f):
        

        if type(f) is str:
            self.f = open(f, 'rb')
        else:
            self.f = f
        self._parse_header(self.f.read(64))
1008804
def __read(usr_path, file_type):
    
    # is there a file path specified ?
    if usr_path:
        # Is this a URL? Download the file and return the local path
        is_url = re.match(re_url, usr_path)
        if is_url:
            # The usr_path will now be a local path to a single file. It will trigger the "elif" statement below
            usr_path = download_from_url(usr_path, get_download_path())

        # Directory path
        if os.path.isdir(usr_path):
            __read_directory(usr_path, file_type)
        # File path
        elif os.path.isfile(usr_path):
            __read_file(usr_path, file_type)
        # Invalid path given
        else:
            print("Error: Path given is invalid")

    # no path specified. ask if they want to load dir or file
    else:
        choice = ""
        count = 3
        while not choice:
            try:
                print("Choose a read option:\n1. One file\n2. Multi-file select\n3. Directory")
                choice = input("Option: ")
                print("\n")
                # now use the given file type and prompt answer to call _read_file or _read_dir
                if choice in ["1", "2", "3"]:
                    # open directory picker
                    if choice == "3":
                        __read_directory(usr_path, file_type)
                    else:
                        # open a file picker
                        __read_file(usr_path, file_type)
                    break
                else:
                    count -= 1
                if count == 0:
                    print("Error: Too many failed attempts")
                    break
            except Exception as e:
                print("Error: Invalid input: {}".format(e))
    return
263486
def get_file_contents(path, binary=False):
    
    # if this isn't a text file, we should raise an IOError
    f = open(path, 'r')
    file_contents = f.read()
    f.close()
    if not binary and file_contents.find('\000') >= 0:
        raise IOError('Expected text file, got binary file')
    return file_contents
215593
def read_file(*path):
    
    with open(os.path.join(*path)) as f:
        return f.read().strip()