When compiling SQLite, enable the SQLITE_OMIT_WAL compile-time option.
[svn/apache.git] / tools / examples / dumpprops.py
blob09c5e6ba5f718d981c8083f1ce22889e027f2a18
1 #!/usr/bin/env python
4 # Licensed to the Apache Software Foundation (ASF) under one
5 # or more contributor license agreements. See the NOTICE file
6 # distributed with this work for additional information
7 # regarding copyright ownership. The ASF licenses this file
8 # to you under the Apache License, Version 2.0 (the
9 # "License"); you may not use this file except in compliance
10 # with the License. You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing,
15 # software distributed under the License is distributed on an
16 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 # KIND, either express or implied. See the License for the
18 # specific language governing permissions and limitations
19 # under the License.
23 # USAGE: dumprops.py [-r REV] repos-path [file]
25 # dump out the properties on a given path (recursively if given a dir)
28 import sys
29 import os
30 import getopt
31 try:
32 my_getopt = getopt.gnu_getopt
33 except AttributeError:
34 my_getopt = getopt.getopt
35 import pprint
37 from svn import fs, core, repos
40 def dumpprops(path, filename='', rev=None):
41 path = core.svn_path_canonicalize(path)
42 repos_ptr = repos.open(path)
43 fsob = repos.fs(repos_ptr)
45 if rev is None:
46 rev = fs.youngest_rev(fsob)
48 root = fs.revision_root(fsob, rev)
49 print_props(root, filename)
50 if fs.is_dir(root, filename):
51 walk_tree(root, filename)
53 def print_props(root, path):
54 raw_props = fs.node_proplist(root, path)
55 # need to massage some buffers into strings for printing
56 props = { }
57 for key, value in raw_props.items():
58 props[key] = str(value)
60 print('--- %s' % path)
61 pprint.pprint(props)
63 def walk_tree(root, path):
64 for name in fs.dir_entries(root, path).keys():
65 full = path + '/' + name
66 print_props(root, full)
67 if fs.is_dir(root, full):
68 walk_tree(root, full)
70 def usage():
71 print("USAGE: dumpprops.py [-r REV] repos-path [file]")
72 sys.exit(1)
74 def main():
75 opts, args = my_getopt(sys.argv[1:], 'r:')
76 rev = None
77 for name, value in opts:
78 if name == '-r':
79 rev = int(value)
80 if len(args) == 2:
81 dumpprops(args[0], args[1], rev)
82 elif len(args) == 1:
83 dumpprops(args[0], "", rev)
84 else:
85 usage()
87 if __name__ == '__main__':
88 main()