packages feed

ipython-kernel 0.9.0.2 → 0.9.1.0

raw patch · 6 files changed

+83/−37 lines, 6 filesdep +cryptonitedep +memorydep −SHA

Dependencies added: cryptonite, memory

Dependencies removed: SHA

Files

ipython-kernel.cabal view
@@ -1,5 +1,5 @@ name:                ipython-kernel-version:             0.9.0.2+version:             0.9.1.0 synopsis:            A library for creating kernels for IPython frontends  description:         ipython-kernel is a library for communicating with frontends for the interactive IPython framework. It is used extensively in IHaskell, the interactive Haskell environment.@@ -39,43 +39,46 @@                        bytestring      ,                        cereal          ,                        containers      ,+                       cryptonite      ,                        directory       ,                        temporary       ,                        filepath        ,                        process         ,+                       memory          ,                        mtl             ,                        text            ,                        transformers    ,                        unordered-containers,                        uuid            ,-                       zeromq4-haskell ,-                       SHA+                       zeromq4-haskell  -- Example program executable simple-calc-example-  hs-source-dirs: examples-  main-is:        Calc.hs-  build-depends:  ipython-kernel,-                  base           ,-                  filepath       ,-                  mtl            ,-                  parsec         ,-                  text           ,-                  transformers+  hs-source-dirs:   examples+  main-is:          Calc.hs+  default-language: Haskell2010+  build-depends:    ipython-kernel ,+                    base           ,+                    filepath       ,+                    mtl            ,+                    parsec         ,+                    text           ,+                    transformers    if !flag(examples)     buildable: False  executable fun-calc-example-  hs-source-dirs: examples-  main-is:        Simple.hs-  build-depends:  ipython-kernel,-                  base           ,-                  filepath       ,-                  mtl            ,-                  parsec         ,-                  text           ,-                  transformers+  hs-source-dirs:   examples+  main-is:          Simple.hs+  default-language: Haskell2010+  build-depends:    ipython-kernel ,+                    base           ,+                    filepath       ,+                    mtl            ,+                    parsec         ,+                    text           ,+                    transformers    if !flag(examples)     buildable: False
src/IHaskell/IPython/EasyKernel.hs view
@@ -56,7 +56,7 @@          {           -- | Info on the language of the kernel.          kernelLanguageInfo :: LanguageInfo-         -- | Write all the files into the kernel directory, including `kernel.js`, `logo-64x64.png`, and any+         -- | Write all the files into the kernel directory, including `kernel.js`, `logo-64x64.svg`, and any          -- other required files. The directory to write to will be passed to this function, and the return          -- value should be the kernelspec to be written to `kernel.json`.          , writeKernelspec :: FilePath -> IO KernelSpec@@ -163,7 +163,12 @@         -> Message         -> MessageHeader         -> m Message-replyTo config _ _ KernelInfoRequest{} replyHeader =+replyTo config _ interface KernelInfoRequest{} replyHeader = do+  let send = writeChan (iopubChannel interface)++  idleHeader <- dupHeader replyHeader StatusMessage+  liftIO . send $ PublishStatus idleHeader Idle+   return     KernelInfoReply       { header = replyHeader@@ -172,6 +177,7 @@       , implementationVersion = kernelImplVersion config       , banner = kernelBanner config       , protocolVersion = kernelProtocolVersion config+      , status = Ok       }  replyTo config _ _ CommInfoRequest{} replyHeader =@@ -198,12 +204,9 @@                                       sendOutput x =                                                       send $ PublishDisplayData                                                                outputHeader-                                                               (languageName $ kernelLanguageInfo-                                                                                 config)                                                                (displayOutput config x)                                   in run config code clearOutput sendOutput-  liftIO . send $ PublishDisplayData outputHeader (languageName $ kernelLanguageInfo config)-                    (displayResult config res)+  liftIO . send $ PublishDisplayData outputHeader (displayResult config res)     idleHeader <- dupHeader replyHeader StatusMessage
src/IHaskell/IPython/Message/Parser.hs view
@@ -178,8 +178,7 @@ displayDataParser = requestParser $ \obj -> do   dataDict :: Object <- obj .: "data"   let displayDatas = makeDisplayDatas dataDict-  maybeSource <- obj .:? "source"-  return $ PublishDisplayData noHeader (fromMaybe "" maybeSource) displayDatas+  return $ PublishDisplayData noHeader displayDatas  requestParser parser content =   case parseEither parser decoded of
src/IHaskell/IPython/Message/Writer.hs view
@@ -8,11 +8,14 @@  import           Data.Aeson import           Data.Aeson.Types (Pair)+import           Data.Aeson.Parser (json) import           Data.Map (Map) import           Data.Monoid (mempty) import           Data.Text (Text, pack)+import           Data.Text.Encoding (encodeUtf8) import qualified Data.Map               as Map import           IHaskell.IPython.Types+import           Data.Maybe (fromMaybe)  instance ToJSON LanguageInfo where   toJSON info = object@@ -20,6 +23,7 @@                   , "version" .= languageVersion info                   , "file_extension" .= languageFileExtension info                   , "codemirror_mode" .= languageCodeMirrorMode info+                  , "pygments_lexer" .= languagePygmentsLexer info                   ]  -- Convert message bodies into JSON.@@ -31,6 +35,7 @@       , "implementation" .= implementation rep       , "implementation_version" .= implementationVersion rep       , "language_info" .= languageInfo rep+      , "status" .= show (status rep)       ]    toJSON CommInfoReply@@ -38,7 +43,9 @@     , commInfo = commInfo     } =     object-      [ "comms" .= Map.map (\comm -> object ["target_name" .= comm]) commInfo ]+      [ "comms" .= Map.map (\comm -> object ["target_name" .= comm]) commInfo+      , "status" .= string "ok"+      ]    toJSON ExecuteRequest     { getCode = code@@ -76,9 +83,9 @@     object ["execution_state" .= executionState]   toJSON PublishStream { streamType = streamType, streamContent = content } =     object ["data" .= content, "name" .= streamType]-  toJSON PublishDisplayData { source = src, displayData = datas } =+  toJSON PublishDisplayData { displayData = datas } =     object-      ["source" .= src, "metadata" .= object [], "data" .= object (map displayDataToJson datas)]+      ["metadata" .= object [], "data" .= object (map displayDataToJson datas)]    toJSON PublishOutput { executionCount = execCount, reprText = reprText } =     object@@ -109,7 +116,9 @@       ]    toJSON ShutdownReply { restartPending = restart } =-    object ["restart" .= restart]+    object ["restart" .= restart+           , "status" .= string "ok"+           ]    toJSON ClearOutput { wait = wait } =     object ["wait" .= wait]@@ -132,7 +141,9 @@     object ["comm_id" .= commUuid req, "data" .= commData req]    toJSON req@HistoryReply{} =-    object ["history" .= map tuplify (historyReply req)]+    object ["history" .= map tuplify (historyReply req)+           , "status" .= string "ok"+           ]     where       tuplify (HistoryReplyElement sess linum res) = (sess, linum, case res of                                                                      Left inp         -> toJSON inp@@ -165,6 +176,12 @@  -- | Convert a MIME type and value into a JSON dictionary pair. displayDataToJson :: DisplayData -> (Text, Value)+displayDataToJson (DisplayData MimeJson dataStr) = +    pack (show MimeJson) .= fromMaybe (String "") (decodeStrict (encodeUtf8 dataStr) :: Maybe Value)+displayDataToJson (DisplayData MimeVegalite dataStr) = +    pack (show MimeVegalite) .= fromMaybe (String "") (decodeStrict (encodeUtf8 dataStr) :: Maybe Value)+displayDataToJson (DisplayData MimeVega dataStr) = +    pack (show MimeVega) .= fromMaybe (String "") (decodeStrict (encodeUtf8 dataStr) :: Maybe Value) displayDataToJson (DisplayData mimeType dataStr) =   pack (show mimeType) .= String dataStr 
src/IHaskell/IPython/Types.hs view
@@ -276,6 +276,7 @@          , languageVersion :: String        -- ^ GHC 7.6.3          , languageFileExtension :: String        -- ^ .hs          , languageCodeMirrorMode :: String        -- ^ 'ihaskell'. can be 'null'+         , languagePygmentsLexer :: String          }   deriving (Show, Eq) @@ -299,6 +300,7 @@                  , implementation :: String -- ^ e.g. IHaskell                  , implementationVersion :: String -- ^ The version of the implementation                  , languageInfo :: LanguageInfo+                 , status :: ExecuteReplyStatus                  }              |              -- | A request from a frontend for information about the comms.@@ -366,7 +368,6 @@              |                PublishDisplayData                  { header :: MessageHeader-                 , source :: String                      -- ^ The name of the data source.                  , displayData :: [DisplayData]          -- ^ A list of data representations.                  }              |@@ -562,11 +563,18 @@  data MimeType = PlainText               | MimeHtml+              | MimeBmp Width Height               | MimePng Width Height               | MimeJpg Width Height+              | MimeGif Width Height               | MimeSvg               | MimeLatex+              | MimeMarkdown               | MimeJavascript+              | MimeJson+              | MimeVega+              | MimeVegalite+              | MimeVdom   deriving (Eq, Typeable, Generic)  -- Extract the plain text from a list of displays.@@ -581,17 +589,31 @@ instance Show MimeType where   show PlainText = "text/plain"   show MimeHtml = "text/html"+  show (MimeBmp _ _) = "image/bmp"   show (MimePng _ _) = "image/png"   show (MimeJpg _ _) = "image/jpeg"+  show (MimeGif _ _) = "image/gif"   show MimeSvg = "image/svg+xml"   show MimeLatex = "text/latex"+  show MimeMarkdown = "text/markdown"   show MimeJavascript = "application/javascript"+  show MimeJson = "application/json"+  show MimeVega = "application/vnd.vega.v2+json"+  show MimeVegalite = "application/vnd.vegalite.v2+json"+  show MimeVdom = "application/vdom.v1+json"  instance Read MimeType where   readsPrec _ "text/plain" = [(PlainText, "")]   readsPrec _ "text/html" = [(MimeHtml, "")]+  readsPrec _ "image/bmp" = [(MimeBmp 50 50, "")]   readsPrec _ "image/png" = [(MimePng 50 50, "")]   readsPrec _ "image/jpg" = [(MimeJpg 50 50, "")]+  readsPrec _ "image/gif" = [(MimeGif 50 50, "")]   readsPrec _ "image/svg+xml" = [(MimeSvg, "")]   readsPrec _ "text/latex" = [(MimeLatex, "")]+  readsPrec _ "text/markdown" = [(MimeMarkdown, "")]   readsPrec _ "application/javascript" = [(MimeJavascript, "")]+  readsPrec _ "application/json" = [(MimeJson, "")]+  readsPrec _ "application/vnd.vega.v2+json" = [(MimeVega, "")]+  readsPrec _ "application/vnd.vegalite.v1+json" = [(MimeVegalite, "")]+  readsPrec _ "application/vdom.v1+json" = [(MimeVdom, "")]
src/IHaskell/IPython/ZeroMQ.hs view
@@ -17,12 +17,14 @@ import           Control.Concurrent import           Control.Exception import           Control.Monad+import qualified Crypto.Hash as Hash+import           Crypto.Hash.Algorithms (SHA256)+import qualified Crypto.MAC.HMAC as HMAC import           Data.Aeson import           Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as Char import qualified Data.ByteString.Lazy as LBS import           Data.Char-import           Data.Digest.Pure.SHA as SHA import           Data.Monoid ((<>)) import qualified Data.Text.Encoding as Text import           System.ZMQ4 as ZMQ4 hiding (stdin)@@ -336,7 +338,7 @@      -- Compute the HMAC SHA-256 signature of a bytestring message.     hmac :: ByteString -> ByteString-    hmac = Char.pack . SHA.showDigest . SHA.hmacSha256 (LBS.fromStrict hmacKey) . LBS.fromStrict+    hmac = Char.pack . show . (HMAC.hmacGetDigest :: HMAC.HMAC SHA256 -> Hash.Digest SHA256) . HMAC.hmac hmacKey      -- Pieces of the message.     head = header message