You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(5) |
Oct
(2) |
Nov
(18) |
Dec
(26) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(14) |
Feb
(28) |
Mar
(21) |
Apr
(17) |
May
(23) |
Jun
(12) |
Jul
(12) |
Aug
(7) |
Sep
(10) |
Oct
|
Nov
(4) |
Dec
(10) |
2007 |
Jan
(5) |
Feb
(8) |
Mar
|
Apr
|
May
(7) |
Jun
(1) |
Jul
(3) |
Aug
(3) |
Sep
(20) |
Oct
(3) |
Nov
(2) |
Dec
(12) |
2008 |
Jan
(40) |
Feb
(15) |
Mar
(1) |
Apr
|
May
(6) |
Jun
(19) |
Jul
(2) |
Aug
(17) |
Sep
(13) |
Oct
(7) |
Nov
(16) |
Dec
(5) |
2009 |
Jan
(15) |
Feb
(11) |
Mar
(11) |
Apr
(8) |
May
(6) |
Jun
(15) |
Jul
(19) |
Aug
(2) |
Sep
|
Oct
(19) |
Nov
(1) |
Dec
(3) |
2010 |
Jan
(12) |
Feb
(25) |
Mar
(45) |
Apr
(4) |
May
(2) |
Jun
(4) |
Jul
(6) |
Aug
(13) |
Sep
(1) |
Oct
(2) |
Nov
(2) |
Dec
(9) |
2011 |
Jan
(24) |
Feb
(7) |
Mar
(1) |
Apr
(6) |
May
(3) |
Jun
(3) |
Jul
|
Aug
(13) |
Sep
(9) |
Oct
(7) |
Nov
(17) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
(5) |
Apr
(3) |
May
|
Jun
|
Jul
(3) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(12) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
(4) |
Feb
(3) |
Mar
|
Apr
(17) |
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(3) |
Oct
(3) |
Nov
|
Dec
|
2015 |
Jan
(11) |
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(10) |
Dec
|
2017 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Bob S. <Bob...@ou...> - 2017-02-28 15:35:48
|
I have searched extensively and not found anything that answers the following: In creating a config file with nested Sections, how can I later in the file return to defining items (i.e., key/value pairs) at the top-level section? E.g., if in the following file: # --------------- start thisFile.ini top1 = 100 top2 = 200 [LEVEL1] Level1A = 1000 [LEVEL2] Level2A = 2000 # Now I want top3 to be defined in the top level, rather than in Section [LEVEL1][LEVEL2] top3 = 200 # ---------------- end thisFile.ini When the config file is processed, cfg=ConfigObj('thisFile.ini'), I'd like top3 to be cfg['top3'], instead of as cfg['LEVEL1']['LEVEL2']['top3']. My only guess was to change the last 2 lines to: [] # hoping maybe return to top level ? top3 = 200 ... but that does not work and causes an exception. So as best I can determine it seems that all top-level definitions must precede any use of a Section. Is that actually correct, or is there a way to return to defining items at the top level? Thanks in advance for any help or advice. |
From: R. J. <lea...@at...> - 2016-11-06 05:25:30
|
Good morning! I wanted to take this opportunity to tell you about my neighbour's daughter. She had trouble learning as a child and no one knew what was wrong with her. At school she was bullied and people called her stupid. They eventually discovered that she was dyslexic. But she's a smart kid and taught herself how to recognize words. Her mom insisted that she read everything that she could, and eventually while still in high school a few years ago, she started reading a IM forum http://sarahonlinemarketinglessons.com/index.php/campaigns/yd728cny393c4/track-url/ko395rfcyg34e/c00d99b642ed86aacc7283be2fd1078774a60b0c. She read up how to start an online business and put what she learnt into action. She managed to pay her own way through college http://sarahonlinemarketinglessons.com/index.php/campaigns/yd728cny393c4/track-url/ko395rfcyg34e/c00d99b642ed86aacc7283be2fd1078774a60b0c and funnily enough is now studying teaching as she wants to help teach kids with learning disabilities. The methods she used to earn cash online are not new and in fact have been tweaked to perfection over the years. You can see a similar method by visiting this link -> CLICK HERE NOW HTTP://SARAHONLINEMARKETINGLESSONS.COM/INDEX.PHP/CAMPAIGNS/YD728CNY393C4/TRACK-URL/KO395RFCYG34E/C00D99B642ED86AACC7283BE2FD1078774A60B0C <- have a great day and best of luck to you! MORAL STORY OF THE DAY: Once upon a time, there lived a washerman who had a thin donkey. His donkey used to carry loads of clothes to the river bank every day. The donkey was not satisfied with the food that the washer man gave to him, so he wandered in the fields nearby and ate the crops. One night, the donkey meta jackal and became his friend Both of them went out in a field and found cucumbers. They ate them to full their stomach. They were happy and decided to come daily to full up their stomach. Once, after a tasty meal of cucumbers, the donkey thought to sing a song. The jackal warned the donkey not to sing. The donkey did not listen to the jackal and started singing. The jackal immediately jumped over the fence and went away. On hearing a donkey braying in a the field, the guard woke up and rushed out to beat the donkey The donkey ran to save his life. The donkey realised his mistake and felt sorry for not listening to the good advice of the jackal. MORAL :THINK BEFORE YOU ACT. SUBSCRIPTION INFO: If you no longer want to receive updates, use the unsubscribe link that is at the very bottom of this email. Stay subscribed you will receive carefully picked recommendations, no cost gifts and marketing downloads and we can get a commission, if you click and buy on links in this email. If you feel that the content is inappropriate reply to this email. http://sarahonlinemarketinglessons.com/index.php/lists/ny799gr1k0d73/unsubscribe/ko395rfcyg34e/yd728cny393c4 Rick Jones 2530 Musgrave Street Oklahoma City 73102 United States |
From: Victoria X. <in...@ma...> - 2016-11-05 11:37:46
|
Need Help ? Look no further. Your answer is just a click away. There’s a new method on the block that people are finding works for them. And I figured out how to gain access. Explore this tried and tested new method here. Have a good day Talk soon, Victoria Moral story of the day: Once upon a time there lived a cat that loved to read. At night, when everybody was asleep, she would put on the spectacles and read the BIG BOOK FOR CATS. One day, she read in the book: If you want a mouse for dinner, repeat the following rhyme: In this house there is a mouse, where is the mouse, where is the mouse? The cat looked up from the book and found that there was a mouse on the top of the table. The cat repeated the rhyme and soon found the same mouse on the bed. Then she jumped upon the bed to catch the mouse and the mouse was gone! The mouse was very clever. Suddenly he squeaked, “Oh, dear cat, run, run fast! There is dog after you!” The cat left the mouse and was ready to jump out of the window. The mouse sat near his hole and said, “Ha-ha-ha! Dear cat that was the trick I learnt from the BIO BOOK FOR MICE!” And the mouse ran into his hole! MORAL :An intelligent person should not think that others are illiterate. Subscription info: If you no longer want to receive updates, use the unsubscribe link that is at the very bottom of this email. Stay subscribed you will receive carefully picked recommendations, no cost gifts and marketing downloads and we can get a commission, if you click and buy on links in this email. If you feel that the content is inappropriate reply to this email. Unsubscribe me from this list To stop receiving these emails:http://victorinoxusa.com/unsubscribe.php?M=227478&C=f1222d67c8f9b095affd3f67bb5b19fd&L=2&N=14 |
From: Victoria X. <in...@ma...> - 2016-11-04 09:19:22
|
Golden Nuggets That Produce Income This will most likely shock you. 99% of the people reading this won't be able to hand it. Because they don't want the truth. So I Show Them This Instead There are some GOLDEN nuggets in that link above. Enjoy, Victoria Moral story of the day: Once there lived a clever fox. One day, he boasted to a dog of his cleverness for escaping his enemies."I have a whole bag of tricks," he said, "which contains a hundred ways of escaping my enemies." The dog did not come in his tricks and said, "I have only one, but I can generally manage with that." Suddenly, they heard the roar of the lions. They heard it carefully and seemed that they were coming towards them. The dog immediately scampered up a tree and hid himself in the branches. The dog said, "This is my plan. What are you going to do?" The fox thought first of one way, then of another, and while he was debating the lions came nearer and nearer. At last the fox in his confusion was caught up by the lions and killed. MORAL :Better one safe way than a hundred on which you cannot reckon. Subscription info: If you no longer want to receive updates, use the unsubscribe link that is at the very bottom of this email. Stay subscribed you will receive carefully picked recommendations, no cost gifts and marketing downloads and we can get a commission, if you click and buy on links in this email. If you feel that the content is inappropriate reply to this email. Unsubscribe me from this list To stop receiving these emails:http://victorinoxusa.com/unsubscribe.php?M=227478&C=f1222d67c8f9b095affd3f67bb5b19fd&L=2&N=13 |
From: Victoria X. <in...@ma...> - 2016-11-03 12:23:33
|
let us have a quick one Let us have a quick one.. As it is getting late now. Instead of writing a lengthy message, let me just write you a quick one here. It is going to be worth your time, at this hour even. You have to see this tonight before it is gone the next morning. To your success, Victoria Moral story of the day: Once upon a time, there lived a washerman who had a thin donkey. His donkey used to carry loads of clothes to the river bank every day. The donkey was not satisfied with the food that the washer man gave to him, so he wandered in the fields nearby and ate the crops. One night, the donkey met a jackal and became his friend Both of them went out in a field and found cucumbers. They ate them to full their stomach. They were happy and decided to come daily to full up their stomach. Once, after a tasty meal of cucumbers, the donkey thought to sing a song. The jackal warned the donkey not to sing. The donkey did not listen to the jackal and started singing. The jackal immediately jumped over the fence and went away. On hearing a donkey braying in a the field, the guard woke up and rushed out to beat the donkey The donkey ran to save his life. The donkey realised his mistake and felt sorry for not listening to the good advice of the jackal. MORAL :Think before you act. Subscription info: If you no longer want to receive updates, use the unsubscribe link that is at the very bottom of this email. Stay subscribed you will receive carefully picked recommendations, no cost gifts and marketing downloads and we can get a commission, if you click and buy on links in this email. If you feel that the content is inappropriate reply to this email. Unsubscribe me from this list To stop receiving these emails:http://victorinoxusa.com/unsubscribe.php?M=227478&C=f1222d67c8f9b095affd3f67bb5b19fd&L=2&N=12 |
From: Arthur G. <art...@gm...> - 2016-09-19 20:23:36
|
in 'Writing a Config File', the value\d+ should be quoted strings. -- Arthur Goldberg https://www.linkedin.com/in/arthurgoldberg art...@gm... |
From: D'Mita L. <dle...@fi...> - 2016-04-09 22:37:11
|
Is it possible to create Xenaccess.conf files using the python ConfigObj library? I have been tasked with this and their documentation is extensive but it seems I can only make the INI type files. I wan to create an object that looks like the one below. WinVista { ostype = "Windows"; win_tasks = 0xa0; win_pdbase = 0x18; win_pid = 0x9c; win_peb = 0x188; win_iba = 0x8; win_ph = 0x18; } https://code.google.com/archive/p/xenaccess/wikis/ConfigurationEntries.wiki Thanks, D'Mita -- D'Mita Levy Cyber Fellow, Applied Research Center Florida International University |
From: <in...@vi...> - 2016-02-28 12:12:59
|
Your e-mail program can not read this letter. In order to view it within your browser, click here: http://www.e-siuntimai.lt/display.php?M=4726178&C=1be01eb8ac3b603416f737784aa1ecb4&S=1733&L=123&N=1360 If you do not want to receive our newsletter, click here:http://www.e-siuntimai.lt/unsubscribe.php?M=4726178&C=1be01eb8ac3b603416f737784aa1ecb4&L=123&N=1733 |
From: Martin <mar...@gm...> - 2016-02-18 13:10:27
|
hi there, I'm having problems with nested lists: >>> from configobj import ConfigObj >>> config = ConfigObj('test.config') >>> nested_list = [5, [2,3], 6] >>> config['nested_list'] = nested_list >>> config.write() this produces $ tail test.config nested_list = 5, "[2, 3]", 6 rereading that config-file gives me this: >>> from configobj import ConfigObj >>> config = ConfigObj('test.config') >>> nested_list = config['nested_list'] >>> type(nested_list) <type 'list'> >>> type(nested_list[1]) <type 'str'> what am I doing wrong? any help would be appreciated! |
From: Eli C. <el...@co...> - 2015-08-03 20:08:20
|
I don't believe there's any way to make a section optional in the way you want. The reasoning is that when a section is defined in the configspec, it always exists in your config even if it's not included in the config file. Therefore, in your example [[[Location]]] will always exist for each of the __many__ subsections regardless of whether the config file defines it. In cases like this I would typically assign default values to all of the options in that subsection. - Eli On Fri, Jul 31, 2015 at 8:08 PM, Sumit's Mailing Lists < li...@ba...> wrote: > I've been looking through the docs and StackOverflow and I'm still a > little stumped on this. Can I have an optional section in my config > specification? For example, say I had this as my configspec: > > config_specification = """ > [General] > > sample_rate = float > > [Data] > [[__many__]] > type = option('sense.xml') > [[[Identifier]]] > type = option("name", "mac", "uuid") > adapter = string(default='') > id = string(default='') > file = string(default='') > [[[Location]]] > type = option("virtual", "gps") > longitude = string(default='') > latitude = string(default='') > altitude = string(default='') > speed = string(default='') > climb = string(default='') > track = string(default='') > longutide_error = string(default='') > latitude_error = string(default='') > altitude_error = string(default='') > speed_error = string(default='') > climb_track = string(default='') > track_error = string(default='') > """ > > Is there a way to make [[[Locaiton]]] optional, so it can be missing and > still pass validation (assuming that I do validation like so): > > cfg = ConfigObj(filename, > configspec=BootStrap.config_specification.split('\n')) > > test = cfg.validate(Validator()) > > valid = True > for (section_list, key, _) in flatten_errors(cfg, test): > if key is not None: > logging.error('Invalid value for key {0} in section > {1}'.format(key, ', '.join(section_list))) > valid = False > else: > logging.error('Section {0} failed validation'.format(', > '.join(section_list))) > valid = False > if not valid: > exit(3) > > Thanks > Sumit > > > ------------------------------------------------------------------------------ > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > |
From: pisymbol . <pis...@gm...> - 2015-08-01 01:47:03
|
On Fri, Jul 31, 2015 at 8:08 PM, Sumit's Mailing Lists <li...@ba...> wrote: > I've been looking through the docs and StackOverflow and I'm still a > little stumped on this. Can I have an optional section in my config > specification? For example, say I had this as my configspec: > > config_specification = """ > [General] > > sample_rate = float > > [Data] > [[__many__]] > type = option('sense.xml') > [[[Identifier]]] > type = option("name", "mac", "uuid") > adapter = string(default='') > id = string(default='') > file = string(default='') > [[[Location]]] > type = option("virtual", "gps") > longitude = string(default='') > latitude = string(default='') > altitude = string(default='') > speed = string(default='') > climb = string(default='') > track = string(default='') > longutide_error = string(default='') > latitude_error = string(default='') > altitude_error = string(default='') > speed_error = string(default='') > climb_track = string(default='') > track_error = string(default='') > """ > > Is there a way to make [[[Locaiton]]] optional, so it can be missing and > still pass validation (assuming that I do validation like so): > Why not just make it non-fatal? for (section_list, key, _) in flatten_errors(config, test): if key == 'Location': pass etc. -aps |
From: Sumit's M. L. <li...@ba...> - 2015-08-01 00:34:32
|
I've been looking through the docs and StackOverflow and I'm still a little stumped on this. Can I have an optional section in my config specification? For example, say I had this as my configspec: config_specification = """ [General] sample_rate = float [Data] [[__many__]] type = option('sense.xml') [[[Identifier]]] type = option("name", "mac", "uuid") adapter = string(default='') id = string(default='') file = string(default='') [[[Location]]] type = option("virtual", "gps") longitude = string(default='') latitude = string(default='') altitude = string(default='') speed = string(default='') climb = string(default='') track = string(default='') longutide_error = string(default='') latitude_error = string(default='') altitude_error = string(default='') speed_error = string(default='') climb_track = string(default='') track_error = string(default='') """ Is there a way to make [[[Locaiton]]] optional, so it can be missing and still pass validation (assuming that I do validation like so): cfg = ConfigObj(filename, configspec=BootStrap.config_specification.split('\n')) test = cfg.validate(Validator()) valid = True for (section_list, key, _) in flatten_errors(cfg, test): if key is not None: logging.error('Invalid value for key {0} in section {1}'.format(key, ', '.join(section_list))) valid = False else: logging.error('Section {0} failed validation'.format(', '.join(section_list))) valid = False if not valid: exit(3) Thanks Sumit |
From: Ame E. <ame...@gm...> - 2015-05-22 01:02:46
|
Arlyss engebretson |
From: Eli C. <el...@co...> - 2015-04-27 23:38:02
|
On Tue, Apr 21, 2015 at 6:00 PM, Darren Spruell <pha...@gm...> wrote: > Before going down the road further on finding a working string > formatted configspec that works for this case (which from my > perspective has so far been more complex than a Python use case > arguably should be), I wanted to detour first and ask: is it possible > to modify the configspec support to allow simply passing a Python list > as an argument to option()? In my opinion this is possibly the > cleanest and most flexible idiom (and least surprise for users I > suspect). > I have no ideological objection to that, but it's an area of the code which I'm not super-familiar with, so I can't say offhand why it was implemented that way to begin with. It might have something to do with the fact that [ and ] characters are used specifically in sections, and therefore there was a desire to avoid using them in other contexts. That combined with the fact that the current syntax works (though it is probably not what people would intuitively guess the syntax to be) would be an argument against changing it. Though as I said, I'd need to look at the code to see if there's any particular difficulties for the parser to use [ and ] to mean two different things. - Eli |
From: Darren S. <pha...@gm...> - 2015-04-21 22:00:36
|
Took a bit of a holiday from this, wanted to come back to it. Before going down the road further on finding a working string formatted configspec that works for this case (which from my perspective has so far been more complex than a Python use case arguably should be), I wanted to detour first and ask: is it possible to modify the configspec support to allow simply passing a Python list as an argument to option()? In my opinion this is possibly the cleanest and most flexible idiom (and least surprise for users I suspect). On Thu, Jan 22, 2015 at 6:19 AM, Rob Dennis <rd...@gm...> wrote: > Getting the same results implies that we're using the same version of > Python/configobj, which is nice. > > The real reason I wrote that example up was to give you a string formatted > configspec example that I believed should work, and one that appeared to be > formatted the same way your example was (But with a different error message > than what you had posted before). > > Is there a way to either link to your code repo, or at least paste the real > config file and validation code to a gist? > > > > On Thu, Jan 22, 2015 at 12:37 AM, Darren Spruell <pha...@gm...> > wrote: >> >> Same results running the Gist: >> >> $ python config_fest.py >> expected to fail: formatted: [(['bar'], 'category', VdtValueError('the >> value "unknown" is unacceptable.',))] >> expected to pass: formatted: [] >> expected to fail: unformatted: [(['bar'], 'category', >> VdtUnknownCheckError('the check "allowed_category_options" is >> unknown.',))] >> expected to pass: unformatted: [(['bar'], 'category', >> VdtUnknownCheckError('the check "allowed_category_options" is >> unknown.',))] >> >> I have to admit ignorance knowing quite how to interpret that though. >> >> - Darren >> >> (My turn to be sorry for a late reply). >> >> >> On Wed, Jan 14, 2015 at 8:31 AM, Rob Dennis <rd...@gm...> wrote: >> > (sorry for the late reply; work situation came up when I started to >> > reply >> > earlier, but I had already checked off that I had responded) >> > >> > I've taken your brief example and made a gist that you can execute: >> > https://gist.github.com/robdennis/bf13312a078fe8557101 >> > Unfortunately, I don't expect your example to work as written, since >> > it'd >> > need the constructed "option" string to be formatted into the >> > configspec. >> > >> > You have a different error message though, so I'm assuming there's some >> > other issue that's not obvious from what you included. >> > >> > the output I show for the test: >> > ``` >> > expected to fail: formatted: [(['bar'], 'category', VdtValueError('the >> > value >> > "unknown" is unacceptable.',))] >> > expected to pass: formatted: [] >> > expected to fail: unformatted: [(['bar'], 'category', >> > VdtUnknownCheckError('the check "allowed_category_options" is >> > unknown.',))] >> > expected to pass: unformatted: [(['bar'], 'category', >> > VdtUnknownCheckError('the check "allowed_category_options" is >> > unknown.',))] >> > ``` >> > >> > Maybe give it a shot and see if that gets your closer? >> > >> > On Sat, Jan 10, 2015 at 6:12 PM, Darren Spruell <pha...@gm...> >> > wrote: >> >> >> >> Thanks. I think it's on the right track (repr() didn't occur to me >> >> before), but although testing with Validator.check() works, I still >> >> get validation failures when using the resulting code within a >> >> configspec. >> >> >> >> BTW this is CPython 2.6.6. >> >> >> >> >> >> # DEFAULTS['CATEGORIES'] is the list() of categories >> >> allowed_category_options = "option({0})".format( >> >> ', '.join([repr(cat) for cat in DEFAULTS['CATEGORIES']]) >> >> ) >> >> >> >> CONFIGSPEC = '''\ >> >> logfile = string >> >> [foo] >> >> user = string >> >> pass = string >> >> [bar] >> >> [[__many__]] >> >> category = allowed_category_options >> >> ''' >> >> >> >> config = ConfigObj(conf_file, configspec=CONFIGSPEC.splitlines()) >> >> validator = Validator() >> >> results = config.validate(validator) >> >> >> >> >> >> Results in: >> >> The 'category' key in section 'bar, 2019761' failed validation >> >> >> >> Should this type of usage in a configspec (the way it's being parsed >> >> in my case) work correctly? >> >> >> >> DS >> >> >> >> >> >> On Sat, Jan 10, 2015 at 6:26 AM, Rob Dennis <rd...@gm...> wrote: >> >> > Hello Darren, >> >> > >> >> > I'm one of the current maintainers along with Eli, I'm modifying a >> >> > slightly >> >> > tweaked example from here: >> >> > >> >> > >> >> > https://configobj.readthedocs.org/en/latest/validate.html#the-standard-functions >> >> > >> >> > I'm seeing the behavior I expect for handcrafting the options >> >> > validator: >> >> >>>> from validate import Validator >> >> >>>> vtor = Validator() >> >> >>>> checked_val = vtor.check("option('option 1', 'option 2', 'option >> >> >>>> 3')", >> >> >>>> 'option 1') >> >> >>>> checked_val >> >> > 'option 1' >> >> >>>> checked_val = vtor.check("option('option 1', 'option 2', 'option >> >> >>>> 3')", >> >> >>>> 'option 4') >> >> > Traceback (most recent call last): >> >> > File "<stdin>", line 1, in <module> >> >> > File "validate.py", line 625, in check >> >> > return self._check_value(value, fun_name, fun_args, fun_kwargs) >> >> > File "validate.py", line 657, in _check_value >> >> > return fun(value, *fun_args, **fun_kwargs) >> >> > File "validate.py", line 1332, in is_option >> >> > raise VdtValueError(value) >> >> > validate.VdtValueError: the value "option 4" is unacceptable. >> >> > >> >> > >> >> > which if we tweak a bit more shows: >> >> >>>> my_categories = 'option 1', 'option 2', 'option 3' >> >> >>>> checked_val = vtor.check("option({})".format(', '.join(repr(cat) >> >> >>>> for >> >> >>>> cat >> >> >>>> in my_categories)), 'option 1') >> >> >>>> checked_val >> >> > 'option 1' >> >> > >> >> > note the example still does use join, but is also joining the repr of >> >> > each >> >> > element (to get the quotes around strings, mostly) >> >> >>>> "option({})".format(', '.join(repr(cat) for cat in my_categories)) >> >> > "option('option 1', 'option 2', 'option 3')" >> >> > >> >> > >> >> > Is this on the right track for what you need? >> >> > I'm out of contact for the next ~6 hours, but could try and respond >> >> > after >> >> > >> >> > On Sat, Jan 10, 2015 at 12:57 AM, Darren Spruell >> >> > <pha...@gm...> >> >> > wrote: >> >> >> >> >> >> I have a case in a script where I have a data structure defined in >> >> >> an >> >> >> external module, which is also a library we use in the script. I'd >> >> >> like to use that data in a DRY fashion in this script (which uses >> >> >> ConfigObj) by passing the structure (a list) as the argument to the >> >> >> option() validator. The reason for this is that the data in the >> >> >> target >> >> >> configuration field will ultimately be passed to the external module >> >> >> and will be validated against it, so the external module is >> >> >> essentially "authoritative" for the application. >> >> >> >> >> >> In the external module (mylib.py): >> >> >> >> >> >> CATEGORIES = ['WHITE', 'GREEN', 'AMBER', 'RED'] >> >> >> >> >> >> >> >> >> In the script: >> >> >> >> >> >> from mylib import CATEGORIES as allowed_categories >> >> >> >> >> >> CONFIGSPEC = '''\ >> >> >> logfile = string >> >> >> [foo] >> >> >> user = string >> >> >> pass = string >> >> >> [bar] >> >> >> [[__many__]] >> >> >> category = string >> >> >> ''' >> >> >> >> >> >> >> >> >> As shown I currently validate the 'category' option with string(), >> >> >> but >> >> >> I'd really like to use option() instead with the set of choices >> >> >> taken >> >> >> from the list imported from mylib; something like the following: >> >> >> >> >> >> category = option(allowed_categories) >> >> >> >> >> >> That syntax doesn't work and various attempts to coerce the list >> >> >> into >> >> >> a string that resembles a list of allowed values with join() hasn't >> >> >> done the trick. Is there currently a way to get this to function as >> >> >> I >> >> >> want? Any way to allow option() to accept a tuple or list as the >> >> >> arguments to ease working with structured data for that validator? >> >> >> >> >> >> -- >> >> >> Darren Spruell >> >> >> pha...@gm... >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> >> Dive into the World of Parallel Programming! The Go Parallel >> >> >> Website, >> >> >> sponsored by Intel and developed in partnership with Slashdot Media, >> >> >> is >> >> >> your >> >> >> hub for all things parallel software development, from weekly >> >> >> thought >> >> >> leadership blogs to news, videos, case studies, tutorials and more. >> >> >> Take a >> >> >> look and join the conversation now. >> >> >> http://goparallel.sourceforge.net >> >> >> _______________________________________________ >> >> >> Configobj-develop mailing list >> >> >> Con...@li... >> >> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > ------------------------------------------------------------------------------ >> >> > Dive into the World of Parallel Programming! The Go Parallel Website, >> >> > sponsored by Intel and developed in partnership with Slashdot Media, >> >> > is >> >> > your >> >> > hub for all things parallel software development, from weekly thought >> >> > leadership blogs to news, videos, case studies, tutorials and more. >> >> > Take >> >> > a >> >> > look and join the conversation now. http://goparallel.sourceforge.net >> >> > _______________________________________________ >> >> > Configobj-develop mailing list >> >> > Con...@li... >> >> > https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> > >> >> >> >> >> >> >> >> -- >> >> Darren Spruell >> >> pha...@gm... >> >> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> Dive into the World of Parallel Programming! The Go Parallel Website, >> >> sponsored by Intel and developed in partnership with Slashdot Media, is >> >> your >> >> hub for all things parallel software development, from weekly thought >> >> leadership blogs to news, videos, case studies, tutorials and more. >> >> Take a >> >> look and join the conversation now. http://goparallel.sourceforge.net >> >> _______________________________________________ >> >> Configobj-develop mailing list >> >> Con...@li... >> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> > >> > >> > >> > >> > ------------------------------------------------------------------------------ >> > New Year. New Location. New Benefits. New Data Center in Ashburn, VA. >> > GigeNET is offering a free month of service with a new server in >> > Ashburn. >> > Choose from 2 high performing configs, both with 100TB of bandwidth. >> > Higher redundancy.Lower latency.Increased capacity.Completely compliant. >> > http://p.sf.net/sfu/gigenet >> > _______________________________________________ >> > Configobj-develop mailing list >> > Con...@li... >> > https://lists.sourceforge.net/lists/listinfo/configobj-develop >> > >> >> >> >> -- >> Darren Spruell >> pha...@gm... >> >> >> ------------------------------------------------------------------------------ >> New Year. New Location. New Benefits. New Data Center in Ashburn, VA. >> GigeNET is offering a free month of service with a new server in Ashburn. >> Choose from 2 high performing configs, both with 100TB of bandwidth. >> Higher redundancy.Lower latency.Increased capacity.Completely compliant. >> http://p.sf.net/sfu/gigenet >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > ------------------------------------------------------------------------------ > New Year. New Location. New Benefits. New Data Center in Ashburn, VA. > GigeNET is offering a free month of service with a new server in Ashburn. > Choose from 2 high performing configs, both with 100TB of bandwidth. > Higher redundancy.Lower latency.Increased capacity.Completely compliant. > http://p.sf.net/sfu/gigenet > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- Darren Spruell pha...@gm... |
From: Rob D. <rd...@gm...> - 2015-01-22 13:19:48
|
Getting the same results implies that we're using the same version of Python/configobj, which is nice. The real reason I wrote that example up was to give you a string formatted configspec example that I believed should work, and one that appeared to be formatted the same way your example was (But with a different error message than what you had posted before). Is there a way to either link to your code repo, or at least paste the real config file and validation code to a gist? On Thu, Jan 22, 2015 at 12:37 AM, Darren Spruell <pha...@gm...> wrote: > Same results running the Gist: > $ python config_fest.py > expected to fail: formatted: [(['bar'], 'category', VdtValueError('the > value "unknown" is unacceptable.',))] > expected to pass: formatted: [] > expected to fail: unformatted: [(['bar'], 'category', > VdtUnknownCheckError('the check "allowed_category_options" is > unknown.',))] > expected to pass: unformatted: [(['bar'], 'category', > VdtUnknownCheckError('the check "allowed_category_options" is > unknown.',))] > I have to admit ignorance knowing quite how to interpret that though. > - Darren > (My turn to be sorry for a late reply). > On Wed, Jan 14, 2015 at 8:31 AM, Rob Dennis <rd...@gm...> wrote: >> (sorry for the late reply; work situation came up when I started to reply >> earlier, but I had already checked off that I had responded) >> >> I've taken your brief example and made a gist that you can execute: >> https://gist.github.com/robdennis/bf13312a078fe8557101 >> Unfortunately, I don't expect your example to work as written, since it'd >> need the constructed "option" string to be formatted into the configspec. >> >> You have a different error message though, so I'm assuming there's some >> other issue that's not obvious from what you included. >> >> the output I show for the test: >> ``` >> expected to fail: formatted: [(['bar'], 'category', VdtValueError('the value >> "unknown" is unacceptable.',))] >> expected to pass: formatted: [] >> expected to fail: unformatted: [(['bar'], 'category', >> VdtUnknownCheckError('the check "allowed_category_options" is unknown.',))] >> expected to pass: unformatted: [(['bar'], 'category', >> VdtUnknownCheckError('the check "allowed_category_options" is unknown.',))] >> ``` >> >> Maybe give it a shot and see if that gets your closer? >> >> On Sat, Jan 10, 2015 at 6:12 PM, Darren Spruell <pha...@gm...> >> wrote: >>> >>> Thanks. I think it's on the right track (repr() didn't occur to me >>> before), but although testing with Validator.check() works, I still >>> get validation failures when using the resulting code within a >>> configspec. >>> >>> BTW this is CPython 2.6.6. >>> >>> >>> # DEFAULTS['CATEGORIES'] is the list() of categories >>> allowed_category_options = "option({0})".format( >>> ', '.join([repr(cat) for cat in DEFAULTS['CATEGORIES']]) >>> ) >>> >>> CONFIGSPEC = '''\ >>> logfile = string >>> [foo] >>> user = string >>> pass = string >>> [bar] >>> [[__many__]] >>> category = allowed_category_options >>> ''' >>> >>> config = ConfigObj(conf_file, configspec=CONFIGSPEC.splitlines()) >>> validator = Validator() >>> results = config.validate(validator) >>> >>> >>> Results in: >>> The 'category' key in section 'bar, 2019761' failed validation >>> >>> Should this type of usage in a configspec (the way it's being parsed >>> in my case) work correctly? >>> >>> DS >>> >>> >>> On Sat, Jan 10, 2015 at 6:26 AM, Rob Dennis <rd...@gm...> wrote: >>> > Hello Darren, >>> > >>> > I'm one of the current maintainers along with Eli, I'm modifying a >>> > slightly >>> > tweaked example from here: >>> > >>> > https://configobj.readthedocs.org/en/latest/validate.html#the-standard-functions >>> > >>> > I'm seeing the behavior I expect for handcrafting the options validator: >>> >>>> from validate import Validator >>> >>>> vtor = Validator() >>> >>>> checked_val = vtor.check("option('option 1', 'option 2', 'option >>> >>>> 3')", >>> >>>> 'option 1') >>> >>>> checked_val >>> > 'option 1' >>> >>>> checked_val = vtor.check("option('option 1', 'option 2', 'option >>> >>>> 3')", >>> >>>> 'option 4') >>> > Traceback (most recent call last): >>> > File "<stdin>", line 1, in <module> >>> > File "validate.py", line 625, in check >>> > return self._check_value(value, fun_name, fun_args, fun_kwargs) >>> > File "validate.py", line 657, in _check_value >>> > return fun(value, *fun_args, **fun_kwargs) >>> > File "validate.py", line 1332, in is_option >>> > raise VdtValueError(value) >>> > validate.VdtValueError: the value "option 4" is unacceptable. >>> > >>> > >>> > which if we tweak a bit more shows: >>> >>>> my_categories = 'option 1', 'option 2', 'option 3' >>> >>>> checked_val = vtor.check("option({})".format(', '.join(repr(cat) for >>> >>>> cat >>> >>>> in my_categories)), 'option 1') >>> >>>> checked_val >>> > 'option 1' >>> > >>> > note the example still does use join, but is also joining the repr of >>> > each >>> > element (to get the quotes around strings, mostly) >>> >>>> "option({})".format(', '.join(repr(cat) for cat in my_categories)) >>> > "option('option 1', 'option 2', 'option 3')" >>> > >>> > >>> > Is this on the right track for what you need? >>> > I'm out of contact for the next ~6 hours, but could try and respond >>> > after >>> > >>> > On Sat, Jan 10, 2015 at 12:57 AM, Darren Spruell <pha...@gm...> >>> > wrote: >>> >> >>> >> I have a case in a script where I have a data structure defined in an >>> >> external module, which is also a library we use in the script. I'd >>> >> like to use that data in a DRY fashion in this script (which uses >>> >> ConfigObj) by passing the structure (a list) as the argument to the >>> >> option() validator. The reason for this is that the data in the target >>> >> configuration field will ultimately be passed to the external module >>> >> and will be validated against it, so the external module is >>> >> essentially "authoritative" for the application. >>> >> >>> >> In the external module (mylib.py): >>> >> >>> >> CATEGORIES = ['WHITE', 'GREEN', 'AMBER', 'RED'] >>> >> >>> >> >>> >> In the script: >>> >> >>> >> from mylib import CATEGORIES as allowed_categories >>> >> >>> >> CONFIGSPEC = '''\ >>> >> logfile = string >>> >> [foo] >>> >> user = string >>> >> pass = string >>> >> [bar] >>> >> [[__many__]] >>> >> category = string >>> >> ''' >>> >> >>> >> >>> >> As shown I currently validate the 'category' option with string(), but >>> >> I'd really like to use option() instead with the set of choices taken >>> >> from the list imported from mylib; something like the following: >>> >> >>> >> category = option(allowed_categories) >>> >> >>> >> That syntax doesn't work and various attempts to coerce the list into >>> >> a string that resembles a list of allowed values with join() hasn't >>> >> done the trick. Is there currently a way to get this to function as I >>> >> want? Any way to allow option() to accept a tuple or list as the >>> >> arguments to ease working with structured data for that validator? >>> >> >>> >> -- >>> >> Darren Spruell >>> >> pha...@gm... >>> >> >>> >> >>> >> >>> >> ------------------------------------------------------------------------------ >>> >> Dive into the World of Parallel Programming! The Go Parallel Website, >>> >> sponsored by Intel and developed in partnership with Slashdot Media, is >>> >> your >>> >> hub for all things parallel software development, from weekly thought >>> >> leadership blogs to news, videos, case studies, tutorials and more. >>> >> Take a >>> >> look and join the conversation now. http://goparallel.sourceforge.net >>> >> _______________________________________________ >>> >> Configobj-develop mailing list >>> >> Con...@li... >>> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >>> > >>> > >>> > >>> > >>> > ------------------------------------------------------------------------------ >>> > Dive into the World of Parallel Programming! The Go Parallel Website, >>> > sponsored by Intel and developed in partnership with Slashdot Media, is >>> > your >>> > hub for all things parallel software development, from weekly thought >>> > leadership blogs to news, videos, case studies, tutorials and more. Take >>> > a >>> > look and join the conversation now. http://goparallel.sourceforge.net >>> > _______________________________________________ >>> > Configobj-develop mailing list >>> > Con...@li... >>> > https://lists.sourceforge.net/lists/listinfo/configobj-develop >>> > >>> >>> >>> >>> -- >>> Darren Spruell >>> pha...@gm... >>> >>> >>> ------------------------------------------------------------------------------ >>> Dive into the World of Parallel Programming! The Go Parallel Website, >>> sponsored by Intel and developed in partnership with Slashdot Media, is >>> your >>> hub for all things parallel software development, from weekly thought >>> leadership blogs to news, videos, case studies, tutorials and more. Take a >>> look and join the conversation now. http://goparallel.sourceforge.net >>> _______________________________________________ >>> Configobj-develop mailing list >>> Con...@li... >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> >> >> ------------------------------------------------------------------------------ >> New Year. New Location. New Benefits. New Data Center in Ashburn, VA. >> GigeNET is offering a free month of service with a new server in Ashburn. >> Choose from 2 high performing configs, both with 100TB of bandwidth. >> Higher redundancy.Lower latency.Increased capacity.Completely compliant. >> http://p.sf.net/sfu/gigenet >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> > -- > Darren Spruell > pha...@gm... > ------------------------------------------------------------------------------ > New Year. New Location. New Benefits. New Data Center in Ashburn, VA. > GigeNET is offering a free month of service with a new server in Ashburn. > Choose from 2 high performing configs, both with 100TB of bandwidth. > Higher redundancy.Lower latency.Increased capacity.Completely compliant. > http://p.sf.net/sfu/gigenet > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop |
From: Darren S. <pha...@gm...> - 2015-01-22 05:37:50
|
Same results running the Gist: $ python config_fest.py expected to fail: formatted: [(['bar'], 'category', VdtValueError('the value "unknown" is unacceptable.',))] expected to pass: formatted: [] expected to fail: unformatted: [(['bar'], 'category', VdtUnknownCheckError('the check "allowed_category_options" is unknown.',))] expected to pass: unformatted: [(['bar'], 'category', VdtUnknownCheckError('the check "allowed_category_options" is unknown.',))] I have to admit ignorance knowing quite how to interpret that though. - Darren (My turn to be sorry for a late reply). On Wed, Jan 14, 2015 at 8:31 AM, Rob Dennis <rd...@gm...> wrote: > (sorry for the late reply; work situation came up when I started to reply > earlier, but I had already checked off that I had responded) > > I've taken your brief example and made a gist that you can execute: > https://gist.github.com/robdennis/bf13312a078fe8557101 > Unfortunately, I don't expect your example to work as written, since it'd > need the constructed "option" string to be formatted into the configspec. > > You have a different error message though, so I'm assuming there's some > other issue that's not obvious from what you included. > > the output I show for the test: > ``` > expected to fail: formatted: [(['bar'], 'category', VdtValueError('the value > "unknown" is unacceptable.',))] > expected to pass: formatted: [] > expected to fail: unformatted: [(['bar'], 'category', > VdtUnknownCheckError('the check "allowed_category_options" is unknown.',))] > expected to pass: unformatted: [(['bar'], 'category', > VdtUnknownCheckError('the check "allowed_category_options" is unknown.',))] > ``` > > Maybe give it a shot and see if that gets your closer? > > On Sat, Jan 10, 2015 at 6:12 PM, Darren Spruell <pha...@gm...> > wrote: >> >> Thanks. I think it's on the right track (repr() didn't occur to me >> before), but although testing with Validator.check() works, I still >> get validation failures when using the resulting code within a >> configspec. >> >> BTW this is CPython 2.6.6. >> >> >> # DEFAULTS['CATEGORIES'] is the list() of categories >> allowed_category_options = "option({0})".format( >> ', '.join([repr(cat) for cat in DEFAULTS['CATEGORIES']]) >> ) >> >> CONFIGSPEC = '''\ >> logfile = string >> [foo] >> user = string >> pass = string >> [bar] >> [[__many__]] >> category = allowed_category_options >> ''' >> >> config = ConfigObj(conf_file, configspec=CONFIGSPEC.splitlines()) >> validator = Validator() >> results = config.validate(validator) >> >> >> Results in: >> The 'category' key in section 'bar, 2019761' failed validation >> >> Should this type of usage in a configspec (the way it's being parsed >> in my case) work correctly? >> >> DS >> >> >> On Sat, Jan 10, 2015 at 6:26 AM, Rob Dennis <rd...@gm...> wrote: >> > Hello Darren, >> > >> > I'm one of the current maintainers along with Eli, I'm modifying a >> > slightly >> > tweaked example from here: >> > >> > https://configobj.readthedocs.org/en/latest/validate.html#the-standard-functions >> > >> > I'm seeing the behavior I expect for handcrafting the options validator: >> >>>> from validate import Validator >> >>>> vtor = Validator() >> >>>> checked_val = vtor.check("option('option 1', 'option 2', 'option >> >>>> 3')", >> >>>> 'option 1') >> >>>> checked_val >> > 'option 1' >> >>>> checked_val = vtor.check("option('option 1', 'option 2', 'option >> >>>> 3')", >> >>>> 'option 4') >> > Traceback (most recent call last): >> > File "<stdin>", line 1, in <module> >> > File "validate.py", line 625, in check >> > return self._check_value(value, fun_name, fun_args, fun_kwargs) >> > File "validate.py", line 657, in _check_value >> > return fun(value, *fun_args, **fun_kwargs) >> > File "validate.py", line 1332, in is_option >> > raise VdtValueError(value) >> > validate.VdtValueError: the value "option 4" is unacceptable. >> > >> > >> > which if we tweak a bit more shows: >> >>>> my_categories = 'option 1', 'option 2', 'option 3' >> >>>> checked_val = vtor.check("option({})".format(', '.join(repr(cat) for >> >>>> cat >> >>>> in my_categories)), 'option 1') >> >>>> checked_val >> > 'option 1' >> > >> > note the example still does use join, but is also joining the repr of >> > each >> > element (to get the quotes around strings, mostly) >> >>>> "option({})".format(', '.join(repr(cat) for cat in my_categories)) >> > "option('option 1', 'option 2', 'option 3')" >> > >> > >> > Is this on the right track for what you need? >> > I'm out of contact for the next ~6 hours, but could try and respond >> > after >> > >> > On Sat, Jan 10, 2015 at 12:57 AM, Darren Spruell <pha...@gm...> >> > wrote: >> >> >> >> I have a case in a script where I have a data structure defined in an >> >> external module, which is also a library we use in the script. I'd >> >> like to use that data in a DRY fashion in this script (which uses >> >> ConfigObj) by passing the structure (a list) as the argument to the >> >> option() validator. The reason for this is that the data in the target >> >> configuration field will ultimately be passed to the external module >> >> and will be validated against it, so the external module is >> >> essentially "authoritative" for the application. >> >> >> >> In the external module (mylib.py): >> >> >> >> CATEGORIES = ['WHITE', 'GREEN', 'AMBER', 'RED'] >> >> >> >> >> >> In the script: >> >> >> >> from mylib import CATEGORIES as allowed_categories >> >> >> >> CONFIGSPEC = '''\ >> >> logfile = string >> >> [foo] >> >> user = string >> >> pass = string >> >> [bar] >> >> [[__many__]] >> >> category = string >> >> ''' >> >> >> >> >> >> As shown I currently validate the 'category' option with string(), but >> >> I'd really like to use option() instead with the set of choices taken >> >> from the list imported from mylib; something like the following: >> >> >> >> category = option(allowed_categories) >> >> >> >> That syntax doesn't work and various attempts to coerce the list into >> >> a string that resembles a list of allowed values with join() hasn't >> >> done the trick. Is there currently a way to get this to function as I >> >> want? Any way to allow option() to accept a tuple or list as the >> >> arguments to ease working with structured data for that validator? >> >> >> >> -- >> >> Darren Spruell >> >> pha...@gm... >> >> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> Dive into the World of Parallel Programming! The Go Parallel Website, >> >> sponsored by Intel and developed in partnership with Slashdot Media, is >> >> your >> >> hub for all things parallel software development, from weekly thought >> >> leadership blogs to news, videos, case studies, tutorials and more. >> >> Take a >> >> look and join the conversation now. http://goparallel.sourceforge.net >> >> _______________________________________________ >> >> Configobj-develop mailing list >> >> Con...@li... >> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> > >> > >> > >> > >> > ------------------------------------------------------------------------------ >> > Dive into the World of Parallel Programming! The Go Parallel Website, >> > sponsored by Intel and developed in partnership with Slashdot Media, is >> > your >> > hub for all things parallel software development, from weekly thought >> > leadership blogs to news, videos, case studies, tutorials and more. Take >> > a >> > look and join the conversation now. http://goparallel.sourceforge.net >> > _______________________________________________ >> > Configobj-develop mailing list >> > Con...@li... >> > https://lists.sourceforge.net/lists/listinfo/configobj-develop >> > >> >> >> >> -- >> Darren Spruell >> pha...@gm... >> >> >> ------------------------------------------------------------------------------ >> Dive into the World of Parallel Programming! The Go Parallel Website, >> sponsored by Intel and developed in partnership with Slashdot Media, is >> your >> hub for all things parallel software development, from weekly thought >> leadership blogs to news, videos, case studies, tutorials and more. Take a >> look and join the conversation now. http://goparallel.sourceforge.net >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > ------------------------------------------------------------------------------ > New Year. New Location. New Benefits. New Data Center in Ashburn, VA. > GigeNET is offering a free month of service with a new server in Ashburn. > Choose from 2 high performing configs, both with 100TB of bandwidth. > Higher redundancy.Lower latency.Increased capacity.Completely compliant. > http://p.sf.net/sfu/gigenet > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- Darren Spruell pha...@gm... |
From: Rob D. <rd...@gm...> - 2015-01-14 15:31:55
|
(sorry for the late reply; work situation came up when I started to reply earlier, but I had already checked off that I had responded) I've taken your brief example and made a gist that you can execute: https://gist.github.com/robdennis/bf13312a078fe8557101 Unfortunately, I don't expect your example to work as written, since it'd need the constructed "option" string to be formatted into the configspec. You have a different error message though, so I'm assuming there's some other issue that's not obvious from what you included. the output I show for the test: ``` expected to fail: formatted: [(['bar'], 'category', VdtValueError('the value "unknown" is unacceptable.',))] expected to pass: formatted: [] expected to fail: unformatted: [(['bar'], 'category', VdtUnknownCheckError('the check "allowed_category_options" is unknown.',))] expected to pass: unformatted: [(['bar'], 'category', VdtUnknownCheckError('the check "allowed_category_options" is unknown.',))] ``` Maybe give it a shot and see if that gets your closer? On Sat, Jan 10, 2015 at 6:12 PM, Darren Spruell <pha...@gm...> wrote: > Thanks. I think it's on the right track (repr() didn't occur to me > before), but although testing with Validator.check() works, I still > get validation failures when using the resulting code within a > configspec. > > BTW this is CPython 2.6.6. > > > # DEFAULTS['CATEGORIES'] is the list() of categories > allowed_category_options = "option({0})".format( > ', '.join([repr(cat) for cat in DEFAULTS['CATEGORIES']]) > ) > > CONFIGSPEC = '''\ > logfile = string > [foo] > user = string > pass = string > [bar] > [[__many__]] > category = allowed_category_options > ''' > > config = ConfigObj(conf_file, configspec=CONFIGSPEC.splitlines()) > validator = Validator() > results = config.validate(validator) > > > Results in: > The 'category' key in section 'bar, 2019761' failed validation > > Should this type of usage in a configspec (the way it's being parsed > in my case) work correctly? > > DS > > > On Sat, Jan 10, 2015 at 6:26 AM, Rob Dennis <rd...@gm...> wrote: > > Hello Darren, > > > > I'm one of the current maintainers along with Eli, I'm modifying a > slightly > > tweaked example from here: > > > https://configobj.readthedocs.org/en/latest/validate.html#the-standard-functions > > > > I'm seeing the behavior I expect for handcrafting the options validator: > >>>> from validate import Validator > >>>> vtor = Validator() > >>>> checked_val = vtor.check("option('option 1', 'option 2', 'option 3')", > >>>> 'option 1') > >>>> checked_val > > 'option 1' > >>>> checked_val = vtor.check("option('option 1', 'option 2', 'option 3')", > >>>> 'option 4') > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > File "validate.py", line 625, in check > > return self._check_value(value, fun_name, fun_args, fun_kwargs) > > File "validate.py", line 657, in _check_value > > return fun(value, *fun_args, **fun_kwargs) > > File "validate.py", line 1332, in is_option > > raise VdtValueError(value) > > validate.VdtValueError: the value "option 4" is unacceptable. > > > > > > which if we tweak a bit more shows: > >>>> my_categories = 'option 1', 'option 2', 'option 3' > >>>> checked_val = vtor.check("option({})".format(', '.join(repr(cat) for > cat > >>>> in my_categories)), 'option 1') > >>>> checked_val > > 'option 1' > > > > note the example still does use join, but is also joining the repr of > each > > element (to get the quotes around strings, mostly) > >>>> "option({})".format(', '.join(repr(cat) for cat in my_categories)) > > "option('option 1', 'option 2', 'option 3')" > > > > > > Is this on the right track for what you need? > > I'm out of contact for the next ~6 hours, but could try and respond after > > > > On Sat, Jan 10, 2015 at 12:57 AM, Darren Spruell <pha...@gm...> > > wrote: > >> > >> I have a case in a script where I have a data structure defined in an > >> external module, which is also a library we use in the script. I'd > >> like to use that data in a DRY fashion in this script (which uses > >> ConfigObj) by passing the structure (a list) as the argument to the > >> option() validator. The reason for this is that the data in the target > >> configuration field will ultimately be passed to the external module > >> and will be validated against it, so the external module is > >> essentially "authoritative" for the application. > >> > >> In the external module (mylib.py): > >> > >> CATEGORIES = ['WHITE', 'GREEN', 'AMBER', 'RED'] > >> > >> > >> In the script: > >> > >> from mylib import CATEGORIES as allowed_categories > >> > >> CONFIGSPEC = '''\ > >> logfile = string > >> [foo] > >> user = string > >> pass = string > >> [bar] > >> [[__many__]] > >> category = string > >> ''' > >> > >> > >> As shown I currently validate the 'category' option with string(), but > >> I'd really like to use option() instead with the set of choices taken > >> from the list imported from mylib; something like the following: > >> > >> category = option(allowed_categories) > >> > >> That syntax doesn't work and various attempts to coerce the list into > >> a string that resembles a list of allowed values with join() hasn't > >> done the trick. Is there currently a way to get this to function as I > >> want? Any way to allow option() to accept a tuple or list as the > >> arguments to ease working with structured data for that validator? > >> > >> -- > >> Darren Spruell > >> pha...@gm... > >> > >> > >> > ------------------------------------------------------------------------------ > >> Dive into the World of Parallel Programming! The Go Parallel Website, > >> sponsored by Intel and developed in partnership with Slashdot Media, is > >> your > >> hub for all things parallel software development, from weekly thought > >> leadership blogs to news, videos, case studies, tutorials and more. > Take a > >> look and join the conversation now. http://goparallel.sourceforge.net > >> _______________________________________________ > >> Configobj-develop mailing list > >> Con...@li... > >> https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > > > > > > ------------------------------------------------------------------------------ > > Dive into the World of Parallel Programming! The Go Parallel Website, > > sponsored by Intel and developed in partnership with Slashdot Media, is > your > > hub for all things parallel software development, from weekly thought > > leadership blogs to news, videos, case studies, tutorials and more. Take > a > > look and join the conversation now. http://goparallel.sourceforge.net > > _______________________________________________ > > Configobj-develop mailing list > > Con...@li... > > https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > > > -- > Darren Spruell > pha...@gm... > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming! The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is > your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > |
From: Darren S. <pha...@gm...> - 2015-01-10 23:12:15
|
Thanks. I think it's on the right track (repr() didn't occur to me before), but although testing with Validator.check() works, I still get validation failures when using the resulting code within a configspec. BTW this is CPython 2.6.6. # DEFAULTS['CATEGORIES'] is the list() of categories allowed_category_options = "option({0})".format( ', '.join([repr(cat) for cat in DEFAULTS['CATEGORIES']]) ) CONFIGSPEC = '''\ logfile = string [foo] user = string pass = string [bar] [[__many__]] category = allowed_category_options ''' config = ConfigObj(conf_file, configspec=CONFIGSPEC.splitlines()) validator = Validator() results = config.validate(validator) Results in: The 'category' key in section 'bar, 2019761' failed validation Should this type of usage in a configspec (the way it's being parsed in my case) work correctly? DS On Sat, Jan 10, 2015 at 6:26 AM, Rob Dennis <rd...@gm...> wrote: > Hello Darren, > > I'm one of the current maintainers along with Eli, I'm modifying a slightly > tweaked example from here: > https://configobj.readthedocs.org/en/latest/validate.html#the-standard-functions > > I'm seeing the behavior I expect for handcrafting the options validator: >>>> from validate import Validator >>>> vtor = Validator() >>>> checked_val = vtor.check("option('option 1', 'option 2', 'option 3')", >>>> 'option 1') >>>> checked_val > 'option 1' >>>> checked_val = vtor.check("option('option 1', 'option 2', 'option 3')", >>>> 'option 4') > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "validate.py", line 625, in check > return self._check_value(value, fun_name, fun_args, fun_kwargs) > File "validate.py", line 657, in _check_value > return fun(value, *fun_args, **fun_kwargs) > File "validate.py", line 1332, in is_option > raise VdtValueError(value) > validate.VdtValueError: the value "option 4" is unacceptable. > > > which if we tweak a bit more shows: >>>> my_categories = 'option 1', 'option 2', 'option 3' >>>> checked_val = vtor.check("option({})".format(', '.join(repr(cat) for cat >>>> in my_categories)), 'option 1') >>>> checked_val > 'option 1' > > note the example still does use join, but is also joining the repr of each > element (to get the quotes around strings, mostly) >>>> "option({})".format(', '.join(repr(cat) for cat in my_categories)) > "option('option 1', 'option 2', 'option 3')" > > > Is this on the right track for what you need? > I'm out of contact for the next ~6 hours, but could try and respond after > > On Sat, Jan 10, 2015 at 12:57 AM, Darren Spruell <pha...@gm...> > wrote: >> >> I have a case in a script where I have a data structure defined in an >> external module, which is also a library we use in the script. I'd >> like to use that data in a DRY fashion in this script (which uses >> ConfigObj) by passing the structure (a list) as the argument to the >> option() validator. The reason for this is that the data in the target >> configuration field will ultimately be passed to the external module >> and will be validated against it, so the external module is >> essentially "authoritative" for the application. >> >> In the external module (mylib.py): >> >> CATEGORIES = ['WHITE', 'GREEN', 'AMBER', 'RED'] >> >> >> In the script: >> >> from mylib import CATEGORIES as allowed_categories >> >> CONFIGSPEC = '''\ >> logfile = string >> [foo] >> user = string >> pass = string >> [bar] >> [[__many__]] >> category = string >> ''' >> >> >> As shown I currently validate the 'category' option with string(), but >> I'd really like to use option() instead with the set of choices taken >> from the list imported from mylib; something like the following: >> >> category = option(allowed_categories) >> >> That syntax doesn't work and various attempts to coerce the list into >> a string that resembles a list of allowed values with join() hasn't >> done the trick. Is there currently a way to get this to function as I >> want? Any way to allow option() to accept a tuple or list as the >> arguments to ease working with structured data for that validator? >> >> -- >> Darren Spruell >> pha...@gm... >> >> >> ------------------------------------------------------------------------------ >> Dive into the World of Parallel Programming! The Go Parallel Website, >> sponsored by Intel and developed in partnership with Slashdot Media, is >> your >> hub for all things parallel software development, from weekly thought >> leadership blogs to news, videos, case studies, tutorials and more. Take a >> look and join the conversation now. http://goparallel.sourceforge.net >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming! The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- Darren Spruell pha...@gm... |
From: Rob D. <rd...@gm...> - 2015-01-10 13:27:05
|
Hello Darren, I'm one of the current maintainers along with Eli, I'm modifying a slightly tweaked example from here: https://configobj.readthedocs.org/en/latest/validate.html#the-standard-functions I'm seeing the behavior I expect for handcrafting the options validator: >>> from validate import Validator >>> vtor = Validator() >>> checked_val = vtor.check("option('option 1', 'option 2', 'option 3')", 'option 1') >>> checked_val 'option 1' >>> checked_val = vtor.check("option('option 1', 'option 2', 'option 3')", 'option 4') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "validate.py", line 625, in check return self._check_value(value, fun_name, fun_args, fun_kwargs) File "validate.py", line 657, in _check_value return fun(value, *fun_args, **fun_kwargs) File "validate.py", line 1332, in is_option raise VdtValueError(value) validate.VdtValueError: the value "option 4" is unacceptable. which if we tweak a bit more shows: >>> my_categories = 'option 1', 'option 2', 'option 3' >>> checked_val = vtor.check("option({})".format(', '.join(repr(cat) for cat in my_categories)), 'option 1') >>> checked_val 'option 1' note the example still does use join, but is also joining the repr of each element (to get the quotes around strings, mostly) >>> "option({})".format(', '.join(repr(cat) for cat in my_categories)) "option('option 1', 'option 2', 'option 3')" Is this on the right track for what you need? I'm out of contact for the next ~6 hours, but could try and respond after On Sat, Jan 10, 2015 at 12:57 AM, Darren Spruell <pha...@gm...> wrote: > I have a case in a script where I have a data structure defined in an > external module, which is also a library we use in the script. I'd > like to use that data in a DRY fashion in this script (which uses > ConfigObj) by passing the structure (a list) as the argument to the > option() validator. The reason for this is that the data in the target > configuration field will ultimately be passed to the external module > and will be validated against it, so the external module is > essentially "authoritative" for the application. > > In the external module (mylib.py): > > CATEGORIES = ['WHITE', 'GREEN', 'AMBER', 'RED'] > > > In the script: > > from mylib import CATEGORIES as allowed_categories > > CONFIGSPEC = '''\ > logfile = string > [foo] > user = string > pass = string > [bar] > [[__many__]] > category = string > ''' > > > As shown I currently validate the 'category' option with string(), but > I'd really like to use option() instead with the set of choices taken > from the list imported from mylib; something like the following: > > category = option(allowed_categories) > > That syntax doesn't work and various attempts to coerce the list into > a string that resembles a list of allowed values with join() hasn't > done the trick. Is there currently a way to get this to function as I > want? Any way to allow option() to accept a tuple or list as the > arguments to ease working with structured data for that validator? > > -- > Darren Spruell > pha...@gm... > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming! The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is > your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > |
From: Darren S. <pha...@gm...> - 2015-01-10 05:57:43
|
I have a case in a script where I have a data structure defined in an external module, which is also a library we use in the script. I'd like to use that data in a DRY fashion in this script (which uses ConfigObj) by passing the structure (a list) as the argument to the option() validator. The reason for this is that the data in the target configuration field will ultimately be passed to the external module and will be validated against it, so the external module is essentially "authoritative" for the application. In the external module (mylib.py): CATEGORIES = ['WHITE', 'GREEN', 'AMBER', 'RED'] In the script: from mylib import CATEGORIES as allowed_categories CONFIGSPEC = '''\ logfile = string [foo] user = string pass = string [bar] [[__many__]] category = string ''' As shown I currently validate the 'category' option with string(), but I'd really like to use option() instead with the set of choices taken from the list imported from mylib; something like the following: category = option(allowed_categories) That syntax doesn't work and various attempts to coerce the list into a string that resembles a list of allowed values with join() hasn't done the trick. Is there currently a way to get this to function as I want? Any way to allow option() to accept a tuple or list as the arguments to ease working with structured data for that validator? -- Darren Spruell pha...@gm... |
From: Eli C. <el...@co...> - 2015-01-09 19:30:46
|
This is not currently possible, unfortunately. Your suggestion seems good. It reads well, though it's not technically backwards-compatible, since it eliminates the ability for people to have config options called __name__ within a section. With that being said, this might be an extreme-enough edge case that we'd be okay with it. At the very least it seems worth considering. I've created an issue for this in our Github: https://github.com/DiffSK/configobj/issues/81 - Eli On Wed, Jan 7, 2015 at 1:29 AM, Darren Spruell <pha...@gm...> wrote: > Greetings, > > Have been enjoying the validator functionality in ConfigObj greatly > (configspecs). > > I have a case where my configuration has a section which may contain > many subsections, and I'd like the ability to apply a validator to the > name of the subsections (they should only be integers in the range of > 100 to 10000000). Is this currently possible in ConfigObj? Otherwise, > something that could be made possible? > > Thinking something along the lines of a key name in the configspec of > __name__, e.g.: > > [foo] > [[__many__]] > __name__ = integer(100,10000000) > field1 = string > field2 = integer(0,100) > > -- > Darren Spruell > pha...@gm... > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming! The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is > your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > |
From: Darren S. <pha...@gm...> - 2015-01-08 19:24:23
|
Very nice, thank you! That works great. DS On Thu, Jan 8, 2015 at 12:20 PM, Eli Courtwright <el...@co...> wrote: > You can create a single-item list by ending your string with a trailing > comma, e.g. > > notify = me...@ex..., > > - Eli > > On Thu, Jan 8, 2015 at 2:15 PM, Darren Spruell <pha...@gm...> > wrote: >> >> Greetings, >> >> I have a field in my configuration section that should be set with a >> list of one or more email addresses for notification; i.e. either of >> these configuration settings would be correct: >> >> notify = me...@ex... >> >> notify = me...@ex..., yo...@ex... >> >> What seems ideal would be for the string_list() validator to accept a >> single list item (essentially, the same validation as string()) and >> not *only* a list. I sampled it with a 'min' value of 1 but that also >> resulted in validation failure with a single value in the field: >> >> notify = string_list(default=None, min=1) >> >> Is there a way to accomplish this with the string_list() validator, or >> does this require a custom validator? Any chance to see a modification >> string_list to support single-item lists if not? >> >> -- >> Darren Spruell >> pha...@gm... >> >> >> ------------------------------------------------------------------------------ >> Dive into the World of Parallel Programming! The Go Parallel Website, >> sponsored by Intel and developed in partnership with Slashdot Media, is >> your >> hub for all things parallel software development, from weekly thought >> leadership blogs to news, videos, case studies, tutorials and more. Take a >> look and join the conversation now. http://goparallel.sourceforge.net >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming! The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- Darren Spruell pha...@gm... |
From: Eli C. <el...@co...> - 2015-01-08 19:20:22
|
You can create a single-item list by ending your string with a trailing comma, e.g. notify = me...@ex..., - Eli On Thu, Jan 8, 2015 at 2:15 PM, Darren Spruell <pha...@gm...> wrote: > Greetings, > > I have a field in my configuration section that should be set with a > list of one or more email addresses for notification; i.e. either of > these configuration settings would be correct: > > notify = me...@ex... > > notify = me...@ex..., yo...@ex... > > What seems ideal would be for the string_list() validator to accept a > single list item (essentially, the same validation as string()) and > not *only* a list. I sampled it with a 'min' value of 1 but that also > resulted in validation failure with a single value in the field: > > notify = string_list(default=None, min=1) > > Is there a way to accomplish this with the string_list() validator, or > does this require a custom validator? Any chance to see a modification > string_list to support single-item lists if not? > > -- > Darren Spruell > pha...@gm... > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming! The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is > your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > |
From: Darren S. <pha...@gm...> - 2015-01-08 19:15:18
|
Greetings, I have a field in my configuration section that should be set with a list of one or more email addresses for notification; i.e. either of these configuration settings would be correct: notify = me...@ex... notify = me...@ex..., yo...@ex... What seems ideal would be for the string_list() validator to accept a single list item (essentially, the same validation as string()) and not *only* a list. I sampled it with a 'min' value of 1 but that also resulted in validation failure with a single value in the field: notify = string_list(default=None, min=1) Is there a way to accomplish this with the string_list() validator, or does this require a custom validator? Any chance to see a modification string_list to support single-item lists if not? -- Darren Spruell pha...@gm... |