ro and rw {localdir: binddir} dicts to docker-py's
    {localdir: {'bind': binddir, 'ro': T/F}} binds dicts
175038
def ro_rw_to_binds(ro, rw):
    
    out = {}
    if ro:
        for localdir, binddir in ro.iteritems():
            out[localdir] = {'bind': binddir, 'ro': True}
    if rw:
        for localdir, binddir in rw.iteritems():
            out[localdir] = {'bind': binddir, 'ro': False}
    return out
232507
def binds(val, **kwargs):  # pylint: disable=unused-argument
    '''
    
    '''
    if not isinstance(val, dict):
        if not isinstance(val, list):
            try:
                val = helpers.split(val)
            except AttributeError:
                raise SaltInvocationError(
                    '\'{0}\' is not a dictionary or list of bind '
                    'definitions'.format(val)
                )
    return val
438685
def _todict(cls):
        
        return dict((getattr(cls, attr), attr) for attr in dir(cls) if not attr.startswith('_'))
548560
function getDockerUid(bindPath) {
  const options = [
    'run',
    '--rm',
    '-v',
    `${bindPath}:/test`,
    'alpine',
    'stat',
    '-c',
    '%u',
    '/bin/sh'
  ];
  const ps = dockerCommand(options);
  return ps.stdout.trim();
}
1171754
def get(dir = Dir.pwd, type = :local, options = {})
      conffile = config_file(dir, type, options)
      res = {}
      res = load_config( conffile ) if File.exist?( conffile )
      res
    end
756803
def __load_docker_compose(path):
    '''
    
    '''
    file_path = __get_docker_file_path(path)
    if file_path is None:
        msg = 'Could not find docker-compose file at {0}'.format(path)
        return None, __standardize_result(False, msg,
                                          None, None)
    if not os.path.isfile(file_path):
        return None, __standardize_result(False,
                                    'Path {} is not present'.format(file_path),
                                    None, None)
    try:
        with salt.utils.files.fopen(file_path, 'r') as fl:
            loaded = yaml.load(fl)
    except EnvironmentError:
        return None, __standardize_result(False,
                                    'Could not read {0}'.format(file_path),
                                    None, None)
    except yaml.YAMLError as yerr:
        msg = 'Could not parse {0} {1}'.format(file_path, yerr)
        return None, __standardize_result(False, msg,
                                    None, None)
    if not loaded:
        msg = 'Got empty compose file at {0}'.format(file_path)
        return None, __standardize_result(False, msg,
                                          None, None)
    if 'services' not in loaded:
        loaded['services'] = {}
    result = {
         'compose_content': loaded,
         'file_name': os.path.basename(file_path)
    }
    return result, None
75464
def import_directory(self, datadir):
        

        def json_stream():
            # load all json, mapped by json_id
            for fname in glob.glob(os.path.join(datadir, self._type + '_*.json')):
                with open(fname) as f:
                    yield json.load(f)

        return self.import_data(json_stream())
235088
def __get_docker_file_path(path):
    '''
    
    '''
    if os.path.isfile(path):
        return path
    for dc_filename in DEFAULT_DC_FILENAMES:
        file_path = os.path.join(path, dc_filename)
        if os.path.isfile(file_path):
            return file_path
812238
def merge_resources(args):
    
    docker_config = _get_docker_config()
    if not docker_config:
        return args
    else:
        def _update_resources(config):
            config["resources"] = _merge_system_configs(config, docker_config)["resources"]
            return config
        return _update_config(args, _update_resources, allow_missing=True)
