def export(gpio_pin, unexport_on_exit=False):
  """ Reserves a pin for userspace use with sysfs /sys/class/gpio interface. 
      If unexport_on_exit=True unexport(gpio_pin) will be called automatically
      when the program exits. Returns True if pin was exported, False if it was 
      already under userspace control. """
  if ("USR" in gpio_pin):
    # The user LEDs are already under userspace control
    return True
  gpio_num = GPIO[gpio_pin]['gpio_num']
  gpio_file = '%s/gpio%i' % (GPIO_FILE_BASE, gpio_num)
  if (os.path.exists(gpio_file)): 
    # Pin already under userspace control
    return True
  with open(EXPORT_FILE, 'wb') as f:
    f.write(str(gpio_num))
  if unexport_on_exit: 
    addToCleanup(lambda: unexport(gpio_pin))
  return True
dataset/ETHPy150Open graycatlabs/PyBBIO/bbio/platform/beaglebone/pinmux.py/export/original