Add a key to a keyring.

    Creates the keyring if it doesn't already exist.

    Logs and returns if the key is already in the keyring.
542000
def add_key(service, key):
    
    keyring = _keyring_path(service)
    if os.path.exists(keyring):
        with open(keyring, 'r') as ring:
            if key in ring.read():
                log('Ceph keyring exists at %s and has not changed.' % keyring,
                    level=DEBUG)
                return
            log('Updating existing keyring %s.' % keyring, level=DEBUG)

    cmd = ['ceph-authtool', keyring, '--create-keyring',
           '--name=client.{}'.format(service), '--add-key={}'.format(key)]
    check_call(cmd)
    log('Created new ceph keyring at %s.' % keyring, level=DEBUG)
997371
public synchronized void add(String k, String v) {
        grow();
        keys[nkeys] = k;
        values[nkeys] = v;
        nkeys++;
    }
1358306
private void createKeysIfNotExist() {
        if (!keyPairExists()) {
            try {
                final KeyPair keyPair = generateKeyPair();
                save(keyPair);
            } catch (NoSuchAlgorithmException e) {
                LOGGER.error("An error occurred generating new keypair");
                LOGGER.error(e.getMessage());
            } catch (IOException e) {
                LOGGER.error("An error occurred saving newly generated keypair");
                LOGGER.error(e.getMessage());
            }
        }
        if (!secretKeyExists()) {
            try {
                final SecretKey secretKey = generateSecretKey();
                save(secretKey);
            } catch (NoSuchAlgorithmException e) {
                LOGGER.error("An error occurred generating new secret key");
                LOGGER.error(e.getMessage());
            } catch (IOException e) {
                LOGGER.error("An error occurred saving newly generated secret key");
                LOGGER.error(e.getMessage());
            }
        }
    }
1171310
public void addForeigerKey(String key) {
    String[] foreigers = new String[foreigerKeys.length + 1];
    int i = 0;
    for (; i < foreigerKeys.length; i++) {
      foreigers[i] = foreigerKeys[i];
    }
    foreigers[i] = key;
    foreigerKeys = foreigers;
  }
1088362
def add(self, key):
        '''
        
        '''
        encodedKey = json.dumps(key)
        with self.connect() as conn:
            with doTransaction(conn):
                sql = 'INSERT IGNORE INTO ' + self.table + ' (name) VALUES (%s)'
                return insertSQL(conn, sql, args=[encodedKey])
195429
async def create(cls, key: str):
        
        return cls._object(await cls._handler.create(key=key))
1201102
int addKey(BufferedString str) {
    // _map is shared and be cast to null (if categorical is killed) -> grab local copy
    IcedHashMap<BufferedString, Integer> m = _map;
    if( m == null ) return Integer.MAX_VALUE;     // Nuked already
    Integer res = m.get(str);
    if( res != null ) return res; // Recorded already
    assert str.length() < 65535; // Length limit so 65535 can be used as a sentinel
    int newVal = _id.incrementAndGet();
    res = m.putIfAbsent(new BufferedString(str), newVal);
    if( res != null ) return res;
    if( m.size() > MAX_CATEGORICAL_COUNT) maxDomainExceeded = true;
    return newVal;
  }
914371
private void addKeyListenerImpl(KeyListener listener) {
		if (keyListeners.contains(listener)) {
			return;
		}
		keyListeners.add(listener);
		allListeners.add(listener);
	}
1180625
def add(key, value)
    if @env.has_key?(key)
      @env[key] += value
    else
      set(key,value)
    end
  end
261402
def add_header(self, key, value):
        

        assert isinstance(key, str), 'header key must be of type str'
        assert isinstance(value, str), 'header value must be of type str'
        self.headers[key] = value
588411
def add(self, key, val, time = 0, min_compress_len = 0):
        '''
        
        '''
        return self._set("add", key, val, time, min_compress_len)
