SHARE
TWEET

Untitled

a guest Sep 12th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  with open(filepath, "w") as fh:
  2.         fw = fh.write
  3.         fw("keyconfig_data = \\\n[")
  4.  
  5.         for km, _kc_x in export_keymaps:
  6.             km = km.active()
  7.             fw("(")
  8.             fw(f"\"{km.name:s}\",\n")
  9.             fw(f"{indent(2)}" "{")
  10.             fw(f"\"space_type\": '{km.space_type:s}'")
  11.             fw(f", \"region_type\": '{km.region_type:s}'")
  12.             # We can detect from the kind of items.
  13.             if km.is_modal:
  14.                 fw(", \"modal\": True")
  15.             fw("},\n")
  16.             fw(f"{indent(2)}" "{")
  17.             is_modal = km.is_modal
  18.             fw(f"\"items\":\n")
  19.             fw(f"{indent(3)}[")
  20.             for kmi in km.keymap_items:
  21.                 if is_modal:
  22.                     kmi_id = kmi.propvalue
  23.                 else:
  24.                     kmi_id = kmi.idname
  25.                 fw(f"(")
  26.                 kmi_args = kmi_args_as_data(kmi)
  27.                 kmi_data = _kmi_attrs_or_none(4, kmi)
  28.                 fw(f"\"{kmi_id:s}\"")
  29.                 if kmi_data is None:
  30.                     fw(f", ")
  31.                 else:
  32.                     fw(",\n" f"{indent(5)}")
  33.  
  34.                 fw(kmi_args)
  35.                 if kmi_data is None:
  36.                     fw(", None),\n")
  37.                 else:
  38.                     fw(",\n")
  39.                     fw(f"{indent(5)}" "{")
  40.                     fw(kmi_data)
  41.                     fw(f"{indent(6)}")
  42.                     fw("},\n" f"{indent(5)}")
  43.                     fw("),\n")
  44.                 fw(f"{indent(4)}")
  45.             fw("],\n" f"{indent(3)}")
  46.             fw("},\n" f"{indent(2)}")
  47.             fw("),\n" f"{indent(1)}")
  48.  
  49.         fw("]\n")
  50.         fw("\n\n")
  51.         fw("if __name__ == \"__main__\":\n")
  52.         fw("    import os\n")
  53.         fw("    from bl_keymap_utils.io import keyconfig_import_from_data\n")
  54.         fw("    keyconfig_import_from_data(os.path.splitext(os.path.basename(__file__))[0], keyconfig_data)\n")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top