Woho! On Wednesday, 18 December 2013, Justin Israel wrote:
> That looks right to me! > On Dec 19, 2013 1:23 AM, "Marcus Ottosson" > <[email protected]<javascript:_e({}, 'cvml', '[email protected]');>> > wrote: > >> What do you think my usage of flags within this "policy" for a >> os.listdir-type object? >> >> class ExcludePolicy(object): >> >> # Flags >> ExcludeHidden = 1 << 0 >> ExcludeInvisible = 1 << 1 >> ExcludeRegex = 1 << 2 >> ExcludeFiles = 1 << 3 >> >> def __init__(self): >> self.__flags = self.ExcludeHidden | self.ExcludeInvisible | >> self.ExcludeFiles >> self.__regex = '' >> >> @property >> def regex(self): >> return self.__regex >> >> @regex.setter >> def regex(self, regex): >> self.__regex = regex >> >> @property >> def flags(self): >> return self.__flags >> >> @flags.setter >> def flags(self, flags): >> self.__flags = flags >> >> >> class ListDir(object): >> def __init__(self): >> self.__excludePolicy = None >> >> def dir(self): >> if not self.__excludePolicy: >> return >> >> pol = self.__excludePolicy >> if pol.flags & pol.ExcludeHidden: >> print "Excluding hidden" >> >> if pol.flags & pol.ExcludeInvisible: >> print "Excluding invisible" >> >> if pol.flags & pol.ExcludeRegex: >> print 'Excluding regex: "%s"' % pol.regex >> >> if pol.flags & pol.ExcludeFiles: >> print "Excluding files" >> >> @property >> def excludePolicy(self): >> return self.__excludePolicy >> >> @excludePolicy.setter >> def excludePolicy(self, policy): >> self.__excludePolicy = policy >> >> >> if __name__ == '__main__': >> pol = ExcludePolicy() >> >> # pol.regex = r'^*.$' >> # pol.flags = pol.ExcludeRegex >> >> ld = ListDir() >> ld.excludePolicy = pol >> ld.dir() >> >> >> >> On 18 December 2013 10:29, Marcus Ottosson <[email protected]>wrote: >> >> Brilliant, that makes sense. >> >> I also came across this thread, the accepted answer is especially helpful. >> http://stackoverflow.com/questions/276706/what-are-bitwise-operators >> >> Thanks, Justin >> >> >> >> On 18 December 2013 10: >> >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODL40VrgCeZ-P%2Bc%3DwpB9feVZFd0KnC79BNtbw5xrxANeA%40mail.gmail.com >> . >> For more options, visit https://groups.google.com/groups/opt_out. >> > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]<javascript:_e({}, > 'cvml', > 'python_inside_maya%[email protected]');>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA26JyquVL3KKD6GtCkcuA2F%3DT9fPEr3%2BtccvJOh7c2chA%40mail.gmail.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- *Marcus Ottosson* [email protected] -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOApGGY1yvV4U28JnWhd1ci0bkM62CRMXdJABY9bhAMznA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
