Here are the examples of the python api urllib.request.pathname2url taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
47 Examples
3
View Complete Implementation : aboutdialog.py
Copyright MIT License
Author : Akuli
Copyright MIT License
Author : Akuli
def show_huge_logo(junk_event=None):
path = os.path.join(dirs.installdir, 'images', 'logo.gif')
astert os.path.isfile(path)
# web browsers are good at displaying large images, and webbrowser.open
# actually tries xdg-open first, so this will be used on linux if an image
# viewer program is installed, and i guess that other platforms just open
# up a web browser or something
webbrowser.open('file://' + pathname2url(path))
3
View Complete Implementation : executor.py
Copyright MIT License
Author : AmeyKamat
Copyright MIT License
Author : AmeyKamat
def execute(self, context):
message = context.message
ensaties = context.nlp_yyyysis.ensaties
if "query" in ensaties:
search_query = ensaties["query"]
else:
search_query = message
result = {}
result["url"] = self.config["search_api"] + urllib.request.pathname2url(search_query)
return result
3
View Complete Implementation : executor.py
Copyright MIT License
Author : AmeyKamat
Copyright MIT License
Author : AmeyKamat
def execute(self, context):
ensaties = context.nlp_yyyysis.ensaties
search_query = ensaties["query"]
result = {}
result["url"] = self.config["wikipedia_api"] + urllib.request.pathname2url(search_query)
return result
3
View Complete Implementation : test_field.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : anhaidgroup
Copyright BSD 3-Clause "New" or "Revised" License
Author : anhaidgroup
def test_init_1(self):
vectors_cache_dir = '.cache'
if os.path.exists(vectors_cache_dir):
shutil.rmtree(vectors_cache_dir)
pathdir = os.path.abspath(os.path.join(test_dir_path, 'test_datasets'))
filename = 'fasttext_sample.vec.zip'
url_base = urljoin('file:', pathname2url(pathdir)) + os.path.sep
mft = FastText(filename, url_base=url_base, cache=vectors_cache_dir)
self.astertEqual(mft.dim, 300)
self.astertEqual(mft.vectors.size(), torch.Size([100, 300]))
if os.path.exists(vectors_cache_dir):
shutil.rmtree(vectors_cache_dir)
3
View Complete Implementation : test_field.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : anhaidgroup
Copyright BSD 3-Clause "New" or "Revised" License
Author : anhaidgroup
@raises(RuntimeError)
def test_init_1(self):
vectors_cache_dir = '.cache'
if os.path.exists(vectors_cache_dir):
shutil.rmtree(vectors_cache_dir)
pathdir = os.path.abspath(os.path.join(test_dir_path, 'test_datasets'))
filename = 'fasttext_sample.vec.zip'
url_base = urljoin('file:', pathname2url(os.path.join(pathdir, filename)))
mftb = FastTextBinary(filename, url_base=url_base, cache=vectors_cache_dir)
if os.path.exists(vectors_cache_dir):
shutil.rmtree(vectors_cache_dir)
3
View Complete Implementation : test_field.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : anhaidgroup
Copyright BSD 3-Clause "New" or "Revised" License
Author : anhaidgroup
@raises(OSError)
def test_init_2(self):
vectors_cache_dir = '.cache'
if os.path.exists(vectors_cache_dir):
shutil.rmtree(vectors_cache_dir)
pathdir = os.path.abspath(os.path.join(test_dir_path, 'test_datasets'))
filename = 'fasttext_sample_not_exist.vec.zip'
url_base = urljoin('file:', pathname2url(os.path.join(pathdir, filename)))
mftb = FastTextBinary(filename, url_base=url_base, cache=vectors_cache_dir)
if os.path.exists(vectors_cache_dir):
shutil.rmtree(vectors_cache_dir)
3
View Complete Implementation : test_field.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : anhaidgroup
Copyright BSD 3-Clause "New" or "Revised" License
Author : anhaidgroup
@raises(OSError)
def test_init_3(self):
vectors_cache_dir = '.cache'
if os.path.exists(vectors_cache_dir):
shutil.rmtree(vectors_cache_dir)
pathdir = os.path.abspath(os.path.join(test_dir_path, 'test_datasets'))
filename = 'fasttext_sample_not_exist.gz'
url_base = urljoin('file:', pathname2url(os.path.join(pathdir, filename)))
mftb = FastTextBinary(filename, url_base=url_base, cache=vectors_cache_dir)
if os.path.exists(vectors_cache_dir):
shutil.rmtree(vectors_cache_dir)
3
View Complete Implementation : test_field.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : anhaidgroup
Copyright BSD 3-Clause "New" or "Revised" License
Author : anhaidgroup
def test_get_vector_data(self):
vectors_cache_dir = '.cache'
if os.path.exists(vectors_cache_dir):
shutil.rmtree(vectors_cache_dir)
pathdir = os.path.abspath(os.path.join(test_dir_path, 'test_datasets'))
filename = 'fasttext_sample.vec'
file = os.path.join(pathdir, filename)
url_base = urljoin('file:', pathname2url(file))
vecs = Vectors(name=filename, cache=vectors_cache_dir, url=url_base)
self.astertIsInstance(vecs, Vectors)
vec_data = MatchingField._get_vector_data(vecs, vectors_cache_dir)
self.astertEqual(len(vec_data), 1)
self.astertEqual(vec_data[0].vectors.size(), torch.Size([100, 300]))
self.astertEqual(vec_data[0].dim, 300)
if os.path.exists(vectors_cache_dir):
shutil.rmtree(vectors_cache_dir)
3
View Complete Implementation : __init__.py
Copyright MIT License
Author : darrikonn
Copyright MIT License
Author : darrikonn
def __init__(self):
db_uri = "file:{}".format(pathname2url(self._get_database_path()))
try:
self.connection = sqlite3.connect("{}?mode=rw".format(db_uri), uri=True)
self.cursor = self.connection.cursor()
except sqlite3.OperationalError:
self._initialise_database(db_uri)
self._link_services()
self.cursor.execute("PRAGMA foreign_keys = ON")
3
View Complete Implementation : utils.py
Copyright Apache License 2.0
Author : google
Copyright Apache License 2.0
Author : google
def file_path_to_file_url(path):
"""Return a path as a file scheme url."""
if not path:
return ''
path = path.lstrip(WINDOWS_PREFIX_PATH)
# TODO(mbarbella): urljoin has several type checks for arguments. Ensure that
# we're pasting newstr on both sides while migrating to Python 3. After
# migrating, ensure that callers past strs to avoid this hack.
from builtins import str
return urllib.parse.urljoin(
str(u'file:'), str(urllib.request.pathname2url(path)))