]> Frank Brehm's Git Trees - pixelpark/ldap-migration.git/commitdiff
Tagging migrated entries
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 26 Nov 2020 16:48:29 +0000 (17:48 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 26 Nov 2020 16:48:29 +0000 (17:48 +0100)
lib/ldap_migration/__init__.py

index ae857758aa652db4cae3b3e7beaa454a347269ca..ac86515ba8110bd30adb0f3ef2d1812728b575c9 100644 (file)
@@ -45,7 +45,7 @@ from .config import LDAPMigrationConfiguration
 from .idict import CaseInsensitiveDict
 from .istringset import CaseInsensitiveStringSet
 
-__version__ = '0.7.1'
+__version__ = '0.7.2'
 
 LOG = logging.getLogger(__name__)
 CFG_BASENAME = 'ldap-migration.ini'
@@ -1183,6 +1183,7 @@ class LDAPMigrationApplication(BaseApplication):
 
         if rev_dn in self.migrated_entries:
             LOG.debug("Entry {!r} is already migrated.".format(tgt_dn))
+            self.write_result_file(fh, tgt_dn, '-')
             return False
 
         src_entry = self.get_source_item(src_dn, tgt_dn, with_acl=with_acl)
@@ -1214,11 +1215,10 @@ class LDAPMigrationApplication(BaseApplication):
                             ch=pp(changes))
                         raise WriteLDAPItemError(msg)
                 self.migrated_entries[rev_dn] = tgt_dn
-                ts = datetime.datetime.now(self.tz).isoformat(' ', timespec='seconds')
-                line = "{dn}: {ts}".format(dn=tgt_dn, ts=ts)
-                print(line, file=fh, flush=True)
+                self.write_result_file(fh, tgt_dn, '+')
                 return True
             else:
+                self.write_result_file(fh, tgt_dn, ' ')
                 return False
 
         (tgt_obj_classes, tgt_entry) = self.generate_target_entry(src_entry, src_dn, tgt_dn)
@@ -1250,10 +1250,15 @@ class LDAPMigrationApplication(BaseApplication):
                 raise WriteLDAPItemError(msg)
 
         self.migrated_entries[rev_dn] = tgt_dn
+        self.write_result_file(fh, tgt_dn, '*')
+        return True
+
+    # -------------------------------------------------------------------------
+    def write_result_file(self, fh, dn, tag=' '):
+
         ts = datetime.datetime.now(self.tz).isoformat(' ', timespec='seconds')
-        line = "{dn}: {ts}".format(dn=tgt_dn, ts=ts)
+        line = "{tag}{dn}: {ts}".format(tag=tag, dn=dn, ts=ts)
         print(line, file=fh, flush=True)
-        return True
 
     # -------------------------------------------------------------------------
     def compare_values(self, first, second):