Guest User

Untitled

a guest
Jan 16th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. pacletKeyOrdering =
  2. {
  3. "Name", "Version", "Creator",
  4. "Description", "Root", "WolframVersion",
  5. "MathematicaVersion", "Internal", "Loading",
  6. "Qualifier", "SystemID", "BuildNumber",
  7. "Tags", "Icon", "Categories",
  8. "Authors", "Extensions"
  9. };
  10. With[{keyOrdering = pacletKeyOrdering},
  11. pacletInfoAssociation[PacletManager`Paclet[k__]] :=
  12. KeySortBy[First@FirstPosition[keyOrdering, #] &]@
  13. With[
  14. {
  15. base =
  16. KeyMap[Replace[s_Symbol :> SymbolName[s]], <|k|>]
  17. },
  18. ReplacePart[base,
  19. "Extensions" ->
  20. AssociationThread[
  21. First /@ Lookup[base, "Extensions", {}],
  22. Association@*Rest /@ Lookup[base, "Extensions", {}]
  23. ]
  24. ]
  25. ]
  26. ];
  27. If[! AssociationQ@$pacletIconCache, $pacletIconCache = <||>];
  28. pacletGetIcon[a_Association] :=
  29. Replace[
  30. FileNames[
  31. Lookup[
  32. a,
  33. "Icon",
  34. "PacletIcon.m" | "PacletIcon.png"
  35. ],
  36. a["Location"]
  37. ],
  38. {
  39. {f_, ___} :>
  40.  
  41. Lookup[$pacletIconCache, f, $pacletIconCache[f] = Import[f]],
  42. {} :>
  43.  
  44. With[{f =
  45. "https://github.com/b3m2a1/mathematica-BTools/raw/master/
  46. Resources/Icons/PacletIcon.png"
  47. },
  48. Image[
  49. Lookup[$pacletIconCache, f, $pacletIconCache[f] = Import[f]],
  50. ImageSize -> 28
  51. ]
  52. ]
  53. }
  54. ];
  55. $formatPaclets = True;
  56. Format[p_PacletManager`Paclet /;
  57. ($formatPaclets && AssociationQ@
  58. pacletInfoAssociation[p])] :=
  59.  
  60. With[{a = pacletInfoAssociation[p]},
  61. RawBoxes@
  62. BoxForm`ArrangeSummaryBox[
  63. "Paclet",
  64. p,
  65. pacletGetIcon[a],
  66. KeyValueMap[
  67. BoxForm`MakeSummaryItem[
  68. {Row[{#, ": "}], #2},
  69. StandardForm
  70. ] &,
  71. a[[{"Name", "Version"}]]
  72. ],
  73. Join[
  74. {
  75. If[KeyMemberQ[a, "Location"],
  76. BoxForm`MakeSummaryItem[
  77. {Row[{"Location", ": "}],
  78. With[{l = a["Location"]},
  79. Button[
  80. Hyperlink[l],
  81. SystemOpen[l],
  82. Appearance -> None,
  83. BaseStyle -> "Hyperlink"
  84. ]
  85. ]},
  86. StandardForm
  87. ],
  88. Nothing
  89. ]
  90. },
  91. KeyValueMap[
  92. BoxForm`MakeSummaryItem[
  93. {Row[{#, ": "}], #2},
  94. StandardForm
  95. ] &,
  96. KeyDrop[a, {"Name", "Version", "Location"}]
  97. ]
  98. ],
  99. StandardForm
  100. ]
  101. ];
  102. FormatValues[PacletManager`Paclet] =
  103. SortBy[
  104. FormatValues[PacletManager`Paclet],
  105. FreeQ[HoldPattern[$formatPaclets]]
  106. ];
  107.  
  108. PacletFind /@ {"BTools", "ChemTools"} // Flatten
  109.  
  110. PacletFind["MQTTLink"][[1]]
Add Comment
Please, Sign In to add comment