
import os.path

from .settings import METADATA_PATH
from .utils import loads, dumps


def list_blobs():
    for id_ in os.listdir(METADATA_PATH):
        id_ = id_.replace('.json', '')
        meta = get_meta(id_)
        yield meta['info']['path']


def get_meta(id_):
    "Load metadata for the given id."
    filepath = os.path.join(METADATA_PATH, id_ + '.json')
    return loads(open(filepath, 'r').read())


def search_meta(term):
    "Search for a term in the metadata and return the corresponding ids"
    for id_ in os.listdir(METADATA_PATH):
        id_ = id_.replace('.json', '')
        meta = get_meta(id_)
        if term in dumps(meta):
            yield id_

@@ -93,17 +93,59 @@
 ist_
-blob
+id
 s():%0A
+    %22List all ids present in the metadata.%22%0A
     
@@ -182,37 +182,37 @@
 _PATH):%0A        
-id_ =
+yield
  id_.replace('.j
@@ -213,32 +213,115 @@
 ce('.json', '')%0A
+%0A%0Adef list_blobs():%0A    %22List all blobs by their path.%22%0A    for id_ in list_ids():%0A
         meta = g
@@ -647,73 +647,19 @@
  in 
-os.
 list
-dir(METADATA_PATH):%0A        id_ = id_.replace('.json', '')
+_ids():
 %0A   

Refactor add list_ids()