549942
def Append(self, **kw):
        
        kw = copy_non_reserved_keywords(kw)
        for key, val in kw.items():
            # It would be easier on the eyes to write this using
            # "continue" statements whenever we finish processing an item,
            # but Python 1.5.2 apparently doesn't let you use "continue"
            # within try:-except: blocks, so we have to nest our code.
            try:
                if key == 'CPPDEFINES' and SCons.Util.is_String(self._dict[key]):
                    self._dict[key] = [self._dict[key]]
                orig = self._dict[key]
            except KeyError:
                # No existing variable in the environment, so just set
                # it to the new value.
                if key == 'CPPDEFINES' and SCons.Util.is_String(val):
                    self._dict[key] = [val]
                else:
                    self._dict[key] = val
            else:
                try:
                    # Check if the original looks like a dictionary.
                    # If it is, we can't just try adding the value because
                    # dictionaries don't have __add__() methods, and
                    # things like UserList will incorrectly coerce the
                    # original dict to a list (which we don't want).
                    update_dict = orig.update
                except AttributeError:
                    try:
                        # Most straightforward:  just try to add them
                        # together.  This will work in most cases, when the
                        # original and new values are of compatible types.
                        self._dict[key] = orig + val
                    except (KeyError, TypeError):
                        try:
                            # Check if the original is a list.
                            add_to_orig = orig.append
                        except AttributeError:
                            # The original isn't a list, but the new
                            # value is (by process of elimination),
                            # so insert the original in the new value
                            # (if there's one to insert) and replace
                            # the variable with it.
                            if orig:
                                val.insert(0, orig)
                            self._dict[key] = val
                        else:
                            # The original is a list, so append the new
                            # value to it (if there's a value to append).
                            if val:
                                add_to_orig(val)
                else:
                    # The original looks like a dictionary, so update it
                    # based on what we think the value looks like.
                    if SCons.Util.is_List(val):
                        if key == 'CPPDEFINES':
                            tmp = []
                            for (k, v) in orig.items():
                                if v is not None:
                                    tmp.append((k, v))
                                else:
                                    tmp.append((k,))
                            orig = tmp
                            orig += val
                            self._dict[key] = orig
                        else:
                            for v in val:
                                orig[v] = None
                    else:
                        try:
                            update_dict(val)
                        except (AttributeError, TypeError, ValueError):
                            if SCons.Util.is_Dict(val):
                                for k, v in val.items():
                                    orig[k] = v
                            else:
                                orig[val] = None
        self.scanner_map_delete(kw)
276677
def add_result(self, key, result):
        
        if len(self.cache) > self.max_size:
            return
        if key is not None:
            self.cache[key] = result
232634
def key_on(self, value):
        
        if isinstance(value, BASESTRING):
            value = (value,)
        self._key_on = value
899008
private void addConstructorByKeyRef() {
    context.constructorByKeyRef = MethodSpec.constructorBuilder().addParameter(keyRefSpec);
    addCommonParameters(context.constructorByKeyRef);
    if (isBaseClass()) {
      assignKeyRefAndValue();
    } else {
      callParentByKeyRef();
    }
  }
749677
def add_key(self):
        ""
        try:
            with open(self.args.ssh_public_key) as f:
                public_key = f.read().strip()
        except:
            log.debug("No key found in {}".format(self.args.ssh_public_key))
            return None
        g = self.gitlab
        url = g['url'] + "/user/keys"
        query = {'private_token': g['token']}
        keys = requests.get(url, params=query).json()
        log.debug("looking for '" + public_key + "' in " + str(keys))
        if (list(filter(lambda key: key['key'] == public_key, keys))):
            log.debug(self.args.ssh_public_key + " already exists")
            return None
        else:
            name = 'github2gitlab'
            log.info("add " + name + " ssh public key from " +
                     self.args.ssh_public_key)
            query['title'] = name
            query['key'] = public_key
            result = requests.post(url, query)
            if result.status_code != requests.codes.created:
                log.warn('Key {} already in GitLab. '
                         'Possible under a different user. Skipping...'
                         .format(self.args.ssh_public_key))
            return public_key
462949
private static void appendKeyValue(StringBuffer str, String key, String value) {

        str.append(key);
        if (value == IS_USED) {
            str.append(";");
        } else {
            str.append("=(");
            str.append(value);
            str.append(");");
        }
    }