Sha256: fe4ab0093d24ba433c07f26fff1f32211df9b22162c728f0391fd50ab426146d

Contents?: true

Size: 989 Bytes

Versions: 147

Compression:

Stored size: 989 Bytes

Contents

require 'rbbt-util'
require 'pycall/import'

module RbbtPython
  extend PyCall::Import
  def self.run(mod = nil, imports = nil, &block)
    if mod
      if imports
        pyfrom mod, :import => imports
      else
        pyimport mod 
      end
    end

    module_eval(&block)
  end

  def self.run_log(mod = nil, imports = nil, severity = 0, severity_err = nil, &block)
    if mod
      if imports
        pyfrom mod, :import => imports
      else
        pyimport mod 
      end
    end

    Log.trap_std("Python STDOUT", "Python STDERR", severity, severity_err) do
      module_eval(&block)
    end
  end

  def self.run_log_stderr(mod = nil, imports = nil, severity = 0, &block)
    if mod
      if imports
        pyfrom mod, :import => imports
      else
        pyimport mod 
      end
    end

    Log.trap_stderr("Python STDERR", severity) do
      module_eval(&block)
    end
  end

  def self.add_path(path)
    self.run 'sys' do
      sys.path.append path
    end
  end

end

Version data entries

147 entries across 147 versions & 1 rubygems

Version Path
rbbt-util-5.32.12 lib/rbbt/util/python.rb
rbbt-util-5.32.11 lib/rbbt/util/python.rb
rbbt-util-5.32.10 lib/rbbt/util/python.rb
rbbt-util-5.32.9 lib/rbbt/util/python.rb
rbbt-util-5.32.7 lib/rbbt/util/python.rb
rbbt-util-5.32.6 lib/rbbt/util/python.rb
rbbt-util-5.32.5 lib/rbbt/util/python.rb
rbbt-util-5.32.4 lib/rbbt/util/python.rb
rbbt-util-5.32.2 lib/rbbt/util/python.rb
rbbt-util-5.32.1 lib/rbbt/util/python.rb
rbbt-util-5.32.0 lib/rbbt/util/python.rb
rbbt-util-5.31.15 lib/rbbt/util/python.rb
rbbt-util-5.31.14 lib/rbbt/util/python.rb
rbbt-util-5.31.13 lib/rbbt/util/python.rb
rbbt-util-5.31.12 lib/rbbt/util/python.rb
rbbt-util-5.31.11 lib/rbbt/util/python.rb
rbbt-util-5.31.10 lib/rbbt/util/python.rb
rbbt-util-5.31.9 lib/rbbt/util/python.rb
rbbt-util-5.31.8 lib/rbbt/util/python.rb
rbbt-util-5.31.7 lib/rbbt/util/python.rb