Search all differences between protocol messages regarding a reference message

        :param refindex: index of reference message
        :rtype: dict[int, set[int]]
549601
def find_differences(self, refindex: int):
        
        differences = defaultdict(set)

        if refindex >= len(self.protocol.messages):
            return differences

        if self.proto_view == 0:
            proto = self.protocol.decoded_proto_bits_str
        elif self.proto_view == 1:
            proto = self.protocol.decoded_hex_str
        elif self.proto_view == 2:
            proto = self.protocol.decoded_ascii_str
        else:
            return differences

        ref_message = proto[refindex]
        ref_offset = self.get_alignment_offset_at(refindex)

        for i, message in enumerate(proto):
            if i == refindex:
                continue

            msg_offset = self.get_alignment_offset_at(i)
            short, long = sorted([len(ref_message) + ref_offset, len(message) + msg_offset])

            differences[i] = {
                j for j in range(max(msg_offset, ref_offset), long)
                if j >= short or message[j - msg_offset] != ref_message[j - ref_offset]
            }

        return differences
991391
function checkReference(reference, index, references) {
			var identifier = reference.identifier;

			if (reference.init === false &&
				reference.isWrite() &&
				// Destructuring assignments can have multiple default value,
				// so possibly there are multiple writeable references for the same identifier.
				(index === 0 || references[index - 1].identifier !== identifier)
			) {
				context.report({
					node: identifier,
					message: ProblemMessages.noNativeReassign,
					data: {name: identifier.name}
				});
			}
		}
558783
def get_event(self, ref):
        
        # is this reference one which has been setup?
        if ref in self._refs:
            return self._refs[ref].get_callback(ref)
        else:
            return None
545848
def get_ref(self):
        
        if self.ref_key == 'NETWORK':
            return self.network
        elif self.ref_key == 'NODE':
            return self.node
        elif self.ref_key == 'LINK':
            return self.link
        elif self.ref_key == 'GROUP':
            return self.group
        elif self.ref_key == 'SCENARIO':
            return self.scenario
        elif self.ref_key == 'PROJECT':
            return self.project
1286668
def _has_sj_index(ref_file):
    """"""
    return (file_exists(os.path.join(ref_file, "sjdbInfo.txt")) and
            (file_exists(os.path.join(ref_file, "transcriptInfo.tab"))))
419256
def reftoindex(self, sds_ref):
        

        sds_idx = _C.SDreftoindex(self._id, sds_ref)
        _checkErr('reftoindex', sds_idx, 'illegal SDS ref number')
        return sds_idx
