Allow explicit types in PGPPacket._clean_type
authorW. Trevor King <wking@tremily.us>
Fri, 20 Dec 2013 21:13:19 +0000 (13:13 -0800)
committerW. Trevor King <wking@tremily.us>
Mon, 23 Dec 2013 02:31:23 +0000 (18:31 -0800)
This will let me use it to clean the signature subpacket type for
parsing signature subpackets.

gpg-migrate.py

index 08ba42402e36467bf1c8d70fd37196380141ec2e..515760b4a5cd29de2e68059cf95b55cbbb81705e 100755 (executable)
@@ -235,8 +235,10 @@ class PGPPacket (dict):
 
     _clean_type_regex = _re.compile('\W+')
 
-    def _clean_type(self):
-        return self._clean_type_regex.sub('_', self['type'])
+    def _clean_type(self, type=None):
+        if type is None:
+            type = self['type']
+        return self._clean_type_regex.sub('_', type)
 
     def __str__(self):
         method_name = '_str_{}'.format(self._clean_type())