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


Python Search.add_code_filter方法代码示例

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


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

示例1: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
    def get_display(self):
        outer_div = DivWdg()
        outer_div.set_id('add_deliverable_files_to_package')

        order_code = self.package_sobject.get('order_code')
        order_search = Search('twog/order')
        order_search.add_code_filter(order_code)
        order_sobject = order_search.get_sobject()

        deliverable_files = get_deliverable_files_in_order(order_sobject)
        selected_files = get_files_for_package(self.package_sobject.get_code())

        # Only show the selectable files and the submit button if the parent order has any deliverable files
        if deliverable_files:
            deliverable_file_select_wdg = get_files_checkbox_from_file_list(deliverable_files, selected_files)
            outer_div.add(deliverable_file_select_wdg)

            submit_button = SubmitWdg('Submit')
            submit_button.add_behavior(self.get_submit_button_behavior())

            outer_div.add(submit_button)
        else:
            outer_div.add('<div>No deliverable files are available for this Order yet.</div>')

        return outer_div
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:27,代码来源:add_deliverable_files_to_package_wdg.py

示例2: add_task_to_component

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
    def add_task_to_component(self, process, component_code, login):
        server = TacticServerStub.get()

        component_search = Search('twog/component')
        component_search.add_code_filter(component_code)
        component = component_search.get_sobject()

        server.insert('sthpw/task', {'process': process, 'login': login}, parent_key=component.get_search_key())
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:10,代码来源:insert_task_wdg.py

示例3: get_platform_connection_by_package_sobject

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
def get_platform_connection_by_package_sobject(package_sobject):
    order_search = Search('twog/order')
    order_search.add_code_filter(package_sobject.get('order_code'))
    order_sobject = order_search.get_sobject()

    platform_connection_search = Search('twog/platform_connection')
    platform_connection_search.add_filter('platform_code', package_sobject.get('platform_code'))
    platform_connection_search.add_filter('division_code', order_sobject.get('division_code'))
    platform_connection = platform_connection_search.get_sobject()

    return platform_connection
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:13,代码来源:utils.py

示例4: get_order_sobject_from_component_sobject

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
def get_order_sobject_from_component_sobject(component_sobject):
    """
    Given a twog/component sobject, get the order that it is assigned to.

    :param component_sobject: twog/component sobject
    :return: twog/order sobject
    """

    order_search = Search('twog/order')
    order_search.add_code_filter(component_sobject.get('order_code'))
    order_sobject = order_search.get_sobject()

    return order_sobject
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:15,代码来源:utils.py

示例5: main

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
def main(server=None, trigger_input=None):
    """
    On the insert|twog/package event, search for an existing connection from the package's division to platform.
    If no entry exists in the twog/platform_connection table, create it by inserting the division_code, platform_code,
    and a connection_status set to 'disconnected'.

    :param server: the TacticServerStub object
    :param trigger_input: a dict with data like like search_key, search_type, sobject, and update_data
    :return: None
    """
    if not trigger_input:
        return

    try:
        from pyasm.search import Search

        # Get the package sobject.
        package_sobject = trigger_input.get('sobject')

        # Search for the twog/order sobject (which leads to the division)
        order_search = Search('twog/order')
        order_search.add_code_filter(package_sobject.get('order_code'))
        order_sobject = order_search.get_sobject()

        # Search for the twog/division sobject
        division_search = Search('twog/division')
        division_search.add_code_filter(order_sobject.get('division_code'))
        division_sobject = division_search.get_sobject()

        # Search for an existing entry in the twog/platform_connection table. If it already exists, no action is needed
        existing_platform_connection_search = Search('twog/platform_connection')
        existing_platform_connection_search.add_filter('division_code', division_sobject.get_code())
        existing_platform_connection_search.add_filter('platform_code', package_sobject.get('platform_code'))
        existing_platform_connection = existing_platform_connection_search.get_sobject()

        if not existing_platform_connection:
            # Insert the new entry
            data_to_insert = {
                'division_code': division_sobject.get_code(),
                'platform_code': package_sobject.get('platform_code'),
                'connection_status': 'disconnected'
            }

            server.insert('twog/platform_connection', data_to_insert)

    except Exception as e:
        traceback.print_exc()
        print str(e)
        raise e
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:51,代码来源:insert_platform_connection_on_package_insert.py

