source: graphvizplugin/tags/0.11-0.7.5/examples/load_examples.py

Last change on this file was 4396, checked in by Christian Boos, 15 years ago

GraphvizPlugin: make the load_examples.py script 0.11 compatible (and a bit more efficient)

  • Property svn:executable set to *
  • Property svn:keywords set to Id HeadURL LastChangedRevision
File size: 821 bytes
Line 
1#! /usr/bin/env python
2
3
4import sys
5import os
6from trac.admin.console import TracAdmin
7
8
9def main(trac_env, examples_dir='.'):
10    loaded = False
11    admin = TracAdmin()
12    admin.env_set(trac_env)
13    for file in os.listdir(examples_dir):
14        if 'GraphvizExamples' in file:
15            admin._do_wiki_import(os.path.join(examples_dir, file), 
16                                  file.replace('%2F', '/'))
17            loaded = True
18
19    if not loaded:
20        print 'The %(examples_dir)s does not contain any GrapgvizExamples files.' % locals()
21
22
23if __name__ == '__main__':
24    argv_len = len(sys.argv)
25    if argv_len == 2:
26        main(sys.argv[1])
27    elif argv_len == 3:
28        main(sys.argv[1], sys.argv[2])
29    else:
30        print 'usage: load_examples.py trac_env_path [examples_directory]'
31        sys.exit(1)
Note: See TracBrowser for help on using the repository browser.