<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> import json <EOL> from django . core . management . base import NoArgsCommand <EOL> from redis . exceptions import ResponseError <EOL> from redis_metrics . utils import get_r <EOL> class Command ( NoArgsCommand ) : <EOL> help = "<STR_LIT>" <EOL> def handle_noargs ( self , * args , ** options ) : <EOL> r = get_r ( ) <EOL> try : <EOL> keys = r . r . smembers ( r . _metric_slugs_key ) <EOL> slugs = set ( s . split ( "<STR_LIT::>" ) [ <NUM_LIT:1> ] for s in keys ) <EOL> r . r . srem ( r . _metric_slugs_key , * keys ) <EOL> r . r . sadd ( r . _metric_slugs_key , * slugs ) <EOL> p = "<STR_LIT>" <EOL> self . stdout . write ( p . format ( len ( keys ) , len ( slugs ) ) ) <EOL> except ( IndexError , ResponseError ) : <EOL> pass <EOL> try : <EOL> keys = r . r . smembers ( r . _gauge_slugs_key ) <EOL> slugs = set ( s . split ( "<STR_LIT::>" ) [ <NUM_LIT:1> ] for s in keys ) <EOL> r . r . srem ( r . _gauge_slugs_key , * keys ) <EOL> r . r . sadd ( r . _gauge_slugs_key , * slugs ) <EOL> p = "<STR_LIT>" <EOL> self . stdout . write ( p . format ( len ( keys ) , len ( slugs ) ) ) <EOL> except ( IndexError , ResponseError ) : <EOL> pass <EOL> i = <NUM_LIT:0> <EOL> categories = r . categories ( ) <EOL> for category in categories : <EOL> try : <EOL> k = r . _category_key ( category ) <EOL> data = r . r . get ( k ) <EOL> if data : <EOL> data = json . loads ( data ) <EOL> r . r . delete ( k ) <EOL> r . r . sadd ( k , * set ( data ) ) <EOL> i += <NUM_LIT:1> <EOL> except ResponseError : <EOL> pass <EOL> if i > <NUM_LIT:0> : <EOL> p = "<STR_LIT>" <EOL> self . stdout . write ( p . format ( i ) ) </s>
