API
1.6
1.6
  • Introduction
  • Plug-in System
  • Data
    • result
    • Events
    • Targets
  • Environment Variables
    • PYBLISHPLUGINPATH
    • PYBLISH_CLIENT_PORT
    • PYBLISH_ALLOW_DUPLICATE_PLUGINS
    • PYBLISH_GUI
    • PYBLISH_EARLY_ADOPTER
    • PYBLISH_STRICT_DATATYPES
  • Ordering
    • CollectorOrder
    • ValidatorOrder
    • ExtractorOrder
    • IntegratorOrder
  • pyblish.util
    • publish
    • collect
    • validate
    • extract
    • integrate
  • pyblish.cli
    • publish
  • pyblish.api
    • AbstractEntity
      • .data
    • Context
      • .append
      • .create_instance
    • Instance
      • .append
      • .context
    • Plugin
      • .hosts
      • .families
      • .label
      • .active
      • .order
      • .optional
      • .requires
      • .actions
      • .version
      • .match
    • ContextPlugin
      • .process
    • InstancePlugin
      • .process
    • Action
      • .process
      • .icon
      • .on
    • Category
    • Separator
    • discover
    • sort
    • register_gui
    • register_host
Powered by GitBook
On this page
  • Public Functions
  • Description
  • Examples

Was this helpful?

  1. pyblish.api

Context

Previous.dataNext.append

Last updated 5 years ago

Was this helpful?

The context represents the world.

Source

Added

0.1.6

Inherits

Public Functions

Output

Method

Instance

4 functions inherited from

Description

The context encapsulates one or more 's along with information about the current execution environment, such as the current user and time of day. Publishing is performed by iterating over the members of a context.

# Psuedo-code
for plugin in plugins:
  for instance in context:
     plugin.process(instance)

Examples

# Creating a context
#
# The context is normally created for you by a user interface or
# through convenience functions, but can be helpful to manually
# create for debugging purposes.

import pyblish.api as pyblish
context = pyblish.Context()
# Creating instances from a context
#
# Instances can be created directly or through a context. When
# created through a context, the context is automatically set
# as the parent of the newly created instance.

import pyblish.api as pyblish
context = pyblish.Context()
instanceA = context.create_instance(name="MyInstanceA")
instanceB = pyblish.Instance(name="MyInstanceB", parent=context)

print("The context contains these instances:")
for instance in context:
    print(instance)
# MyInstanceA
# MyInstanceB
# Setting data on a context
# 
# Both Instance and Context inherit from AbstractEntity which
# provides the mechanism for modifying data.

import pyblish.api as pyblish
context = pyblish.Context()
data = context.data
context.data["hostname"] = "localhost"
assert "hostname" in context.data is True
context.data.pop("hostname")
assert "hostname" in context.data is False

{{ file.mtime }}

(str, **kwargs)

AbstractEntity
AbstractEntity
Instance
Link
.create_instance