File: extractor.py

package info (click to toggle)
subversion 1.6.12dfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 48,292 kB
  • ctags: 47,714
  • sloc: ansic: 578,414; python: 77,551; sh: 13,100; ruby: 12,194; cpp: 10,097; java: 8,428; lisp: 7,702; perl: 7,320; makefile: 1,035; xml: 759; sql: 62
file content (64 lines) | stat: -rwxr-xr-x 2,099 bytes parent folder | download | duplicates (3)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
#
# extractor.py: extract function names from declarations in header files
#
# ====================================================================
# Copyright (c) 2000-2006, 2008 CollabNet.  All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.  The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://subversion.tigris.org/.
# ====================================================================
#

import os
import re
import string

#
# This parses the following two types of declarations:
#
#    void
#    svn_foo_bar (args)
# or
#    void svn_foo_bar (args)
#
_funcs = re.compile(r'^(?:(?:(?:\w+|\*) )+\*?)?((?:svn|apr)_[a-z_0-9]+)\s*\(', re.M)

def extract_funcs(fname):
  funcs = [ ]
  for name in _funcs.findall(open(fname).read()):
    if name not in _filter_names:
      funcs.append(name)
  return funcs

_filter_names = [
  'svn_boolean_t',  # svn_config_enumerator_t looks like (to our regex) a
                    # function declaration for svn_boolean_t

  # Not available on Windows
  'svn_auth_get_keychain_simple_provider',
  'svn_auth_get_keychain_ssl_client_cert_pw_provider',
  'svn_auth_get_gnome_keyring_simple_provider',
  'svn_auth_get_gnome_keyring_ssl_client_cert_pw_provider',
  'svn_auth_get_kwallet_simple_provider',
  'svn_auth_get_kwallet_ssl_client_cert_pw_provider',
  'svn_auth_gnome_keyring_version',
  'svn_auth_kwallet_version',
  ]

if __name__ == '__main__':
  # run the extractor over each file mentioned
  import sys
  print("EXPORTS")
  for fname in sys.argv[1:]:
    for func in extract_funcs(fname):
      print(func)
    if os.path.basename(fname) == 'svn_ctype.h':
      print('svn_ctype_table = svn_ctype_table_internal CONSTANT')