34849
def handle_basic_container_args(options, parser=None):
    
    dir_modes = {}
    error_fn = parser.error if parser else sys.exit

    def handle_dir_mode(path, mode):
        path = os.path.abspath(path)
        if not os.path.isdir(path):
            error_fn(
                "Cannot specify directory mode for '{}' because it does not exist or is no directory."
                .format(path))
        if path in dir_modes:
            error_fn("Cannot specify multiple directory modes for '{}'.".format(path))
        dir_modes[path] = mode

    for path in options.hidden_dir:
        handle_dir_mode(path, DIR_HIDDEN)
    for path in options.read_only_dir:
        handle_dir_mode(path, DIR_READ_ONLY)
    for path in options.overlay_dir:
        handle_dir_mode(path, DIR_OVERLAY)
    for path in options.full_access_dir:
        handle_dir_mode(path, DIR_FULL_ACCESS)

    if options.keep_tmp:
        if "/tmp" in dir_modes and not dir_modes["/tmp"] == DIR_FULL_ACCESS:
            error_fn("Cannot specify both --keep-tmp and --hidden-dir /tmp.")
        dir_modes["/tmp"] = DIR_FULL_ACCESS
    elif not "/tmp" in dir_modes:
        dir_modes["/tmp"] = DIR_HIDDEN

    if not "/" in dir_modes:
        dir_modes["/"] = DIR_OVERLAY
    if not "/run" in dir_modes:
        dir_modes["/run"] = DIR_HIDDEN

    if options.container_system_config:
        if options.network_access:
            logging.warning("The container configuration disables DNS, "
                "host lookups will fail despite --network-access. "
                "Consider using --keep-system-config.")
    else:
        # /etc/resolv.conf is necessary for DNS lookups and on many systems is a symlink
        # to either /run/resolvconf/resolv.conf or /run/systemd/resolve/sub-resolve.conf,
        # so we keep that directory accessible as well.
        if not "/run/resolvconf" in dir_modes and os.path.isdir("/run/resolvconf"):
            dir_modes["/run/resolvconf"] = DIR_READ_ONLY
        if not "/run/systemd/resolve" in dir_modes and os.path.isdir("/run/systemd/resolve"):
            dir_modes["/run/systemd/resolve"] = DIR_READ_ONLY

    return {
        'network_access': options.network_access,
        'container_tmpfs': options.tmpfs,
        'container_system_config': options.container_system_config,
        'dir_modes': dir_modes,
        }
471992
def local(self):
        
        assert self.name in CFG["container"]["images"].value
        tmp_dir = local.path(str(CFG["tmp_dir"]))
        target_dir = tmp_dir / self.name

        if not target_dir.exists() or not is_valid(self, target_dir):
            unpack(self, target_dir)

        return target_dir
87525
def mktar_from_dockerfile(fileobject: BinaryIO) -> IO:
    

    f = tempfile.NamedTemporaryFile()
    t = tarfile.open(mode="w:gz", fileobj=f)

    if isinstance(fileobject, BytesIO):
        dfinfo = tarfile.TarInfo("Dockerfile")
        dfinfo.size = len(fileobject.getvalue())
        fileobject.seek(0)
    else:
        dfinfo = t.gettarinfo(fileobj=fileobject, arcname="Dockerfile")

    t.addfile(dfinfo, fileobject)
    t.close()
    f.seek(0)
    return f
508659
def rrmdir(directory):
    
    for root, dirs, files in os.walk(directory, topdown=False):
        for name in files:
            os.remove(os.path.join(root, name))
        for name in dirs:
            os.rmdir(os.path.join(root, name))
    os.rmdir(directory)
558762
def localpath(*args):
    """"""
    plist = [ROOT] + list(args)
    return os.path.abspath(pjoin(*plist))
370242
function tryBindPath(serverless, bindPath, testFile) {
  const options = [
    'run',
    '--rm',
    '-v',
    `${bindPath}:/test`,
    'alpine',
    'ls',
    `/test/${testFile}`
  ];
  try {
    const ps = dockerCommand(options);
    if (process.env.SLS_DEBUG) {
      serverless.cli.log(`Trying bindPath ${bindPath} (${options})`);
      serverless.cli.log(ps.stdout.trim());
    }
    return ps.stdout.trim() === `/test/${testFile}`;
  } catch (err) {
    return false;
  }
}
857535
function (res, args) {
            var newValue = args.moduleDescription.container[args.moduleDescription.property];
            var boundTo = args.boundTo;
            if (this._utils.resolvePath(boundTo.path, boundTo.storage) == null) {
                this._pathUtils.setValue(boundTo.storage, boundTo.path, null);
            }
            var dataDesc = this._pathUtils.describe(boundTo.storage, boundTo.path);
            this.json.setValue(dataDesc.container, dataDesc.property, newValue);
        }
12192
def mkdirs(remote_dir, use_sudo=False):
    
    func = use_sudo and sudo or run
    result = func(' '.join(['mkdir -pv',remote_dir])).split('\n')
    #extract dir list from ["mkdir: created directory `example.com/some/dir'"]
    if result[0]: result = [dir.split(' ')[3][1:-1] for dir in result if dir]
    return result