本文整理汇总了Python中urllib.url2pathname函数的典型用法代码示例。如果您正苦于以下问题:Python url2pathname函数的具体用法?Python url2pathname怎么用?Python url2pathname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了url2pathname函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: info_alumno_cra
def info_alumno_cra():
cursor = configuracion.conexion().cursor()
filtroCRA = ''
#Capturamos los diferentes filtros
if request.args.get('filtroCRA'):
filtroCRA = url2pathname(request.args.get('filtroCRA')).encode('utf-8')
filtroMuni = ''
if request.args.get('filtroMuni'):
filtroMuni = url2pathname(request.args.get('filtroMuni')).encode('utf-8')
query = "SELECT to_number(REPLACE(SUBSTRING(distancia from 1 for (char_length(distancia)-3)),',','.'), '99999.999'),\
to_number(REPLACE(SUBSTRING(tiempo_estimado from 1 for (char_length(tiempo_estimado)-19)),',','.'), '99999.999')/60,\
educ_cra_evol.año FROM public.educ_cra_evol, public.trayecto WHERE educ_cra_evol.id_mun = trayecto.id_mun AND \
educ_cra_evol.id_cra = trayecto.cra_id AND trayecto.año = (SELECT MAX(año) FROM public.trayecto) AND\
educ_cra_evol.año = (SELECT MAX(año) FROM public.educ_cra_evol) AND educ_cra_evol.id_cra="+str(filtroCRA).strip()+" AND educ_cra_evol.id_mun="+str(filtroMuni).strip()+";"
cursor.execute(query)
resultado = cursor.fetchone()
cursor.close()
if resultado is not None:
info_alumno_cra={
'cra_id':str(filtroCRA).strip(),
'id_mun':str(filtroMuni).strip(),
'distancia':resultado[0],
'tiempo_estimado':resultado[1]
}
return json.dumps(info_alumno_cra)
else:
return "No existe ese trayecto"
开发者ID:eunzue,项目名称:CRAS-AOD-Version,代码行数:30,代码来源:views.py
示例2: onDND
def onDND(self, list, context, x, y, dragData, dndId, time):
""" External Drag'n'Drop """
import urllib
if dragData.data == '':
context.finish(False, False, time)
return
# A list of filenames, without 'file://' at the beginning
if dndId == consts.DND_POGO_URI:
tracks = media.getTracks([urllib.url2pathname(uri) for uri in dragData.data.split()])
# A list of filenames starting with 'file://'
elif dndId == consts.DND_URI:
tracks = media.getTracks([urllib.url2pathname(uri)[7:] for uri in dragData.data.split()])
else:
assert False
# dropInfo is tuple (path, drop_pos)
dropInfo = list.get_dest_row_at_pos(x, y)
# Insert the tracks, but beware of the AFTER/BEFORE mechanism used by GTK
if dropInfo is None:
self.insert(tracks, playNow=False, highlight=True)
else:
path, drop_mode = dropInfo
iter = self.tree.store.get_iter(path)
self.insert(tracks, iter, drop_mode, playNow=False, highlight=True)
# We want to allow dropping tracks only when we are sure that no dir is
# selected. This is needed for dnd from nautilus.
self.tree.dir_selected = True
context.finish(True, False, time)
开发者ID:csryan,项目名称:pogo,代码行数:33,代码来源:Tracktree.py
示例3: test_quoting
def test_quoting(self):
# Test automatic quoting and unquoting works for pathnam2url() and
# url2pathname() respectively
given = os.path.join("needs", "quot=ing", "here")
expect = "needs/%s/here" % urllib.quote("quot=ing")
result = urllib.pathname2url(given)
self.assertEqual(expect, result,
"pathname2url() failed; %s != %s" %
(expect, result))
expect = given
result = urllib.url2pathname(result)
self.assertEqual(expect, result,
"url2pathname() failed; %s != %s" %
(expect, result))
given = os.path.join("make sure", "using_quote")
expect = "%s/using_quote" % urllib.quote("make sure")
result = urllib.pathname2url(given)
self.assertEqual(expect, result,
"pathname2url() failed; %s != %s" %
(expect, result))
given = "make+sure/using_unquote"
expect = os.path.join("make+sure", "using_unquote")
result = urllib.url2pathname(given)
self.assertEqual(expect, result,
"url2pathname() failed; %s != %s" %
(expect, result))
开发者ID:CONNJUR,项目名称:SparkyExtensions,代码行数:26,代码来源:test_urllib.py
示例4: rutas_para_scrapear
def rutas_para_scrapear():
cursor = configuracion.conexion().cursor()
filtroCRA = ''
#Capturamos los diferentes filtros
if request.args.get('filtroCRA'):
filtroCRA = url2pathname(request.args.get('filtroCRA')).encode('utf-8')
filtroMuni = ''
if request.args.get('filtroMuni'):
filtroMuni = url2pathname(request.args.get('filtroMuni')).encode('utf-8')
query = "SELECT educ_cra.id_cra, educ_cra.cra, educ_cra.lat, educ_cra.lon, a_municipios.id_mun, a_municipios.municipio, a_municipios.lat, a_municipios.lon, educ_cra_evol.año FROM public.educ_cra_evol, public.educ_cra, public.a_municipios WHERE educ_cra.id_cra = educ_cra_evol.id_cra AND a_municipios.id_mun = educ_cra_evol.id_mun AND año = (SELECT MAX(año) FROM educ_cra_evol) AND educ_cra_evol.id_mun="+str(filtroMuni).strip()+" AND educ_cra_evol.id_cra="+str(filtroCRA).strip()+";"
cursor.execute(query)
resultado = cursor.fetchone()
cursor.close()
if resultado is not None:
cra={
'id': resultado[0],
'name': resultado[1].replace('á', 'aacute;').replace('é', 'eacute;').replace('í', 'iacute;').replace('ó', 'oacute;').replace('ú', 'uacute;').replace('Á', 'Aacute;').replace('É', 'Eacute;').replace('Í', 'Iacute;').replace('Ó', 'Oacute;').replace('Ú', 'Uacute;').replace('"', 'quot;').replace('<', 'lt;').replace('>', 'gt;').replace('¿', 'iquest;').replace('¡', 'iexcl;').replace('Ñ', 'Ntilde;').replace('ñ', 'ntilde;').replace('º', 'ordm;').replace('ª', 'ordf;').replace('#', 'almohadilla;').replace('ü', 'uuml;'),
'latlng': [resultado[2], resultado[3]]
}
municipio={
'id':resultado[4],
'name': resultado[5].replace('á', 'aacute;').replace('é', 'eacute;').replace('í', 'iacute;').replace('ó', 'oacute;').replace('ú', 'uacute;').replace('Á', 'Aacute;').replace('É', 'Eacute;').replace('Í', 'Iacute;').replace('Ó', 'Oacute;').replace('Ú', 'Uacute;').replace('"', 'quot;').replace('<', 'lt;').replace('>', 'gt;').replace('¿', 'iquest;').replace('¡', 'iexcl;').replace('Ñ', 'Ntilde;').replace('ñ', 'ntilde;').replace('º', 'ordm;').replace('ª', 'ordf;').replace('#', 'almohadilla;').replace('ü', 'uuml;'),
'latlng': [resultado[6], resultado[7]]
}
datos={
'origen':municipio,
'destino':cra
}
return render_template('scrapeo.html', data=datos)
else:
return "No existe ese trayecto"
开发者ID:eunzue,项目名称:CRAS-AOD-Version,代码行数:35,代码来源:views.py
示例5: __iter__
def __iter__(self):
base = urllib.url2pathname(self.output.strip('/'))
for item in self.previous:
pathkey = self.pathkey(*item.keys())[0]
if not pathkey or not self.output: # not enough info
yield item;
continue
path = item[pathkey]
type = item.get('_type')
path = os.path.join(base, urllib.url2pathname(path))
#TODO replace field in item with file object and make other
# blueprints expect a file. This will reduce memory usage.
meta_data = item.get('_content_info')
if meta_data:
meta_data = dict(meta_data)
if type in ['Document']:
item['text'] = self.savefile(item['text'], path, meta_data)
elif type in ['Page']:
item['body'] = self.savefile(item['body'], path, meta_data)
elif type in ['File']:
item['file'] = self.savefile(item['file'], path, meta_data)
elif type in ['Image']:
item['image'] = self.savefile(item['image'], path, meta_data)
elif type in ['Folder', 'ContentFolder']:
makedirs(path)
elif item.get('_html', None) is not None:
item['_html'] = self.savefile(item['_html'], path, meta_data)
elif item.get('_content') is not None:
item['_content'] = self.savefile(item['_content'], path, meta_data)
yield item
开发者ID:sureshvv,项目名称:transmogrify.webcrawler,代码行数:32,代码来源:staticcreator.py
示例6: destPathFromURI
def destPathFromURI(uri):
"""Return the local path where a uri should be stored"""
urlParts = urlparse.urlparse(uri)
# take the leading / off the path part, and return it
pathPart = urlParts[2][1:]
fullPath = os.path.join(config.mediaStoreRoot, urllib.url2pathname(urlParts[1]), pathPart)
# check if the pathname is already in use, and if it is,
# append a number that increments until we find a
# filename that's available.
pathNameOK = not os.path.exists(fullPath)
count = 1
while not pathNameOK:
# another download has this filename already
try:
basename = pathPart[:pathPart.rindex(u'.')]
exten = pathPart[pathPart.rindex(u'.'):]
except ValueError:
basename = pathPart
exten = ""
fullPath = os.path.join(config.mediaStoreRoot, urllib.url2pathname(urlParts[1]), basename + u'_' + unicode(count) + exten)
pathNameOK = not os.path.exists(fullPath)
count += 1
return fullPath
开发者ID:lee-b,项目名称:katchtv,代码行数:25,代码来源:utils.py
示例7: put
def put(self, sourceurl, desturl):
sourceurl = urllib.url2pathname(sourceurl)
desturl = urllib.url2pathname(desturl)
self.instrumentation.say("put(%s, %s)" % (sourceurl, desturl))
destdir = os.path.dirname(desturl)
self._shell.mkdirs(destdir, ignoreexisting=True)
self._shell.copy(sourceurl, desturl)
开发者ID:isleon,项目名称:Jaxer,代码行数:7,代码来源:net.py
示例8: __iter__
def __iter__(self):
base = urllib.url2pathname(self.output.strip('/'))
for item in self.previous:
pathkey = self.pathkey(*item.keys())[0]
if not pathkey or not self.output: # not enough info
yield item;
continue
path = item[pathkey]
type = item.get('_type')
path = os.path.join(base, urllib.url2pathname(path))
meta_data = item.get('_content_info')
if meta_data:
meta_data = dict(meta_data)
if '_redir' in item:
#important we save redirects to preseve exact behaviour of website
meta_data = {'Location':item['_site_url']+item['_redir']}
savefile(None, path, meta_data, self.logger)
elif type in ['Document']:
item['text'] = savefile(item['text'], path, meta_data, self.logger)
elif type in ['Page']:
item['body'] = savefile(item['body'], path, meta_data, self.logger)
elif type in ['File']:
item['file'] = savefile(item['file'], path, meta_data, self.logger)
elif type in ['Image']:
item['image'] = savefile(item['image'], path, meta_data, self.logger)
elif type in ['Folder', 'ContentFolder']:
makedirs(path)
elif item.get('_html', None) is not None:
item['_html'] = savefile(item['_html'], path, meta_data, self.logger)
elif item.get('_content') is not None:
item['_content'] = savefile(item['_content'], path, meta_data, self.logger)
yield item
开发者ID:collective,项目名称:transmogrify.webcrawler,代码行数:34,代码来源:staticcreator.py
示例9: Download
def Download(path):
dp = xbmcgui.DialogProgress()
dp.create("xnapi" )
dp.update( 50, "Searching for subtitles...", " ", " " )
d = md5.new();
subtitlesCustomPath = xbmc.executehttpapi('GetGuiSetting(3;subtitles.custompath)').replace("<li>", "")
d.update(open(path,"rb").read(10485760))
arch=xbmc.translatePath( os.path.join( "special://userdata/", "napisy.txt"))
str = "http://napiprojekt.pl/unit_napisy/dl.php?l=PL&f="+d.hexdigest()+"&t="+f(d.hexdigest())+"&v=dreambox&kolejka=false&nick=&pass=&napios="+os.name
subs=urllib.urlopen(str).read()
if (subs[0:4]=='NPc0'):
xbmcgui.Dialog().ok( "xnapi","No subtitles found.")
else:
file(arch,"wb").write(subs)
if subtitlesCustomPath == "": #save in movie directory
if (path[0:6]=="""rar://"""): # playing rar file
filename=(os.path.join((os.path.split(os.path.split(urllib.url2pathname(path))[0])[0])[6:],(os.path.split(path)[1])[:-3]+'txt'))#.replace('/','\\')
#remove rar://, get directory outside archive, add playing file name
else:
filename=path[:-3]+'txt'
else:
filename=os.path.join(subtitlesCustomPath,os.path.split(urllib.url2pathname(path))[1][:-3]+'txt')
if os.path.isfile(filename) == True: # there already were subs
filename=filename[:-4]+'-xnapi.txt'
if os.path.isfile(filename) == True:
dp.update( 75, "Replacing old subtitles...", " ", " " )
shutil.copyfile(arch,filename)
xbmcgui.Dialog().ok( "xnapi", "Subtitles extracted to: \n" + os.path.dirname(filename))
开发者ID:drrlramsey,项目名称:xbmc-addons,代码行数:31,代码来源:xnapi_download.py
示例10: onDND
def onDND(self, list, context, x, y, dragData, dndId, time):
""" External Drag'n'Drop """
import urllib
if dragData.data == '':
context.finish(False, False, time)
return
# A list of filenames, without 'file://' at the beginning
if dndId == consts.DND_DAP_URI:
tracks = media.getTracks([urllib.url2pathname(uri) for uri in dragData.data.split()])
# A list of filenames starting with 'file://'
elif dndId == consts.DND_URI:
tracks = media.getTracks([urllib.url2pathname(uri)[7:] for uri in dragData.data.split()])
# A list of tracks
elif dndId == consts.DND_DAP_TRACKS:
tracks = [track.unserialize(serialTrack) for serialTrack in dragData.data.split('\n')]
dropInfo = list.get_dest_row_at_pos(x, y)
# Insert the tracks, but beware of the AFTER/BEFORE mechanism used by GTK
if dropInfo is None: self.insert(tracks, False)
elif dropInfo[1] == gtk.TREE_VIEW_DROP_AFTER: self.insert(tracks, False, dropInfo[0][0] + 1)
else: self.insert(tracks, False, dropInfo[0][0])
context.finish(True, False, time)
开发者ID:rshk-archive,项目名称:decibel-audio-player,代码行数:26,代码来源:Tracklist.py
示例11: test_goodfile
def test_goodfile(self):
# Our file templates. Try a vanilla version and one with escapes.
# NB:
# This is only supported on the Mac at the moment, when
# windows support arrives we will need to extract the paths and
# see what it looks like and add a test here.
path1 = "/Users/xxx/Music/iTunes/iTunes%20Music/"
path2 = ("/Volumes/%E3%83%9B%E3%83%BC%E3%83%A0/" +
"xxx/Music/iTunes/iTunes%20Media/")
file_snippet1 = file_template % dict(path=(self.file_url + path1))
file_snippet2 = file_template % dict(path=(self.file_url + path2))
tmpf_dir = os.path.dirname(self.tmpf_path)
# Test vanilla path
self._clean_tmpf()
self.tmpf.write(file_snippet1)
self.tmpf.flush()
path = import_itunes_path(tmpf_dir)
self.assertEquals(path, urllib.url2pathname(path1))
# Test path with utf-8 escapes
self._clean_tmpf()
self.tmpf.write(file_snippet2)
self.tmpf.flush()
path = import_itunes_path(tmpf_dir)
self.assertEquals(path, urllib.url2pathname(path2))
开发者ID:cool-RR,项目名称:Miro,代码行数:26,代码来源:importtest.py
示例12: decoded_data
def decoded_data(self):
import urllib
if not hasattr(self, '_decoded_data'):
self._decoded_data = {}
for keyvalue in self.data.split('&'):
key, value = keyvalue.split(':')
self._decoded_data[urllib.url2pathname(key)] = urllib.url2pathname(value)
return self._decoded_data
开发者ID:boxed,项目名称:kodare,代码行数:8,代码来源:models.py
示例13: get_xhtml_content
def get_xhtml_content(path):
if path.startswith("/") or path.startswith("\\"):
path = os.path.join(settings.BASEDIR, url2pathname(path[1:]))
else:
path = os.path.join(settings.BASEDIR, url2pathname(path))
f = codecs.open(path, "r", "utf8")
content = f.read()
f.close()
return content
开发者ID:Yaco-Sistemas,项目名称:wirecloud,代码行数:9,代码来源:utils.py
示例14: _uri_to_path
def _uri_to_path(uri):
"""Return the path corresponding to the URI <uri>, unless it is a
non-local resource in which case we return the pathname with the type
identifier intact.
"""
if uri.startswith('file://'):
return urllib.url2pathname(uri[7:])
else:
return urllib.url2pathname(uri)
开发者ID:HenryHu,项目名称:Comix,代码行数:9,代码来源:thumbremover.py
示例15: test_ntpath
def test_ntpath(self):
given = ("/C:/", "///C:/", "/C|//")
expect = "C:\\"
for url in given:
result = urllib.url2pathname(url)
self.assertEqual(expect, result, "nturl2path.url2pathname() failed; %s != %s" % (expect, result))
given = "///C|/path"
expect = "C:\\path"
result = urllib.url2pathname(given)
self.assertEqual(expect, result, "nturl2path.url2pathname() failed; %s != %s" % (expect, result))
开发者ID:plirof,项目名称:minibloq_v0.83,代码行数:10,代码来源:test_urllib.py
示例16: _get_move
def _get_move(self, data):
old_file_path = url2pathname(data[1])
new_file_path = url2pathname(data[2])
# check if the data string is correct
if len(old_file_path) == 0 or len(new_file_path) == 0:
self.connection.send('ERROR\n')
else:
answer = self.parent.move(old_file_path, new_file_path, self.computer_name)
if answer:
self.connection.send('OK\n')
开发者ID:martinzellner,项目名称:sourceBox,代码行数:11,代码来源:server_communication_controller.py
示例17: filename
def filename(self):
"""a local filename equivalent to the URI"""
if self.scheme != "file":
raise ValueError("only the file scheme supports filenames")
elif self.netloc:
raise ValueError("only local files have filenames")
else:
if os.name == "nt":
return fsdecode(url2pathname(self.path))
else:
return url2pathname(self.path)
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:11,代码来源:uri.py
示例18: dbPath2SrcPathFn
def dbPath2SrcPathFn(self, path):
p = urlparse.urlparse(path)
if not p.scheme == 'file':
self.number_warnings += 1
self.log.warning("WARNING: FIX dbPath2SrcPathFn: "+ path)
path_fn = urllib.url2pathname(p.path) # converts to unicode, does not work
path_fn = urllib.url2pathname(p.path).encode('latin-1') # does work
#path_fn = urllib.unquote(p.path)
#print "dbPath2SrcPathFn() Orig path: %s" % path
#print "dbPath2SrcPathFn() New path (%s): %s" % (type(path_fn), path_fn)
return path_fn
开发者ID:chadn,项目名称:android-utils,代码行数:11,代码来源:enqueue-playlists.py
示例19: _del_groups
def _del_groups(self, req):
groups_to_del = req.args.get('selgroup')
try:
if isinstance(groups_to_del,types.StringTypes):
self.authz.del_group(url2pathname(groups_to_del))
elif isinstance(groups_to_del,types.ListType):
for group in groups_to_del:
self.authz.del_group(url2pathname(group))
else:
req.hdf['delgroup.error'] = "Invalid type of group selection"
except Exception, e:
req.hdf['delgroup.error'] = e
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:12,代码来源:admin_ui.py
示例20: media_path
def media_path(path):
# Check for stacked movies
try:
path = os.path.split(path)[0].rsplit(' , ', 1)[1].replace(",,", ",")
except:
path = os.path.split(path)[0]
# Fixes problems with rared movies and multipath
if path.startswith("rar://"):
path = os.path.split(urllib.url2pathname(path.replace("rar://", "")))[0]
elif path.startswith("multipath://"):
temp_path = path.replace("multipath://", "").split('%2f/')
path = urllib.url2pathname(temp_path[0])
return path
开发者ID:braz96,项目名称:script.toolbox,代码行数:13,代码来源:Utils.py
注:本文中的urllib.url2pathname函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论