def package_id_or_name_exists(package_id_or_name, context):
 model = context['model']
 session = context['session']
 result = session.query(model.Package).get(package_id_or_name)
 if result:
  return package_id_or_name
 result = session.query(model.Package).filter_by(name=package_id_or_name).first()
 if (not result):
  raise Invalid(('%s: %s' % (_('Not found'), _('Dataset'))))
 return package_id_or_name

def package_id_or_name_exists ( package_id_or_name , context ) : model = context [ 'model' ] session = context [ 'session' ] result = session . query ( model . Package ) . get ( package_id_or_name ) if result : return package_id_or_name result = session . query ( model . Package ) . filter_by ( name = package_id_or_name ) . first ( ) if ( not result ) : raise Invalid ( ( '%s: %s' % ( _ ( 'Not found' ) , _ ( 'Dataset' ) ) ) ) return package_id_or_name
return the given package_id_or_name if such a package exists .