Sha256: 000f341bd28479e58ef140174b30c46a8b260e92edfb3ae44f8020a4e63da841

Contents?: true

Size: 912 Bytes

Versions: 8

Compression:

Stored size: 912 Bytes

Contents

require 'rbbt/workflow/step'

class Step
  def python_file(file, options = {})
    CMD.cmd_log(:python, file, options)
  end

  def python_block(options = {}, &block)
    RbbtPython.run options, &block
  end

  def python(python = nil, options = {}, &block)
    begin
      RbbtPython.add_path self.workflow.libdir.python.find
    rescue
      Log.warn "Error loading libdir python for workflow '#{Misc.fingerprint self.workflow}'"
    end
    case python
    when Path
      python_file python.find, options
    when String
      if Open.exists?(python)
        python_file python
      else
        TmpFile.with_file do |dir|
          pkg = "pkg#{rand(100)}"
          Open.write File.join(dir, "#{pkg}/__init__.py"), code

          RbbtPython.add_path dir

          Misc.in_dir dir do
            yield pkg
          end
        end
      end
    else
      python_block(python, &block)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rbbt-util-5.44.1 lib/rbbt/util/python/step.rb
rbbt-util-5.43.0 lib/rbbt/util/python/step.rb
rbbt-util-5.42.0 lib/rbbt/util/python/step.rb
rbbt-util-5.41.1 lib/rbbt/util/python/step.rb
rbbt-util-5.41.0 lib/rbbt/util/python/step.rb
rbbt-util-5.40.5 lib/rbbt/util/python/step.rb
rbbt-util-5.40.4 lib/rbbt/util/python/step.rb
rbbt-util-5.40.3 lib/rbbt/util/python/step.rb