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


Python Tree.fill方法代码示例

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


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

示例1: test_fill

# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import fill [as 别名]
 def test_fill(self):
     fi = TFile('tree.root','RECREATE')
     tr = Tree('test_tree', 'A test tree')
     tr.var('a')
     tr.var('b')
     tr.fill('a', 3)
     tr.fill('a', 4)
     tr.fill('b', 5)
     tr.tree.Fill()
     fi.Write()
     fi.Close()
开发者ID:HEP-FCC,项目名称:heppy,代码行数:13,代码来源:test_tree.py

示例2: test_cwn

# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import fill [as 别名]
 def test_cwn(self):
     fi = TFile('tree2.root','RECREATE')
     tr = Tree('test_tree', 'A test tree')
     tr.var('nvals', the_type=int)
     tr.vector('x', 'nvals', 20)
     tr.fill('nvals', 10)
     tr.vfill('x', range(10))
     tr.tree.Fill()
     tr.reset()
     tr.fill('nvals', 5)
     tr.vfill('x', range(5))
     tr.tree.Fill()        
     fi.Write()
     fi.Close()
开发者ID:HEP-FCC,项目名称:heppy,代码行数:16,代码来源:test_tree.py

示例3: run

# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import fill [as 别名]
    def run(self, log):
        if not self.check_path(self.source):
            log.emit("Source directory {} not available, or check permissions!".format(self.source), self.verbose, "error")
            print("Error: Check sincsopht.log")
            sys.exit()
        if not self.check_path(self.target):
            log.emit("Target directory {} not available, or check permissions!".format(self.target), self.verbose, "error")
            print("Error: Check sincsopht.log")
            sys.exit()

        Source = Tree(self.source)
# initialise the tree object, i.e. generate a tree with as much levels as required (as acquired the treestatistics)
# and set the correct size of each level (attribute levels), i.e. the number of the directories of each
# level (of type Directory)
        Target = Tree(self.target)

# The fill methods runs through the directory tree and establishes following data model:
# tree object, hier the instance source, which includes
# list of level objects. A level object includes all directory objects of same tree level.
# A directory object contains the own local path (important to be local) and a list of all file objects in this directory
# The directory object doesn't need to know about the own subdirectories thanks to the level concept
# The file object contains the own name and the os file attributes to be compared
#
# Level 0                             Root
#                                  /     \
# Level 1                         foo     bar
#                               /  \     /  \
# Level 2                      bla  blu  pip  pap

        Source.fill()
        Target.fill()
        Source.Compare_with(Target)


#The synchronisation is performed in two-way mode.
#Way 1, Source to Target: Run through levels (source and target in parallel). Run through directories of each level.
#1. If a directory on source is not available on target, copy source directory and all included files to target.
#2. If a directory on source is available on target, the included files are checked.
#3. If file on source is not available on target, copy file from source to target.
#4. if file on source is available on target:
#4.1 if source file is newer than target one, source file is copied overriding the target
#4.2 if source file is older than target one
#4.2.1 if --bidirectional, target file is copied overriding source file
#4.2.2 if not --bidirectional
#4.2.2.1 If --force (the older) source file is copied overriding the (newer) target and log a warning
#4.2.2.2 If not --force output an information and pass
#
#Way 2, Target to Source: Run again through levels (source and target in parallel). Run through directories of each level.
#5. If a directory on target is not available on source
#5.1 If --delete delete directory including all included files (and subdirectories) on target
#5.2 If --bidirectional then copy target directory to source including all files and subdirectories
#5.3 If not --delete and not --bidirectional output info and pass
#6. If a directory on target is available on source, the included files are checked.
#7. If file on target is not available on source
#7.1 If --delete delete file on target
#7.2 If --bidirectional copy target file to source
#7.3 If not --delete and not --bidirectional output info and pass
#8. if file on target is available on source: this case is covered by Way 1 (no coding required).

        Source.sync_with(Target, self, log)
        print("Success: Check sincsopht.log")
        log.emit("Synchronisation Successful!", self.verbose, "success")
开发者ID:ahoer,项目名称:sincsopht,代码行数:64,代码来源:systemdata.py


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