python - aws s3 boto retrieve objects by date -


the format stored them in was:

website/website/objecthash/xcord/ycord/likelyhood/year/month/datenumber/hour/minutes

right have bucket want pull them out of.

say want recent 10 stored objects. efficient way this?

i have bucket, do it?

my solution todays i'm not sure logic recent:

def getkeys():     b = bucket.list()     thekeys=[]     key in b:         thekeys.append(key)     return thekeys  def getdecompiledtoday():     time = datetime.datetime.now()         year =time.strftime("%y")     month = time.strftime("%m")     day = time.strftime("%d")     keys = getkeys()     objects = []     k in keys:         splitk= k.split("/")         if splitk[6]==year , splitk[7]==month , splitk[8]==day:             objets.append(bucket.get_key(k))     return 

the solution came with.

def getpastamountdecompiledfromfile(number):     if bucketkeys.__len__() > 0:         found=[]         latest=bucketkeys[0]         while found.__len__() < number:             laterfound = false             k in bucketkeys:                 if latest in found:                     latest=k                 current = k.split("/")                 best = k.split("/")                 if k not in found , latest != k:                     if int(current[6]) > int(best[6]):                         laterfound=true                     if int(current[6]) == int(best[6]) , int(current[7]) > int(best[7]):                         laterfound=true                     if int(current[6]) == int(best[6]) , int(current[7]) == int(best[7]) , int(current[8]) > int(best[8]):                         laterfound=true                     if int(current[6]) == int(best[6]) , int(current[7]) == int(best[7]) , int(current[8]) == int(best[8]) , int(current[9]) > int(best[9]):                         laterfound=true                     if laterfound:                         latest = k             if laterfound:                 found.append(latest)         return getkeyfromkeynames(found)     else:         getkeysinfile()         getpastamountdecompiledfromfile(number)     return 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -