def manage_entries(options, selection, approved):
 approved_text = (u'approved' if approved else u'pending')
 with Session() as session:
  if (selection == u'all'):
   entries = list_pending_entries(session=session, approved=(not approved))
  else:
   try:
    entry = get_entry_by_id(session, selection)
    if (entry.approved is approved):
     console((colorize(u'red', u'ERROR: ') + (u'Entry with ID %s is already %s' % (entry.id, approved_text))))
     sys.exit(1)
   except NoResultFound:
    console((u'Pending entry with ID %s does not exist' % selection))
    sys.exit(1)
   else:
    entries = [entry]
  if (not entries):
   console((u'All entries are already %s' % approved_text))
   return
  for entry in entries:
   if (entry.approved is not approved):
    console((u'Setting pending entry with ID %s status to %s' % (entry.id, approved_text)))
    entry.approved = approved

def manage_entries ( options , selection , approved ) : approved_text = ( u'approved' if approved else u'pending' ) with Session ( ) as session : if ( selection == u'all' ) : entries = list_pending_entries ( session = session , approved = ( not approved ) ) else : try : entry = get_entry_by_id ( session , selection ) if ( entry . approved is approved ) : console ( ( colorize ( u'red' , u'ERROR: ' ) + ( u'Entry with ID %s is already %s' % ( entry . id , approved_text ) ) ) ) sys . exit ( 1 ) except NoResultFound : console ( ( u'Pending entry with ID %s does not exist' % selection ) ) sys . exit ( 1 ) else : entries = [ entry ] if ( not entries ) : console ( ( u'All entries are already %s' % approved_text ) ) return for entry in entries : if ( entry . approved is not approved ) : console ( ( u'Setting pending entry with ID %s status to %s' % ( entry . id , approved_text ) ) ) entry . approved = approved
manage pending entries .