Package deefuzzer :: Package deefuzzer :: Package tools :: Module tools
[hide private]
[frames] | no frames]

Source Code for Module deefuzzer.deefuzzer.tools.tools

 1  #!/usr/bin/python 
 2  # -*- coding: utf-8 -*- 
 3  # 
 4  # Copyright (c) 2007-2009 Guillaume Pellerin <yomguy@parisson.com> 
 5  # All rights reserved. 
 6  # 
 7  # This software is licensed as described in the file COPYING, which 
 8  # you should have received as part of this distribution. The terms 
 9  # are also available at http://svn.parisson.org/deefuzz/wiki/DefuzzLicense. 
10  # 
11  # Author: Guillaume Pellerin <yomguy@parisson.com> 
12   
13  import os 
14  import re 
15  import string 
16   
17 -def clean_word(word) :
18 """ Return the word without excessive blank spaces, underscores and 19 characters causing problem to exporters""" 20 word = re.sub("^[^\w]+","",word) #trim the beginning 21 word = re.sub("[^\w]+$","",word) #trim the end 22 word = re.sub("_+","_",word) #squeeze continuous _ to one _ 23 word = re.sub("^[^\w]+","",word) #trim the beginning _ 24 #word = string.replace(word,' ','_') 25 #word = string.capitalize(word) 26 dict = '&[];"*:,' 27 for letter in dict: 28 word = string.replace(word,letter,'_') 29 return word
30
31 -def get_file_info(media):
32 file_name = media.split(os.sep)[-1] 33 file_title = file_name.split('.')[:-1] 34 file_title = '.'.join(file_title) 35 file_ext = file_name.split('.')[-1] 36 return file_name, file_title, file_ext
37