1- # coding: utf-8
2-
31import os
42import re
53
1311ALNUM_NAME_RE = re .compile (FOLDER_REGEX , re .U )
1412
1513TRANSPOSE_CHOICES = (
16- ("" , u "-----" ),
17- ("0" , _ (u "Flip horizontal" )),
18- ("1" , _ (u "Flip vertical" )),
19- ("2" , _ (u "Rotate 90° CW" )),
20- ("4" , _ (u "Rotate 90° CCW" )),
21- ("3" , _ (u "Rotate 180°" )),
14+ ("" , "-----" ),
15+ ("0" , _ ("Flip horizontal" )),
16+ ("1" , _ ("Flip vertical" )),
17+ ("2" , _ ("Rotate 90° CW" )),
18+ ("4" , _ ("Rotate 90° CCW" )),
19+ ("3" , _ ("Rotate 180°" )),
2220)
2321
2422
@@ -27,7 +25,7 @@ class CreateDirForm(forms.Form):
2725 Form for creating a folder.
2826 """
2927
30- name = forms .CharField (widget = forms .TextInput (attrs = dict ({'class' : 'vTextField' }, max_length = 50 , min_length = 3 )), label = _ (u 'Name' ), help_text = _ (u 'Only letters, numbers, underscores, spaces and hyphens are allowed.' ), required = True )
28+ name = forms .CharField (widget = forms .TextInput (attrs = dict ({'class' : 'vTextField' }, max_length = 50 , min_length = 3 )), label = _ ('Name' ), help_text = _ ('Only letters, numbers, underscores, spaces and hyphens are allowed.' ), required = True )
3129
3230 def __init__ (self , path , * args , ** kwargs ):
3331 self .path = path
@@ -39,10 +37,10 @@ def clean_name(self):
3937 if self .cleaned_data ['name' ]:
4038 # only letters, numbers, underscores, spaces and hyphens are allowed.
4139 if not ALNUM_NAME_RE .search (self .cleaned_data ['name' ]):
42- raise forms .ValidationError (_ (u 'Only letters, numbers, underscores, spaces and hyphens are allowed.' ))
40+ raise forms .ValidationError (_ ('Only letters, numbers, underscores, spaces and hyphens are allowed.' ))
4341 # Folder must not already exist.
4442 if self .site .storage .isdir (os .path .join (self .path , convert_filename (self .cleaned_data ['name' ]))):
45- raise forms .ValidationError (_ (u 'The Folder already exists.' ))
43+ raise forms .ValidationError (_ ('The Folder already exists.' ))
4644 return convert_filename (self .cleaned_data ['name' ])
4745
4846
@@ -51,8 +49,8 @@ class ChangeForm(forms.Form):
5149 Form for renaming a file/folder.
5250 """
5351
54- custom_action = forms .ChoiceField (label = _ (u 'Actions' ), required = False )
55- name = forms .CharField (widget = forms .TextInput (attrs = dict ({'class' : 'vTextField' }, max_length = 50 , min_length = 3 )), label = _ (u 'Name' ), help_text = _ (u 'Only letters, numbers, underscores, spaces and hyphens are allowed.' ), required = True )
52+ custom_action = forms .ChoiceField (label = _ ('Actions' ), required = False )
53+ name = forms .CharField (widget = forms .TextInput (attrs = dict ({'class' : 'vTextField' }, max_length = 50 , min_length = 3 )), label = _ ('Name' ), help_text = _ ('Only letters, numbers, underscores, spaces and hyphens are allowed.' ), required = True )
5654
5755 def __init__ (self , * args , ** kwargs ):
5856 self .path = kwargs .pop ("path" , None )
@@ -61,7 +59,7 @@ def __init__(self, *args, **kwargs):
6159 super (ChangeForm , self ).__init__ (* args , ** kwargs )
6260
6361 # Initialize choices of custom action
64- choices = [("" , u "-----" )]
62+ choices = [("" , "-----" )]
6563 for name , action in self .site .applicable_actions (self .fileobject ):
6664 choices .append ((name , action .short_description ))
6765 self .fields ['custom_action' ].choices = choices
@@ -71,10 +69,10 @@ def clean_name(self):
7169 if self .cleaned_data ['name' ]:
7270 # only letters, numbers, underscores, spaces and hyphens are allowed.
7371 if not ALNUM_NAME_RE .search (self .cleaned_data ['name' ]):
74- raise forms .ValidationError (_ (u 'Only letters, numbers, underscores, spaces and hyphens are allowed.' ))
72+ raise forms .ValidationError (_ ('Only letters, numbers, underscores, spaces and hyphens are allowed.' ))
7573 # folder/file must not already exist.
7674 if self .site .storage .isdir (os .path .join (self .path , convert_filename (self .cleaned_data ['name' ]))) and os .path .join (self .path , convert_filename (self .cleaned_data ['name' ])) != self .fileobject .path :
77- raise forms .ValidationError (_ (u 'The Folder already exists.' ))
75+ raise forms .ValidationError (_ ('The Folder already exists.' ))
7876 elif self .site .storage .isfile (os .path .join (self .path , convert_filename (self .cleaned_data ['name' ]))) and os .path .join (self .path , convert_filename (self .cleaned_data ['name' ])) != self .fileobject .path :
79- raise forms .ValidationError (_ (u 'The File already exists.' ))
77+ raise forms .ValidationError (_ ('The File already exists.' ))
8078 return convert_filename (self .cleaned_data ['name' ])
0 commit comments