- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
#реализация 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))) )
#реализация 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)
выдавил из себя 2 куска) вот теперь думаю как реализовать нормально)