From michael at askus.fr Fri Mar 30 17:24:54 2007 From: michael at askus.fr (Michael REMY Askus) Date: Fri, 30 Mar 2007 17:24:54 +0200 Subject: [icalendar-dev] how to verify if a date is into the ical file ? Message-ID: <460D2BC6.1070009@askus.fr> hi, this is my first question after subscribed to the mailing list. This module is very useful for my application (TinyERP) to determinate easter days (stored in a iCal file) But, i don't find in the doc how to verifiy is a date is present or not into a iCal file. What is the method ? In waiting your answer, i justed do a string presence of the date, like a novice ! for exampl : from icalendar import Calendar, Event cal = Calendar.from_string(open('/home/remy/local/dev/cvs_cpn/SV3.4.0.1/bin/icalendar/france.ics','rb').read()) txt=str(cal) found=False thedate="20070521" if (found==False and txt.find(thedate)!=-1): found=True So, is there any method to test a date instead this string search one ?? Thank for help Mike (from France) From matt-icalendar at mosuki.com Fri Mar 30 17:36:49 2007 From: matt-icalendar at mosuki.com (Matt Chisholm) Date: Fri, 30 Mar 2007 08:36:49 -0700 Subject: [icalendar-dev] how to verify if a date is into the ical file ? In-Reply-To: <460D2BC6.1070009@askus.fr> References: <460D2BC6.1070009@askus.fr> Message-ID: <20070330153649.GA17870@theory.org> You don't need iCalendar to do this. Just do: found = open('/path/to/france.ics','r').read().find('20070521') != -1 Of course, that will fail if somebody puts '20070521' in an event summary or description. -m On Mar 30 2007, 17:24, Michael REMY Askus wrote: >hi, > >this is my first question after subscribed to the mailing list. >This module is very useful for my application (TinyERP) to determinate >easter days (stored in a iCal file) > >But, i don't find in the doc how to verifiy is a date is present or not >into a iCal file. >What is the method ? > >In waiting your answer, i justed do a string presence of the date, like >a novice ! >for exampl : > >from icalendar import Calendar, Event > cal = >Calendar.from_string(open('/home/remy/local/dev/cvs_cpn/SV3.4.0.1/bin/icalendar/france.ics','rb').read()) > > txt=str(cal) > found=False > > thedate="20070521" > if (found==False and txt.find(thedate)!=-1): > found=True > >So, is there any method to test a date instead this string search one ?? > >Thank for help > >Mike (from France) > >_______________________________________________ >icalendar-dev mailing list >icalendar-dev at codespeak.net >http://codespeak.net/mailman/listinfo/icalendar-dev From maxm at mxm.dk Fri Mar 30 21:48:38 2007 From: maxm at mxm.dk (Max M) Date: Fri, 30 Mar 2007 21:48:38 +0200 Subject: [icalendar-dev] how to verify if a date is into the ical file ? In-Reply-To: <460D2BC6.1070009@askus.fr> References: <460D2BC6.1070009@askus.fr> Message-ID: <460D6996.3080801@mxm.dk> Michael REMY Askus skrev: > hi, > > this is my first question after subscribed to the mailing list. > This module is very useful for my application (TinyERP) to determinate > easter days (stored in a iCal file) > > But, i don't find in the doc how to verifiy is a date is present or not > into a iCal file. > What is the method ? > > In waiting your answer, i justed do a string presence of the date, like > a novice ! You can just treat the ical object as a dict and loop through it: for key in cal.keys(): val = cal.decoded(key) if val = date: return True return False -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 46 93 23 92 Mobile: +45 29 93 42 96