Skip to content

Instantly share code, notes, and snippets.

@schwehr
Last active August 21, 2016 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schwehr/f16520a0c55d17444da6f0fe68d2a5e8 to your computer and use it in GitHub Desktop.
Save schwehr/f16520a0c55d17444da6f0fe68d2a5e8 to your computer and use it in GitHub Desktop.
Find constructor implementations in GDAL. Does not find ctors embedded in the actual class.
#!/usr/bin/env python
# Look for ClassName::ClassName matches.
import glob
import re
import sys
files = sorted(glob.glob('*/*.cpp'))
CTOR_RE = re.compile('(?P<name>[a-zA-Z][_a-zA-Z0-9]+)::(?P=name)')
skips = (
'arcobjects',
'carto/',
'cloudant',
'db2',
'mongodb',
'dwg',
'filegdb/'
'fme/',
'grass/',
'idb',
'ingress',
'mdb/',
'mssqlspatial',
'oci',
'sde',
'sosi',
)
for filename in files:
do_skip = False
for skip in skips:
if skip in filename:
do_skip = True
break
if do_skip:
continue
for line_num, line in enumerate(open(filename)):
search = CTOR_RE.search(line)
if search is None:
continue
print '%s:%s:%s' % (filename, line_num + 1, line.rstrip() )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment