本文整理汇总了Python中utils.clean函数的典型用法代码示例。如果您正苦于以下问题:Python clean函数的具体用法?Python clean怎么用?Python clean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
def register(username, password):
"""Registra el usuario y clave, devuelve:
0 si se registro exitosamente
1 si el usuario ya existe
2 si hubo otro problema
"""
username = utils.clean(username)
password = utils.clean(password)
# vemos si existe (medio feo, pero por ahora funciona, dependemos de
# que get_personal tira una excepcion si el usuario no existe)
p = None
try:
p = get_personal(username)
except:
pass
if p != None:
return 1
p = Personal()
p.username = username
p.password = password
try:
p.save()
except:
return 2
return 0
示例2: get_data
def get_data():
path = '/Users/zyzdiana/Dropbox/vNav_Test_Data/Apr_17_test_data/'
dict_10mm = {}
dict_6_4mm = {}
dict_8mm = {}
for root, dirs, files in os.walk(path):
if len(dirs)==0:
if('10mm' in root):
dict_10mm[root] = clean(files)
if('6_4mm' in root):
dict_6_4mm[root] = clean(files)
if('8mm' in root):
dict_8mm[root] = clean(files)
list_10mm = []
for item in dict_10mm.iteritems():
list_10mm.append(os.path.join(item[0],item[1][0]))
list_10mm.sort()
vols_10mm = get_volume(list_10mm, 26)
list_6_4mm = []
for item in dict_6_4mm.iteritems():
list_6_4mm.append(os.path.join(item[0],item[1][0]))
list_6_4mm.sort()
vols_6_4mm = get_volume(list_6_4mm, 40)
list_8mm = []
for item in dict_8mm.iteritems():
list_8mm.append(os.path.join(item[0],item[1][0]))
list_8mm.sort()
vols_8mm = get_volume(list_8mm, 32)
return vols_6_4mm, vols_8mm, vols_10mm
示例3: get_data_all
def get_data_all():
path = '/Users/zyzdiana/Dropbox/vNav_Test_Data/Apr_17_test_data/'
dict_10mm = {}
dict_6_4mm = {}
dict_8mm = {}
for root, dirs, files in os.walk(path):
if len(dirs)==0:
if('10mm' in root):
dict_10mm[root] = clean(files)
if('6_4mm' in root):
dict_6_4mm[root] = clean(files)
if('8mm' in root):
dict_8mm[root] = clean(files)
keys_10 = sorted(dict_10mm.keys())
keys_8 = sorted(dict_8mm.keys())
keys_6_4 = sorted(dict_6_4mm.keys())
all_10mm = {}
all_8mm = {}
all_6_4mm = {}
for i in xrange(5):
all_10mm[idx_to_key(i, keys_10)] = []
all_8mm[idx_to_key(i, keys_8)] = []
all_6_4mm[idx_to_key(i, keys_6_4)] = []
for j in xrange(5):
# 10mm
path = os.path.join(idx_to_key(i, keys_10),dict_10mm[idx_to_key(i, keys_10)][j])
all_10mm[idx_to_key(i, keys_10)].append(get_volume_1(path, 26))
# 8mm
path = os.path.join(idx_to_key(i, keys_8),dict_8mm[idx_to_key(i, keys_8)][j])
all_8mm[idx_to_key(i, keys_8)].append(get_volume_1(path, 32))
# 6.4mm
path = os.path.join(idx_to_key(i, keys_6_4),dict_6_4mm[idx_to_key(i, keys_6_4)][j])
all_6_4mm[idx_to_key(i, keys_6_4)].append(get_volume_1(path, 40))
return all_10mm, all_8mm, all_6_4mm
示例4: main
def main(_):
if FLAGS.train:
if FLAGS.clean:
clean(FLAGS)
train()
else:
evaluate_line()
示例5: install
def install():
utils.clean()
peg.install()
fcgi.install()
json_glib.install()
discount.install()
balde.install()
bluster.install()
utils.clean()
示例6: register
def register(username, password):
"""Registra el usuario y clave, devuelve:
0 si se registro exitosamente
1 si el usuario ya existe
2 si hubo otro problema
"""
# TODO: si alguien molesta con esto, hay que armar un mecanismo para
# evitar DoS (tampoco es muy complicado).
username = utils.clean(username)
password = utils.clean(password)
return personal.register(username, password)
示例7: listar_radios
def listar_radios(name,url):
link= clean(abrir_url(url))
radios=re.compile('<td><a href="/portalradio/conteudos/ficha/.+?radio_id=(.+?)">(.+?)</a></td><td>(.+?)</td>.+?<td align="center">').findall(link)
for idradio,nomeradio,concelho in radios:
addDir('[B]'+nomeradio+'[/B] ('+concelho+')',RadiosURL + 'Sintonizador/?radio_id=' + idradio + '&scope=0',21,'http://www.radio.com.pt/APR.ROLI.WEB/Images/Logos/'+ idradio +'.gif',len(radios),'',False)
xbmc.executebuiltin("Container.SetViewMode(501)")
paginasradios(url,link)
示例8: eligibility
def eligibility(self):
try:
table = utils.Table(self.soup.select("table[summary~=Land]")[0])
except IndexError:
return None
return utils.clean(table["Eligibility"].text.strip())
示例9: load_words
def load_words(self, folderpath):
filenames = glob.glob(folderpath)
for f in filenames:
with open(f, 'r') as infile:
text = infile.read()
text = utils.clean(text)
self.words.append([text])
示例10: post
def post(self):
db=self.application.database
content = self.request.arguments.get("content", [""])[0]
parent = self.request.arguments.get("parent", [None])[0]
super_parent = self.request.arguments.get("super_parent", [None])[0]
content = clean(content)
new_comment = {
"content" : content,
"time" : datetime.utcnow(),
"author" : self.get_current_user(),
"plusvote": list(),
"minusvote": list()
}
if parent != None:
new_comment["parent"] = parent
if super_parent != None:
new_comment["super_parent"] = super_parent
new_id = db.comments.insert(new_comment)
print new_id
print parent
print db.comments.update({"_id": ObjectId(parent)}, {"$push": {"children": str(new_id)}})
self.redirect("/")
示例11: __init__
def __init__(self, schema, output_dir=None):
''' Bind array of cleaned schema file lines to validator object. '''
self.schema = utils.clean(schema)
self.output_dir = output_dir
self.indent_size = self._find_first_indent()['indent_size']
self.error = {'msg': None}
示例12: rate
def rate(classifier,filename,medi,mad,medi_ld,mad_ld):
#For now, just assuming the text is csv
results = classifier
with open(filename,'rU') as f:
reader = csv.reader(f,delimiter=',')
data = [(get_features(tech.clean(row[2]),medi,mad,medi_ld,mad_ld),row[0]) for row in reader]
print nltk.classify.accuracy(classifier,data)
示例13: new
def new(self):
self.name = self.parse('company.name')
self.suffix = self.fetch('company.suffix')
self.website = "http://www.%s.%s" % (
clean(self.name),
self.fetch('internet.domain_suffix')
)
示例14: process_text
def process_text(self):
text = utils.clean(self.get_tweet_text())
self.set_tweet_text(text)
self.set_tweet_source(utils.parse_alink(self.get_tweet_source()))
if self.translation:
self.detect_language_or_translate()
self.filter_text()
示例15: listasextras
def listasextras():
iptvurl='http://01.gen.tr/HasBahCa_IPTV/'
link= clean(abrir_url(iptvurl))
streams=re.compile('<a class="autoindex_a" href="./(.+?)">.+?<td class="autoindex_td_right">.+?</td.+?td class="autoindex_td_right">(.+?)</td>').findall(link)
for nomepasta,act in streams:
if re.search('.m3u',nomepasta):
titulo=nomepasta.replace('.m3u','').replace('_',' ').title()
addDir("[B]%s[/B] (act.%s)" % (titulo,act[2:-2]),iptvurl + nomepasta,5,tvporpath + art + 'listas-ver2.png',1,'',True)