relative-path

How do I make these relative imports work in Python 3?

时光总嘲笑我的痴心妄想 提交于 2019-12-30 11:15:11
问题 I have a directory structure that looks like this: project/ __init__.py foo/ __init.py__ first.py second.py third.py plum.py In project/foo/__init__.py I import classes from first.py , second.py and third.py and put them in __all__ . There's a class in first.py named WonderfulThing which I'd like to use in second.py , and want to import by importing * from foo . (It's outside of the scope of this question why I'd like to do so, assume I have a good reason.) In second.py I've tried from .foo

Preferred way to include relative reference to JavaScript in VS 2008 nested Masterpage

假如想象 提交于 2019-12-30 04:38:19
问题 Our base Masterpage has something like the following <head runat="server"> <title></title> <script type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/actions.js")%>"></script> <script type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/jquery/jquery-1.2.6.min.js")%>"></script> <asp:contentplaceholder id="cph_htmlhead" runat="server"> </asp:contentplaceholder> </head> If this Masterpage is the Masterpage for an ASPX page things work fine. If this Masterpage is

Preferred way to include relative reference to JavaScript in VS 2008 nested Masterpage

自古美人都是妖i 提交于 2019-12-30 04:38:19
问题 Our base Masterpage has something like the following <head runat="server"> <title></title> <script type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/actions.js")%>"></script> <script type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/jquery/jquery-1.2.6.min.js")%>"></script> <asp:contentplaceholder id="cph_htmlhead" runat="server"> </asp:contentplaceholder> </head> If this Masterpage is the Masterpage for an ASPX page things work fine. If this Masterpage is

Relative paths with fetch in Javascript

倖福魔咒の 提交于 2019-12-30 03:50:07
问题 I was surprised by an experience with relative paths in Javascript today. I’ve boiled down the situation to the following: Suppose you have a directory structure like: app/ | +--app.html +--js/ | +--app.js +--data.json All my app.html does is run js/app.js <!DOCTYPE html> <title>app.html</title> <body> <script src=js/app.js></script> </body> app.js loads the JSON file and sticks it at the beginning of body : // js/app.js fetch('js/data.json') // <-- this path surprises me .then(response =>

Relative Links with Extension-less URLs

ぃ、小莉子 提交于 2019-12-29 09:17:06
问题 I have an ASP.NET 4.0 application that implements URL routing. This gives me page URLs with no extension (e.g. /Articles/{title}) Some of these pages contain relative links. When I test the site from Visual Studio, relative links point to /Articles/{title}/mylink. However, when I deploy my site to a shared hosting account, the same relative link points to /Articles/mylink. You can see the problem at http://blackbeltcoder.com/Articles/asp/creating-website-thumbnails-in-asp-net. The link to an

File Uri Scheme and Relative Files

我的梦境 提交于 2019-12-28 04:59:08
问题 Assume that the scheme for a uri is "file". Also assume that the path starts with '.' An example path is './.bashrc'. How would the fulluri look? 'file://./.bashrc' appears odd to me. 回答1: In short, a file URL takes the form of: file://localhost/absolute/path/to/file [ok] or you can omit the host (but not the slash): file:///absolute/path/to/file [ok] but not this: file://file_at_current_dir [no way] nor this: file://./file_at_current_dir [no way] I just confirmed that via Python's urllib2

Saving image - path problem

一笑奈何 提交于 2019-12-25 14:11:18
问题 public void SaveJpeg(string path, Image image, int quality) { //ensure the quality is within the correct range if ((quality < 0) || (quality > 100)) { //create the error message string error = string.Format("Jpeg image quality must be between 0 and 100, with 100 being the highest quality. A value of {0} was specified.", quality); //throw a helpful exception throw new ArgumentOutOfRangeException(error); } //create an encoder parameter for the image quality EncoderParameter qualityParam = new

Saving image - path problem

萝らか妹 提交于 2019-12-25 14:08:40
问题 public void SaveJpeg(string path, Image image, int quality) { //ensure the quality is within the correct range if ((quality < 0) || (quality > 100)) { //create the error message string error = string.Format("Jpeg image quality must be between 0 and 100, with 100 being the highest quality. A value of {0} was specified.", quality); //throw a helpful exception throw new ArgumentOutOfRangeException(error); } //create an encoder parameter for the image quality EncoderParameter qualityParam = new

Resolving an image uri relative to application root

末鹿安然 提交于 2019-12-25 03:45:28
问题 I am using Asp.Net MVC 5. Assume for this question that my application is being served from localhost:9000/app . I've got this in my _layout.cshtml : <img src="@Url.Content("~/Content/logo.png")" /> When the user requests localhost:9000/app/foobar , the image URI is correctly resolved to localhost:9000/app/Content/logo.png . But when the user requests localhost:9000/app/folder/bender_is_great , the image URI resolves to localhost:9000/app/folder/Content/logo.png . How do I get the image URI

Changing relative URLs of Javascript files

孤人 提交于 2019-12-25 02:58:12
问题 I'm screen scraping using Curl like this: <?php $url = "http://www.bbc.com/news/"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $curl_scraped_page = curl_exec($ch); curl_close($ch); echo $curl_scraped_page; ?> And then I echo the content on an HTML page. The problem is that when I look in my console I see 404 errors because of relative URLs assigned to javascript files. For instance if the URL is: somejavascriptfile.js on loading the page my domain name is added like