# HG changeset patch # User Matti Hamalainen # Date 1468251370 -10800 # Node ID 1eefa9b5e945ec2a97cbc69ebcc06f01419ff837 # Parent c4b8d934d7abfe459eec6964da0af8581107d4d3 Unicodify. diff -r c4b8d934d7ab -r 1eefa9b5e945 multimerge.py --- a/multimerge.py Mon Jul 11 14:04:50 2016 +0300 +++ b/multimerge.py Mon Jul 11 18:36:10 2016 +0300 @@ -82,19 +82,19 @@ try: store = oauth2client.file.Storage(mcfg.credential_file) except Exception as e: - gcm_fatal("Failed to read credential file:\n{0}\n\nERROR: {1}\n".format(mcfg.credential_file, str(e))) + gcm_fatal(u"Failed to read credential file:\n{0}\n\nERROR: {1}\n".format(mcfg.credential_file, str(e))) credentials = store.get() if not credentials or credentials.invalid: try: flow = client.flow_from_clientsecrets(mcfg.secret_file, mcfg.scope) except Exception as e: - gcm_fatal("Failed to fetch client secret:\n{0}\n\nERROR: {1}\n".format(mcfg.secret_file, str(e))) + gcm_fatal(u"Failed to fetch client secret:\n{0}\n\nERROR: {1}\n".format(mcfg.secret_file, str(e))) flow.user_agent = mcfg.app_name credentials = tools.run_flow(flow, store, mcfg) if not credentials or credentials.invalid: - gcm_fatal("Failed to authenticate / invalid credentials.") + gcm_fatal(u"Failed to authenticate / invalid credentials.") return credentials @@ -148,13 +148,13 @@ self.g = int(src[3:5], 16) self.b = int(src[6:7], 16) else: - gcm_fatal("Expected hex-triplet string for GCMColor() initializer: {0}".format(src)) + gcm_fatal(u"Expected hex-triplet string for GCMColor() initializer: {0}".format(src)) elif isinstance(src, GCMColor): self.r = src.r self.g = src.g self.b = src.b else: - gcm_fatal("Invalid initializer for GCMColor() object.") + gcm_fatal(u"Invalid initializer for GCMColor() object.") def delta(self, other): ctmp = GCMColor() @@ -203,12 +203,12 @@ if name in self.m_data: return self.m_data[name] else: - gcm_fatal("GCMSettings.__getattr__(): No such attribute '"+ name +"'.") + gcm_fatal(u"GCMSettings.__getattr__(): No such attribute '"+ name +"'.") def mvalidate(self, name, value): if name in self.m_validate and self.m_validate[name]: if not self.m_validate[name](value): - gcm_fatal("GCMSettings.mvalidate(): Invalid value for attribute '{0}': {1}".format(name, value)) + gcm_fatal(u"GCMSettings.mvalidate(): Invalid value for attribute '{0}': {1}".format(name, value)) def mtranslate(self, name, value): if name in self.m_translate and self.m_translate[name]: @@ -277,7 +277,7 @@ def is_bool(self, mvalue): mval = self.trans_bool(mvalue) if not isinstance(mval, bool): - gcm_fatal("GCMSettings.is_bool(): Invalid boolean value '{0}', should be true|false|1|0|on|off|yes|no.".format(mvalue)) + gcm_fatal(u"GCMSettings.is_bool(): Invalid boolean value '{0}', should be true|false|1|0|on|off|yes|no.".format(mvalue)) else: return True @@ -286,9 +286,9 @@ if self.is_str(mvalue): mvalue = re.split("\s*,\s*", mvalue, flags=re.IGNORECASE) if not isinstance(mvalue, list): - gcm_fatal("GCMSettings.trans_list(): Could not parse list '{0}'.".format(mvalue)) + gcm_fatal(u"GCMSettings.trans_list(): Could not parse list '{0}'.".format(mvalue)) elif not isinstance(mvalue, list): - gcm_fatal("GCMSettings.trans_list(): Invalid value '{0}'.".format(mvalue)) + gcm_fatal(u"GCMSettings.trans_list(): Invalid value '{0}'.".format(mvalue)) return mvalue def is_list(self, mvalue): @@ -311,7 +311,7 @@ if mvalue != None: for email in mvalue: if not self.is_email(email): - gcm_fatal("Invalid e-mail address '{0}' in list {1}.".format(email, ", ".join(mvalue))) + gcm_fatal(u"Invalid e-mail address '{0}' in list {1}.".format(email, ", ".join(mvalue))) return True @@ -360,12 +360,12 @@ cfgparser = ConfigParser.RawConfigParser() cfgparser.readfp(codecs.open(sys.argv[1], "r", "UTF-8")) except Exception as e: - gcm_fatal("Failed to read configuration file '{0}': {1}".format(sys.argv[1], str(e))) + gcm_fatal(u"Failed to read configuration file '{0}': {1}".format(sys.argv[1], str(e))) # Check that the required section exists section = "gcm" if not cfgparser.has_section(section): - gcm_fatal("Invalid configuration, missing '{0}' section.".format(section)) + gcm_fatal(u"Invalid configuration, missing '{0}' section.".format(section)) # Debug setting is a special case, we need to get it # set before everything else, so do it here .. @@ -379,27 +379,27 @@ ## Validate settings if cfg.email: if cfg.email_subject == None or len(cfg.email_subject) == 0: - gcm_fatal("E-mail enabled but email_subject not set.") + gcm_fatal(u"E-mail enabled but email_subject not set.") elif cfg.email_sender == None: - gcm_fatal("E-mail enabled but email_sender not set.") + gcm_fatal(u"E-mail enabled but email_sender not set.") elif cfg.email_to == None: - gcm_fatal("E-mail enabled but email_to not set.") + gcm_fatal(u"E-mail enabled but email_to not set.") else: cfg.mset("email_ok", True) if len(cfg.source_regmap) != cfg.source_regmap_len: - gcm_fatal("Setting source_regmap list must be {0} items.".format(cfg.source_regmap_len)) + gcm_fatal(u"Setting source_regmap list must be {0} items.".format(cfg.source_regmap_len)) else: # Force to integers try: cfg.source_regmap = map(lambda x: int(x), cfg.source_regmap) except Exception as e: - gcm_fatal("Invalid source_regmap: {0}".format(str(e))) + gcm_fatal(u"Invalid source_regmap: {0}".format(str(e))) if not cfg.dest_name and not cfg.dest_id: - gcm_fatal("Target calendar ID or name required, but not set.") + gcm_fatal(u"Target calendar ID or name required, but not set.") if cfg.dest_name: @@ -430,7 +430,7 @@ break if len(calendars) == 0: - gcm_fatal("No calendars found?") + gcm_fatal(u"No calendars found?") gcm_debug(u"{0} calendars total found.".format(len(calendars))) @@ -470,7 +470,7 @@ try: colors = service.colors().get().execute() except Exception as e: - gcm_fatal("Failed to fetch calendar color settings:\n\n{0}".format(str(e))) + gcm_fatal(u"Failed to fetch calendar color settings:\n\n{0}".format(str(e))) ## Now, we fetch and collect events @@ -488,12 +488,12 @@ c_found = None if "colorId" in calendar and calendar["colorId"] in colors["calendar"]: - gcm_debug("Calendar color: {0}".format(colors["calendar"][calendar["colorId"]])) + gcm_debug(u"Calendar color: {0}".format(colors["calendar"][calendar["colorId"]])) c_found = gcm_find_nearest_color(colors["event"], colors["calendar"][calendar["colorId"]], 100) if c_found: - gcm_debug("Found nearest event color ID: {0}, {1}".format(c_found, colors["event"][c_found])) + gcm_debug(u"Found nearest event color ID: {0}, {1}".format(c_found, colors["event"][c_found])) else: - gcm_debug("No matching event color found!") + gcm_debug(u"No matching event color found!") # Add events, if any, to main list events = gcm_generate_ids(result.get("items", []), calendar["id"], "___") @@ -539,7 +539,7 @@ event["iCalUID"] = event["gcm_id"] new_event = service.events().update(calendarId=cfg.dest_id, eventId=d_event["id"], body=event).execute() except Exception as e: - gcm_fatal("Failed to update event {0}:\n\n{1}\n\nERROR: {2}\n".format(event["gcm_id"], event, str(e))) + gcm_fatal(u"Failed to update event {0}:\n\n{1}\n\nERROR: {2}\n".format(event["gcm_id"], event, str(e))) else: gcm_debug(u"No need to update event {0} : {1}.".format(event["id"], event["gcm_id"])) else: @@ -550,7 +550,7 @@ try: new_event = service.events().insert(calendarId=cfg.dest_id, body=event).execute() except Exception as e: - gcm_fatal("Failed to insert new event:\n\n{0}\n\nERROR: {1}\n".format(event, str(e))) + gcm_fatal(u"Failed to insert new event:\n\n{0}\n\nERROR: {1}\n".format(event, str(e))) ## Remove "stale" events @@ -562,7 +562,7 @@ try: service.events().delete(calendarId=cfg.dest_id, eventId=event["id"]).execute() except Exception as e: - gcm_fatal("Failed to delete stale event:\n{0}\n\nERROR: {1}\n".format(event, str(e))) + gcm_fatal(u"Failed to delete stale event:\n{0}\n\nERROR: {1}\n".format(event, str(e))) gcm_debug(u"Finished.")