diff options
author | Jeremy Allison <jra@samba.org> | 2010-03-31 10:01:03 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2010-03-31 10:01:03 -0700 |
commit | 2e839a636b2ea3f4d8dfcf5a8e99d9725787ba61 (patch) | |
tree | 42f219978f7d07d8fa196cb9ebd9db7be971450d /lib/testtools/testtools/content_type.py | |
parent | f58d02dbeeeba037ee79fba93a707e959e90ffa3 (diff) | |
parent | 6f30b9a6ff57ca6112e6319c64c411d2bf09be79 (diff) | |
download | samba-2e839a636b2ea3f4d8dfcf5a8e99d9725787ba61.tar.gz samba-2e839a636b2ea3f4d8dfcf5a8e99d9725787ba61.tar.bz2 samba-2e839a636b2ea3f4d8dfcf5a8e99d9725787ba61.zip |
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'lib/testtools/testtools/content_type.py')
-rw-r--r-- | lib/testtools/testtools/content_type.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/testtools/testtools/content_type.py b/lib/testtools/testtools/content_type.py new file mode 100644 index 0000000000..aded81b732 --- /dev/null +++ b/lib/testtools/testtools/content_type.py @@ -0,0 +1,30 @@ +# Copyright (c) 2009 Jonathan M. Lange. See LICENSE for details. + +"""ContentType - a MIME Content Type.""" + + +class ContentType(object): + """A content type from http://www.iana.org/assignments/media-types/ + + :ivar type: The primary type, e.g. "text" or "application" + :ivar subtype: The subtype, e.g. "plain" or "octet-stream" + :ivar parameters: A dict of additional parameters specific to the + content type. + """ + + def __init__(self, primary_type, sub_type, parameters=None): + """Create a ContentType.""" + if None in (primary_type, sub_type): + raise ValueError("None not permitted in %r, %r" % ( + primary_type, sub_type)) + self.type = primary_type + self.subtype = sub_type + self.parameters = parameters or {} + + def __eq__(self, other): + if type(other) != ContentType: + return False + return self.__dict__ == other.__dict__ + + def __repr__(self): + return "%s/%s params=%s" % (self.type, self.subtype, self.parameters) |