code: def units_from_metadata(obj, guess=True):
      
      # try to guess from metadata
      for key in ['file_name', 'name']:
          if key not in obj.metadata:
              continue
          # get the string which might contain unit hints
          hints = obj.metadata[key].lower()
          if 'unit' in hints:
              # replace all delimiter options with white space
              for delim in '_-.':
                  hints = hints.replace(delim, ' ')
              # loop through each hint
              for hint in hints.strip().split():
                  # key word is "unit" or "units"
                  if 'unit' not in hint:
                      continue
                  # get rid of keyword and whitespace
                  hint = hint.replace(
                      'units', '').replace(
                          'unit', '').strip()
                  # if the hint is a valid unit return it
                  if hint in TO_INCH:
                      return hint
  
      if not guess:
          raise ValueError('no units and not allowed to guess')
  
      # we made it to the wild ass guess section
      # if the scale is larger than 100 mystery units
      # declare the model to be millimeters, otherwise inches
      log.warning('no units: guessing from scale')
      if float(obj.scale) > 100.0:
          return 'millimeters'
      else:
          return 'inches'
docs: Try to extract hints from metadata and if that fails
      guess based on the object scale.
  
  
      Parameters
      ------------
      obj: object
          Has attributes 'metadata' (dict) and 'scale' (float)
      guess : bool
          If metadata doesn't indicate units, guess from scale
  
      Returns
      ------------
      units: str
          A guess of what the units might be