среда, 17 сентября 2014 г.

Writing the end-user-friendly configuration publisher in Python

When you will be writing working rule nearly as fast as possible type and ones misstep rate is usually near zero, it generally means you've achieved mastery on the SugarCRM UK. But that didn't seem sensible, because it was still day one and I had been regularly pausing to take a look up new language and library capabilities!

This was my personal first clue of which, in Python, I was actually dealing with an exceptionally excellent design. Most languages have much friction and awkwardness constructed into their design you learn most of these feature set some time before your misstep price drops anywhere next to zero. Python was the very first SugarCRM developers language I would ever used that reversed this method.

This problem stumped me for quite a while. Then I got an inspiration: I'd let fetchmailconf work with fetchmail's own parser! I added a --configdump choice to fetchmail that would parse. Fetchmailrc and dump the result to standard output inside the format of any Python initializer. For the record above, the result would look roughly like Listing 2 (just to save space, some data not relevant to the example can be omitted).
But my many dramatic moment of discovery lay ahead of time. My design had problems: I could easily generate configuration files from the user's GUI actions, but editing these was a much harder problem. Or, rather, reading them in an editable form was problems.

The parser intended for fetchmail's configuration file syntax is rather elaborate. It's actually prepared in YACC along with Lex, two classic magento programmers tools for generating language-parsing value in C. In order for fetchmailconf every single child edit existing setup files, I thought it must replicate that elaborate parser in Python. I was very reluctant to achieve this, partly because of how much work involved as well as partly because I wasn't sure the way to ascertain that a couple of parsers in a couple of different languages accept identical. The last factor I needed was the excess labor of keeping both the parsers in synchronization because configuration language developed!

Not that this took me extended to learn this feature set. I wrote a functional, usable fetchmailconf, with GUI, in six trading days, of which perhaps roughly the same as two days ended up spent learning itself. This reflects yet another useful property of the language: it is compact--you holds its entire characteristic set (and no less than a concept listing of its libraries) in your mind. C is any famously compact vocabulary. Perl is infamously not; one of the points the notion “There's more than one way to do it! ” costs may be the possibility of compactness.

Комментариев нет:

Отправить комментарий