示例6: get_client_division_sobject_from_order_sobject

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
def get_client_division_sobject_from_order_sobject(order_sobject):
    """
    Given an order sobject, get the division sobject associated with it. If there isn't one, return None

    :param order_sobject: twog/order sobject
    :return: twog/division sobject or None
    """

    division_search = Search('twog/division')
    division_search.add_code_filter(order_sobject.get('division_code'))
    division_sobject = division_search.get_sobject()

    if division_sobject:
        return division_sobject
    else:
        return None
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:18,代码来源:utils.py

示例7: get_task_estimated_hours_from_task_code

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
def get_task_estimated_hours_from_task_code(task_code):
    task_search = Search('sthpw/task')
    task_search.add_code_filter(task_code)
    task = task_search.get_sobject()

    component = task.get_parent()

    instructions_code = component.get('instructions_code')

    if instructions_code:
        instructions_sobject = get_sobject_by_code('twog/instructions', instructions_code)

        if instructions_sobject:
            return get_task_estimated_hours_from_instructions_document(instructions_sobject, task.get('process'))

    return 0
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:18,代码来源:utils.py

示例8: get_sobject_by_code

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
def get_sobject_by_code(search_type, sobject_code):
    """
    Given a search type and an sobject code, return the sobject associated with the code.

    :param search_type: Search type ('twog/order' for example)
    :param sobject_code: sobject unique code
    :return: sobject
    """

    search = Search(search_type)
    search.add_code_filter(sobject_code)
    search_result = search.get_sobject()

    if search_result:
        return search_result
    else:
        return None
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:19,代码来源:utils.py

示例9: get_client_division_sobject_for_task_sobject

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
def get_client_division_sobject_for_task_sobject(task):
    """
    Given a task sobject, travel up the chain of Component and Order to get the Division the order is assigned
    to. This will only work for tasks that are assigned to components.

    :param task: task sobject
    :return: twog/division sobject
    """

    parent_component = task.get_parent()

    order_search = Search('twog/order')
    order_search.add_code_filter(parent_component.get('order_code'))
    order = order_search.get_sobject()

    division_search = Search('twog/division')
    division_search.add_code_filter(order.get('division_code'))
    division = division_search.get_sobject()

    return division
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:22,代码来源:utils.py

示例10: get_client_name_from_division_code

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
def get_client_name_from_division_code(division_code):
    """
    Get the name of the client that owns the division.

    :param division_code: A unique division code
    :return: The client's name
    """
    division_search = Search('twog/division')
    division_search.add_code_filter(division_code)
    division = division_search.get_sobject()

    if division:
        client_search = Search('twog/client')
        client_search.add_code_filter(division.get('client_code'))
        client = client_search.get_sobject()

        if client:
            return client.get('name')

    return None
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:22,代码来源:order_builder_utils.py

示例11: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
    def get_display(self):
        outer_div = DivWdg()
        outer_div.set_id('change-title')

        title_code = self.component_sobject.get_value('title_code')

        if title_code:
            title_sobject_search = Search('twog/title')
            title_sobject_search.add_code_filter(title_code)
            title_sobject = title_sobject_search.get_sobject()

            outer_div.add('Title is currently set to: {0}'.format(title_sobject.get_value('name')))
        else:
            outer_div.add('No Title currently selected')

        outer_div.add(get_title_select_wdg())

        submit_button = SubmitWdg('Submit')
        submit_button.add_behavior(self.get_submit_button_behavior())

        outer_div.add(submit_button)

        return outer_div
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:25,代码来源:change_title_wdg.py

