comparison multimerge.py @ 124:977ecff4bd7d

Use list comprehensions instead of map().
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 07 Nov 2016 09:10:29 +0200
parents 4500fbf91294
children 76e49e34b40a bb8b455218ec
comparison
equal deleted inserted replaced
123:612cfa40d5eb 124:977ecff4bd7d
484 if len(cfg.src_regmap) != cfg.src_regmap_len: 484 if len(cfg.src_regmap) != cfg.src_regmap_len:
485 gcm_fatal(u"Setting src_regmap list must be {0} items.".format(cfg.src_regmap_len)) 485 gcm_fatal(u"Setting src_regmap list must be {0} items.".format(cfg.src_regmap_len))
486 else: 486 else:
487 # Force to integers 487 # Force to integers
488 try: 488 try:
489 cfg.src_regmap = map(lambda x: int(x), cfg.src_regmap) 489 cfg.src_regmap = [int(x) for x in cfg.src_regmap]
490 except Exception as e: 490 except Exception as e:
491 gcm_fatal(u"Invalid src_regmap: {0}".format(str(e))) 491 gcm_fatal(u"Invalid src_regmap: {0}".format(str(e)))
492 492
493 493
494 if not cfg.dst_regex and not cfg.dst_id: 494 if not cfg.dst_regex and not cfg.dst_id:
607 gcm_debug(3, u"Found {0} event(s).".format(len(dst_events))) 607 gcm_debug(3, u"Found {0} event(s).".format(len(dst_events)))
608 608
609 609
610 ## Start populating/updating events .. 610 ## Start populating/updating events ..
611 gcm_debug(3, u"Re-merging events to target calendar ..") 611 gcm_debug(3, u"Re-merging events to target calendar ..")
612 dst_ids = frozenset(map(lambda x: x["gcm_id"], dst_events)) 612 dst_ids = frozenset([x["gcm_id"] for x in dst_events])
613 src_ids = frozenset(map(lambda x: x["gcm_id"], src_events)) 613 src_ids = frozenset([x["gcm_id"] for x in src_events])
614 614
615 evn_new = evn_updated = evn_unchanged = 0 615 evn_new = evn_updated = evn_unchanged = 0
616 616
617 for event in src_events: 617 for event in src_events:
618 # Does the event exist already in the target? 618 # Does the event exist already in the target?