当前位置: 首页>>代码示例>>Python>>正文


Python WorkflowManager.metadata方法代码示例

本文整理汇总了Python中vis.workflow.WorkflowManager.metadata方法的典型用法代码示例。如果您正苦于以下问题:Python WorkflowManager.metadata方法的具体用法?Python WorkflowManager.metadata怎么用?Python WorkflowManager.metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vis.workflow.WorkflowManager的用法示例。


在下文中一共展示了WorkflowManager.metadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: import_files

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import metadata [as 别名]
def import_files(request):
    """
    Called with the /api/import URL to load files into the WorkflowManager and return the metadata
    it discovers.
    """
    filepaths = [piece.file.path for piece in Piece.objects.filter(user_id=request.session.session_key)]
    workm = WorkflowManager(filepaths)
    workm.load('pieces')
    request.session['workm'] = workm
    return [
        {"Filename": os.path.basename(workm.metadata(i, 'pathname')),
         "Title": workm.metadata(i, 'title'),
         "Part Names": workm.metadata(i, 'parts'),
         "Offset": None,
         "Part Combinations": None,
         "Repeat Identical": False}
        for i in xrange(len(workm))
    ], 200
开发者ID:ELVIS-Project,项目名称:web-vis,代码行数:20,代码来源:views.py

示例2: WorkflowWrapper

# 需要导入模块: from vis.workflow import WorkflowManager [as 别名]
# 或者: from vis.workflow.WorkflowManager import metadata [as 别名]
class WorkflowWrapper(QAbstractTableModel):
    """
    This is a wrapper class for the :class:`vis.workflow.WorkflowManager` that allows its use as a
    :class:`QAbstractTableModel` for PyQt4. This class only wraps :meth:`metadata` and
    :meth:`setting`, which are those methods needed by PyQt. For all other :class:`Workflowmanager`
    methods, access the internally-stored instance with :meth:`get_workflow_manager`.

    ** How to Use the WorkflowWrapper: **

    The :class:`WorkflowWrapper` always returns valid values, and will not raise exceptions of its
    own. However, "valid" values are not always "correct" or "expected." We recommend you use the
    :class:`WorkflowWrapper` like this:

    #. Instantiate the object.
    #. Set the object as the model for its view.
    #. Call :meth:`insertRows` with the total number of pieces to be added.
    #. Call :meth:`setData` once per piece to set the pathname.
    #. Once each row has a pathname, the object will instantiate its internal
        :class:`WorkflowManager` instance and call its :meth:`load` method to import the score,
        run the :class:`NoteRestIndexer`, and save its metadata.
    #. Subsequent calls to :meth:`data` will return the most correct information available.

    ** How not to Use the WorkflowWrapper: **

    We recommend you do not use the :class:`WorkflowWrapper` like this:

    * Do not add pieces by calling :meth:`insertRows` then :meth:`setData` with the pathname, then
        :meth:`insertRows` then :meth:`setData` with the pathname, and so on. In this case, the
        :class:`WorkflowWrapper` would create a new :class:`WorkflowManager` after each call to
        :meth:`setData`, which would import each piece many times.
    * Do not add pieces after you modify a metadata or setting field. When you add a piece, a new
        :class:`WorkflowManager` instance is created. The new instance replaces any customized
        settings and metadata with the default values.
    * Do not call :meth:`data` before you add the pathnames of all pieces. Real metadata is only
        available after the :class:`WorkflowManager` is created, which happens after all the pieces
        have a pathname. If you call :meth:`data` when there is no :class:`WorkflowManager`, the
        return value will always be ``None``.

    ** Columns in the Data Model: **

    The :class:`WorkflowWrapper` creates a two-dimensional data model, where each row represents an
    :class:`IndexedPiece` stored in the :class:`WorkflowManager` and each column represents either
    a setting or a metadatum field. The following six fields are different for each piece, and
    should be displayed in the :class:`QTableView` widget:

    * filename
    * title
    * parts_list
    * offset_interval
    * parts_combinations
    * repeat_identical

    The :class:`WorkflowManager` additionally wraps these data fields, which are shared by all
    pieces, and will therefore not apear in the :class:`QTableView` widget:

    * quality
    * simple_ints

    Use class properties with those names to specify columns to :meth:`data` and :meth:`getData`.
    For example:

    >>> workm.data((0, WorkflowWrapper.title), Qt.DisplayRole)
    u'02_eleva'
    >>> workm.setData((0, WorkflowWrapper.title), u'Elevator Love Letter', Qt.EditRole)
    >>> workm.data((0, WorkflowWrapper.parts_list), Qt.DisplayRole)
    [u'Amy Milan', u'Torquil Campbell', u'Evan Cranley', u'Chris Seligman', u'Pat McGee']
    """

    # Public class variables to track which column has which data
    # NOTE: Update _num_cols whenever you change the number of columns,
    #       since this variable is used by columnCount().
    # NOTE: Update _header_names whenever you change the number or definition of
    #       columns, since this variale is used by headerData().
    _num_cols = 6
    _header_names = ['Path', 'Title', 'List of Part Names', 'Offset Interval',
                    'Part Combinations', 'Repeat Identical']
    # displayed fields
    filename = 0
    title = 1
    parts_list = 2
    offset_interval = 3
    parts_combinations = 4
    repeat_identical = 5

    # non-displayed fields
    quality = 100
    simple_ints = 101

    # instead of DisplayRole; used to tell data() to return the list of part names as a list
    ListRole = 4000

    # when a value hasn't been set, return a QVariant with this in it
    default_value = u'(unset)'

    def __init__(self, parent=QModelIndex()):
        """
        Create a new :class:`WorkflowWrapper` instance.
        """
        super(WorkflowWrapper, self).__init__()
        self._pathnames = []  # hold a list of pathnames for before the WorkflowManager
#.........这里部分代码省略.........
开发者ID:ELVIS-Project,项目名称:desktop_vis,代码行数:103,代码来源:pyqt.py


注:本文中的vis.workflow.WorkflowManager.metadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。