示例12: main

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
def main(server=None, trigger_input=None):
    """
    :param server: the TacticServerStub object
    :param trigger_input: a dict with data like like search_key, search_type, sobject, and update_data
    :return: None
    """
    if not trigger_input:
        trigger_input = {}

    # Get the task
    task_sobject = trigger_input.get('sobject')

    # Only proceed if the task exists and is attached to a twog/component sobject
    if not (task_sobject and task_sobject.get('search_type') == u'twog/component?project=twog'):
        return

    component_search_code = task_sobject.get('search_code')

    component_search = Search('twog/component')
    component_search.add_code_filter(component_search_code)
    component = component_search.get_sobject()

    task_status = task_sobject.get('status')

    # If the task is marked as complete, check if the component needs to be set to complete as well (only happens if
    # all other tasks on that component are marked as complete)
    if task_status.lower() == 'complete':
        tasks = get_task_sobjects_from_component_sobject(component)

        for task in tasks:
            if task.get('status') != 'Complete':
                return
        else:
            server.update(component.get_search_key(), {'status': 'complete'})
    elif task_status.lower() == 'in progress':
        if component.get('status').lower() != 'in_progress':
            server.update(component.get_search_key(), {'status': 'in_progress'})
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:39,代码来源:update_component_status_on_task_status_update.py

示例13: set_row

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
    def set_row(self, order, table, counter, header_groups, tasks):
        order_name = order.get('name')
        order_code = order.get('code')
        division_code = order.get('division_code')
        due_date = order.get('due_date')

        order_table = Table()
        order_table.add_style('width', '100%')

        name_row = order_table.add_row()
        name_row.add_style('font-size', '14px')
        name_row.add_style('font-weight', 'bold')

        name_data = '<span style="color: #FF0000">{0}.</span> <u>{1}</u>'.format(counter, order_name)

        order_table.add_cell(data=name_data, row=name_row, css='order-row')

        code_row = order_table.add_row()
        code_row.add_style('font-size', '12px')

        code_cell = order_table.add_cell(data='<strong>Order code:</strong> {0}'.format(order_code), row=code_row)
        code_cell.add_style('padding-top', '3px')
        code_cell.add_style('padding-bottom', '3px')
        code_cell.add_style('padding-left', '3px')

        division_row = order_table.add_row()

        division_search = Search('twog/division')
        division_search.add_code_filter(division_code)
        division = division_search.get_sobject()

        # TODO: Find the division image
        division_data = '<b>Division:</b> {0}'.format(division.get('name'))

        order_table.add_cell(data=division_data, row=division_row)

        date_row = order_table.add_row()
        due_date_data = '<b>Due:</b> {0}'.format(due_date)
        order_table.add_cell(data=due_date_data, row=date_row)

        # Add the buttons for the Order
        button_row = order_table.add_row()

        order_builder_button = ButtonNewWdg(title='Order Builder', icon='WORK')
        order_builder_button.add_behavior(get_order_builder_launch_behavior(order.get('__search_key__')))

        note_button = ButtonNewWdg(title='Add Note', icon='NOTE')
        note_button.add_behavior(get_add_notes_behavior(order.get('__search_key__')))
        note_button.add_style('display', 'inline-block')

        order_table.add_cell(data=order_builder_button, row=button_row)
        order_table.add_cell(data=note_button, row=button_row)

        current_row = table.add_row()
        current_row.add_style('width', '100%')
        current_row.add_style('vertical-align', 'top')

        order_cell_background_color = '#D7D7D7'

        order_cell = table.add_cell(order_table, row=current_row)
        order_cell.add_style('background-color', order_cell_background_color)
        order_cell.add_style('border', '1px solid #EEE')
        order_cell.add_style('padding', '4px')
        order_cell.add_style('width', '24%')

        for column in header_groups:
            if tasks:
                column_tasks = tasks.get(column)
            else:
                column_tasks = []

            if column_tasks:
                task_table = Table()
                task_table.add_style('width', '100%')
                task_table.add_style('font-size', '10px')

                for task in column_tasks:
                    current_task_row = task_table.add_row()
                    current_task_row.add_style('background-color',
                                               self.TASK_COLOR_DICT.get(task.get_value('status').lower(), '#FFFFFF'))
                    current_task_row.add_style('padding', '3px')
                    current_task_row.add_style('min-height', '20px')
                    current_task_row.add_style('border-top-left-radius', '10px')
                    current_task_row.add_style('border-bottom-left-radius', '10px')

                    inspect_button = ButtonNewWdg(title='Task Inspect', icon='WORK')
                    inspect_button.add_behavior(get_load_popup_widget_behavior('Task Inspect',
                                                                               'widgets.TaskInspectWdg',
                                                                               task.get_search_key(),
                                                                               width=600, height=600))
                    task_table.add_cell(data=inspect_button, row=current_task_row)

                    # Each task in the row will have the following properties to be displayed
                    cell_names = ['process', 'status']

                    # Add each property from left to right in the current task row. Abbreviate the text to make it
                    # fit better
                    for cell_name in cell_names:
                        task_table.add_cell(data=abbreviate_text(task.get_value(cell_name), 15), row=current_task_row)

