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


Python Search.get_by_search_keys方法代码示例

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


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

示例1: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def execute(my):

        my.collection_key = my.kwargs.get("collection_key")
        my.search_keys = my.kwargs.get("search_keys")

        collection = Search.get_by_search_key(my.collection_key)
        collection_code = collection.get("code")
        sobjects = Search.get_by_search_keys(my.search_keys)
        search_codes = [x.get_code() for x in sobjects]


        search_type = collection.get_base_search_type()
        parts = search_type.split("/")
        collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])

        search = Search(collection_type)
        search.add_filter("parent_code", collection.get_code())
        search.add_filters("search_code", search_codes)

        items = search.get_sobjects()

        for item in items:
            item.delete()

        my.add_description("Remove [%s] item(s) from Collection [%s]" % (len(my.search_keys), collection_code))
开发者ID:0-T-0,项目名称:TACTIC,代码行数:27,代码来源:collection_wdg.py

示例2: get_files

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def get_files(my):

        paths = []

        # remember this here for now
        my.files = {}

        my.snapshots = {}


        search_key = my.kwargs.get("search_key")
        search_keys = my.kwargs.get("search_keys")
        if search_key:
            sobject = SearchKey.get_by_search_key(search_key)
            my.sobjects = [sobject]

        if search_keys:
            if isinstance(search_keys, basestring):
                search_keys = search_keys.replace("'", '"')
                search_keys = jsonloads(search_keys)
            my.sobjects = Search.get_by_search_keys(search_keys)

        if not my.sobjects:
            return []

        my.sobject = my.sobjects[0]


        for sobject in my.sobjects:
            sobject_paths = my.get_sobject_files(sobject)
            paths.extend(sobject_paths)

        return paths
开发者ID:blezek,项目名称:TACTIC,代码行数:35,代码来源:snapshot_files_wdg.py

示例3: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def execute(my):

        search_keys = my.kwargs.get("search_keys")
        if not search_keys:
            return

        element_name = my.kwargs.get("element_name")

        # get all of the sobjects
        sobjects = Search.get_by_search_keys(search_keys)
        if not sobjects:
            return

        from pyasm.widget import WidgetConfigView

        search_type = sobjects[0].get_base_search_type()
        view = "definition"

        config = WidgetConfigView.get_by_search_type(search_type, view)

        # TEST
        widget = config.get_display_widget(element_name)
        for sobject in sobjects:
            widget.set_sobject(sobject)
            value = widget.get_text_value()
            sobject.set_value(element_name, value)
            sobject.commit()
开发者ID:raidios,项目名称:TACTIC,代码行数:29,代码来源:expression_element_wdg.py

示例4: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def execute(my):

        collection_key = my.kwargs.get("collection_key")
        search_keys = my.kwargs.get("search_keys")

        collection = Search.get_by_search_key(collection_key)
        if not collection:
            raise Exception("Collection does not exist")


        search_type = collection.get_base_search_type()
        parts = search_type.split("/")
        collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])
        search = Search(collection_type)
        search.add_filter("parent_code", collection.get_code())
        items = search.get_sobjects()


        search_codes = [x.get_value("search_code") for x in items]
        search_codes = set(search_codes)



        has_keywords = SearchType.column_exists(search_type, "keywords")

        if has_keywords:
            collection_keywords = collection.get_value("keywords", no_exception=True)
            collection_keywords = collection_keywords.split(" ")
            collection_keywords = set(collection_keywords)



        # create new items

        sobjects = Search.get_by_search_keys(search_keys)
        for sobject in sobjects:
            if sobject.get_code() in search_codes:
                continue

            new_item = SearchType.create(collection_type)
            new_item.set_value("parent_code", collection.get_code())
            new_item.set_value("search_code", sobject.get_code())
            new_item.commit()


            # copy the metadata of the collection
            if has_keywords:
                keywords = sobject.get_value("keywords")

                keywords = keywords.split(" ")
                keywords = set(keywords)

                keywords = keywords.union(collection_keywords)
                keywords = " ".join(keywords)

                sobject.set_value("keywords", keywords)
                sobject.commit()
