Re: Parsing VHDL with python, where to start.
On Jul 29, 5:14 pm, Wolfgang Grafen [EMAIL PROTECTED] wrote: For me it is not very clear what you intend to do. After years of parsing parts of VHDL from time to time the rapid parsing way for me is using regular expressions instead of one of the parser frame works because of following reasons: - It is hard for me to understand those frameworks - They are very slow - It is too much work for me to bring them up to work in a sensible way - Compared with regular expression matching they usually need a lot of extra work. I agree with frameworks being difficult to understand and that is why I also have been using regular expressions in tcl to parse spice netlists before. Now I want to parse spice, vhdl and also maybe verilog. I think I will end up with regular expressions unless I get a grip on SimpleParse. The rationale for the whole project has been to finally be able to view spice and specially vhdl code for projects I work on. This has been something I have wanted to have for years, without having the ressources to complete it. There are commercial tools available, but I was looking for something more open/free that could be maintained independently of what tools I have at work. PyQt as a widget framework is not useful until here, but of course you could display your results in arbitrary graphical ways with PyQt, if you rally need to. You should know, printing out an ASCII or XML representation is so much more easy and quicker to code so I always prefer that. There are even editors/visualizers ready to display XML... PyQt4 doesn't help me parse my sources, but it helps me visualise them. I did something in tcl/tk to get hierarchical spice netlists into a tree structure, but extending that app was too much hassle. PyQt4 offers a lot of functionality once the threshold of learning it has been passed. It also installs nicely on windows and most linux distributions offer it ready to install. And I like Qt. -- Svenn -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing VHDL with python, where to start.
Hi again, when I get far enough to parse the VHDL (which is not currently the fact, but I have to look at the work coming up downstream) I will have to put it into an internal data structure and then write some classes to handle the MVC between whatever data I have and the PyQt4 widget that is going to show the block diagram. I own the book Rapig GUI Programming with Python and Qt by Mark Summerfield and try to read up on the PyQt way of doing things as I try to make a plan for my application. I have been looking for possible data structures with google just to find out that most of the ideas are stored in proceedings or to conferences or ieee papers not generally available to me. Is anybody experienced with designing data structures willing to share some ideas with me? Since I am using the open-source version of PyQt4, any information will eventually be available to public (if the app pass the planning stage) if that makes helping out any easier: :-) There is already an app called Qucs that is running in Qt-3 and being ported to Qt-4 that is written in C++, but I don't know how wise it is to just reverse-engineering C++ classes and translate them into python classes. -- Svenn -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing VHDL with python, where to start.
On Jul 23, 1:03 pm, [EMAIL PROTECTED] (c d saunter) wrote: How much of VHDL are you looking to parse? Are you just looking at files intended for synthesis, or at simulation/testbench files as well? As a start I want to parse VHDL which is going to be synthesised, and I am limiting myself to the entities and the structural component placement. I will drop the processes and the concurrent assignments even if that will mask important information. It is a design viewer tool, not a design tool that I am writing. Xilinx ISE do give me the opportunity to browse my synthesised netlist, but there is simply too much information. Later the app can be extended with more functionality, depends on my success with the initial problems that I have. If I started again I'd use pyparsing:http://pyparsing.wikispaces.com/ Looks like someone is already there in part:http://pyparsing.wikispaces.com/message/view/home/103973 I also got a pointer to SimpleParse and now try to translate the parts of the VHDL BNF that I need into a definition that SimpleParse can understand. But looking at the BNF it is clear that VHDL is no easy language to parse, just as it is no easy language to do structural design in. -- Svenn -- http://mail.python.org/mailman/listinfo/python-list
Parsing VHDL with python, where to start.
Hi, I am in the need to write an application for PyQt to visualise the structure of a VHDL project I am working on. Looking for a sensible way to parse VHDL files and putting them into a data structure that PyQt can represent as a tree (or whatever the MVC is supporting) through search engines does not give me many hints. From what I know, VHDL is not a very easy language to parse. There seems to be a parser for perl available, but I do not know if it is wise to use a perl module as a template for writing something similar in python. My initial idea is to start simple and extend features in my application, but I fear that I may start off with wrong ideas how to parse and then code myself into a dead-end requiring myself to rewrite the whole application in order to get any further. I would start finding definitions of entities and the instantiations of these and build a tree from a set of external vhdl files stored in a file hierarchy. If somebody have a starting point where to get going with a task like this, I would be happy to know. -- kind regards, Svenn -- http://mail.python.org/mailman/listinfo/python-list
Re: executing newgrp from python in current shell possible?
On Jan 9, 9:18 pm, Zentrader [EMAIL PROTECTED] wrote: On Jan 9, 5:56 am, Svenn Are Bjerkem [EMAIL PROTECTED] wrote: I have been looking for a way to execute this command as a part of a script, but it seems that the changes are only valid in the context of the script and when the script exits, the current shell still have the original users group setting. I don't think you would want it any other way. Would you want a user to be able to change the group and have it remain permanently? Who's going to remember whether they were last in A or B, and it opens up oportunities for the practical joker when you go to the restroom and leave the terminal on. Put the change the group code into a separate function in a separate file (with only you as the owner) and call it whenever you want to change groups. I am trying to create a script that make it easy for users in a design team to create files that belong to the same group, but retain the users uid. In order to make it visible that the user is creating files with a different gid, the script will change the prompt to indicate so. In a tcl solution I have now, the users home is changed to the design area as some tools are reading and writing setup files into $HOME. I have not found a way to change the gid in tcl so I turned to python in hope that this scripting language could do so. The tcl solution spawns a new tcsh after setting several environment variables and works quite well except for not being able to change gid. And it is also a wish from my side to port this script to python. Is your suggestion to put newgrp design into a new file and then exec this file in my python script? What happens to the group id of the shell that called the python script in this case? I would try to avoid spawning a new tcsh as this make execution of tools on a remote computer difficult as the handover of command line arguments does not seem to be handed over to the newly spawned shell. I may be understanding something wrongly here. -- Svenn -- http://mail.python.org/mailman/listinfo/python-list
executing newgrp from python in current shell possible?
Hi, as a user on a linux system I am member of the groups users and design with users as my default group. To controll the accessibility of some parts of the file system, creation of files and directories in those parts must be done with group design. This is currently done manually with newgrp design on the command line before doing anything else. I have been looking for a way to execute this command as a part of a script, but it seems that the changes are only valid in the context of the script and when the script exits, the current shell still have the original users group setting. It looks like the command spawns a new command line in the context of the current xterm as I get back to my old command line when exiting (instead of the xterm dissapearing) A possible alternative could be to have the python script launch a new shell, but I still have the problem to set the group id for that new shell (lack of python knowledge). I am happy for any advice. Maybe it is simply not possible to do this kind of operation from a script in python on linux. -- kind regards, Svenn -- http://mail.python.org/mailman/listinfo/python-list
Re: Script to extract text from PDF files
On Sep 26, 11:50 pm, [EMAIL PROTECTED] wrote: On Sep 26, 4:49 pm, Svenn Are Bjerkem [EMAIL PROTECTED] wrote: I have downloaded this package and installed it and found that the text-extraction is more or less useless. Looking into the code and comparing with the PDF spec show a very early implementation of text extraction. Luckily it is possible to overwrite the textextraction method in the base class without having to fiddle with the original code. I tried to contact the developer to offer some help on implementing text extraction, but he didn't answer my emails. -- Svenn Well, feel free to send any ideas or help to me! It seems simple... Do a binary read. Find 'stream' and 'endstream' sections. zlib.decompress() all the streams. Find BT and ET markers (Begin Text End Text) and finally locate the parens within those and string the text together. This works great on 3 out of 10 PDF documents, but my main issue seems to be the zlib compressed streams. Some of them don't seem to be FlateDecodeable (although they claim to be) or the header is somehow incorrect. But, once I get a good stream and decompress it, things are OK from that point on. Seriously, if you have ideas, please let me know. I'll be glad to share what I've got so far. So far I have found that extracting text from the IEEE journal papers is not as simple as described above. The IEEE journals are typesetting things in typical journal style with two columns body text and one column abstract and a blob of header and author information. Take figures and formulas and footnotes and spread them around in the journal and you are basically using all block text layout commands there is in PDF. I wanted to to get the pdftotext from xpdf package to see what that tool does to the IEEE pdfs in order to see if I should dive into the sources to see what they do to get things right. So far I have not got this far. Purpose of my work was to extract the abstract of each paper to put into a database for later search, but IEEE also has a search engine on their journal DVD = postpone python work. Got my gentoo machine back on track so that may maybe change again.. -- Svenn -- http://mail.python.org/mailman/listinfo/python-list
Re: Script to extract text from PDF files
On Sep 25, 9:18 pm, [EMAIL PROTECTED] wrote: On Sep 25, 3:02 pm, Paul Hankin [EMAIL PROTECTED] wrote: Googling for 'pdf to text python' and following the first link giveshttp://pybrary.net/pyPdf/ Doesn't work that well, I've tried it, you should too... the author even admits this: extractText() [#] Locate all text drawing commands, in the order they are provided in the content stream, and extract the text. This works well for some PDF files, but poorly for others, depending on the generator used. This will be refined in the future. Do not rely on the order of text coming out of this function, as it will change if this function is made more sophisticated. - sourcehttp://pybrary.net/pyPdf/pythondoc-pyPdf.pdf.html I have downloaded this package and installed it and found that the text-extraction is more or less useless. Looking into the code and comparing with the PDF spec show a very early implementation of text extraction. Luckily it is possible to overwrite the textextraction method in the base class without having to fiddle with the original code. I tried to contact the developer to offer some help on implementing text extraction, but he didn't answer my emails. -- Svenn -- http://mail.python.org/mailman/listinfo/python-list
Re: A Tcl/Tk programmer learns Python--any advice?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... That is a misconception. There are several really good packages for OO in Tcl. XOTcl, [incr] Tcl, and my favorite Snit. None of which are core functions. As I stated, there is currently no OO in the core like in python. On top of that there is currently being added OO to the core of Tcl as well. That should all be integrated in when 8.5 comes out in the spring. Which once again is a confirmation that my statement was correct about missing OO in the current core. Tk is getting a native LF uplift as well. This is just eye candy, Tkinter was long time GUI for python and no reason to move from Tcl to python. Today you can choose about any toolkit for python and Tcl still has rusty old Tk. It is all a question what you want to solve and how you want to solve it. Tcl/Tk was once the best way to write throwaway applications with a GUI, and it still is, in my opinion, but then I know too little python so far. (and python can not do set result [exec someprog $input] as far as I know) -- Svenn -- http://mail.python.org/mailman/listinfo/python-list
Re: A Tcl/Tk programmer learns Python--any advice?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Why does there need to be OO in the core? That is one thing I have never understood. If you want OO, get a package that fits your style of OO and package require you are off and running. That probably isn't what you would be looking at Tcl for anyway. We are now starting the normal discussion that tcl'ers have about OO in the core, and thus just whipping up old dirt. For people like me who has invested a lot of time to learn a language that I use to solve everyday problems, it would be nice if I could continue to use that same language to do more advanced stuff. Loading packages is a work-around in my eyes, and I am actually following your advice of looking at a different language, that's why I am here in the first place. There is no need to wear rubber boots at a party if you can wear sneakers. -- Svenn -- http://mail.python.org/mailman/listinfo/python-list
Re: A Tcl/Tk programmer learns Python--any advice?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Ah, another one leaves the fold... : \ I think I saw somebody say about OO in Python: It's there, but you don't have to use it. Every time somebody wants OO in the core of tcl, he is asked: Why do you want it? If OO was as easy in Tcl as in Python, there would be no real reason to switch in my opinion. (And maybe simpler namespaces and passing of lists to functions, we all love the uplevel and upvar commands, don't we?) -- Svenn -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's edu corner: the Journey of Foreign Characters thru Internet
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Something I don't quite understand, if people think it is troll, just ignore it. What I see is that people are feeding it by commenting about either him or his post. I saw a number of threads ended up that way(like the rather long one about Microsoft). Make it illegal to have opinions and the problem will be solved. (Oops did I break my own rule, there?) -- Svenn -- http://mail.python.org/mailman/listinfo/python-list
Re: forum
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Forum commuication is easier, and I've just started a new forum and would like to invite all of you to sign up and post there. I'm still I don't agree. USENET is easier because you can search and post on groups.google.com. You don't have to register, you can use your favourite NNTP reader etc. -- Svenn -- http://mail.python.org/mailman/listinfo/python-list