def parse_resource(resource):
 error_msg = 'Resources should be defined as '
 "'/buckets/<bid>/collections/<cid>' or '<bid>/<cid>'. "
 'with valid collection and bucket ids.'
 from kinto.views import NameGenerator
 id_generator = NameGenerator()
 parts = resource.split('/')
 if (len(parts) == 2):
  (bucket, collection) = parts
 elif (len(parts) == 5):
  (_, _, bucket, _, collection) = parts
 else:
  raise ValueError(error_msg)
 if ((bucket == '') or (collection == '')):
  raise ValueError(error_msg)
 if ((not id_generator.match(bucket)) or (not id_generator.match(collection))):
  raise ValueError(error_msg)
 return {'bucket': bucket, 'collection': collection}

def parse_resource ( resource ) : error_msg = 'Resources should be defined as ' from kinto . views import NameGenerator id_generator = NameGenerator ( ) parts = resource . split ( '/' ) if ( len ( parts ) == 2 ) : ( bucket , collection ) = parts elif ( len ( parts ) == 5 ) : ( _ , _ , bucket , _ , collection ) = parts else : raise ValueError ( error_msg ) if ( ( bucket == '' ) or ( collection == '' ) ) : raise ValueError ( error_msg ) if ( ( not id_generator . match ( bucket ) ) or ( not id_generator . match ( collection ) ) ) : raise ValueError ( error_msg ) return { 'bucket' : bucket , 'collection' : collection }
extract the bucket_id and collection_id of the given resource .