Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#28450 closed enhancement (implemented)

Add a parse_bytes function to load descriptors from bytes

Reported by: irl Owned by: irl
Priority: Medium Milestone:
Component: Archived/Stem Version:
Severity: Normal Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: atagar Sponsor:


This is a convenience function that wraps the bytes in a BytesIO and calls parse_file().

Child Tickets

Attachments (1)

0001-Adds-a-parse_bytes-function-to-load-descriptors.patch (2.8 KB) - added by irl 21 months ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 21 months ago by irl

Owner: changed from atagar to irl
Status: newaccepted

comment:2 Changed 21 months ago by irl

Reviewer: atagar
Status: acceptedneeds_review

comment:3 Changed 21 months ago by atagar

Status: needs_reviewneeds_information

Thanks irl! I took this in a slightly different direction.

Changes from your patch are...

  • Moved this to Descriptor.from_str() to match the convention used elsewhere in stem's codebase.
  • Fixed a bug where the kwargs weren't passed along.
  • The method provides a single descriptor by default, with a multiple = True argument that must be supplied if you want a list instead. I did this because for the common case of parsing a single descriptor stem's been a little clunky.
  • Descriptor type inference can now be done in three ways: a descriptor_type argument, a @type annotation, and use of from_str() on subclasses (for example, RelayServerDescriptor.from_str()).
  • Test coverage.


comment:4 Changed 21 months ago by atagar

Resolution: implemented
Status: needs_informationclosed

Resolving. Feel free to reopen if ya need anything else.

comment:5 Changed 21 months ago by irl

I am now using this in bushel and it is working great.

Note: See TracTickets for help on using tickets.