ethpm / py-ethpm

This library is deprecated. ethPM python tooling is now located in web3.py
MIT License
24 stars 13 forks source link

Expose simple properties on the Package object #6

Closed pipermerriam closed 6 years ago

pipermerriam commented 6 years ago

What needs to be done?

Packages have a few simple properties:

These properties should be exposed on the Package object through the Package.name and Package.version properties.

def name(self):
   ... # return the package name pulled from the package info

Additionally, implement a __repr__ function on the Package object which returns a string formatted like <Package {package_name}=={version})>.

The package named tokens at version 1.2.3 would return the string "<Package owned==1.2.3>" when repr is called on it.

carver commented 6 years ago

The (name, version) tuple is non-unique, right? Maybe it's worth adding more info here to get to uniqueness (or close enough). I imagine the first 20 characters of the content hash are sufficient. Or maybe there's some other attribute that's better.

pipermerriam commented 6 years ago

I imagine the first 20 characters of the content hash are sufficient. Or maybe there's some other attribute that's better.

I'm 👍 on this to be done in a separate issue which exposes a new property Package.hash which returns the keccak256 hash of the package contents.

pipermerriam commented 6 years ago

Also, see https://github.com/ethpm/ethpm-spec/issues/77 which should help with hashing packages in a consistent manner.