372963
def build_ref_list(refs):
    
    ref_list = []
    for reference in refs:
        ref = ea.Citation()
        # Publcation Type
        utils.set_attr_if_value(ref, 'publication_type', reference.get('publication-type'))
        # id
        utils.set_attr_if_value(ref, 'id', reference.get('id'))
        # Article title
        utils.set_attr_if_value(ref, 'article_title', reference.get('full_article_title'))
        # Source
        utils.set_attr_if_value(ref, 'source', reference.get('source'))
        # Volume
        utils.set_attr_if_value(ref, 'volume', reference.get('volume'))
        # Issue
        utils.set_attr_if_value(ref, 'issue', reference.get('issue'))
        # First page
        utils.set_attr_if_value(ref, 'fpage', reference.get('fpage'))
        # Last page
        utils.set_attr_if_value(ref, 'lpage', reference.get('lpage'))
        # DOI
        utils.set_attr_if_value(ref, 'doi', reference.get('doi'))
        # Year
        utils.set_attr_if_value(ref, 'year', reference.get('year'))
        # Year date in iso 8601 format
        utils.set_attr_if_value(ref, 'year_iso_8601_date', reference.get('year-iso-8601-date'))
        # Can set the year_numeric now
        if ref.year_iso_8601_date is not None:
            # First preference take it from the iso 8601 date, if available
            try:
                ref.year_numeric = int(ref.year_iso_8601_date.split('-')[0])
            except ValueError:
                ref.year_numeric = None
        if ref.year_numeric is None:
            # Second preference, use the year value if it is entirely numeric
            if utils.is_year_numeric(ref.year):
                ref.year_numeric = ref.year
        # date-in-citation
        utils.set_attr_if_value(ref, 'date_in_citation', reference.get('date-in-citation'))
        # elocation-id
        utils.set_attr_if_value(ref, 'elocation_id', reference.get('elocation-id'))
        # uri
        utils.set_attr_if_value(ref, 'uri', reference.get('uri'))
        if not ref.uri:
            # take uri value from uri_text
            utils.set_attr_if_value(ref, 'uri', reference.get('uri_text'))
        # pmid
        utils.set_attr_if_value(ref, 'pmid', reference.get('pmid'))
        # isbn
        utils.set_attr_if_value(ref, 'isbn', reference.get('isbn'))
        # accession
        utils.set_attr_if_value(ref, 'accession', reference.get('accession'))
        # patent
        utils.set_attr_if_value(ref, 'patent', reference.get('patent'))
        # patent country
        utils.set_attr_if_value(ref, 'country', reference.get('country'))
        # publisher-loc
        utils.set_attr_if_value(ref, 'publisher_loc', reference.get('publisher_loc'))
        # publisher-name
        utils.set_attr_if_value(ref, 'publisher_name', reference.get('publisher_name'))
        # edition
        utils.set_attr_if_value(ref, 'edition', reference.get('edition'))
        # version
        utils.set_attr_if_value(ref, 'version', reference.get('version'))
        # chapter-title
        utils.set_attr_if_value(ref, 'chapter_title', reference.get('chapter-title'))
        # comment
        utils.set_attr_if_value(ref, 'comment', reference.get('comment'))
        # data-title
        utils.set_attr_if_value(ref, 'data_title', reference.get('data-title'))
        # conf-name
        utils.set_attr_if_value(ref, 'conf_name', reference.get('conf-name'))
        # Authors
        if reference.get('authors'):
            for author in reference.get('authors'):
                ref_author = {}
                eautils.set_if_value(ref_author, 'group-type', author.get('group-type'))
                eautils.set_if_value(ref_author, 'surname', author.get('surname'))
                eautils.set_if_value(ref_author, 'given-names', author.get('given-names'))
                eautils.set_if_value(ref_author, 'collab', author.get('collab'))
                if ref_author:
                    ref.add_author(ref_author)
        # Try to populate the doi attribute if the uri is a doi
        if not ref.doi and ref.uri:
            if ref.uri != eautils.doi_uri_to_doi(ref.uri):
                ref.doi = eautils.doi_uri_to_doi(ref.uri)
        # Append the reference to the list
        ref_list.append(ref)
    return ref_list
1263760
def resolve_relative_rst_links(text: str, base_link: str):
    
    document = parse_rst(text)
    visitor = SimpleRefCounter(document)
    document.walk(visitor)
    for target in visitor.references:
        name = target.attributes['name']
        uri = target.attributes['refuri']
        new_link = '`{} <{}{}>`_'.format(name, base_link, uri)
        if name == uri:
            text = text.replace('`<{}>`_'.format(uri), new_link)
        else:
            text = text.replace('`{} <{}>`_'.format(name, uri), new_link)
    return text
918267
def _prepare_record(record, index, doc_type):
        
        if current_app.config['INDEXER_REPLACE_REFS']:
            data = copy.deepcopy(record.replace_refs())
        else:
            data = record.dumps()

        data['_created'] = pytz.utc.localize(record.created).isoformat() \
            if record.created else None
        data['_updated'] = pytz.utc.localize(record.updated).isoformat() \
            if record.updated else None

        # Allow modification of data prior to sending to Elasticsearch.
        before_record_index.send(
            current_app._get_current_object(),
            json=data,
            record=record,
            index=index,
            doc_type=doc_type,
        )

        return data
512654
def sort_references_dict(refs):
    

    if _use_odict:
        refs_sorted = OrderedDict()
    else:
        refs_sorted = dict()

    # We insert this first, That is ok - it will be overwritten
    # with the sorted version later
    refs_sorted['molssi_bse_schema'] = refs['molssi_bse_schema']

    # This sorts the entries by reference key (author1985a, etc)
    for k, v in sorted(refs.items()):
        refs_sorted[k] = sort_single_reference(v)

    return refs_sorted
221646
def list_matching(self, ref_name: str, filter_: str) \
            -> Iterable[ListEntry]:
        
        canonical, canonical_i = self._get_pattern(ref_name + filter_)
        for entry in self.list():
            if entry.name == 'INBOX':
                if canonical_i.match('INBOX'):
                    yield entry
            elif canonical.match(entry.name):
                yield entry
