code: def _get_package(auth, owner, package_name):
      
      package = (
          Package.query
          .filter_by(owner=owner, name=package_name)
          .join(Package.access)
          .filter(_access_filter(auth))
          .one_or_none()
      )
      if package is None:
          raise PackageNotFoundException(owner, package_name, auth.is_logged_in)
      return package
docs: Helper for looking up a package and checking permissions.
      Only useful for *_list functions; all others should use more efficient queries.