Get the conda prefix for a particular user (~/anaconda)
    If user is None it defaults to /opt/anaconda
499947
def conda_prefix(user=None):
    
    if user == 'root':
        return __salt__['grains.get']('conda:prefix', default='/opt/anaconda')
    else:
        if user is None:
            user = __salt__['pillar.get']('system:user', 'ubuntu')
        for u in pwd.getpwall():
            if u.pw_name == user:
                return os.path.join(u.pw_dir, 'anaconda')
470452
def mktns(self, root):
        """"""
        tns = root.get("targetNamespace")
        prefix = root.findPrefix(tns)
        if prefix is None:
            log.debug("warning: tns (%s), not mapped to prefix", tns)
            prefix = "tns"
        return (prefix, tns)
469442
def environment_exists(self, name=None, prefix=None, abspath=True,
                           log=True):
        
        if log:
            logger.debug(str((name, prefix)))

        if name and prefix:
            raise TypeError("Exactly one of 'name' or 'prefix' is required.")

        if name:
            prefix = self.get_prefix_envname(name, log=log)

        if prefix is None:
            prefix = self.ROOT_PREFIX

        return os.path.isdir(os.path.join(prefix, 'conda-meta'))
384990
def get_user(self):
        
        for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
            user = os.environ.get(name)
            if user:
                break     
        for u in users:
            if u['name'] == user:
                return u['type'], u['name']
907487
def _get_config_name():
  ''''''
  p = subprocess.Popen('git config --get user.name', shell=True,
                       stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  output = p.stdout.readlines()
  return _stripslashes(output[0])
181851
def namespace_for_prefix(self, prefix):
        
        try:
            ni = self.__lookup_prefix(prefix)
        except PrefixNotFoundError:
            return None
        else:
            return ni.uri
1265746
def get_index(self, prefix=''):
        
        if prefix:
            prefixed = '%s_index' % prefix
        else:
            prefixed = 'index'

        if prefixed in self.__cli and self.__cli[prefixed]:
            index = self.__cli.get(prefixed)
            from_conf = False
        else:
            index = self.__config.get(prefixed)
            from_conf = True

        return self.__abspath(index, from_conf)
1019615
def env(client, paths, opt):
    """"""
    old_prefix = False
    old_prefix = opt.prefix and not (opt.add_prefix or
                                     opt.add_suffix or
                                     not opt.merge_path)
    if old_prefix:
        LOG.warning("the prefix option is deprecated "
                    "please use"
                    "--no-merge-path --add-prefix $OLDPREFIX_ instead")
    elif opt.prefix:
        LOG.warning("the prefix option is deprecated"
                    "please use"
                    "--no-merge-path --add-prefix $OLDPREFIX_ instead")
    key_map = cli_hash(opt.key_map)
    for path in paths:
        secrets = client.read(path)
        if secrets and 'data' in secrets:
            if is_aws(secrets['data']) and 'sts' not in path:
                renew_secret(client, secrets, opt)

            for s_key, s_val in secrets['data'].items():
                o_key = s_key
                if s_key in key_map:
                    o_key = key_map[s_key]

                # see https://github.com/Autodesk/aomi/issues/40
                env_name = None
                if old_prefix:
                    env_name = ("%s_%s" % (opt.prefix, o_key)).upper()
                else:
                    env_name = secret_key_name(path, o_key, opt).upper()

                print("%s=\"%s\"" % (env_name, s_val))
                if opt.export:
                    print("export %s" % env_name)
598775
def current_user_name_or_id
      require 'etc' if !defined?(Etc)
      begin
        user = Etc.getpwuid(Process.uid)
      rescue ArgumentError
        user = nil
      end
      if user
        return user.name
      else
        return "##{Process.uid}"
      end
    end
1306529
def get_specific_config(prefix):
    
    conf_dict = {}
    for uuid, val in cfg.CONF.get(prefix, {}).items():
        conf_dict[uuid] = dict(val)
    return conf_dict
699082
def get_namespace_prefix(self, package=None):
        
        result = ""
        if package is None:
            package = self.project_config.project__package__name_managed
        packages = self.tooling.query(
            "SELECT SubscriberPackage.NamespacePrefix, SubscriberPackage.Name "
            "FROM InstalledSubscriberPackage"
        )
        match = [
            p for p in packages["records"] if p["SubscriberPackage"]["Name"] == package
        ]
        if match:
            result = match[0]["SubscriberPackage"]["NamespacePrefix"] + "__"
        return result
205974
def _get_counter_prefix_from_socket_name(self, name):
        
        base = os.path.splitext(os.path.basename(name))[0]
        if base.startswith(self.config['socket_prefix']):
            base = base[len(self.config['socket_prefix']):]
        return 'ceph.' + base
1181966
def resolvePrefix(self, prefix):
        
        ns = Namespace.default
        if self.parent is not None:
            ns = self.parent.resolvePrefix(prefix)
        return ns
698004
def _get_proc_username(proc):
    '''
    
    '''
    try:
        return salt.utils.data.decode(proc.username() if PSUTIL2 else proc.username)
    except (psutil.NoSuchProcess, psutil.AccessDenied, KeyError):
        return None
1117002
def rm_env(user, name):
    '''
    
    '''
    lst = list_tab(user)
    ret = 'absent'
    rm_ = None
    for ind in range(len(lst['env'])):
        if name == lst['env'][ind]['name']:
            rm_ = ind
    if rm_ is not None:
        lst['env'].pop(rm_)
        ret = 'removed'
    comdat = _write_cron_lines(user, _render_tab(lst))
    if comdat['retcode']:
        # Failed to commit, return the error
        return comdat['stderr']
    return ret
892660
def _get_conn(ret=None):
    '''
    
    '''
    _options = _get_options(ret)
    dsn = _options.get('dsn')
    user = _options.get('user')
    passwd = _options.get('passwd')

    return pyodbc.connect('DSN={0};UID={1};PWD={2}'.format(
            dsn,
            user,
            passwd))
601244
def _get_conda_version(stdout, stderr):
        """"""
        # argparse outputs version to stderr in Python < 3.4.
        # http://bugs.python.org/issue18920
        pat = re.compile(r'conda:?\s+(\d+\.\d\S+|unknown)')
        m = pat.match(stderr.decode().strip())
        if m is None:
            m = pat.match(stdout.decode().strip())

        if m is None:
            raise Exception('output did not match: {0}'.format(stderr))

        return m.group(1)