# HG changeset patch # User Arthur Lutz <arthur.lutz@logilab.fr> # Date 1475076398 -7200 # Wed Sep 28 17:26:38 2016 +0200 # Node ID 9387dfaca9ccd77e18de7a56b88dd42605d6c855 # Parent ab5d742735e51f518a0ae98bf5eba6758c4eaa3d [ccplugin] add --except-etypes option to skip a given type diff --git a/ccplugin.py b/ccplugin.py --- a/ccplugin.py +++ b/ccplugin.py @@ -42,6 +42,9 @@ ('etype', {'type': 'string', 'default': '', 'help': 'only index a given etype' '[default:all indexable types]'}), + ('except-etype', {'type': 'string', 'default': '', + 'help': 'all indexable types except given etype' + '[default:None]'}), ] def run(self, args): @@ -56,10 +59,12 @@ if self.config.etype: etypes = (self.config.etype,) else: - etypes = indexable_types(schema) + etypes = indexable_types(schema, + custom_skip_list=((self.config.except_etype,))) + assert self.config.except_etype not in etypes if self.config.debug and not self.config.etype: print(u'found indexable_types {}'.format( - ','.join(indexable_types(schema)))) + ','.join(etypes))) for _ in parallel_bulk(es, self.bulk_actions(etypes, cnx, diff --git a/es.py b/es.py --- a/es.py +++ b/es.py @@ -33,7 +33,7 @@ log = logging.getLogger(__name__) -def indexable_types(schema): +def indexable_types(schema, custom_skip_list=None): ''' introspect indexable types ''' @@ -42,6 +42,9 @@ return INDEXABLE_TYPES indexable_types = [] skip_list = ('TrInfo', 'EmailAddress') + if custom_skip_list: + skip_list = skip_list + custom_skip_list + print skip_list for eschema in schema.entities(): if eschema.type in skip_list: continue