#.........这里部分代码省略.........
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:103,代码来源:hottoday.py

示例14: main

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
def main(server=None, input=None):
    """
    :param server: the TacticServerStub object
    :param input: a dict with data like like search_key, search_type, sobject, and update_data
    :return: None
    """

    # Start by getting all the divisions
    divisions_search = Search('twog/division')
    divisions = divisions_search.get_sobjects()

    for division in divisions:
        # Get the division's retention policy, if one exists
        retention_policy_search = Search('twog/retention_policy')
        retention_policy_search.add_code_filter(division.get('retention_policy_code'))
        retention_policy = retention_policy_search.get_sobject()

        if retention_policy:
            # Get the number of days until archive
            source_days_to_archive = retention_policy.get('source_file_archive_days')
            intermediate_days_to_archive = retention_policy.get('intermediate_file_archive_days')
            deliverable_days_to_archive = retention_policy.get('deliverable_file_archive_days')

            # Get the number of days until deletion
            source_days_to_delete = retention_policy.get('source_file_delete_days')
            intermediate_days_to_delete = retention_policy.get('intermediate_file_delete_days')
            deliverable_days_to_delete = retention_policy.get('deliverable_file_delete_days')

            # Get all the files associated with the division, if any
            division_file_search = Search('twog/file')
            division_file_search.add_filter('division_code', division.get_code())
            # Only get files with san_status 'exists', 'needs_archive', or 'archived', they are the only files that
            # potentially need updating
            division_file_search.add_filter('san_status', 'deleted', op='!=')
            division_file_search.add_filter('san_status', 'needs_delete', op='!=')
            division_files = division_file_search.get_sobjects()

            for division_file in division_files:
                # Search for any orders that the file is a part of
                file_in_order_search = Search('twog/file_in_order')
                file_in_order_search.add_filter('file_code', division_file.get_code())
                file_in_order_entries = file_in_order_search.get_sobjects()

                # Get all the orders that the file is a part of. Do this by first getting all the order codes,
                # then doing a search for all the order sobjects
                order_codes = []

                for file_in_order_entry in file_in_order_entries:
                    order_code = "'{0}'".format(file_in_order_entry.get('order_code'))

                    if order_code not in order_codes:
                        order_codes.append(order_code)

                if order_codes:
                    # Search for the orders
                    orders_search = Search('twog/order')
                    orders_search.add_where('\"code\" in ({0})'.format(','.join(order_codes)))
                    orders = orders_search.get_sobjects()

                    # If the file is part of any order that isn't marked as complete, return immediately, since the
                    # file is still in use. If it is complete, use the most recent completion date from all the orders
                    # to determine when the file was last used
                    most_recent_completion_date = get_most_recent_completed_order_date(orders)

                    if most_recent_completion_date:
                        number_of_days_passed = (datetime.today() - most_recent_completion_date).days

                        file_classification = division_file.get('classification')

                        # Determine the file type, and which part of the retention policy to compare against
                        if file_classification == 'source':
                            days_to_archive = source_days_to_archive
                            days_to_delete = source_days_to_delete
                        elif file_classification == 'intermediate':
                            days_to_archive = intermediate_days_to_archive
                            days_to_delete = intermediate_days_to_delete
                        else:
                            days_to_archive = deliverable_days_to_archive
                            days_to_delete = deliverable_days_to_delete

                        if days_to_delete and days_to_delete < number_of_days_passed:
                            # Mark the file for deletion
                            search_key = server.build_search_key('twog/file', division_file.get_code(),
                                                                 project_code='twog')

                            server.update(search_key, {'san_status': 'needs_delete'})
                        elif days_to_archive and days_to_archive < number_of_days_passed:
                            # Mark the file for archiving
                            search_key = server.build_search_key('twog/file', division_file.get_code(),
                                                                 project_code='twog')

                            server.update(search_key, {'san_status': 'needs_archive'})
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:94,代码来源:check_files_against_retention_policies.py

