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


Python FlagFramework.splitpath方法代码示例

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


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

示例1: tree

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import splitpath [as 别名]
    def tree(self,tree_cb = None, pane_cb=None, branch = ('/'), layout="horizontal"):
        """ A Text tree implementation """
        query = self.defaults

        try:
            ## Get the right part:
            branch=FlagFramework.splitpath(query['open_tree'])
        except KeyError:
            branch=['']

        #Start building the tree using the branch.
        def draw_branch(depth,tree_array):
            #We search through all the items until we find the one
            #that matches the branch for this depth, then recurse into
            #it.
            branch_array=branch[:depth]
            path = FlagFramework.joinpath(branch[:depth])
            for k,v,t in tree_cb(path):
                if not k: continue
                if not t: continue
                tree_array.append((depth,k,v,t))

                try:
                    if k == branch[depth]:
                        #Recurse into the next level in the tree
                        draw_branch(depth+1,tree_array)
                except IndexError:
                    pass

        tree_array = []

        #The first item in the tree is the first one provided in branch
        if not branch[0]:
            tree_array.append((0,'/','/','branch'))
        else:
            tree_array.append((0,branch[0],branch[0],'branch'))

        #Build the tree_array
        draw_branch(1,tree_array)       

        left = self.__class__(self)
                        
        for depth,k,v,t in tree_array:
            icon = '-'
            if t=="branch":
                icon = '+'
            left.text(" "*depth + icon + v.__str__() + "\r\n")

        right = self.__class__(self)
        path = FlagFramework.joinpath(branch)
        pane_cb(path, right)

        self.row(left, right)
开发者ID:anarchivist,项目名称:pyflag,代码行数:55,代码来源:TEXTUI.py

示例2: tree_cb

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import splitpath [as 别名]
        def tree_cb(path):
            branch = FlagFramework.splitpath(path)
            
            node = get_node(branch)
            try:
                for field in node.list():
                    if field.startswith("_"): continue

                    child = getattr(node, field)
                    try:
                        yield  ( field, child.get_name(), 'branch')
                    except AttributeError:
                        yield  ( field, field, 'leaf')

            except AttributeError:
                pass
            
            return
开发者ID:anarchivist,项目名称:pyflag,代码行数:20,代码来源:PCAPFS.py

示例3: __init__

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import splitpath [as 别名]
    def __init__(self, case=None, table=None, id=None, path=None, **node):
        """ Retrieve or create the node with the id given.

        if id is given we retrieve said node, else we create a new
        node with fields as in the dictionary 'node'.
        """
        self.case = case
        self.table = table
        
        dbh = DB.DBO(self.case)
        if id!=None:
            dbh.execute("select * from %s where `%s`=%r",(self.table, self.key, id))
            self.row = dbh.fetch()
            if not self.row:
                raise IOError("Can not find node with id %s" % id)

            self.id = self.row[self.key]
        elif path!=None:
            parent = 0
            branches = FlagFramework.splitpath(path)
            if not branches:
                self.id = 0
                self.row = {self.parent_field: 0}
                return
            
            for name in branches:
                dbh.execute("select * from `%s` where `%s`=%r and `%s`=%r",
                            (self.table, self.parent_field,
                             parent, self.node_name, name))
                    
                self.row = dbh.fetch()
                if not self.row:
                    raise IOError("Can not find path element %s" % name)
                
                parent = self.row[self.key]

            self.id = self.row[self.key]
        else:
            self.id = self.new_node(node)
            self.row = node
开发者ID:anarchivist,项目名称:pyflag,代码行数:42,代码来源:TreeObj.py

示例4: pane_cb

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import splitpath [as 别名]
        def pane_cb(path,result):
            branch = FlagFramework.splitpath(path)
            
            node = get_node(branch)

            result.heading("Packet %s" % id)
            data = dissected_packet.serialise()
            
            h=FlagFramework.HexDump(data, result)
            try:
                result.text("%s" % node.get_name(), font='bold')
                result.text('',style='black', font='normal')
                start,length = node.get_range()
                
            except AttributeError:
                result.text("%s\n" % node, style='red', wrap='full', font='typewriter', sanitise='full')
                result.text('',style='black', font='normal')
                node = get_node(branch[:-1])
                start,length = node.get_range(branch[-1])

            h.dump(highlight=[[start,length,'highlight'],])

            return
开发者ID:anarchivist,项目名称:pyflag,代码行数:25,代码来源:PCAPFS.py

示例5: tree

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import splitpath [as 别名]
    def tree(self, tree_cb = None, pane_cb=None, branch = None, layout=None):
        """ A tree widget.

        This implementation uses javascript/iframes extensively.
        """            
        id = self.get_unique_id()

        def right(query,result):
            result.decoration = "raw"
            result.content_type = "text/html"
            
            try:
                path=FlagFramework.normpath(query['open_tree'])
            except KeyError:
                path='/'
                
            pane_cb(path,result)

        def tree(query,result):
            result.decoration = "raw"
            result.content_type = "text/html"

            ## I think this is secure enough??? This should really be
            ## json.parse but do we need to pull in a whole module
            ## just for this???
            data = eval(query['data'],{'__builtins__':None, 'true':True, 'false':False})
            path=FlagFramework.normpath(data['node']['objectId'])

            r=[]
            for x in tree_cb(path):
                if not x[0] or len(x[0])==0: continue
                
                tmp = dict(title = x[0], objectId="/%s/%s" % (path,x[1]))
                if x[2]=='branch':
                    tmp['isFolder']='true'
                else:
                    tmp['isFolder']='false'
                r.append(tmp)

            result.result=r
         
        t=self.store_callback(tree)
        r=self.store_callback(right)
        query = self.defaults.clone()

        ## Calculate the default tree structure which is obtained from query['open_tree']
        try:
            branch = FlagFramework.splitpath(self.defaults['open_tree'])
        except KeyError:
            branch = ['']

        def do_node(depth,path):
            if depth>=len(branch): return ''
            
            result=''
            for x in tree_cb('/'+'/'.join(branch[:depth])):
                if len(x[0])==0: continue

                if not x[1]: continue

                if x[2]=='branch':
                    isFolder='true'
                else:
                    isFolder='false'

                children=''
                opened='0'
                if x[1]==branch[depth]:
                    children = do_node(depth+1,path+'/'+branch[depth])
                    opened='1'
                    
                result+='<div dojoType="TreeNode" isFolder="%s" title="%s" objectId="%s" expandlevel="%s" >%s</div>' % (isFolder,x[0],'/'.join((path,x[1])),opened,children)
                
            return result

        tree_nodes='<div dojoType="TreeNode" isFolder="true" title="/" objectId="/" expandlevel="1">%s</div>' % do_node(0,'')

        ## Calculate the initial contents of the right pane:
        right_ui = self.__class__(self)
        right(query,right_ui)
        
        del query['open_tree']

        self.result+="""
        <div dojoType="SplitContainer"
	orientation="horizontal"
	sizerWidth="5"
	activeSizing="0"
        style="border: 0px ; width: 100%%; height: 100%%; overflow: hidden;"
        >
        <div dojoType="ContentPane"
        cacheContent="false" 
        layoutAlign="left"
        id="treepane%(id)s"
        widgetId="treepane%(id)s"
        right_cb="%(r)s"
        sizeMin="20" sizeShare="80"
        style="border: 0px ; width: 25%%; min-height: 100%%; overflow: auto;"
        executeScripts="true">

#.........这里部分代码省略.........
开发者ID:anarchivist,项目名称:pyflag,代码行数:103,代码来源:AJAXUI.py


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