:calls: `POST /repos/:owner/:repo/git/blobs <http://developer.github.com/v3/git/blobs>`_
        :param content: string
        :param encoding: string
        :rtype: :class:`github.GitBlob.GitBlob`
508932
def create_git_blob(self, content, encoding):
        
        assert isinstance(content, (str, unicode)), content
        assert isinstance(encoding, (str, unicode)), encoding
        post_parameters = {
            "content": content,
            "encoding": encoding,
        }
        headers, data = self._requester.requestJsonAndCheck(
            "POST",
            self.url + "/git/blobs",
            input=post_parameters
        )
        return github.GitBlob.GitBlob(self._requester, headers, data, completed=True)
1014811
def write_yum_repo(content, filename='ceph.repo'):
    """"""
    repo_path = os.path.join('/etc/yum.repos.d', filename)
    if not isinstance(content, str):
        content = content.decode('utf-8')
    write_file(repo_path, content.encode('utf-8'))
844062
def decode_to_unicode(content):
    
    if content and not isinstance(content, str):
        try:
            # Try to decode ISO-8859-1 to unicode
            return content.decode("ISO-8859-1")
        except UnicodeEncodeError:
            # Assume content is unicode already
            return content
    return content
938598
def content(self, value):
        
        if isinstance(value, bytes):
            self._content = value
        else:
            self._content = value.encode(ENCODING)
        self.size = len(value)
468750
private static String guessEncodingByNutch(byte[] content) {
        int length = Math.min(content.length, CHUNK_SIZE);

        String str = "";
        try {
            str = new String(content, "ascii");
        } catch (UnsupportedEncodingException e) {
            return null;
        }

        Matcher metaMatcher = metaPattern.matcher(str);
        String encoding = null;
        if (metaMatcher.find()) {
            Matcher charsetMatcher = charsetPattern.matcher(metaMatcher.group(1));
            if (charsetMatcher.find()) {
                encoding = new String(charsetMatcher.group(1));
            }
        }
        if (encoding == null) {
            metaMatcher = charsetPatternHTML5.matcher(str);
            if (metaMatcher.find()) {
                encoding = new String(metaMatcher.group(1));
            }
        }
        if (encoding == null) {
            if (length >= 3 && content[0] == (byte) 0xEF
                    && content[1] == (byte) 0xBB && content[2] == (byte) 0xBF) {
                encoding = "UTF-8";
            } else if (length >= 2) {
                if (content[0] == (byte) 0xFF && content[1] == (byte) 0xFE) {
                    encoding = "UTF-16LE";
                } else if (content[0] == (byte) 0xFE
                        && content[1] == (byte) 0xFF) {
                    encoding = "UTF-16BE";
                }
            }
        }

        return encoding;
    }
1355680
def as_binary(self, content, encoding='utf8'):
        ''''''
        if hasattr(content, 'read'):
            return content.read()
        elif isinstance(content, six.text_type):
            return content.encode(encoding)
        else:
            return content
175223
def write_json_or_yaml(file_path, content):
    
    with codecs.open(file_path, "w", "utf-8") as f:
        f.write(get_json_or_yaml(file_path, content))
137158
def _parse_content_type(content_type: Optional[str]) -> Tuple[Optional[str], str]:
    
    if not content_type:
        return None, "utf-8"
    else:
        type_, parameters = cgi.parse_header(content_type)
        encoding = parameters.get("charset", "utf-8")
        return type_, encoding
882376
def render_markdown(self, text, context=github.GithubObject.NotSet):
        
        assert isinstance(text, (str, unicode)), text
        assert context is github.GithubObject.NotSet or isinstance(context, github.Repository.Repository), context
        post_parameters = {
            "text": text
        }
        if context is not github.GithubObject.NotSet:
            post_parameters["mode"] = "gfm"
            post_parameters["context"] = context._identity
        status, headers, data = self.__requester.requestJson(
            "POST",
            "/markdown",
            input=post_parameters
        )
        return data
970595
def upload_attachment(self, location, data):
        
        self.validate_attachment_location(location)
        content = data.read() if hasattr(data, 'read') else data
        orig_content = content
        if isinstance(content, bytes):
            content = base64.b64encode(orig_content).decode('ascii')
        else:
            pass  # Should be base64 encoded already
        apath = '%s/%s' % (self.attachment_location, location)
        url = '%s/contents/%s' % (self.base_url, apath)
        result = requests.put(
            url, auth=(self.user, self.token), data=json.dumps({
                'message': 'file attachment %s' % location,
                'content': content}))
        if result.status_code != 201:
            raise ValueError(
                "Can't upload attachment %s due to error %s." % (
                    location, result.reason))
        return '[%s](https://github.com/%s/%s/blob/master/%s)' % (
            location, self.owner, self.realm, apath)
982683
def content_encoding
      vs = @metas['content-encoding']
      if vs && %r{\A#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?(?:,#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?)*}o =~ (v = vs.join(', '))
        v.scan(RE_TOKEN).map {|content_coding| content_coding.downcase}
      else
        []
      end
    end
1149461
def format_content_type_object(repo, content_type, uuid):
    
    try:
        storage_manager = StorageManager(repo)
        model_class = load_model_class(repo, content_type)
        return dict(storage_manager.get(model_class, uuid))
    except GitCommandError:
        raise NotFound('Object does not exist.')
790424
def content(self, content):
        
        if self.cache_content:
            self.cached_content = b2u(content)

        try:
            with self._open_dockerfile('wb') as dockerfile:
                dockerfile.write(u2b(content))
        except (IOError, OSError) as ex:
            logger.error("Couldn't write content to dockerfile: %r", ex)
            raise
62042
def append(self, content, encoding='utf8'):
        
        if not self.parent.exists:
            self.parent.create()
        with open(self._filename, "ab") as output_file:
            if not is_text(content):
                Log.error(u"expecting to write unicode only")
            output_file.write(content.encode(encoding))
            output_file.write(b"\n")
671130
def _get_content(org, repo, branch, filepath):
    """"""
    url = "https://github.com/{}/{}/raw/{}/{}".format(org, repo, branch, filepath)
    r = requests.get(url)
    if not r.ok:
        if r.status_code == 404:
            raise InvalidSlugError(_("Invalid slug. Did you mean to submit something else?"))
        else:
            raise Error(_("Could not connect to GitHub."))
    return r.content
1103886
def get_content(self, content_type=github.GithubObject.NotSet):
        
        if self.content_url == None:
            return None
            
        if content_type == "PullRequest":
            headers, data = self._requester.requestJsonAndCheck(
                "GET",
                self.content_url.replace("issues", "pulls")
            )
            return github.PullRequest.PullRequest(self._requester, headers, data, completed=True)
        elif content_type is github.GithubObject.NotSet or content_type == "Issue":
            headers, data = self._requester.requestJsonAndCheck(
                "GET",
                self.content_url
            )
            return github.Issue.Issue(self._requester, headers, data, completed=True)
        else:
            assert False, "Unknown content type: %s" % content_type
236817
def _WritesString(self, content):
    
    content_bytes = codecs.encode(content, 'utf-8')
    self._sample_file.write(content_bytes)