docs: def to_credentials(arg):
      '''
      to_credentials(arg) converts arg into a pair (key, secret) if arg can be coerced into such a
        pair and otherwise raises an error.
      
      Possible inputs include:
        * A tuple (key, secret)
        * A mapping with the keys 'key' and 'secret'
        * The name of a file that can load credentials via the load_credentials() function
        * A string that separates the key and secret by ':', e.g., 'mykey:mysecret'
        * A string that separates the key and secret by a "\n", e.g., "mykey\nmysecret"
      '''
      if pimms.is_str(arg):
          try: return load_credentials(arg)
          except Exception: pass
          try: return str_to_credentials(arg)
          except Exception:
              raise ValueError('String "%s" is neither a file containing credentials nor a valid'
                               ' credentials string itself.' % arg)
      elif pimms.is_map(arg) and 'key' in arg and 'secret' in arg: return (arg['key'], arg['secret'])
      elif pimms.is_vector(arg, str) and len(arg) == 2: return tuple(arg)
      else: raise ValueError('given argument cannot be coerced to credentials: %s' % arg)