Compatibility helper function to make __utils__ available on demand.
165643
def pack_dunder(name):
    '''
    
    '''
    # TODO: Deprecate starting with Beryllium

    mod = sys.modules[name]
    if not hasattr(mod, '__utils__'):
        setattr(mod, '__utils__', salt.loader.utils(mod.__opts__))
918841
def RetryOnUnavailable(func):
  """"""

  @functools.wraps(func)
  def Wrapper(*args, **kwargs):
    while True:
      try:
        response = func(*args, **kwargs)
      except (httpclient.HTTPException, socket.error, urlerror.URLError) as e:
        time.sleep(5)
        if (isinstance(e, urlerror.HTTPError)
            and e.getcode() == httpclient.SERVICE_UNAVAILABLE):
          continue
        elif isinstance(e, socket.timeout):
          continue
        raise
      else:
        if response.getcode() == httpclient.OK:
          return response
        else:
          raise StatusException(response)
  return Wrapper
105381
def pkg_available(pkg_name,required=False):
    ''''''
    if pkg_name in pkgs:
        return True
    if required:
        nl.notify('Error: could not find required analysis package %s' % pkg_name,level=nl.level.error)
    return False
1180205
def getavailable(self):
        """"""

        from importlib import import_module

        available = []

        for script in self.SCRIPTS:
            if have(script):
                available.append(script)

        for module in self.MODULES:
            try:
                import_module(module)
                available.append(module)
            except ImportError:
                pass

        return sorted(available)
758600
function load( available, toLoad ) {
    let loadList = available;
    if ('string' === typeof toLoad ) {
      loadList = [toLoad];
    }
    if (Array.isArray(toLoad)) {
      loadList = toLoad;
    }
    loadList.forEach(function( name ) {
      if ( available.indexOf(name) < 0 ) {
        return;
      }
      require('./'+name);
    });
  }
637922
def pull_dependencies(collector, image, **kwargs):
    """"""
    for dep in image.commands.dependent_images:
        kwargs["image"] = dep
        pull_arbitrary(collector, **kwargs)
9414
def grain_funcs(opts, proxy=None):
    '''
    
    '''
    ret = LazyLoader(
        _module_dirs(
            opts,
            'grains',
            'grain',
            ext_type_dirs='grains_dirs',
        ),
        opts,
        tag='grains',
    )
    ret.pack['__utils__'] = utils(opts, proxy=proxy)
    return ret
320602
def available(self, request, *args, **kwargs):
        
        packs = []
        for pack_name in get_available_pack_names():
            packs.append(pack_name)
        return Response(packs)
635122
def overrideable_partial(func, *args, **default_kwargs):
    
    import functools
    @functools.wraps(func)
    def partial_wrapper(*given_args, **given_kwargs):
        kwargs = default_kwargs.copy()
        kwargs.update(given_kwargs)
        return func(*(args + given_args), **kwargs)
    return partial_wrapper
5312
def _get_available(recommended=False, restart=False):
    '''
    
    '''
    cmd = ['softwareupdate', '--list']
    out = salt.utils.mac_utils.execute_return_result(cmd)

    # rexp parses lines that look like the following:
    #    * Safari6.1.2MountainLion-6.1.2
    #         Safari (6.1.2), 51679K [recommended]
    #    - iCal-1.0.2
    #         iCal, 1.0.2, 6520K
    rexp = re.compile('(?m)^   [*|-] '
                      r'([^ ].*)[\r\n].*\(([^\)]+)')

    if salt.utils.data.is_true(recommended):
        # rexp parses lines that look like the following:
        #    * Safari6.1.2MountainLion-6.1.2
        #         Safari (6.1.2), 51679K [recommended]
        rexp = re.compile('(?m)^   [*] '
                          r'([^ ].*)[\r\n].*\(([^\)]+)')

    keys = ['name', 'version']
    _get = lambda l, k: l[keys.index(k)]

    updates = rexp.findall(out)

    ret = {}
    for line in updates:
        name = _get(line, 'name')
        version_num = _get(line, 'version')
        ret[name] = version_num

    if not salt.utils.data.is_true(restart):
        return ret

    # rexp parses lines that look like the following:
    #    * Safari6.1.2MountainLion-6.1.2
    #         Safari (6.1.2), 51679K [recommended] [restart]
    rexp1 = re.compile('(?m)^   [*|-] '
                       r'([^ ].*)[\r\n].*restart*')

    restart_updates = rexp1.findall(out)
    ret_restart = {}
    for update in ret:
        if update in restart_updates:
            ret_restart[update] = ret[update]

    return ret_restart
113404
def install_handler!(opts={}, &block)
      stat = find_stat(opts, &block)
      raise NoAvailableHandler unless stat
      stat.install
    end
280362
def requires_libsodium(func):
    
    @wraps(func)
    def wrapper(*args, **kwargs):
        libsodium_check()
        return func(*args, **kwargs)

    return wrapper
530314
function getRequire(context, options, tag, type, resource) {
    const loaders = normalizeLoaders(options.map[type]);
    const selectLoader = require.resolve('./loader.js');
    const request = {
        tag,
        type,
        options
    };
    const url = loaderUtils.stringifyRequest(context, `!${loaders}!${selectLoader}?${JSON.stringify(request)}!${resource}`)
    const prefix = tag === 'script' ? 'module.exports = ' : 'const $style = ';
    return `${prefix}require(${url});\r\n`;
}
1236722
def avail_images(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The avail_images function must be called with '
            '-f or --function, or with the --list-images option'
        )

    ret = {}
    conn = get_conn(service='SoftLayer_Product_Package')
    for category in conn.getCategories(id=50):
        if category['categoryCode'] != 'os':
            continue
        for group in category['groups']:
            for price in group['prices']:
                ret[price['id']] = price['item'].copy()
                del ret[price['id']]['id']
    return ret
19281
def require_compatible_version(compatible_version, word="File"):
    """"""
    if isinstance(compatible_version, str):
        compatible_version = parse_version(compatible_version)
    elif not isinstance(compatible_version, Version):
        raise ValueError("Type of `compatible_version` not understood.")
    
    current_version = parse_version(CURRENT_VERSION)
    if current_version < compatible_version:
        raise VersionError("{0} written for version >= {1}, this is {2}.".format(
            word, str(compatible_version), CURRENT_VERSION
        ))
820327
def ui_func(cls, id_, name, function_type, avail_fn=always):
    """"""
    return cls(id_, name, 0, 0, function_type, FUNCTION_TYPES[function_type],
               avail_fn)
1322139
def require_content_types(*allowed_content_types):
    
    """
    def decorator(f):
        @wraps(f)
        def inner(*args, **kwargs):
            if request.mimetype not in allowed_content_types:
                raise InvalidContentType(allowed_content_types)
            return f(*args, **kwargs)
        return inner
    return decorator