Browse Source

Merge pull request #7 from Qyriad/fixes/config-without-endpoints

emitters: allow endpoint-less configurations
main
Kate Temkin 4 years ago
committed by GitHub
parent
commit
fb56782455
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions
  1. +4
    -6
      usb_protocol/emitters/descriptor.py

+ 4
- 6
usb_protocol/emitters/descriptor.py View File

@@ -3,9 +3,10 @@
# #




from . import ConstructEmitter
from collections import defaultdict from collections import defaultdict


from . import ConstructEmitter

class ComplexDescriptorEmitter(ConstructEmitter): class ComplexDescriptorEmitter(ConstructEmitter):
""" Base class for emitting complex descriptors, which contain nested subordinates. """ """ Base class for emitting complex descriptors, which contain nested subordinates. """


@@ -28,7 +29,7 @@ class ComplexDescriptorEmitter(ConstructEmitter):
# Store a list of subordinate descriptors, and a count of # Store a list of subordinate descriptors, and a count of
# subordinate descriptor types. # subordinate descriptor types.
self._subordinates = [] self._subordinates = []
self._type_counts = {}
self._type_counts = defaultdict(int)




def add_subordinate_descriptor(self, subordinate): def add_subordinate_descriptor(self, subordinate):
@@ -48,10 +49,7 @@ class ComplexDescriptorEmitter(ConstructEmitter):
# Count this descriptor type... # Count this descriptor type...
subordinate_type = subordinate[1] subordinate_type = subordinate[1]


try:
self._type_counts[subordinate_type] += 1
except KeyError:
self._type_counts[subordinate_type] = 1
self._type_counts[subordinate_type] += 1


# ... and add the relevant bytes to our list of subordinates. # ... and add the relevant bytes to our list of subordinates.
self._subordinates.append(subordinate) self._subordinates.append(subordinate)


Loading…
Cancel
Save