sregistry/utils/recipes.py
def find_folder_recipes(base_folder,
                        pattern="Singularity",
                        manifest=None,
                        base=None):

    '''find folder recipes will find recipes based on a particular pattern.
       
       Parameters
       ==========
       base_folder: the base folder to recursively walk
       pattern: a default pattern to search for
       manifest: an already started manifest
       base: if defined, consider folders under this level recursively.
       
    '''

    # The user is not appending to an existing manifest
    if manifest is None:
        manifest = dict()

    for root, dirnames, filenames in os.walk(base_folder):

        for filename in fnmatch.filter(filenames, pattern):

            container_path = os.path.join(root, filename)
            if base is not None:
                container_base = container_path.replace(base,'').strip('/')
                collection = container_base.split('/')[0]
                recipe = os.path.basename(container_base)
                container_uri = "%s/%s" %(collection,recipe)
            else:
                container_uri = '/'.join(container_path.strip('/').split('/')[-2:])

            add_container = True

            # Add the most recently updated container
            if container_uri in manifest:
                if manifest[container_uri]['modified'] > os.path.getmtime(container_path):
                    add_container = False

            if add_container:
                manifest[container_uri] = {'path': os.path.abspath(container_path),
                                           'modified':os.path.getmtime(container_path)}

    return manifest
def find_folder_recipes(base_folder,
                        pattern="Singularity",
                        manifest=None,
                        base=None):

    '''find folder recipes will find recipes based on a particular pattern.
       
       Parameters
       ==========
       base_folder: the base folder to recursively walk
       pattern: a default pattern to search for
       manifest: an already started manifest
       base: if defined, consider folders under this level recursively.
       
    '''

    # The user is not appending to an existing manifest
    if manifest is None:
        manifest = dict()

    for root, dirnames, filenames in os.walk(base_folder):

        for filename in fnmatch.filter(filenames, pattern):

            container_path = os.path.join(root, filename)
            if base is not None:
                container_base = container_path.replace(base,'').strip('/')
                collection = container_base.split('/')[0]
                recipe = os.path.basename(container_base)
                container_uri = "%s/%s" %(collection,recipe)
            else:
                container_uri = '/'.join(container_path.strip('/').split('/')[-2:])

            add_container = True

            # Add the most recently updated container
            if container_uri in manifest:
                if manifest[container_uri]['modified'] > os.path.getmtime(container_path):
                    add_container = False

            if add_container:
                manifest[container_uri] = {'path': os.path.abspath(container_path),
                                           'modified':os.path.getmtime(container_path)}

    return manifest
def find_folder_recipes ( base_folder , pattern = "Singularity" , manifest = None , base = None ) : # The user is not appending to an existing manifest if manifest is None : manifest = dict ( ) for root , dirnames , filenames in os . walk ( base_folder ) : for filename in fnmatch . filter ( filenames , pattern ) : container_path = os . path . join ( root , filename ) if base is not None : container_base = container_path . replace ( base , '' ) . strip ( '/' ) collection = container_base . split ( '/' ) [ 0 ] recipe = os . path . basename ( container_base ) container_uri = "%s/%s" % ( collection , recipe ) else : container_uri = '/' . join ( container_path . strip ( '/' ) . split ( '/' ) [ - 2 : ] ) add_container = True # Add the most recently updated container if container_uri in manifest : if manifest [ container_uri ] [ 'modified' ] > os . path . getmtime ( container_path ) : add_container = False if add_container : manifest [ container_uri ] = { 'path' : os . path . abspath ( container_path ) , 'modified' : os . path . getmtime ( container_path ) } return manifest
find folder recipes will find recipes based on a particular pattern.
       
       Parameters
       ==========
       base_folder: the base folder to recursively walk
       pattern: a default pattern to search for
       manifest: an already started manifest
       base: if defined, consider folders under this level recursively.
find folder recipes will find recipes based on a particular pattern . Parameters ========== base_folder : the base folder to recursively walk pattern : a default pattern to search for manifest : an already started manifest base : if defined consider folders under this level recursively .