Show
Ignore:
Timestamp:
04/16/07 18:52:23 (17 years ago)
Author:
jerome
Message:

Added --orderby command line switch to dumpykota.
Doesn't work yet with the LDAP backend, since sorting will have
to be done by PyKota's code instead of relying on the database
backend itself to do the dirty work.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/dumper.py

    r3142 r3165  
    8080            raise PyKotaCommandLineError, _("Invalid modifier [%s] for --data command line option, see help.") % datatype 
    8181                     
     82        orderby = options["orderby"]              
     83        if orderby : 
     84            fields = [f.strip() for f in orderby.split(",")] 
     85            orderby = [] 
     86            for field in fields : 
     87                if field.isalpha() \ 
     88                   or ((field[0] in ("+", "-")) and field[1:].isalpha()) : 
     89                    orderby.append(field) 
     90                else :     
     91                    self.printInfo("Skipping invalid ordering statement '%(field)s'" % locals(), "error")  
     92        else : 
     93            orderby = [] 
     94             
    8295        extractonly = {} 
    8396        if datatype == "all" :             
     
    147160            retcode = self.dumpXml(allentries, neededdatatypes) 
    148161        else :     
    149             entries = getattr(self.storage, "extract%s" % datatype.title())(extractonly) 
     162            entries = getattr(self.storage, "extract%s" % datatype.title())(extractonly, orderby) 
    150163            if entries : 
    151164                nbentries = len(entries)