Return collated content for ``ident_hash``.
337253
def get_collated_content(ident_hash, context_ident_hash, cursor):
    """"""
    cursor.execute(SQL['get-collated-content'],
                   (ident_hash, context_ident_hash,))
    try:
        return cursor.fetchone()[0]
    except TypeError:  # NoneType
        return
809012
def get_contents_sig(self):
        

        try:
            return self.contentsig
        except AttributeError:
            pass

        executor = self.get_executor()

        result = self.contentsig = SCons.Util.MD5signature(executor.get_contents())
        return result
411587
def _extract(self, identifier):
		'''  '''

		conjugation = []
		if self.tree.xpath('//p/b[normalize-space(text()) = "' + identifier.decode('utf-8') + '"]'):
			p = self.tree.xpath('//p/b[normalize-space(text()) = "' + identifier.decode('utf-8') + '"]')[0].getparent()
			for font in p.iterfind('font'):
				text = self._normalize(font.text_content())
				next = font.getnext()
				text += ' ' + self._normalize(next.text_content())
				while True:
					next = next.getnext()
					if next.tag != 'span':
						break
					text += '/' + self._normalize(next.text_content())
				conjugation.append(text)
		return conjugation
1267391
def extract_content(image_path, member_name, return_hash=False):
    '''
    '''
    if member_name.startswith('./'):
        member_name = member_name.replace('.','',1)
    if return_hash:
        hashy = hashlib.md5()

    try:
        content = Client.execute(image_path,'cat %s' %(member_name))
    except:
        return None

    if not isinstance(content,bytes):
        content = content.encode('utf-8')
        content = bytes(content)

    # If permissions don't allow read, return None
    if len(content) == 0:
        return None
    if return_hash:
        hashy.update(content)
        return hashy.hexdigest()
    return content
1151477
def md5hash(self):
        """"""
        digest = hashlib.md5(self.content).digest()
        return b64_string(digest)
986897
def autodetect_format(content):
    """"""
    formats = set()
    for impl in FORMAT_IDENTIFIER_TO_FORMAT_CLASS.values():
        guess = impl.guess_format(content)
        if guess is not None:
            formats.add(guess)

    if len(formats) == 1:
        return formats.pop()
    elif not formats:
        raise FormatAutodetectionError("No suitable formats")
    else:
        raise FormatAutodetectionError("Multiple suitable formats (%r)" % formats)
170903
def getanymentions(idf, anidfobject):
    """"""
    name = anidfobject.obj[1]
    foundobjs = []
    keys = idfobjectkeys(idf)
    idfkeyobjects = [idf.idfobjects[key.upper()] for key in keys]
    for idfobjects in idfkeyobjects:
        for idfobject in idfobjects:
            if name.upper() in [item.upper() 
                                    for item in idfobject.obj 
                                        if isinstance(item, basestring)]:
                foundobjs.append(idfobject)
    return foundobjs
1186058
def get_content(ident_hash, context=None):
    
    id, version = get_id_n_version(ident_hash)
    filename = 'index.cnxml.html'

    if context is not None:
        stmt = _get_sql('get-baked-content.sql')
        args = dict(id=id, version=version, context=context)
    else:
        stmt = _get_sql('get-content.sql')
        args = dict(id=id, version=version, filename=filename)

    with db_connect() as db_conn:
        with db_conn.cursor() as cursor:
            cursor.execute(stmt, args)
            try:
                content, _ = cursor.fetchone()
            except TypeError:
                raise ContentNotFound(ident_hash, context, filename)
    return content[:]
1264438
def hash(self):
        """"""
        content = json.dumps(self.data, sort_keys=True, separators=(",", ":"))
        return hashlib.sha256(content.encode("utf8")).hexdigest()
807160
def sha256(content):
    """"""
    if isinstance(content, str):
        content = content.encode('utf-8')
    return hashlib.sha256(content).hexdigest()
1219544
function(source, identifier, options) {
  const hash = crypto.createHash("md4");

  const contents = JSON.stringify({ source, options, identifier });

  hash.update(contents);

  return hash.digest("hex") + ".json";
}
285433
def get_hash_table_entry(self, filename):
        """"""
        hash_a = self._hash(filename, 'HASH_A')
        hash_b = self._hash(filename, 'HASH_B')
        for entry in self.hash_table:
            if (entry.hash_a == hash_a and entry.hash_b == hash_b):
                return entry
774187
def hcode(*content, sep=' '):
    
    return _md(quote_html(_join(*content, sep=sep)), symbols=MD_SYMBOLS[6])
401661
def _get_digest(self, info):
        
        result = None
        for algo in ('sha256', 'md5'):
            key = '%s_digest' % algo
            if key in info:
                result = (algo, info[key])
                break
        return result
1313302
def get_tree(ident_hash, baked=False):
    """"""
    id, version = get_id_n_version(ident_hash)

    stmt = _get_sql('get-tree.sql')
    args = dict(id=id, version=version, baked=baked)

    with db_connect() as db_conn:
        with db_conn.cursor() as cursor:
            cursor.execute(stmt, args)
            try:
                tree = cursor.fetchone()[0]
            except TypeError:
                raise NotFound(ident_hash)
    if tree is None:
        raise NotFound(ident_hash)

    return tree
52703
def canonicalize(assess_id):
    
    
    hash_regex = re.compile(r'\w{32}')
    
    lines = assess_id.split('\n')
    canon_lines = []
  
    parsing_code = False
    for line in lines:
        line = line.strip()

        if not parsing_code and len(line) > 0:
            for prompt in DICT_PROMPT_TO_CHARACTER:
                if line.startswith(prompt):
                    parsing_code = True
                    comment_character = DICT_PROMPT_TO_CHARACTER[prompt]
                    break

        # If False still in preamble and do not include in canonicalized lines
        if parsing_code:
            # Remove any comments
            comment_index = line.find(comment_character)
            if comment_index >= 0:
                line = line[0:comment_index].strip()

            # If a hashed answer, replace with constant since these vary by semester
            if hash_regex.match(line):
                line = 'LOCKED_ANSWER'

            # Remove any '# locked' text since these are here regardless of language
            if line == '# locked':
                line = ''

            if len(line) > 0:
                canon_lines.append(line)

    return '\n'.join(canon_lines) + '\n'
1206398
def row_to_content_obj(key_row):
    '''
    '''
    key, row = key_row
    cid = mk_content_id(key.encode('utf-8'))
    response = row.get('response', {})

    other_bows = defaultdict(StringCounter)
    for attr, val in row.get('indices', []):
        other_bows[attr][val] += 1
    try:
        artifact_id = key
        if isinstance(artifact_id, str):
            artifact_id = unicode(artifact_id, 'utf-8')
        fc = html_to_fc(
            response.get('body', ''),
            url=row.get('url'), timestamp=row.get('timestamp'),
            other_features=dict(other_bows, **{'artifact_id': artifact_id}))
    except:
        fc = None
        print('Could not create FC for %s:' % cid, file=sys.stderr)
        print(traceback.format_exc(), file=sys.stderr)
    return cid, fc