<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_file(filename, mime=False):
 """ Opens file, attempts to identify content based off magic number and will return the file extension. If mime is True it will return the mime type instead. :param filename: path to file :param mime: Return mime, not extension :return: guessed extension or mime """


    head, foot = _file_details(filename)
    return _magic(head, foot, mime, ext_from_filename(filename))