Subversion Repositories basico

Rev

Rev 357 | Rev 359 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 357 Rev 358
Line 72... Line 72...
72
72
73
    def get_file_extension(self, path):
73
    def get_file_extension(self, path):
74
        # Get extension
74
        # Get extension
75
        rest, extension = os.path.splitext(path)
75
        rest, extension = os.path.splitext(path)
76
        ext = (extension[1:]).lower()
76
        ext = (extension[1:]).lower()
77
        self.log.debug("\tExtension: %s", ext)
-
 
78
        if (len(ext) != 0):
-
 
-
 
77
        ext = ext.strip()
-
 
78
        if len(ext) > 0:
79
            return '%s' % ext
79
            return '%s' % ext
80
        else:
80
        else:
81
            return '#noext#'
81
            return '#noext#'
82
82
83
83
Line 92... Line 92...
92
    def get_file_name_with_ext(self, path):
92
    def get_file_name_with_ext(self, path):
93
        # Filename
93
        # Filename
94
        basename = self.get_file_basename(path)
94
        basename = self.get_file_basename(path)
95
        extension = self.get_file_extension(path)
95
        extension = self.get_file_extension(path)
96
        if extension == '#noext#':
96
        if extension == '#noext#':
97
            extension = ''
-
 
98
        title = '%s.%s' % (basename, extension)
-
 
-
 
97
            title = basename
-
 
98
        else:
-
 
99
            title = '%s.%s' % (basename, extension)
99
        self.log.debug("\tTitle: %s", title)
100
        self.log.debug("\tTitle: %s", title)
100
        return title
101
        return title
101
       
102
       
102
103
103
    def get_file_mimetype(self, ext):
104
    def get_file_mimetype(self, ext):
104
        try:
105
        try:
105
            mimetype, description = self.extensions[ext]
106
            mimetype, description = self.extensions[ext]
106
            self.log.debug("\tMimetype: %s", mimetype)
107
            self.log.debug("\tMimetype: %s", mimetype)
107
            return mimetype
108
            return mimetype
108
        except Exception as error:
-
 
109
            self.log.error(error)
-
 
110
            return None
-
 
111
           
-
 
-
 
109
        except Exception as warning:
-
 
110
            self.log.warning(warning)
-
 
111
            return 'application/x-other'
112
112
113
113
114
    def get_file_doctype(self, mimetype):
114
    def get_file_doctype(self, mimetype):
115
        mtype = mimetype[:mimetype.rfind('/')]
115
        mtype = mimetype[:mimetype.rfind('/')]
116
        doctype = mtype.title()
116
        doctype = mtype.title()
Line 121... Line 121...
121
    def get_file_description(self, ext):
121
    def get_file_description(self, ext):
122
        try:
122
        try:
123
            filetype, description = self.extensions[ext]
123
            filetype, description = self.extensions[ext]
124
            self.log.debug("\tDescription: %s", description)
124
            self.log.debug("\tDescription: %s", description)
125
            return description
125
            return description
126
        except:
-
 
127
            return None
-
 
-
 
126
        except Exception as warning:
-
 
127
            self.log.error(warning)
-
 
128
            return 'Unknow file type'
128
129
129
130
130
    def get_disk_usage(self, path):
131
    def get_disk_usage(self, path):
131
        """
132
        """
132
        Get disk usage for a given path
133
        Get disk usage for a given path