Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for unicode type for tags and pairs

  • Loading branch information...
commit 2718d8a0b3789f9b35cbe26cbbd5a3c5d7eabb47 1 parent ada3e68
@harryf authored
Showing with 8 additions and 8 deletions.
  1. +8 −8 dammit/uri.py
View
16 dammit/uri.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import sys, datetime, sha, re
+import sys, datetime, sha, re, logging
import constants
def Property(function):
@@ -227,7 +227,7 @@ def fset(self, time):
raise TypeError("Expecting datetime.datetime not %s" % type(time))
self._updated = time
- validtag = re.compile("^[a-zA-Z0-9]{1,%s}$" % constants.URI_TAG_LEN)
+ validtag = re.compile("^[a-zA-Z0-9]{1,%s}$" % constants.URI_TAG_LEN, re.U)
@Property
def tags():
"""
@@ -266,7 +266,7 @@ def fset(self, keywords):
)
for tag in keywords:
- if not isinstance(tag, str):
+ if not type(tag) in (unicode, str):
raise TypeError(
"Tag '%s' must be a string not %s" % (tag, type(tag))
)
@@ -295,7 +295,7 @@ def tags_updated():
def fget(self):
return self.meta.get('tags_updated', False)
- validpairkey = re.compile("^[a-zA-Z0-9]{1,%s}$" % constants.URI_PAIR_KEY_LEN)
+ validpairkey = re.compile("^[a-zA-Z0-9]{1,%s}$" % constants.URI_PAIR_KEY_LEN, re.U)
@Property
def pairs():
"""
@@ -340,7 +340,7 @@ def fset(self, mapping):
for k, v in mapping.items():
- if not isinstance(k, str):
+ if not type(k) in (unicode, str):
raise TypeError(
"Key '%s' must be a string not %s" % (k, type(v))
)
@@ -348,7 +348,7 @@ def fset(self, mapping):
if not URI.validpairkey.match(k):
raise ValueError("Invalid key '%s'" % k)
- if not isinstance(v, str):
+ if not type(v) in (unicode, str):
raise TypeError(
"Value for key '%s' must be a string not %s" % (k, type(v))
)
@@ -689,8 +689,8 @@ def apply_attribute(uri, key, value):
if not getattr(uri, key) == value:
setattr(uri, key, value)
updated = True
- except:
- pass
+ except Exception, e:
+ logging.error("Error applying key '%s' for '%s': %s", key, uri.uri, e)
return updated
Please sign in to comment.
Something went wrong with that request. Please try again.