<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __user_location(__pkg: str, type_) -> str: """Utility function to look up XDG basedir locations Args: __pkg: Package name __type: Location type """

    if ALLOW_DARWIN and sys.platform == 'darwin':
        user_dir = '~/Library/{}'.format(__LOCATIONS[type_][0])
    else:
        user_dir = getenv('XDG_{}_HOME'.format(type_.upper()),
                           path.sep.join([getenv('HOME', ''),
                                          __LOCATIONS[type_][1]]))
    return path.expanduser(path.sep.join([user_dir, __pkg]))