开发者ID:asmboom,项目名称:TACTIC,代码行数:59,代码来源:collection_wdg.py

示例5: get_files

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def get_files(self):

        paths = []

        # remember this here for now
        self.files = {}

        self.snapshots = {}


        search_key = self.kwargs.get("search_key")
        search_keys = self.kwargs.get("search_keys")
        if search_key:
            sobject = SearchKey.get_by_search_key(search_key)
            self.sobjects = [sobject]

        if search_keys:
            if isinstance(search_keys, basestring):
                search_keys = search_keys.replace("'", '"')
                search_keys = jsonloads(search_keys)
            self.sobjects = Search.get_by_search_keys(search_keys)

        if not self.sobjects:
            return []

        self.sobject = self.sobjects[0]


        for sobject in self.sobjects:
            
            if sobject.get_base_search_type() in ['sthpw/task', 'sthpw/note']:
                parent = sobject.get_parent()
                sobject_paths = self.get_sobject_files(parent)
                paths.extend(sobject_paths)

            else:
                sobject_paths = self.get_sobject_files(sobject)
                paths.extend(sobject_paths)


        return paths
开发者ID:mincau,项目名称:TACTIC,代码行数:43,代码来源:snapshot_files_wdg.py

示例6: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def execute(my):

        # if a single sobject is passed in
        sobject = my.kwargs.get("sobject")
        if not sobject:
            search_key = my.kwargs.get("search_key")
            sobject = Search.get_by_search_key(search_key)

        if sobject:
            sobjects = [sobject]
        else:
            search_keys = my.kwargs.get("search_keys")
            sobjects = Search.get_by_search_keys(search_keys)

        if not sobjects:
            return

        # find all the relationships
        my.schema = Schema.get()

        for sobject in sobjects:
            my.delete_sobject(sobject)
开发者ID:pombredanne,项目名称:TACTIC,代码行数:24,代码来源:delete_wdg.py