示例15: main

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_code_filter [as 别名]
def main(server=None, input_data=None):
    if not input_data:
        return

    # The input for the script should be a sthpw/task sobject
    task_sobject = input_data.get('sobject')

    # This script only applies to tasks that are marked as Complete, and are attached to twog/component sobjects
    if not (task_sobject.get('status') == 'Complete' and task_sobject.get(
            'search_type') == u'twog/component?project=twog'):
        return

    # Tasks saved on twog/component have extra data associated with them, saved under twog/task_data
    # Retrieve the entry of twog/task_data for this task sobject
    task_data_search = Search('twog/task_data')
    task_data_search.add_filter('task_code', task_sobject.get('code'))
    task_data = task_data_search.get_sobject()

    if not task_data:
        return

    # Get the next task in the pipeline
    # Start by getting the component sobject the task is attached to
    component_search = Search('twog/component')
    component_search.add_code_filter(task_sobject.get('search_code'))
    component_sobject = component_search.get_sobject()

    if not component_sobject:
        return

    # Then get the output processes. Start by fetching the pipeline object
    pipeline = Pipeline('twog/component')
    pipeline.set_pipeline(get_pipeline_xml(component_sobject.get('pipeline_code')))

    # Then get the names of the processes contained in that pipeline (which corresponds to all the names of the tasks
    # within this component)
    output_processes = pipeline.get_output_processes(task_sobject.get('process'))

    # Now, get the actual task objects
    tasks_search = Search('sthpw/task')
    tasks_search.add_filter('process', output_processes)
    tasks_search.add_parent_filter(component_sobject)
    output_tasks = tasks_search.get_sobjects()

    # Fetch the output files attached to the original task
    out_files_search = Search('twog/task_data_out_file')
    out_files_search.add_filter('task_data_code', task_data.get_code())
    out_files = out_files_search.get_sobjects()

    if not out_files:
        return

    # Go through each output task and attach the output files as input files
    for output_task in output_tasks:
        output_task_data_search = Search('twog/task_data')
        output_task_data_search.add_filter('task_code', output_task.get_code())
        output_task_data = output_task_data_search.get_sobject()

        for out_file in out_files:
            inserted_data = {
                'task_data_code': output_task_data.get_code(),
                'file_code': out_file.get('file_code')
            }

            server.insert('twog/task_data_in_file', inserted_data)

            # The file should be added to the files in order list
            server.insert('twog/file_in_order', {'order_code': component_sobject.get('order_code'),
                                                 'file_code': out_file.get('file_code')})
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:71,代码来源:move_task_out_files_to_next_task.py


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