github.com/artpar/rclone@v1.67.3/bin/test_metadata_mapper.py (about)

     1  #!/usr/bin/env python3
     2  """
     3  A demo metadata mapper
     4  """
     5  
     6  import sys
     7  import json
     8  
     9  def main():
    10      i = json.load(sys.stdin)
    11      # Add tag to description
    12      metadata = i["Metadata"]
    13      if "description" in metadata:
    14          metadata["description"] += " [migrated from domain1]"
    15      else:
    16          metadata["description"] = "[migrated from domain1]"
    17      # Modify owner
    18      if "owner" in metadata:
    19          metadata["owner"] = metadata["owner"].replace("domain1.com", "domain2.com")
    20      o = { "Metadata": metadata }
    21      json.dump(o, sys.stdout, indent="\t")
    22  
    23  if __name__ == "__main__":
    24      main()