示例7: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def get_display(my):

        top = my.top
        my.set_as_panel(top)
        top.add_class("spt_checkout_top")
        top.add_color("background", "background")
        top.add_style("width: 800px")

        inner = DivWdg()
        top.add(inner)

        snapshot_codes = my.kwargs.get("snapshot_codes")
        search_keys = my.kwargs.get("search_keys")

        if snapshot_codes:
            if isinstance(snapshot_codes, basestring):
                snapshots_codes = eval(snapshot_codes)

            search = Search("sthpw/snapshot")
            search.add_filters("code", snapshot_codes)
            snapshots = search.get_sobjects()
        elif search_keys:

            if isinstance(search_keys, basestring):
                search_keys = eval(search_keys)

            sobjects = Search.get_by_search_keys(search_keys)
            snapshots = []
            for sobject in sobjects:
                snapshot = Snapshot.get_latest_by_sobject(sobject, process="publish")
                if snapshot:
                    snapshots.append(snapshot)

            snapshot_codes = []
            for snapshot in snapshots:
                snapshot_codes.append( snapshot.get("code") )

        if not snapshot_codes:
            no_snapshots_div = DivWdg()
            no_snapshots_div.add("No files in selection")
            inner.add(no_snapshots_div)
            return top


        sandbox_dir = Environment.get_sandbox_dir("default")
        project_code = Project.get_project_code()
        sandbox_dir = "%s/%s" % (sandbox_dir, project_code)

        base_dir = my.kwargs.get("base_dir")

        if base_dir:
            title_div = DivWdg()
            inner.add(title_div)
            title_div.add_color("background", "background3")
            title_div.add_color("color", "color3")
            title_div.add_style("padding", "15px")
            title_div.add_style("font-weight: bold")
            title_div.add("Path: %s" % base_dir)


        inner.add("Check-out to: %s" % sandbox_dir)


        button_div = ButtonRowWdg()
        inner.add(button_div)

        button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH)
        button_div.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_checkout_top");
            spt.panel.refresh(top)
            '''
        } )


        web = WebContainer.get_web()
        if web.use_applet():

            button = ButtonNewWdg(title="Check-out", icon=IconWdg.CHECK_OUT)
            button_div.add(button)

            button.add_behavior( {
                'type': 'click_up',
                'snapshot_codes': snapshot_codes,
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_checkout_top");
                var progress = top.getElement(".spt_checkout_progress");
                var message = top.getElement(".spt_checkout_message");
                var snapshot_codes = bvr.snapshot_codes;
                var num_snapshots = snapshot_codes.length;

                var server = TacticServerStub.get();

                for (var i = 0; i < snapshot_codes.length; i++) {
                    var snapshot_code = snapshot_codes[i];

                    var percent = parseInt( (i+1) / (num_snapshots-1) * 100);

#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:checkout_wdg.py

示例8: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def get_display(my):
        top = my.top
        my.set_as_panel(top)
        top.add_class("spt_delete_top")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_border()
        top.add_style("width: 300px")
        top.add_border()


        search_key = my.kwargs.get("search_key")
        search_keys = my.kwargs.get("search_keys")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            sobjects = [sobject]
            search_keys = [search_key]
        elif search_keys:
            sobjects = Search.get_by_search_keys(search_keys)
            sobject = sobjects[0]

        if not sobjects:
            msg =  "%s not found" %search_key
            return msg
        search_type = sobject.get_base_search_type()

        if search_type in ['sthpw/project', 'sthpw/search_object']:
            msg = 'You cannot delete these items with this tool'
            return msg


        my.search_keys = search_keys


        title = DivWdg()
        top.add(title)
        title.add_color("background", "background", -10)
        if my.search_keys:
            title.add("Delete %s Items" % len(my.search_keys))
        else:
            title.add("Delete Item [%s]" % (sobject.get_code()))
        title.add_style("font-size: 14px")
        title.add_style("font-weight: bold")
        title.add_style("padding: 10px")

        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")


        content.add("The item to be deleted has a number of dependencies as described below:<br/>", 'heading')

        # find all the relationships
        schema = Schema.get()
        related_types = schema.get_related_search_types(search_type, direction="children")
        parent_type = schema.get_parent_type(search_type)
        child_types = schema.get_child_types(search_type)


        # some special considerations
        # FIXME: this needs to be more automatic.  Should only be
        # deletable children (however, that will be defined)
        if search_type in ['sthpw/task','sthpw/note', 'sthpw/snapshot']:
            if "sthpw/project" in related_types:
                related_types.remove("sthpw/project")

            if "sthpw/login" in related_types:
                related_types.remove("sthpw/login")

            if "config/process" in related_types:
                related_types.remove("config/process")



        if parent_type in related_types:
            related_types.remove(parent_type)

        related_types.append('sthpw/note')
        related_types.append('sthpw/task')
        related_types.append('sthpw/snapshot')
        if 'sthpw/work_hour' not in related_types:
            related_types.append('sthpw/work_hour')
       
        items_div = DivWdg()
        content.add( items_div )
        items_div.add_style("padding: 10px")
        valid_related_ctr = 0
        for related_type in related_types:
            if related_type == "*":
                print "WARNING: related_type is *"
                continue
            if related_type == search_type:
                continue
            if related_type in ['sthpw/search_object','sthpw/search_type']:
                continue

            item_div = my.get_item_div(sobjects, related_type)
            if item_div:
                items_div.add(item_div)
                valid_related_ctr += 1
#.........这里部分代码省略.........
开发者ID:blezek,项目名称:TACTIC,代码行数:103,代码来源:delete_wdg.py

示例9: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def get_display(self):
        top = self.top
        self.set_as_panel(top)
        top.add_class("spt_delete_top")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_border()
        top.add_style("width: 400px")
        top.add_border()


        search_key = self.kwargs.get("search_key")
        search_keys = self.kwargs.get("search_keys")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            sobjects = [sobject]
            search_keys = [search_key]
        elif search_keys:
            sobjects = Search.get_by_search_keys(search_keys)
            sobject = sobjects[0]

        if not sobjects or not sobject:
            msg =  "%s not found" %search_key
            return msg
        search_type = sobject.get_base_search_type()

        if search_type in ['sthpw/project', 'sthpw/search_object']:
            msg = 'You cannot delete these items with this tool'
            return msg


        self.search_keys = search_keys


        title = DivWdg()
        top.add(title)

        icon = IconWdg("WARNING", IconWdg.WARNING)
        icon.add_style("float: left")
        title.add(icon)

        if len(self.search_keys) > 1:
            title.add("Delete %s Items" % len(self.search_keys))
        else:
            title.add("Delete Item [%s]" % (sobject.get_code()))
        title.add_style("font-size: 20px")
        title.add_style("font-weight: bold")
        title.add_style("padding: 10px")

        title.add("<hr/>")

        content = DivWdg()
        top.add(content)
        content.add_style("margin: 5px 10px 20px 10px")


        content.add("The item to be deleted has a number of dependencies as described below:<br/>", 'heading')

        # find all the relationships
        related_types = SearchType.get_related_types(search_type, direction='children') 
       
        items_div = DivWdg()
        content.add( items_div )
        items_div.add_style("padding: 10px")
        valid_related_ctr = 0
        for related_type in related_types:
            if related_type == "*":
                print("WARNING: related_type is *")
                continue
            if related_type == search_type:
                continue
            if related_type in ['sthpw/search_object','sthpw/search_type']:
                continue

            item_div = self.get_item_div(sobjects, related_type)
            if item_div:
                items_div.add(item_div)
                valid_related_ctr += 1


        

        if valid_related_ctr > 0:
            #icon = IconWdg("Note", "BS_NOTE")
            #icon.add_style("float: left")
            #content.add( icon )
            content.add("<div><b>By selecting the above, the corresponding related items will be deleted as well.</b></div>")
            content.add("<br/>"*2)
        else:
            # changed the heading to say no dependencies
            content.add("The item to be deleted has no dependencies.<br/>", 'heading')


        num_items = len(self.search_keys)
        if num_items == 1:
            verb = "is 1 item"
        else:
            verb = "are %s items" % num_items
        content.add("There %s to be deleted" % verb)
        content.add("<br/>"*2)
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:delete_wdg.py

示例10: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def execute(self):
        project_code = self.kwargs.get("project_code")
        transaction_code = self.kwargs.get("transaction_code")
        login = self.kwargs.get("login")

        session = self.kwargs.get("session")
        start_time = session.get("start_time")
        end_time = session.get("end_time")

        search_keys = session.get("search_keys")
        if search_keys != None:
            if search_keys == '':
                raise TacticException("No search keys passed in")
            search_keys = search_keys.split("|")
            if not search_keys:
                raise TacticException("No search keys passed in")

            transactions = Search.get_by_search_keys(search_keys)
            codes = [x.get_code() for x in transactions]
            assert len(search_keys) == len(codes)
            expr = '''@SOBJECT(sthpw/transaction_log['code','in','%s']['@ORDER_BY','code asc'])''' % ("|".join(codes))
        else:
            expr = '''@SOBJECT(sthpw/transaction_log['login','%s']['namespace','%s']['timestamp','&gt;','%s']['timestamp','&lt;','%s']['@ORDER_BY','code asc'])''' % (login, project_code, start_time, end_time)

        manifest_xml = '''