401225
def resolve_ref(cls, domain, env, fromdocname, builder, typ, target, node,
                    contnode):
        
        targets = domain.data['targets'].get(cls.ref_type, {})
        try:
            todocname, targetname = targets[target]
        except KeyError:
            env.warn(fromdocname, "Missing BB reference: bb:%s:%s" % (cls.ref_type, target),
                     node.line)
            return None

        return make_refnode(builder, fromdocname,
                            todocname, targetname,
                            contnode, target)
113725
def set_ref(self, ref_key, ref_id):
        
        if ref_key == 'NETWORK':
            self.network_id = ref_id
        elif ref_key == 'NODE':
            self.node_id = ref_id
        elif ref_key == 'LINK':
            self.link_id = ref_id
        elif ref_key == 'GROUP':
            self.group_id = ref_id
        elif ref_key == 'SCENARIO':
            self.scenario_id = ref_id
        elif ref_key == 'PROJECT':
            self.project_id = ref_id

        else:
            raise HydraError("Ref Key %s not recognised."%ref_key)
110876
def _get_relative_reference(self, cursor, ref_key):
        

        magics = ["X", "Y", "Z"]

        # mapper takes magic, key, ref_key to build string
        def get_rel_key_ele(cursor_ele, ref_key_ele):
            """Returns relative key suffix for given key and reference key"""

            # cursor is current cursor position
            # ref_key is absolute target position

            diff_key_ele = ref_key_ele - cursor_ele

            if diff_key_ele == 0:
                return u""

            elif diff_key_ele < 0:
                return u"-" + str(abs(diff_key_ele))

            elif diff_key_ele > 0:
                return u"+" + str(diff_key_ele)

            else:
                msg = _("{key} seems to be no Integer")
                msg = msg.format(key=diff_key_ele)
                raise ValueError(msg)

        key_strings = []

        for magic, cursor_ele, ref_key_ele in zip(magics, cursor, ref_key):
            key_strings.append(magic +
                               get_rel_key_ele(cursor_ele, ref_key_ele))

        key_string = u", ".join(key_strings)

        return u"S[" + key_string + u"]"
539529
def diff(self, a_ref, target=None, b_ref=None):
    
    result = {}
    diff_dct = self.scm.get_diff_trees(a_ref, b_ref=b_ref)
    result[DIFF_A_REF] = diff_dct[DIFF_A_REF]
    result[DIFF_B_REF] = diff_dct[DIFF_B_REF]
    if diff_dct[DIFF_EQUAL]:
        result[DIFF_EQUAL] = True
        return result
    result[DIFF_LIST] = []
    diff_outs = _get_diff_outs(self, diff_dct)
    if target is None:
        result[DIFF_LIST] = [
            _diff_royal(self, path, diff_outs[path]) for path in diff_outs
        ]
    elif target in diff_outs:
        result[DIFF_LIST] = [_diff_royal(self, target, diff_outs[target])]
    else:
        msg = "Have not found file/directory '{}' in the commits"
        raise FileNotInCommitError(msg.format(target))
    return result
1000877
def match_ref(self, ref):
        
        if ref in self.refs:
            self._matched_ref = ref
            return True
        return False
341756
def _get_ref_info_helper(cls, repo, ref_path):
        """"""
        tokens = None
        repodir = _git_dir(repo, ref_path)
        try:
            with open(osp.join(repodir, ref_path), 'rt') as fp:
                value = fp.read().rstrip()
            # Don't only split on spaces, but on whitespace, which allows to parse lines like
            # 60b64ef992065e2600bfef6187a97f92398a9144                branch 'master' of git-server:/path/to/repo
            tokens = value.split()
            assert(len(tokens) != 0)
        except (OSError, IOError):
            # Probably we are just packed, find our entry in the packed refs file
            # NOTE: We are not a symbolic ref if we are in a packed file, as these
            # are excluded explicitly
            for sha, path in cls._iter_packed_refs(repo):
                if path != ref_path:
                    continue
                # sha will be used
                tokens = sha, path
                break
            # END for each packed ref
        # END handle packed refs
        if tokens is None:
            raise ValueError("Reference at %r does not exist" % ref_path)

        # is it a reference ?
        if tokens[0] == 'ref:':
            return (None, tokens[1])

        # its a commit
        if repo.re_hexsha_only.match(tokens[0]):
            return (tokens[0], None)

        raise ValueError("Failed to parse reference information from %r" % ref_path)