try:
os.makedirs(dir)
except IOError:
- raise 'Could not create the '+dir+' directory !'
+ raise 'Could not create the ' + dir + ' directory !'
def get_files(self):
list = []
def read_bin(self, file):
path = self.dir + os.sep + file
- f = open(path, 'r')
+ f = open(path, 'r')
data = f.read()
f.close()
return data
def read_stream_bin(self, file):
path = self.dir + os.sep + file
chunk_size = 0x80000
- f = open(path, 'r')
+ f = open(path, 'r')
while True:
chunk = f.read(chunk_size)
if not len(chunk):
def get_random_hash():
hash = random.getrandbits(64)
return "%016x" % hash
-
+
class MediaResource(ModelCore):
"Base class of all media objects"
return 'image' in self.mime_type or is_url_image
def save(self, force_insert=False, force_update=False, author=None):
- super(MediaRelated, self).save(force_insert, force_update)
+ super(MediaRelated, self).save(force_insert, force_update)
def set_mime_type(self):
if self.file:
"Check if the collection code is well formed"
regex = '^' + collection_code_regex + '$'
if not re.match(regex, value):
- raise ValidationError(u'%s is not a valid collection code' % value)
+ raise ValidationError('%s is not a valid collection code' % value)
# General informations
reference = CharField(_('reference'), unique=True, null=True)
title = CharField(_('title'))
date = DateTimeField(_('date'), auto_now=True)
description = TextField(_('description'))
- author = ForeignKey(User, related_name="markers", verbose_name=_('author'),
+ author = ForeignKey(User, related_name="markers", verbose_name=_('author'),
blank=True, null=True)
class Meta(MetaCore):