From 56d5d44ecdb9a86f33b77422b6690e97d042465a Mon Sep 17 00:00:00 2001 From: rcritten Date: Tue, 17 Nov 2009 15:47:26 +0000 Subject: [PATCH] - Update to upstream version 0.0.9a - Include patch that adds parsing for the Any type --- .cvsignore | 2 +- pyasn1-any.patch | 110 +++++++++++++++++++++++++++++++++++++++++++++ python-pyasn1.spec | 10 ++++- sources | 2 +- 4 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 pyasn1-any.patch diff --git a/.cvsignore b/.cvsignore index 6e95705..bc1a19d 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -pyasn1-0.0.8a.tar.gz +pyasn1-0.0.9a.tar.gz diff --git a/pyasn1-any.patch b/pyasn1-any.patch new file mode 100644 index 0000000..302aeb2 --- /dev/null +++ b/pyasn1-any.patch @@ -0,0 +1,110 @@ +diff -uN --recursive pyasn1-0.0.9a/pyasn1/v1/codec/ber/decoder.py pyasn1-0.0.9a.any/pyasn1/v1/codec/ber/decoder.py +--- pyasn1-0.0.9a/pyasn1/v1/codec/ber/decoder.py 2008-11-23 06:45:14.000000000 -0500 ++++ pyasn1-0.0.9a.any/pyasn1/v1/codec/ber/decoder.py 2009-11-16 15:36:38.000000000 -0500 +@@ -312,6 +312,29 @@ + class UTCTimeDecoder(OctetStringDecoder): + protoComponent = useful.UTCTime() + ++class AnyDecoder(ChoiceDecoder): ++ protoComponent = univ.Any ++ def __init__(self, header): ++ self.__header = header ++ def _createComponent(self, tagSet, asn1Spec): ++ if asn1Spec is None: ++ return self.protoComponent(tagSet=tagSet) ++ else: ++ return asn1Spec.clone() ++ def valueDecoder(self, substrate, asn1Spec, tagSet, ++ length, state, decodeFun): ++ if not decodeFun: ++ return r, substrate ++ component, new_substrate = decodeFun( ++ substrate, None, tagSet, length, state ++ ) ++ assert substrate.endswith(new_substrate) ++ if new_substrate: ++ substrate = substrate[:-len(new_substrate)] ++ return univ.Any(self.__header+substrate), new_substrate ++ ++ indefLenValueDecoder = valueDecoder ++ + codecMap = { + eoo.endOfOctets.tagSet: EndOfOctetsDecoder(), + univ.Integer.tagSet: IntegerDecoder(), +@@ -352,6 +375,7 @@ + # Decode tag & length + while state != stStop: + if state == stDecodeTag: ++ substrate_full = substrate + # Decode tag + if not substrate: + raise error.SubstrateUnderrunError( +@@ -415,6 +439,7 @@ + raise error.SubstrateUnderrunError( + '%d-octet short' % (length - len(substrate)) + ) ++ substrate_header = substrate_full[:-len(substrate) or None] + if state == stGetValueDecoder: + if asn1Spec is None: + state = stGetValueDecoderByTag +@@ -457,7 +482,12 @@ + __chosenSpec = asn1Spec + else: + __chosenSpec = None +- if __chosenSpec is None or not\ ++ if __chosenSpec is None and isinstance(asn1Spec, dict) and \ ++ isinstance(asn1Spec.get(univ.Any.tagSet), univ.Any): ++ concreteDecoder = AnyDecoder(substrate_header) ++ asn1Spec = None ++ state = stDecodeValue ++ elif __chosenSpec is None or not\ + __chosenSpec.getTypeMap().has_key(tagSet): + state = stTryAsExplicitTag + else: +Binary files pyasn1-0.0.9a/pyasn1/v1/codec/ber/.decoder.py.swp and pyasn1-0.0.9a.any/pyasn1/v1/codec/ber/.decoder.py.swp differ +diff -uN --recursive pyasn1-0.0.9a/pyasn1/v1/codec/ber/encoder.py pyasn1-0.0.9a.any/pyasn1/v1/codec/ber/encoder.py +--- pyasn1-0.0.9a/pyasn1/v1/codec/ber/encoder.py 2008-05-17 05:59:56.000000000 -0400 ++++ pyasn1-0.0.9a.any/pyasn1/v1/codec/ber/encoder.py 2009-11-16 15:36:38.000000000 -0500 +@@ -194,6 +194,16 @@ + ) + substrate + return substrate, 1 + ++class AnyEncoder(AbstractItemEncoder): ++ def _encodeTag(self, t, isConstructed): ++ if isConstructed: ++ return chr(t[0]|t[1]|t[2]|tag.tagFormatConstructed) ++ else: ++ return chr(t[0]|t[1]|t[2]) ++ def _encodeValue(self, encodeFun, value, defMode, maxChunkSize): ++ assert len(value._value) <= maxChunkSize ++ return str(value._value), 0 ++ + codecMap = { + eoo.endOfOctets.tagSet: EndOfOctetsEncoder(), + univ.Boolean.tagSet: IntegerEncoder(), +@@ -234,7 +244,10 @@ + if len(tagSet) > 1: + concreteEncoder = explicitlyTaggedItemEncoder + else: +- concreteEncoder = self.__codecMap.get(tagSet) ++ if isinstance(value, univ.Any): ++ concreteEncoder = AnyEncoder() ++ else: ++ concreteEncoder = self.__codecMap.get(tagSet) + if not concreteEncoder: + # XXX + baseTagSet = tagSet.getBaseTag() +diff -uN --recursive pyasn1-0.0.9a/pyasn1/v1/type/univ.py pyasn1-0.0.9a.any/pyasn1/v1/type/univ.py +--- pyasn1-0.0.9a/pyasn1/v1/type/univ.py 2008-11-23 06:45:35.000000000 -0500 ++++ pyasn1-0.0.9a.any/pyasn1/v1/type/univ.py 2009-11-16 15:36:38.000000000 -0500 +@@ -629,5 +629,10 @@ + + def setDefaultComponents(self): pass + ++class Any(base.AbstractSimpleAsn1Item): ++ tagSet = tag.TagSet() # untagged, XXX as in Choice ++ defaultValue = '' ++ def prettyOut(self, value): return repr(value) ++ + # XXX + # coercion rules? diff --git a/python-pyasn1.spec b/python-pyasn1.spec index d210942..471a9d2 100644 --- a/python-pyasn1.spec +++ b/python-pyasn1.spec @@ -3,8 +3,8 @@ %define module pyasn1 Name: python-pyasn1 -Version: 0.0.8a -Release: 5%{?dist} +Version: 0.0.9a +Release: 1%{?dist} Summary: ASN.1 tools for Python License: BSD Group: System Environment/Libraries @@ -13,6 +13,7 @@ URL: http://pyasn1.sourceforge.net/ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch BuildRequires: python-devel python-setuptools +Patch1: pyasn1-any.patch %description This project is dedicated to implementation of ASN.1 types (concrete syntax) @@ -22,6 +23,7 @@ compiler is planned for implementation in the future. %prep %setup -n %{module}-%{version} -q +%patch1 -p1 %build @@ -44,6 +46,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Nov 16 2009 Rob Crittenden - 0.0.9a-1 +- Update to upstream version 0.0.9a +- Include patch that adds parsing for the Any type + * Wed Sep 2 2009 Rob Crittenden - 0.0.8a-5 - Include doc/notes.html in the package diff --git a/sources b/sources index b696bfb..73f8ec0 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -1befe83fd3d8dd8bb0d0fbe58a5788a5 pyasn1-0.0.8a.tar.gz +a6b26c57bae5484381cd558c15277c03 pyasn1-0.0.9a.tar.gz