code: def detect_scheme(filename):
      
  
      logger = logging.getLogger(__name__)
      logger.info('Detecting partitioning scheme')
  
      with open(filename, 'rb') as f:
          # Look for MBR signature first
          f.seek(mbr.MBR_SIG_OFFSET)
          data = f.read(mbr.MBR_SIG_SIZE)
          signature = struct.unpack("<H", data)[0]
  
          if signature != mbr.MBR_SIGNATURE:
              # Something else
              logger.debug('Unknown partitioning scheme')
              return PartitionScheme.SCHEME_UNKNOWN
          else:
              # Could be MBR or GPT, look for GPT header
              f.seek(gpt.GPT_HEADER_OFFSET)
              data = f.read(gpt.GPT_SIG_SIZE)
              signature = struct.unpack("<8s", data)[0]
  
              if signature != gpt.GPT_SIGNATURE:
                  logger.debug('MBR scheme detected')
                  return PartitionScheme.SCHEME_MBR
              else:
                  logger.debug('GPT scheme detected')
                  return PartitionScheme.SCHEME_GPT
docs: Detects partitioning scheme of the source
  
      Args:
          filename (str): path to file or device for detection of \
          partitioning scheme.
  
      Returns:
          SCHEME_MBR, SCHEME_GPT or SCHEME_UNKNOWN
  
      Raises:
          IOError: The file doesn't exist or cannot be opened for reading
  
      >>> from rawdisk.scheme.common import *
      >>> scheme = detect_scheme('/dev/disk1')
      >>> if scheme == PartitionScheme.SCHEME_MBR:
      >>> <...>