Skip to content

Instantly share code, notes, and snippets.

@twobraids
Created July 15, 2015 21:03
Show Gist options
  • Save twobraids/3bd2ea5e127b6f64d7d8 to your computer and use it in GitHub Desktop.
Save twobraids/3bd2ea5e127b6f64d7d8 to your computer and use it in GitHub Desktop.
sample code using socorro that will take a old signture and remove templates and arguments to make a new signature
socorroᛤ ./scripts/sigtool.py --help
usage:
./scripts/sigtool.py [OPTIONS]...
[ signature ]
OPTIONS:
--admin.conf
the pathname of the config file (path/filename)
--admin.dump_conf
a pathname to which to write the current config
(default: )
--admin.expose_secrets
should options marked secret get written out or hidden?
(default: False)
--admin.print_conf
write current config to stdout (json, ini, conf)
--admin.strict
mismatched options generate exceptions rather than just warnings
(default: False)
--help
print this
--signature
the signature to translate
(default: )
socorroᛤ ./scripts/sigtool.py "@0xb6f11e3c | some_func<int, foo<unsigned longbottom>>() | aont(onth()) | operator()(ortho)"
@0xb6f11e3c | some_func<T> | aont | operator()
#!/usr/bin/env python
from configman import configuration, Namespace
from configman.dotdict import DotDict
from socorro.processor.signature_utilities import CSignatureToolBase
required_config = Namespace()
required_config.add_option(
"signature",
default='',
doc='the signature to translate',
is_argument=True
)
config = configuration(required_config)
config.collapse_arguments = True
ct = CSignatureToolBase(config)
# template section
signature_with_no_templates = ct._collapse(
config.signature,
open_string='<',
replacement_open_string='',
close_string='>',
replacement_close_string='<T>',
)
# argument section
signature_with_no_arguments = ct._collapse(
signature_with_no_templates,
open_string='(',
replacement_open_string='',
close_string=')',
replacement_close_string='',
exception_substring_list=(
'operator',
'anonymous namespace'
)
)
print signature_with_no_arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment