[Oi-commits] r1329 - in trunk/sanat: . templatetags

oi-commits at pardus.org.tr oi-commits at pardus.org.tr
Sat May 3 13:26:18 EEST 2008


Author: jnmbk
Date: Sat May  3 13:26:18 2008
New Revision: 1329

Modified:
   trunk/sanat/signals.py
   trunk/sanat/templatetags/thumbman.py
   trunk/sanat/utils.py
   trunk/sanat/views.py
Log:
find sanat/ -name "*.py"|xargs sed -i "s/\t/    /g"
In English: converted all tabs to spaces


Modified: trunk/sanat/signals.py
=================================================================
--- trunk/sanat/signals.py	(original)
+++ trunk/sanat/signals.py	Sat May  3 13:26:18 2008
@@ -8,28 +8,28 @@
 from utils import remove_model_thumbnails,make_thumbnail
 
 def crt_thumb(sender, instance, signal, *args,**kwargs):
-	""" create a new thumb for the created url"""
+    """ create a new thumb for the created url"""
 
-	#when it is deleted control if it has a thumbnail?
-	make_thumbnail(instance.file)
+    #when it is deleted control if it has a thumbnail?
+    make_thumbnail(instance.file)
 
 
 def rm_thumb(sender, instance, signal, *args,**kwargs):
-	""" Delete the ones that we dont need anymore"""
+    """ Delete the ones that we dont need anymore"""
 
-	remove_model_thumbnails(instance)
+    remove_model_thumbnails(instance)
 
 
 def rmv_files(sender, instance, signal, *args,**kwargs):
-	""" Delete the files associated with the tema file when it is deleted
-	we need that one because the relation is manytomany"""
+    """ Delete the files associated with the tema file when it is deleted
+    we need that one because the relation is manytomany"""
 
-	#may add not to remove the default one ???
+    #may add not to remove the default one ???
 
-	#remove the associated screens
-	for screen in instance.screens.all():
-		screen.delete()
-
-	#remove the assciated files
-	for file in instance.file_data.all():
-		file.delete()
+    #remove the associated screens
+    for screen in instance.screens.all():
+        screen.delete()
+
+    #remove the assciated files
+    for file in instance.file_data.all():
+        file.delete()

Modified: trunk/sanat/templatetags/thumbman.py
=================================================================
--- trunk/sanat/templatetags/thumbman.py	(original)
+++ trunk/sanat/templatetags/thumbman.py	Sat May  3 13:26:18 2008
@@ -73,9 +73,9 @@
     #
 
     if ('width' not in kwargs) and ('height' not in kwargs):
-		kwargs['width']=DEFAULT_WIDTH
-		kwargs['height']=DEFAULT_HEIGHT
-		#raise template.TemplateSyntaxError, "thumbnail filter requires arguments (width and/or height)"
+        kwargs['width']=DEFAULT_WIDTH
+        kwargs['height']=DEFAULT_HEIGHT
+        #raise template.TemplateSyntaxError, "thumbnail filter requires arguments (width and/or height)"
 
     ret = make_thumbnail(url, **kwargs)
     if ret is None:

Modified: trunk/sanat/utils.py
=================================================================
--- trunk/sanat/utils.py	(original)
+++ trunk/sanat/utils.py	Sat May  3 13:26:18 2008
@@ -25,28 +25,28 @@
 DEFAULT_WIDTH=100
 
 def _get_thumbnail_path(path, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT):
-	""" create thumbnail path from path and required width and/or height.
-	thumbnail file name is constructed like this:
+    """ create thumbnail path from path and required width and/or height.
+    thumbnail file name is constructed like this:
     <basename>_t_[w<width>][_h<height>].<extension>"""
 
-	basedir = os.path.dirname(path) + '/'
-	base, ext = os.path.splitext(os.path.basename(path))
+    basedir = os.path.dirname(path) + '/'
+    base, ext = os.path.splitext(os.path.basename(path))
 
-	# make thumbnail filename
-	th_name = base + '_t'
+    # make thumbnail filename
+    th_name = base + '_t'
 
-	if (width is not None) and (height is not None):
-		th_name += '_w%d_h%d' % (width, height)
+    if (width is not None) and (height is not None):
+        th_name += '_w%d_h%d' % (width, height)
 
-	elif width is not None:
-		th_name += '%d' % width # for compatibility with admin
+    elif width is not None:
+        th_name += '%d' % width # for compatibility with admin
 
-	elif height is not None:
-		th_name += '_h%d' % height
+    elif height is not None:
+        th_name += '_h%d' % height
 
-	th_name += ext
+    th_name += ext
 
-	return urlparse.urljoin(basedir, th_name)
+    return urlparse.urljoin(basedir, th_name)
 #
 
 def _get_path_from_url(url, root=MEDIA_ROOT, url_root=MEDIA_URL):
@@ -71,37 +71,37 @@
     # one of width/height is required
     #assert (width is not None) or (height is not None)
 
-	#if we just want to get a default one
-	if not width and not height:
-		place=_get_path_from_url(photo_url)
-
-		if place:
-			import fnmatch, os
-    		base, ext = os.path.splitext(os.path.basename(place))
-    		basedir = os.path.dirname(place)
-    		for file in fnmatch.filter(os.listdir(basedir), _THUMBNAIL_GLOB % (base, ext)):
-				#if it comes here it has a thumbnail
-				return True
-
-
-		else:
-			return False
-
-	else:
-		import os
-		return os.path.isfile(_get_path_from_url(_get_thumbnail_path(photo_url, width, height), root, url_root))
+    #if we just want to get a default one
+    if not width and not height:
+        place=_get_path_from_url(photo_url)
+
+        if place:
+            import fnmatch, os
+            base, ext = os.path.splitext(os.path.basename(place))
+            basedir = os.path.dirname(place)
+            for file in fnmatch.filter(os.listdir(basedir), _THUMBNAIL_GLOB % (base, ext)):
+                #if it comes here it has a thumbnail
+                return True
+
+
+        else:
+            return False
+
+    else:
+        import os
+        return os.path.isfile(_get_path_from_url(_get_thumbnail_path(photo_url, width, height), root, url_root))
 
 def model_has_thumbnail(model):
-	""" To see if given model has a thumbnail"""
-	for obj in model._meta.fields:
-		if isinstance(obj, FileField):
-			x=getattr(obj,'file')
-			if x :
-				x=_get_url_from_path(x)
-				return _has_thumbnail(x)
+    """ To see if given model has a thumbnail"""
+    for obj in model._meta.fields:
+        if isinstance(obj, FileField):
+            x=getattr(obj,'file')
+            if x :
+                x=_get_url_from_path(x)
+                return _has_thumbnail(x)
 
-			else:
-				return False
+            else:
+                return False
 
 
 def make_thumbnail(photo_url, width=DEFAULT_HEIGHT, height=DEFAULT_WIDTH, root=MEDIA_ROOT, url_root=MEDIA_URL):
@@ -161,28 +161,28 @@
 #
 
 def _remove_thumbnails(photo_url, root=MEDIA_ROOT, url_root=MEDIA_URL):
-	if not photo_url: return # empty url
-	file_name = _get_path_from_url(photo_url, root, url_root)
-	import fnmatch, os
-	base, ext = os.path.splitext(os.path.basename(file_name))
-	basedir = os.path.dirname(file_name)
+    if not photo_url: return # empty url
+    file_name = _get_path_from_url(photo_url, root, url_root)
+    import fnmatch, os
+    base, ext = os.path.splitext(os.path.basename(file_name))
+    basedir = os.path.dirname(file_name)
 
 
-	for file in fnmatch.filter(os.listdir(basedir), _THUMBNAIL_GLOB % (base, ext)):
-
-		path = os.path.join(basedir, file)
-		os.remove(path)
-		image_cache.delete(path) # delete from cache
+    for file in fnmatch.filter(os.listdir(basedir), _THUMBNAIL_GLOB % (base, ext)):
+
+        path = os.path.join(basedir, file)
+        os.remove(path)
+        image_cache.delete(path) # delete from cache
 
 
 def remove_model_thumbnails(model):
 
-	""" remove all thumbnails for all ImageFields (and subclasses) in the model """
-	for obj in model._meta.fields:
-		#print obj
-		if isinstance(obj, FileField):
-			url = getattr(model,'file')
-			_remove_thumbnails(url)
+    """ remove all thumbnails for all ImageFields (and subclasses) in the model """
+    for obj in model._meta.fields:
+        #print obj
+        if isinstance(obj, FileField):
+            url = getattr(model,'file')
+            _remove_thumbnails(url)
     #
 #
 

Modified: trunk/sanat/views.py
=================================================================
Suppressed!
	Too long (more than 250 lines) diff output suppressed...


More information about the Oi-commits mailing list