<manifest code='transaction_log' version='1'>
<sobject expression="%s" search_type="sthpw/transaction_log"/>
</manifest>
        ''' % (expr)


        plugin = SearchType.create("sthpw/plugin")
        plugin.set_value("code", "transaction_log")
        plugin.set_value("version", "1.0")

        creator = PluginCreator(manifest=manifest_xml, plugin=plugin)
        creator.execute()

        plugin_path = creator.get_plugin_path()

        plugin_dir = creator.get_plugin_dir()

        # find all the logs (again!!!)
        # FIXME: should get from plugin
        expr = expr.replace("&gt;", ">")
        expr = expr.replace("&lt;", "<")
        logs = Search.eval(expr)

        asset_dir = Environment.get_asset_dir()

        for log in logs:
            transaction_xml = log.get_xml_value("transaction").to_string()
            cmd = TransactionFilesCmd(transaction_xml=transaction_xml)
            paths = cmd.execute()
            for path in paths:
                rel_path = path.replace(asset_dir, "")
                rel_path = rel_path.lstrip("/")
                new_path = "%s/assets/%s" % (plugin_dir, rel_path)
                dirname = os.path.dirname(new_path)

                if not os.path.exists(dirname):
                    os.makedirs(dirname)

                print("adding: [%s]" % new_path)
                shutil.copy(path, new_path)
开发者ID:mincau,项目名称:TACTIC,代码行数:67,代码来源:run_transaction_cmd.py

示例11: preprocess

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def preprocess(my):
        my.max_value = 0
        my.min_value = 0
        my.steps = 0

        web = WebContainer.get_web()
        my.width = web.get_form_value("width")
        if not my.width:
            my.width = my.kwargs.get("width")


        my.chart_type = web.get_form_value("chart_type")
        if not my.chart_type:
            my.chart_type = my.kwargs.get("chart_type")
        if not my.chart_type:
            my.chart_type = 'bar'


        my.x_axis = web.get_form_value("x_axis")
        if not my.x_axis:
            my.x_axis = my.kwargs.get("x_axis")
        if not my.x_axis:
            my.x_axis = 'code'


        # FIXME: which should override???
        my.y_axis = web.get_form_values("y_axis")
        if not my.y_axis:
            my.y_axis = my.kwargs.get("y_axis")

        if my.y_axis:
            my.elements = my.y_axis
        else:
            my.elements = my.kwargs.get("elements")
            if not my.elements:
                my.elements = web.get_form_value("elements")

        if isinstance(my.elements,basestring):
            if my.elements:
                my.elements = my.elements.split('|')
            else:
                my.elements = []




        my.search_type = web.get_form_value("search_type")
        if not my.search_type:
            my.search_type = my.kwargs.get("search_type")


        my.search_keys = my.kwargs.get("search_keys")
        if my.search_type and my.search_type.startswith("@SOBJECT("):
            my.sobjects = Search.eval(my.search_type)
        elif my.search_keys:
            if isinstance(my.search_keys, basestring):
                my.search_keys = eval(my.search_keys)
            my.sobjects = Search.get_by_search_keys(my.search_keys)
        else:
            search = Search(my.search_type)
            search.add_limit(100)
            my.sobjects = search.get_sobjects()

        # get the definition
        sobjects = my.sobjects
        if sobjects:
            sobject = sobjects[0]
            search_type = sobject.get_search_type()
            view = 'definition'

            from pyasm.widget import WidgetConfigView
            my.config = WidgetConfigView.get_by_search_type(search_type, view)
        else:
            my.config = None


        my.widgets = {}
开发者ID:0-T-0,项目名称:TACTIC,代码行数:79,代码来源:bar_chart_wdg.py

示例12: _test_get_by_search_keys

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
 def _test_get_by_search_keys(my):
     search_keys = ['table/posts?project=mongodb&code=POSTS52086a28e138236a389e670e']
     sobjects = Search.get_by_search_keys(search_keys, keep_order=True)
     my.assertEquals( 1, len(sobjects) )
开发者ID:0-T-0,项目名称:TACTIC,代码行数:6,代码来源:mongodb_test.py

示例13: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def execute(my):
        assert my.search_type
        assert my.view
        assert my.file_path

        search = Search(my.search_type)
        if my.search_ids:
            search.add_enum_order_by("id", my.search_ids)
            search.add_filters("id", my.search_ids)
            sobjects = search.get_sobjects()
        elif my.search_keys:

            sobjects = Search.get_by_search_keys(my.search_keys, keep_order=True)
            """
            search_codes = [SearchKey.extract_code(i) for i in my.search_keys if SearchKey.extract_code(i) ]
            if search_codes:
                search.add_filters("code", search_codes)
            else:
                search_ids = [SearchKey.extract_id(i) for i in my.search_keys if SearchKey.extract_id(i) ]
                search.add_filters("id", search_ids)
            """
        else:
            sobjects = search.get_sobjects()

        from pyasm.widget import WidgetConfigView
        from pyasm.web import Widget
        config = WidgetConfigView.get_by_search_type(my.search_type, my.view)
        
        columns = []
        if my.column_names:
            columns = my.column_names
        # should allow exporting ids only
        """
        else:
            if not config:
                columns = search.get_columns()
            else:
                columns = config.get_element_names()
        """
        if my.include_id:
            columns.insert(0, "id")

        # create the csv file
        org_file = file(my.file_path, 'w')
        csvwriter = csv.writer(org_file, quoting=csv.QUOTE_NONNUMERIC)

        # write the titles
        csvwriter.writerow(columns)

        elements = my.get_elements(config, columns)
        display_option_dict = {}
        # this is for widgets that do preprocessing on all sobjects
        for idx, element in enumerate(elements):
            element.set_sobjects(sobjects)
            element.preprocess()
            display_options = config.get_display_options(columns[idx])
            display_option_dict[element] = display_options
            
        for idx, sobject in enumerate(sobjects):
            values = []
            
            for element in elements:
                
                element.set_current_index(idx)
                value = element.get_text_value()
                if isinstance(value, Widget):
                    value = value.get_buffer_display()
                elif isinstance(value, basestring):
                    if isinstance(value, unicode):
                        value = value.encode('UTF-8', 'ignore')
                else:
                    value = str(value)

                options = display_option_dict.get(element)
                if options.get('csv_force_string')=='true' and value:
                    value= '#FORCESTRING#%s'%value
                values.append( value )
            # write the values as list
            csvwriter.writerow(values)

        org_file.close()


        file2 = open(my.file_path, 'r')
        mod_file_path = '%s_mod' %my.file_path
        mod_file = open(mod_file_path, 'w')
        for line in file2:
            mod_line = re.sub(r'(\'|\"|)(#FORCESTRING#)', '=\\1', line)
            mod_file.write(mod_line)

        # new file
        file2.close()
        mod_file.close()

        #os.unlink(my.file_path)
        shutil.move(mod_file_path, my.file_path)
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:98,代码来源:csv_export_cmd.py

示例14: get_paths

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def get_paths(my, file_type='main'):

        # this is the selected one
        search_key = my.kwargs.get("search_key")
      
        search_keys = my.kwargs.get("search_keys")
        paths = my.kwargs.get("paths")

        if not paths:
            paths = []
        """
        if search_keys:
            sobjects = Search.get_by_search_keys(search_keys)
            snapshots = Snapshot.get_by_sobjects(sobjects, is_latest=True)
            file_objects = File.get_by_snapshots(snapshots, file_type='main')
            paths = [x.get_web_path() for x in file_objects]

            web_file_objects = File.get_by_snapshots(snapshots, file_type='web')
            web_paths = [x.get_web_path() for x in web_file_objects]
            #paths = web_paths

            for sobject, path in zip(sobjects, paths):
                my.sobject_data[path] = sobject
        """
        if search_keys:
            sobjects = Search.get_by_search_keys(search_keys, keep_order=True)

            # return_dict=True defaults to return the first of each snapshot list 
            # and so works well with is_latest=True
            if sobjects and sobjects[0].get_base_search_type() == "sthpw/snapshot":
                sobj_snapshot_dict = {}
                for sobject in sobjects:
                    tmp_search_key = sobject.get_search_key()
                    sobj_snapshot_dict[tmp_search_key] = sobject
                snapshots = sobjects

            else:
                sobj_snapshot_dict = Snapshot.get_by_sobjects(sobjects, is_latest=True, return_dict=True)

                snapshots = sobj_snapshot_dict.values()

            file_dict = Snapshot.get_files_dict_by_snapshots(snapshots, file_type=file_type)

            for sobject in sobjects:
                path = ''
                snapshot = sobj_snapshot_dict.get(sobject.get_search_key())
                # it is supposed to get one (latest), just a precaution
                if isinstance(snapshot, list):
                    snapshot = snapshot[0]
                if not snapshot:
                    continue

                file_list = file_dict.get(snapshot.get_code())
                if not file_list: 
                    continue
                
                for file_object in file_list:
                    path = file_object.get_web_path()
                    my.sobject_data[path] = sobject
                    paths.append(path)  
	            # set the current path the user clicks on
                if not my.curr_path and sobject.get_search_key() == search_key and file_type=='main':
                    my.curr_path = path
                        

        elif paths:
            return paths

        else:
            # TEST
            paths = [
                '/assets/test/store/The%20Boxter_v001.jpg',
                '/assets/test/store/Another%20one_v001.jpg',
                '/assets/test/store/Whatever_v001.jpg'
            ]

        return paths
开发者ID:nuxping,项目名称:TACTIC,代码行数:79,代码来源:gallery_wdg.py

示例15: get_paths

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_by_search_keys [as 别名]
    def get_paths(self, file_type='main'):

        # this is the selected one
        search_key = self.kwargs.get("search_key")
      
        search_keys = self.kwargs.get("search_keys")
        paths = self.kwargs.get("paths")

        if not paths:
            paths = []


        if search_keys:
            sobjects = Search.get_by_search_keys(search_keys, keep_order=True)

            # return_dict=True defaults to return the first of each snapshot list 
            # and so works well with is_latest=True
            if sobjects and sobjects[0].get_base_search_type() == "sthpw/snapshot":
                sobj_snapshot_dict = {}
                for sobject in sobjects:
                    tmp_search_key = sobject.get_search_key()
                    sobj_snapshot_dict[tmp_search_key] = sobject
                snapshots = sobjects

            else:
                sobj_snapshot_dict = Snapshot.get_by_sobjects(sobjects, is_latest=True, return_dict=True)

                snapshots = sobj_snapshot_dict.values()

            file_dict = Snapshot.get_files_dict_by_snapshots(snapshots, file_type=file_type)
            for sobject in sobjects:
                path = ''
                snapshot = sobj_snapshot_dict.get(sobject.get_search_key())
                # it is supposed to get one (latest), just a precaution
                if isinstance(snapshot, list):
                    snapshot = snapshot[0]
                if not snapshot:
                    continue

                file_list = file_dict.get(snapshot.get_code())
                if not file_list: 
                    paths.append("")
                    continue


               
                # NOTE: there should only be one file
                tmp_paths = []
                for file_object in file_list:
                    path = file_object.get_web_path()

                    if path.find("#") != -1:
                        expanded_paths = snapshot.get_expanded_web_paths()
                        path = "|".join(expanded_paths)

                    tmp_paths.append(path)  

                path = "|".join(tmp_paths)
                self.sobject_data[path] = sobject
                paths.append(path)

	            # set the current path the user clicks on
                if not self.curr_path and sobject.get_search_key() == search_key and file_type=='main':
                    self.curr_path = path
                        

        elif paths:
            return paths

        else:
            # TEST
            paths = [
                '/assets/test/store/The%20Boxter_v001.jpg',
                '/assets/test/store/Another%20one_v001.jpg',
                '/assets/test/store/Whatever_v001.jpg'
            ]

        """
        for index,path in enumerate(paths):
            path = urllib.pathname2url(path)
            paths[index] = path
        """

        return paths
开发者ID:mincau,项目名称:TACTIC,代码行数:86,代码来源:gallery_wdg.py


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