File: ceres-tree-find

package info (click to toggle)
python-ceres 0.10.0~git20130913-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 200 kB
  • ctags: 232
  • sloc: python: 1,156; makefile: 126
file content (28 lines) | stat: -rwxr-xr-x 678 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python

import sys
from optparse import OptionParser
from ceres import CeresTree


parser = OptionParser(usage='''%prog [options] <path/to/tree/root/> <metric-pattern>''')
parser.add_option('--fromtime', default=None, type='int')
parser.add_option('--untiltime', default=None, type='int')
parser.add_option('--fspath', action='store_true')

options, args = parser.parse_args()

if len(args) < 2:
  parser.print_usage()
  sys.exit(1)


root_dir = args[0]
pattern = args[1]
tree = CeresTree(root_dir)

for node in tree.find(pattern, fromTime=options.fromtime, untilTime=options.untiltime):
  if options.fspath:
    print node.fsPath
  else:
    print node.nodePath