Oops! Was: RE: [PyCrust] 0.6 in the oven, now with PyFilling, should be done cooking soon
Brought to you by:
pobrien
From: Patrick K. O'B. <po...@or...> - 2001-09-21 19:46:08
|
Oops! That wasn't the only change that got committed to cvs the other night. Hold on to your hats, there's another feature in the cvs code that might freak you out if I don't explain. <grin> The new feature is a shell façade class that I was working on, to simplify what users see when they type ">>> shell." in the shell window. The idea is to hide all the attributes that have to do with the StyledTextControl or internal mechanisms. This lets the shell user focus on the shell commands that are relevant to the typical shell session. Basically, I was getting tired of typing "shell." and seeing a huge list of irrelevant stuff. This new façade class takes care of that problem, while still magically allowing all the attributes and method calls to work, as long as you know what they are. And if you ever want to see the full list, you can just do "shell.other." Here is the code, and you can also see a pretty diff at http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pycrust/PyCrust/shell.py.diff ?r1=1.19&r2=1.20. class ShellFacade: """Simplified interface to all shell-related functionality. This is a semi-transparent facade, in that all attributes of other are still accessible, even though only some are visible to the user.""" name = 'PyCrust Shell Interface' revision = __version__ def __init__(self, other): """Create a ShellFacade instance.""" methods = ['ask', 'clear', 'pause', 'prompt', 'quit', 'redirectStderr', 'redirectStdin', 'redirectStdout', 'run', 'runfile', ] for method in methods: self.__dict__[method] = getattr(other, method) d = self.__dict__ d['other'] = other d['help'] = 'There is no help available, yet.' def __getattr__(self, name): if hasattr(self.other, name): return getattr(self.other, name) else: raise AttributeError, name def __setattr__(self, name, value): if self.__dict__.has_key(name): self.__dict__[name] = value elif hasattr(self.other, name): return setattr(self.other, name, value) else: raise AttributeError, name def _getAttributeNames(self): """Return list of magic attributes to extend introspection.""" list = ['autoCallTip', 'autoComplete', 'autoCompleteCaseInsensitive', 'autoCompleteIncludeDouble', 'autoCompleteIncludeMagic', 'autoCompleteIncludeSingle', ] list.sort() return list --- Patrick K. O'Brien Orbtech (http://www.orbtech.com) "I am, therefore I think." -----Original Message----- From: pyc...@li... [mailto:pyc...@li...]On Behalf Of Patrick K. O'Brien Sent: Wednesday, September 19, 2001 7:32 PM To: pyc...@li... Subject: RE: [PyCrust] 0.6 in the oven, now with PyFilling, should be done cooking soon That's a perfectly reasonable scenario, so I will indeed add your suggested code. I try to avoid superfluous code as much as I can, but please don't take my reluctance as a lack of concern for your needs. I very much want PyCrust components to be useable in a wide variety of situations and you have identified something I hadn't considered. Thank you for your suggestion. It should appear in cvs with the next checkin. --- Patrick K. O'Brien Orbtech (http://www.orbtech.com) "I am, therefore I think." |