Skip to content

Hashing an EPM #73

@cthoyt

Description

@cthoyt

It might be worth having a way to hash an EPM so they can be quickly indexed / compared for equality

def get_hash(self) -> str:
    import hashlib
    from operator import attrgetter

    h = hashlib.md5()
    for record in sorted(self.records, key=attrgetter("prefix")):
        h.update(record.prefix.encode("utf8"))
        h.update(record.uri_prefix.encode("utf8"))
        for s in itt.chain(sorted(record.prefix_synonyms), sorted(record.uri_prefix_synonyms)):
            h.update(s.encode("utf8"))
    return h.hexdigest()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions