Mistři v programování na #hovnokod

Python #389

#version 1
servrun = lambda method, list: list and method(list)
servrun( self.server.mkdir, (map(lambda item: item[1], filter(lambda item: item[0] == storagesyncer.ACTION_DIR_CREATED, changes))) )
servrun( self.server.deldir, (map(lambda item: item[1], filter(lambda item: item[0] == storagesyncer.ACTION_DIR_DELETED, changes))) )
servrun( self.server.upload, 
             (map(lambda item: [item[1], self.abs(item[1])], 
                      filter(lambda item: item[0] == storagesyncer.ACTION_FILE_CREATED or item[0] == storagesyncer.ACTION_UPDATED, 
                             changes))) )


#version 2
mkdirs = [path for (action, path) in changes if action == storagesyncer.ACTION_DIR_CREATED]
if mkdirs:
   self.server.mkdir(mkdirs)

deldirs = [path for (action, path) in changes if action == storagesyncer.ACTION_DIR_DELETED]
if deldirs:
    self.server.deldir(deldirs)

uploads = [[path, self.abs(path)] for (action, path) in changes 
                           if action == (storagesyncer.ACTION_FILE_CREATED or action == storagesyncer.ACTION_UPDATED)
                           and os.path.isfile(self.abs(path))]
if uploads:
   self.server.upload(uploads)

HovnoKod,