src/cm/utils/files.py
author Simon Descarpentries <sid@sopinspace.com>
Wed, 09 May 2012 17:13:33 +0200
changeset 417 c5e91f204371
parent 0 40c8f766c9b8
permissions -rw-r--r--
After investigations, commit the proposed patch by kklimonda presented with the following introduction : cm/templates/site/login_form.html template uses a relative url for the form action, which seems to break deployment in the subfolder when trailing slash is missing (the form redirects to the upper folder breaking login). Using {% url login %} (as in the attached patch) instead would fix the issue.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     1
def remove_extension(file_name):
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     2
    """
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     3
    Remove 3 letters and 4 letters extension from filename
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     4
    
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     5
    >>> remove_extension('my file.tex')
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     6
    'my file'
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     7
    >>> remove_extension('my file.html')
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     8
    'my file'
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     9
    >>> remove_extension('my file')
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    10
    'my file'
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    11
    """
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    12
    for point_loc in [3,4]:
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    13
        if len(file_name)>point_loc and file_name[-point_loc-1] == '.':
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    14
            return file_name[:-point_loc-1] 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    15
    return file_name
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    16
    
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    17
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    18
if __name__ == "__main__":
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    19
    import doctest
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    20
    doctest.testmod()