Python
Moderators: Col_Fury, michel, Arthur, Somebody, StrayLamb
- Russ Chappell
- Site Admin
- Posts: 5670
- Joined: Thu Feb 12, 2004 5:40 pm
- Location: Tuscaloosa, AL
- Contact:
Python
Is anyone familiar with basic, rudimentary Python? The Search function is written in Python, and I need some help with coding it to ignore something in the listings.
I can't promise you that things will improve, if we make changes;
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
-
- Big Bad
- Posts: 193
- Joined: Sat Jun 06, 2015 6:20 am
Re: Python
Yeah, I know basic Python. I could take a look, but I don't know everything about Python, so if it's too complex, I'm not sure to to what extent I could help. But yeah, I'm up for it.
- Russ Chappell
- Site Admin
- Posts: 5670
- Joined: Thu Feb 12, 2004 5:40 pm
- Location: Tuscaloosa, AL
- Contact:
Re: Python
Thanks for the offer. Here's the deal, and of course, anyone is free to chip in:
Each character in the project has some code surrounding their name that allows us to collapse or expand the listings, so it doesn't take up as much screen space. Here's the way a normal character is listed:
The collapse/expand program uses the "char" and "chron" classes to control what gets expanded or collapsed. All of that works fine with the Search Program.
However, we're creating a new page that's giving us problems. We're setting up one page as a repository of alternate universe characters, with characters grouped together under their alternate universe. You can view the page here:
http://www.chronologyproject.com/alternate.php
The difference in this page from all the others is that we want to be able to also collapse individual universes. Here's the way we list a universe that has three characters:
Note the following:
The line that begins with "<div id"
The line that reads "</span></div>
The line that reads "<p><hr></p>
In addition, note that the FIRST character in each universe (and ONLY the first character) begins its entry with an extra <span class="chron">
We've got that code working the way that we want it for collapsing and expanding, but it's giving the Search program indigestion.
When I run the python program that builds the search index, we get a lot of warnings about "not an ok figure". It doesn't like any of the three lines that I pointed out above. It doesn't seem to have any problem with the extra <span class="chron"> at the beginning of every universe's first character.
I'm hoping that we can solve the problem by getting the python program to ignore any lines that read:
and
and any line that starts with:
You'll probably need a copy of the python program we use to build the search index. It's fairly small, and I can email it to you. Is the email attached to your account here appropriate for that?
Each character in the project has some code surrounding their name that allows us to collapse or expand the listings, so it doesn't take up as much screen space. Here's the way a normal character is listed:
Code: Select all
<p id="2-D"><span class="char"><b>2-D</b></span><br>
<span class="chron">
A:I@ 1/5-FB<br>
</span></p>
However, we're creating a new page that's giving us problems. We're setting up one page as a repository of alternate universe characters, with characters grouped together under their alternate universe. You can view the page here:
http://www.chronologyproject.com/alternate.php
The difference in this page from all the others is that we want to be able to also collapse individual universes. Here's the way we list a universe that has three characters:
Code: Select all
<div id="EARTH-27"><span class="char"><input type="button" value="Universe" disabled> <b>EARTH-27</b></span>
<span class="chron"><p id="MAGNETO_27"><span class="char"><b>MAGNETO | EARTH-27</b></span><br>
<span class="chron">
EX2 83<br>
</span></p>
<p id="NIGHTCRAWLER_27"><span class="char"><b>NIGHTCRAWLER | EARTH-27</b></span><br>
<span class="chron">
EX2 83<br>
</span></p>
<p id="ROGUE_27"><span class="char"><b>ROGUE | EARTH-27</b></span><br>
<span class="chron">
EX2 83<br>
</span></p>
</span></div>
<p><hr></p>
The line that begins with "<div id"
The line that reads "</span></div>
The line that reads "<p><hr></p>
In addition, note that the FIRST character in each universe (and ONLY the first character) begins its entry with an extra <span class="chron">
We've got that code working the way that we want it for collapsing and expanding, but it's giving the Search program indigestion.
When I run the python program that builds the search index, we get a lot of warnings about "not an ok figure". It doesn't like any of the three lines that I pointed out above. It doesn't seem to have any problem with the extra <span class="chron"> at the beginning of every universe's first character.
I'm hoping that we can solve the problem by getting the python program to ignore any lines that read:
Code: Select all
</span></div>
Code: Select all
<p><hr></p>
Code: Select all
<div id=
I can't promise you that things will improve, if we make changes;
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
-
- Big Bad
- Posts: 193
- Joined: Sat Jun 06, 2015 6:20 am
Re: Python
Yep, a copy of the code would be useful. Any e-mail I have attached to this forum is there for this kind of thing, so feel free to send it to me. Thanks!
-
- Big Bad
- Posts: 193
- Joined: Sat Jun 06, 2015 6:20 am
Re: Python
Ok, I haven't looked at the code in-depth yet, but as I see it, there are three solutions to the problem:
1) We find a way to make the program completely skip those lines.
2) We find a way to make the program ignore those lines (like comments).
3) We find another way to get the desired effect on the web page.
Probably won't work, but have you tried using the exception function to simply ignore the errors? (https://docs.python.org/2/tutorial/errors.html)
-wolverine
1) We find a way to make the program completely skip those lines.
2) We find a way to make the program ignore those lines (like comments).
3) We find another way to get the desired effect on the web page.
Probably won't work, but have you tried using the exception function to simply ignore the errors? (https://docs.python.org/2/tutorial/errors.html)
-wolverine
- Russ Chappell
- Site Admin
- Posts: 5670
- Joined: Thu Feb 12, 2004 5:40 pm
- Location: Tuscaloosa, AL
- Contact:
Re: Python
Not really a fan of option 3, since everything else works the way we want. #2 SHOULD be an option in any programming language; I just don't know how to carry it out in Python.wolverine7230 wrote:1) We find a way to make the program completely skip those lines.
2) We find a way to make the program ignore those lines (like comments).
3) We find another way to get the desired effect on the web page.
As I mentioned in my email, the program APPEARS to work properly, even though I get errors, so it may be possible to simply manually ignore the errors, but I'm hesitant to use an exception to not report the error, since there could be true errors on the pages that need to be corrected (unless we could write the exception to specifically focus on those phrases I mentioned in the earlier post).Probably won't work, but have you tried using the exception function to simply ignore the errors? (https://docs.python.org/2/tutorial/errors.html)
I can't promise you that things will improve, if we make changes;
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
Re: Python
Obvious question time - have you tried copying the .chron style to a new style (say, .universe, with JS copying to follow) so that there wouldn't be a <div style="chron"> inside a <div style="chron">? I don't know how much attention the program pays to the HTML, but it's at least possible that confuses it.
- Russ Chappell
- Site Admin
- Posts: 5670
- Joined: Thu Feb 12, 2004 5:40 pm
- Location: Tuscaloosa, AL
- Contact:
Re: Python
We don't have that, now.Somebody wrote:so that there wouldn't be a <div style="chron"> inside a <div style="chron">?
It's a SPAN style chron inside a DIV style chron. Two different things. I had thought about making the new universe coding a span style too, but that would require nesting spans within each other. Is that possible?
And even then, we'd still need to find a way to get it to ignore the visual separator between universes (the hr).
I can't promise you that things will improve, if we make changes;
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
-
- Big Bad
- Posts: 193
- Joined: Sat Jun 06, 2015 6:20 am
Re: Python
On the 'is that possible?': I find with programming it's just about going for it. Backup the file and try it.
Re: Python
On phone right now, so this is from memory.
You can put inline within inline (i.e., span within span) and block within block (i.e., div within div). What you can't - or at least shouldn't - do, IIRC, is put block within inline (i.e., div inside a span).Russ Chappell wrote:We don't have that, now.Somebody wrote:so that there wouldn't be a <div style="chron"> inside a <div style="chron">?
It's a SPAN style chron inside a DIV style chron. Two different things. I had thought about making the new universe coding a span style too, but that would require nesting spans within each other. Is that possible?
Meh.Russ Chappell wrote:And even then, we'd still need to find a way to get it to ignore the visual separator between universes (the hr).
Code: Select all
.universe{border-bottom:1px black}
- Russ Chappell
- Site Admin
- Posts: 5670
- Joined: Thu Feb 12, 2004 5:40 pm
- Location: Tuscaloosa, AL
- Contact:
Re: Python
That's not the point. We can come up with all kinds of ways to draw a line, and we can probably come up with clever alternatives to collapse and expand the listings. The problem is that all of these ways will introduce coding that the search script doesn't expect to see, and it vomits.Somebody wrote:Meh.
.universe{border-bottom:1px black}
We have to teach the search script to ignore something. The collapse and expand scripts already work perfectly, so let's teach it to ignore something that's already there, rather than reinventing the wheel, and teaching the search to ignore that.
I can't promise you that things will improve, if we make changes;
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
- Russ Chappell
- Site Admin
- Posts: 5670
- Joined: Thu Feb 12, 2004 5:40 pm
- Location: Tuscaloosa, AL
- Contact:
Re: Python
I've located the section of the Search script that's returning the error, and if I'm reading the coding right, it appears that when the script encounters these bits of text, it's not doing anything (which is what we want). It's just alerting me that it found something unusual. I still want to eliminate the warnings (and I think I may have figured out a way to handle two of the situations), but at least I can feel reasonably comfortable that I'm not messing up the Search functionality. Maybe something by the weekend...
I can't promise you that things will improve, if we make changes;
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
- Russ Chappell
- Site Admin
- Posts: 5670
- Joined: Thu Feb 12, 2004 5:40 pm
- Location: Tuscaloosa, AL
- Contact:
Re: Python
I have eliminated the warnings caused by
<p><hr></p>
and
</span></div>
<p><hr></p>
and
</span></div>
I can't promise you that things will improve, if we make changes;
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
- Russ Chappell
- Site Admin
- Posts: 5670
- Joined: Thu Feb 12, 2004 5:40 pm
- Location: Tuscaloosa, AL
- Contact:
Re: Python
And now
<div id=
has been solved.
Stand down.
<div id=
has been solved.
Stand down.
I can't promise you that things will improve, if we make changes;
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
I can promise you that they won't improve, if we don't.
![Image](https://www.chronologyproject.com/mcpbannr.gif)
Adventures in the Marvelous Zone! A Girl's View of the Marvel Universe
-
- Big Bad
- Posts: 193
- Joined: Sat Jun 06, 2015 6:20 am
Re: Python
Hello!
Sorry if you thought I'd abandoned you, but I was on holiday skiing, and didn't have access to a computer
.
Glad you found a solution!
-wolverine
Sorry if you thought I'd abandoned you, but I was on holiday skiing, and didn't have access to a computer
![Sad :(](./images/smilies/icon_sad.gif)
Glad you found a solution!
-wolverine