bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def read(self, size=-1):
|
def read(self, size=-1):
| 16,900
|
def read(self, size=-1):
|
def read(self, size=-1):
| 16,901
|
def readline(self, size=None):
|
def readline(self, size=None):
| 16,902
|
def readlines(self, sizehint=0):
|
def readlines(self, sizehint=0):
| 16,903
|
def __init__(self, *args): apply(URLopener.__init__, (self,) + args) self.auth_cache = {} self.tries = 0 self.maxtries = 10
|
def __init__(self, *args, **kwargs): apply(URLopener.__init__, (self,) + args, kwargs) self.auth_cache = {} self.tries = 0 self.maxtries = 10
| 16,904
|
def lock(self, how, *args):
|
def lock(self, how, *args):
| 16,905
|
def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_lecmp(s, s2) s2 = u'\ud800\ude01' test_lecmp(s, s2) s2 = u'\ud900\ude01' test_lecmp(s, s2) s2 = u'\uda00\ude01' test_lecmp(s, s2) s2 = u'\udb00\ude01' test_lecmp(s, s2) s2 = u'\ud800\udfff' test_lecmp(s, s2) s2 = u'\ud900\udfff' test_lecmp(s, s2) s2 = u'\uda00\udfff' test_lecmp(s, s2) s2 = u'\udb00\udfff' test_lecmp(s, s2)
|
def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_lecmp(s, s2) s2 = u'\ud800\ude01' test_lecmp(s, s2) s2 = u'\ud900\ude01' test_lecmp(s, s2) s2 = u'\uda00\ude01' test_lecmp(s, s2) s2 = u'\udb00\ude01' test_lecmp(s, s2) s2 = u'\ud800\udfff' test_lecmp(s, s2) s2 = u'\ud900\udfff' test_lecmp(s, s2) s2 = u'\uda00\udfff' test_lecmp(s, s2) s2 = u'\udb00\udfff' test_lecmp(s, s2)
| 16,906
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
| 16,907
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
| 16,908
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
| 16,909
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
| 16,910
|
def _stringify(string): return string
|
def _stringify(string): return string
| 16,911
|
def __repr__(self): return ( "<Fault %s: %s>" % (repr(self.faultCode), repr(self.faultString)) )
|
def __repr__(self): return ( "<Fault %s: %s>" % (self.faultCode, repr(self.faultString)) )
| 16,912
|
def __init__(self, target): import xmllib # lazy subclassing (!) if xmllib.XMLParser not in SlowParser.__bases__: SlowParser.__bases__ = (xmllib.XMLParser,) self.handle_xml = target.xml self.unknown_starttag = target.start self.handle_data = target.data self.unknown_endtag = target.end xmllib.XMLParser.__init__(self)
|
def __init__(self, target): import xmllib # lazy subclassing (!) if xmllib.XMLParser not in SlowParser.__bases__: SlowParser.__bases__ = (xmllib.XMLParser,) self.handle_xml = target.xml self.unknown_starttag = target.start self.handle_data = target.data self.unknown_endtag = target.end xmllib.XMLParser.__init__(self)
| 16,913
|
def dump_instance(self, value): # check for special wrappers if value.__class__ in WRAPPERS: value.encode(self) else: # store instance attributes as a struct (really?) self.dump_struct(value.__dict__)
|
def dump_instance(self, value): # check for special wrappers if value.__class__ in WRAPPERS: value.encode(self) else: # store instance attributes as a struct (really?) self.dump_struct(value.__dict__)
| 16,914
|
def dump_instance(self, value): # check for special wrappers if value.__class__ in WRAPPERS: value.encode(self) else: # store instance attributes as a struct (really?) self.dump_struct(value.__dict__)
|
def dump_instance(self, value): # check for special wrappers if value.__class__ in WRAPPERS: value.encode(self) else: # store instance attributes as a struct (really?) self.dump_struct(value.__dict__)
| 16,915
|
def getparser(): """getparser() -> parser, unmarshaller Create an instance of the fastest available parser, and attach it to an unmarshalling object. Return both objects. """ if FastParser and FastUnmarshaller: target = FastUnmarshaller(True, False, binary, datetime) parser = FastParser(target) else: target = Unmarshaller() if FastParser: parser = FastParser(target) elif SgmlopParser: parser = SgmlopParser(target) elif ExpatParser: parser = ExpatParser(target) else: parser = SlowParser(target) return parser, target
|
def getparser(): """getparser() -> parser, unmarshaller Create an instance of the fastest available parser, and attach it to an unmarshalling object. Return both objects. """ if FastParser and FastUnmarshaller: target = FastUnmarshaller(True, False, binary, datetime) parser = FastParser(target) else: target = Unmarshaller() if FastParser: parser = FastParser(target) elif SgmlopParser: parser = SgmlopParser(target) elif ExpatParser: parser = ExpatParser(target) else: parser = SlowParser(target) return parser, target
| 16,916
|
def dumps(params, methodname=None, methodresponse=None, encoding=None): """data [,options] -> marshalled data Convert an argument tuple or a Fault instance to an XML-RPC request (or response, if the methodresponse option is used). In addition to the data object, the following options can be given as keyword arguments: methodname: the method name for a methodCall packet methodresponse: true to create a methodResponse packet. If this option is used with a tuple, the tuple must be a singleton (i.e. it can contain only one element). encoding: the packet encoding (default is UTF-8) All 8-bit strings in the data structure are assumed to use the packet encoding. Unicode strings are automatically converted, as necessary. """ assert isinstance(params, TupleType) or isinstance(params, Fault),\ "argument must be tuple or Fault instance" if isinstance(params, Fault): methodresponse = 1 elif methodresponse and isinstance(params, TupleType): assert len(params) == 1, "response tuple must be a singleton" if not encoding: encoding = "utf-8" m = Marshaller(encoding) data = m.dumps(params) if encoding != "utf-8": xmlheader = "<?xml version='1.0' encoding=%s?>\n" % repr(encoding) else: xmlheader = "<?xml version='1.0'?>\n" # utf-8 is default # standard XML-RPC wrappings if methodname: # a method call if not isinstance(methodname, StringType): methodname = methodname.encode(encoding) data = ( xmlheader, "<methodCall>\n" "<methodName>", methodname, "</methodName>\n", data, "</methodCall>\n" ) elif methodresponse: # a method response, or a fault structure data = ( xmlheader, "<methodResponse>\n", data, "</methodResponse>\n" ) else: return data # return as is return string.join(data, "")
|
def dumps(params, methodname=None, methodresponse=None, encoding=None): """data [,options] -> marshalled data Convert an argument tuple or a Fault instance to an XML-RPC request (or response, if the methodresponse option is used). In addition to the data object, the following options can be given as keyword arguments: methodname: the method name for a methodCall packet methodresponse: true to create a methodResponse packet. If this option is used with a tuple, the tuple must be a singleton (i.e. it can contain only one element). encoding: the packet encoding (default is UTF-8) All 8-bit strings in the data structure are assumed to use the packet encoding. Unicode strings are automatically converted, as necessary. """ assert isinstance(params, TupleType) or isinstance(params, Fault),\ "argument must be tuple or Fault instance" if isinstance(params, Fault): methodresponse = 1 elif methodresponse and isinstance(params, TupleType): assert len(params) == 1, "response tuple must be a singleton" if not encoding: encoding = "utf-8" m = Marshaller(encoding) data = m.dumps(params) if encoding != "utf-8": xmlheader = "<?xml version='1.0' encoding=%s?>\n" % repr(encoding) else: xmlheader = "<?xml version='1.0'?>\n" # utf-8 is default # standard XML-RPC wrappings if methodname: # a method call if not isinstance(methodname, StringType): methodname = methodname.encode(encoding) data = ( xmlheader, "<methodCall>\n" "<methodName>", methodname, "</methodName>\n", data, "</methodCall>\n" ) elif methodresponse: # a method response, or a fault structure data = ( xmlheader, "<methodResponse>\n", data, "</methodResponse>\n" ) else: return data # return as is return string.join(data, "")
| 16,917
|
def dumps(params, methodname=None, methodresponse=None, encoding=None): """data [,options] -> marshalled data Convert an argument tuple or a Fault instance to an XML-RPC request (or response, if the methodresponse option is used). In addition to the data object, the following options can be given as keyword arguments: methodname: the method name for a methodCall packet methodresponse: true to create a methodResponse packet. If this option is used with a tuple, the tuple must be a singleton (i.e. it can contain only one element). encoding: the packet encoding (default is UTF-8) All 8-bit strings in the data structure are assumed to use the packet encoding. Unicode strings are automatically converted, as necessary. """ assert isinstance(params, TupleType) or isinstance(params, Fault),\ "argument must be tuple or Fault instance" if isinstance(params, Fault): methodresponse = 1 elif methodresponse and isinstance(params, TupleType): assert len(params) == 1, "response tuple must be a singleton" if not encoding: encoding = "utf-8" m = Marshaller(encoding) data = m.dumps(params) if encoding != "utf-8": xmlheader = "<?xml version='1.0' encoding=%s?>\n" % repr(encoding) else: xmlheader = "<?xml version='1.0'?>\n" # utf-8 is default # standard XML-RPC wrappings if methodname: # a method call if not isinstance(methodname, StringType): methodname = methodname.encode(encoding) data = ( xmlheader, "<methodCall>\n" "<methodName>", methodname, "</methodName>\n", data, "</methodCall>\n" ) elif methodresponse: # a method response, or a fault structure data = ( xmlheader, "<methodResponse>\n", data, "</methodResponse>\n" ) else: return data # return as is return string.join(data, "")
|
def dumps(params, methodname=None, methodresponse=None, encoding=None): """data [,options] -> marshalled data Convert an argument tuple or a Fault instance to an XML-RPC request (or response, if the methodresponse option is used). In addition to the data object, the following options can be given as keyword arguments: methodname: the method name for a methodCall packet methodresponse: true to create a methodResponse packet. If this option is used with a tuple, the tuple must be a singleton (i.e. it can contain only one element). encoding: the packet encoding (default is UTF-8) All 8-bit strings in the data structure are assumed to use the packet encoding. Unicode strings are automatically converted, where necessary. """ assert isinstance(params, TupleType) or isinstance(params, Fault),\ "argument must be tuple or Fault instance" if isinstance(params, Fault): methodresponse = 1 elif methodresponse and isinstance(params, TupleType): assert len(params) == 1, "response tuple must be a singleton" if not encoding: encoding = "utf-8" m = Marshaller(encoding) data = m.dumps(params) if encoding != "utf-8": xmlheader = "<?xml version='1.0' encoding=%s?>\n" % repr(encoding) else: xmlheader = "<?xml version='1.0'?>\n" # utf-8 is default # standard XML-RPC wrappings if methodname: # a method call if not isinstance(methodname, StringType): methodname = methodname.encode(encoding) data = ( xmlheader, "<methodCall>\n" "<methodName>", methodname, "</methodName>\n", data, "</methodCall>\n" ) elif methodresponse: # a method response, or a fault structure data = ( xmlheader, "<methodResponse>\n", data, "</methodResponse>\n" ) else: return data # return as is return string.join(data, "")
| 16,918
|
def _send_request(self, method, url, body, headers): # If headers already contains a host header, then define the # optional skip_host argument to putrequest(). The check is # harder because field names are case insensitive. if 'Host' in (headers or [k for k in headers.iterkeys() if k.lower() == "host"]): self.putrequest(method, url, skip_host=1) else: self.putrequest(method, url)
|
def _send_request(self, method, url, body, headers): # If headers already contains a host header, then define the # optional skip_host argument to putrequest(). The check is # harder because field names are case insensitive. if 'host' in [k.lower() for k in headers]: self.putrequest(method, url, skip_host=1) else: self.putrequest(method, url)
| 16,919
|
def setup(**geometry): """ Sets the size and position of the main window. Keywords are width, height, startx and starty width: either a size in pixels or a fraction of the screen. Default is 50% of screen. height: either the height in pixels or a fraction of the screen. Default is 75% of screen. Setting either width or height to None before drawing will force use of default geometry as in older versions of turtle.py startx: starting position in pixels from the left edge of the screen. Default is to center window. Setting startx to None is the default and centers window horizontally on screen. starty: starting position in pixels from the top edge of the screen. Default is to center window. Setting starty to None is the default and centers window vertically on screen. Examples: >>> setup (width=200, height=200, startx=0, starty=0) sets window to 200x200 pixels, in upper left of screen >>> setup(width=.75, height=0.5, startx=None, starty=None) sets window to 75% of screen by 50% of screen and centers >>> setup(width=None) forces use of default geometry as in older versions of turtle.py """ global _width, _height, _startx, _starty width = geometry.get('width',_width) if width >= 0 or width == None: _width = width else: raise ValueError, "width can not be less than 0" height = geometry.get('height',_height) if height >= 0 or height == None: _height = height else: raise ValueError, "height can not be less than 0" startx = geometry.get('startx', _startx) if startx >= 0 or startx == None: _startx = _startx else: raise ValueError, "startx can not be less than 0" starty = geometry.get('starty', _starty) if starty >= 0 or starty == None: _starty = starty else: raise ValueError, "startx can not be less than 0" if _root and _width and _height: if 0 < _width <= 1: _width = _root.winfo_screenwidth() * +width if 0 < _height <= 1: _height = _root.winfo_screenheight() * _height # center window on screen if _startx is None: _startx = (_root.winfo_screenwidth() - _width) / 2 if _starty is None: _starty = (_root.winfo_screenheight() - _height) / 2 _root.geometry("%dx%d+%d+%d" % (_width, _height, _startx, _starty))
|
def setup(**geometry): """ Sets the size and position of the main window. Keywords are width, height, startx and starty: width: either a size in pixels or a fraction of the screen. Default is 50% of screen. height: either the height in pixels or a fraction of the screen. Default is 75% of screen. Setting either width or height to None before drawing will force use of default geometry as in older versions of turtle.py startx: starting position in pixels from the left edge of the screen. Default is to center window. Setting startx to None is the default and centers window horizontally on screen. starty: starting position in pixels from the top edge of the screen. Default is to center window. Setting starty to None is the default and centers window vertically on screen. Examples: >>> setup (width=200, height=200, startx=0, starty=0) sets window to 200x200 pixels, in upper left of screen >>> setup(width=.75, height=0.5, startx=None, starty=None) sets window to 75% of screen by 50% of screen and centers >>> setup(width=None) forces use of default geometry as in older versions of turtle.py """ global _width, _height, _startx, _starty width = geometry.get('width',_width) if width >= 0 or width == None: _width = width else: raise ValueError, "width can not be less than 0" height = geometry.get('height',_height) if height >= 0 or height == None: _height = height else: raise ValueError, "height can not be less than 0" startx = geometry.get('startx', _startx) if startx >= 0 or startx == None: _startx = _startx else: raise ValueError, "startx can not be less than 0" starty = geometry.get('starty', _starty) if starty >= 0 or starty == None: _starty = starty else: raise ValueError, "startx can not be less than 0" if _root and _width and _height: if 0 < _width <= 1: _width = _root.winfo_screenwidth() * +width if 0 < _height <= 1: _height = _root.winfo_screenheight() * _height # center window on screen if _startx is None: _startx = (_root.winfo_screenwidth() - _width) / 2 if _starty is None: _starty = (_root.winfo_screenheight() - _height) / 2 _root.geometry("%dx%d+%d+%d" % (_width, _height, _startx, _starty))
| 16,920
|
def title(title): """ set the window title. By default this is set to 'Turtle Graphics' Example: >>> title("My Window") """ global _title _title = title
|
def title(title): """Set the window title. By default this is set to 'Turtle Graphics' Example: >>> title("My Window") """ global _title _title = title
| 16,921
|
def addpackage(sitedir, name): global _dirs_in_sys_path if _dirs_in_sys_path is None: _init_pathinfo() reset = 1 else: reset = 0 fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir, dircase = makepath(sitedir, dir) if not dircase in _dirs_in_sys_path and os.path.exists(dir): sys.path.append(dir) _dirs_in_sys_path[dircase] = 1 if reset: _dirs_in_sys_path = None
|
def addpackage(sitedir, name): global _dirs_in_sys_path if _dirs_in_sys_path is None: _init_pathinfo() reset = 1 else: reset = 0 fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir, dircase = makepath(sitedir, dir) if not dircase in _dirs_in_sys_path and os.path.exists(dir): sys.path.append(dir) _dirs_in_sys_path[dircase] = 1 if reset: _dirs_in_sys_path = None
| 16,922
|
def test_main(): tests = [Signed_TestCase, Unsigned_TestCase] try: from _testcapi import getargs_L, getargs_K except ImportError: pass # PY_LONG_LONG not available else: tests.append(LongLong_TestCase) test_support.run_unittest(*tests)
|
def test_main(): tests = [Signed_TestCase, Unsigned_TestCase, Tuple_TestCase] try: from _testcapi import getargs_L, getargs_K except ImportError: pass # PY_LONG_LONG not available else: tests.append(LongLong_TestCase) test_support.run_unittest(*tests)
| 16,923
|
def formatException(self, ei): """ Format and return the specified exception information as a string.
|
def formatException(self, ei): """ Format and return the specified exception information as a string.
| 16,924
|
def handleError(self, record): """ Handle errors which occur during an emit() call.
|
def handleError(self, record): """ Handle errors which occur during an emit() call.
| 16,925
|
def __init__(self, filename, mode="a"): """ Open the specified file and use it as the stream for logging. """ StreamHandler.__init__(self, open(filename, mode)) #keep the absolute path, otherwise derived classes which use this #may come a cropper when the current directory changes self.baseFilename = os.path.abspath(filename) self.mode = mode
|
def __init__(self, filename, mode='a', encoding=None): """ Open the specified file and use it as the stream for logging. """ StreamHandler.__init__(self, open(filename, mode)) #keep the absolute path, otherwise derived classes which use this #may come a cropper when the current directory changes self.baseFilename = os.path.abspath(filename) self.mode = mode
| 16,926
|
def __init__(self, filename, mode="a"): """ Open the specified file and use it as the stream for logging. """ StreamHandler.__init__(self, open(filename, mode)) #keep the absolute path, otherwise derived classes which use this #may come a cropper when the current directory changes self.baseFilename = os.path.abspath(filename) self.mode = mode
|
def __init__(self, filename, mode="a"): """ Open the specified file and use it as the stream for logging. """ if codecs is None: encoding = None if encoding is None: stream = open(filename, mode) else: stream = codecs.open(filename, mode, encoding) StreamHandler.__init__(self, stream) #keep the absolute path, otherwise derived classes which use this #may come a cropper when the current directory changes self.baseFilename = os.path.abspath(filename) self.mode = mode
| 16,927
|
def basicConfig(**kwargs): """ Do basic configuration for the logging system. This function does nothing if the root logger already has handlers configured. It is a convenience method intended for use by simple scripts to do one-shot configuration of the logging package. The default behaviour is to create a StreamHandler which writes to sys.stderr, set a formatter using the BASIC_FORMAT format string, and add the handler to the root logger. A number of optional keyword arguments may be specified, which can alter the default behaviour. filename Specifies that a FileHandler be created, using the specified filename, rather than a StreamHandler. filemode Specifies the mode to open the file, if filename is specified (if filemode is unspecified, it defaults to "a"). format Use the specified format string for the handler. datefmt Use the specified date/time format. level Set the root logger level to the specified level. stream Use the specified stream to initialize the StreamHandler. Note that this argument is incompatible with 'filename' - if both are present, 'stream' is ignored. Note that you could specify a stream created using open(filename, mode) rather than passing the filename and mode in. However, it should be remembered that StreamHandler does not close its stream (since it may be using sys.stdout or sys.stderr), whereas FileHandler closes its stream when the handler is closed. """ if len(root.handlers) == 0: filename = kwargs.get("filename") if filename: mode = kwargs.get("filemode", "a") hdlr = FileHandler(filename, mode) else: stream = kwargs.get("stream") hdlr = StreamHandler(stream) fs = kwargs.get("format", BASIC_FORMAT) dfs = kwargs.get("datefmt", None) fmt = Formatter(fs, dfs) hdlr.setFormatter(fmt) root.addHandler(hdlr) level = kwargs.get("level") if level: root.setLevel(level)
|
def basicConfig(**kwargs): """ Do basic configuration for the logging system. This function does nothing if the root logger already has handlers configured. It is a convenience method intended for use by simple scripts to do one-shot configuration of the logging package. The default behaviour is to create a StreamHandler which writes to sys.stderr, set a formatter using the BASIC_FORMAT format string, and add the handler to the root logger. A number of optional keyword arguments may be specified, which can alter the default behaviour. filename Specifies that a FileHandler be created, using the specified filename, rather than a StreamHandler. filemode Specifies the mode to open the file, if filename is specified (if filemode is unspecified, it defaults to 'a'). format Use the specified format string for the handler. datefmt Use the specified date/time format. level Set the root logger level to the specified level. stream Use the specified stream to initialize the StreamHandler. Note that this argument is incompatible with 'filename' - if both are present, 'stream' is ignored. Note that you could specify a stream created using open(filename, mode) rather than passing the filename and mode in. However, it should be remembered that StreamHandler does not close its stream (since it may be using sys.stdout or sys.stderr), whereas FileHandler closes its stream when the handler is closed. """ if len(root.handlers) == 0: filename = kwargs.get("filename") if filename: mode = kwargs.get("filemode", "a") hdlr = FileHandler(filename, mode) else: stream = kwargs.get("stream") hdlr = StreamHandler(stream) fs = kwargs.get("format", BASIC_FORMAT) dfs = kwargs.get("datefmt", None) fmt = Formatter(fs, dfs) hdlr.setFormatter(fmt) root.addHandler(hdlr) level = kwargs.get("level") if level: root.setLevel(level)
| 16,928
|
def basicConfig(**kwargs): """ Do basic configuration for the logging system. This function does nothing if the root logger already has handlers configured. It is a convenience method intended for use by simple scripts to do one-shot configuration of the logging package. The default behaviour is to create a StreamHandler which writes to sys.stderr, set a formatter using the BASIC_FORMAT format string, and add the handler to the root logger. A number of optional keyword arguments may be specified, which can alter the default behaviour. filename Specifies that a FileHandler be created, using the specified filename, rather than a StreamHandler. filemode Specifies the mode to open the file, if filename is specified (if filemode is unspecified, it defaults to "a"). format Use the specified format string for the handler. datefmt Use the specified date/time format. level Set the root logger level to the specified level. stream Use the specified stream to initialize the StreamHandler. Note that this argument is incompatible with 'filename' - if both are present, 'stream' is ignored. Note that you could specify a stream created using open(filename, mode) rather than passing the filename and mode in. However, it should be remembered that StreamHandler does not close its stream (since it may be using sys.stdout or sys.stderr), whereas FileHandler closes its stream when the handler is closed. """ if len(root.handlers) == 0: filename = kwargs.get("filename") if filename: mode = kwargs.get("filemode", "a") hdlr = FileHandler(filename, mode) else: stream = kwargs.get("stream") hdlr = StreamHandler(stream) fs = kwargs.get("format", BASIC_FORMAT) dfs = kwargs.get("datefmt", None) fmt = Formatter(fs, dfs) hdlr.setFormatter(fmt) root.addHandler(hdlr) level = kwargs.get("level") if level: root.setLevel(level)
|
def basicConfig(**kwargs): """ Do basic configuration for the logging system. This function does nothing if the root logger already has handlers configured. It is a convenience method intended for use by simple scripts to do one-shot configuration of the logging package. The default behaviour is to create a StreamHandler which writes to sys.stderr, set a formatter using the BASIC_FORMAT format string, and add the handler to the root logger. A number of optional keyword arguments may be specified, which can alter the default behaviour. filename Specifies that a FileHandler be created, using the specified filename, rather than a StreamHandler. filemode Specifies the mode to open the file, if filename is specified (if filemode is unspecified, it defaults to "a"). format Use the specified format string for the handler. datefmt Use the specified date/time format. level Set the root logger level to the specified level. stream Use the specified stream to initialize the StreamHandler. Note that this argument is incompatible with 'filename' - if both are present, 'stream' is ignored. Note that you could specify a stream created using open(filename, mode) rather than passing the filename and mode in. However, it should be remembered that StreamHandler does not close its stream (since it may be using sys.stdout or sys.stderr), whereas FileHandler closes its stream when the handler is closed. """ if len(root.handlers) == 0: filename = kwargs.get("filename") if filename: mode = kwargs.get("filemode", 'a') hdlr = FileHandler(filename, mode) else: stream = kwargs.get("stream") hdlr = StreamHandler(stream) fs = kwargs.get("format", BASIC_FORMAT) dfs = kwargs.get("datefmt", None) fmt = Formatter(fs, dfs) hdlr.setFormatter(fmt) root.addHandler(hdlr) level = kwargs.get("level") if level: root.setLevel(level)
| 16,929
|
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = hdr.split(" ", 2) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: int(hdrfields[1], 8) break except ValueError: pass if out_file is None: out_file = hdrfields[2].rstrip() if mode is None: mode = int(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not str: raise Error, 'Truncated input file'
|
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = hdr.split(" ", 2) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: int(hdrfields[1], 8) break except ValueError: pass if out_file is None: out_file = hdrfields[2].rstrip() if mode is None: mode = int(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: # Workaround for broken uuencoders by /Fredrik Lundh nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not s: raise Error, 'Truncated input file'
| 16,930
|
def test_communicate_stderr(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("pineapple")'], stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertEqual(stderr, "pineapple")
|
def test_communicate_stderr(self): p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("pineapple")'], stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) self.assertEqual(stderr, "pineapple")
| 16,931
|
def flush(self): """Write any pending changes to disk.""" if not self._pending: return self._lookup() new_file = _create_temporary(self._path) try: new_toc = {} self._pre_mailbox_hook(new_file) for key in sorted(self._toc.keys()): start, stop = self._toc[key] self._file.seek(start) self._pre_message_hook(new_file) new_start = new_file.tell() while True: buffer = self._file.read(min(4096, stop - self._file.tell())) if buffer == '': break new_file.write(buffer) new_toc[key] = (new_start, new_file.tell()) self._post_message_hook(new_file) except: new_file.close() os.remove(new_file.name) raise _sync_close(new_file) # self._file is about to get replaced, so no need to sync. self._file.close() try: os.rename(new_file.name, self._path) except OSError, e: if e.errno == errno.EEXIST or \ (os.name == 'os2' and e.errno == errno.EACCES): os.remove(self._path) os.rename(new_file.name, self._path) else: raise self._file = open(self._path, 'rb+') self._toc = new_toc self._pending = False if self._locked: _lock_file(self._file, dotlock=False)
|
def flush(self): """Write any pending changes to disk.""" if not self._pending: return assert self._toc is not None self._file.seek(0, 2) cur_len = self._file.tell() if cur_len != self._file_length: raise ExternalClashError('Size of mailbox file changed ' '(expected %i, found %i)' % (self._file_length, cur_len)) new_file = _create_temporary(self._path) try: new_toc = {} self._pre_mailbox_hook(new_file) for key in sorted(self._toc.keys()): start, stop = self._toc[key] self._file.seek(start) self._pre_message_hook(new_file) new_start = new_file.tell() while True: buffer = self._file.read(min(4096, stop - self._file.tell())) if buffer == '': break new_file.write(buffer) new_toc[key] = (new_start, new_file.tell()) self._post_message_hook(new_file) except: new_file.close() os.remove(new_file.name) raise _sync_close(new_file) # self._file is about to get replaced, so no need to sync. self._file.close() try: os.rename(new_file.name, self._path) except OSError, e: if e.errno == errno.EEXIST or \ (os.name == 'os2' and e.errno == errno.EACCES): os.remove(self._path) os.rename(new_file.name, self._path) else: raise self._file = open(self._path, 'rb+') self._toc = new_toc self._pending = False if self._locked: _lock_file(self._file, dotlock=False)
| 16,932
|
def _generate_toc(self): """Generate key-to-(start, stop) table of contents.""" starts, stops = [], [] self._file.seek(0) next_pos = 0 label_lists = [] while True: line_pos = next_pos line = self._file.readline() next_pos = self._file.tell() if line == '\037\014' + os.linesep: if len(stops) < len(starts): stops.append(line_pos - len(os.linesep)) starts.append(next_pos) labels = [label.strip() for label in self._file.readline()[1:].split(',') if label.strip() != ''] label_lists.append(labels) elif line == '\037' or line == '\037' + os.linesep: if len(stops) < len(starts): stops.append(line_pos - len(os.linesep)) elif line == '': stops.append(line_pos - len(os.linesep)) break self._toc = dict(enumerate(zip(starts, stops))) self._labels = dict(enumerate(label_lists)) self._next_key = len(self._toc)
|
defself._file.seek(0, 2) self._file_length = self._file.tell() _generate_toc(self):self._file.seek(0, 2) self._file_length = self._file.tell() """Generateself._file.seek(0, 2) self._file_length = self._file.tell() key-to-(start,self._file.seek(0, 2) self._file_length = self._file.tell() stop)self._file.seek(0, 2) self._file_length = self._file.tell() tableself._file.seek(0, 2) self._file_length = self._file.tell() ofself._file.seek(0, 2) self._file_length = self._file.tell() contents."""self._file.seek(0, 2) self._file_length = self._file.tell() starts,self._file.seek(0, 2) self._file_length = self._file.tell() stopsself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() [],self._file.seek(0, 2) self._file_length = self._file.tell() []self._file.seek(0, 2) self._file_length = self._file.tell() self._file.seek(0)self._file.seek(0, 2) self._file_length = self._file.tell() next_posself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() 0self._file.seek(0, 2) self._file_length = self._file.tell() label_listsself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() []self._file.seek(0, 2) self._file_length = self._file.tell() whileself._file.seek(0, 2) self._file_length = self._file.tell() True:self._file.seek(0, 2) self._file_length = self._file.tell() line_posself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() next_posself._file.seek(0, 2) self._file_length = self._file.tell() lineself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() self._file.readline()self._file.seek(0, 2) self._file_length = self._file.tell() next_posself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() self._file.tell()self._file.seek(0, 2) self._file_length = self._file.tell() ifself._file.seek(0, 2) self._file_length = self._file.tell() lineself._file.seek(0, 2) self._file_length = self._file.tell() ==self._file.seek(0, 2) self._file_length = self._file.tell() '\037\014'self._file.seek(0, 2) self._file_length = self._file.tell() +self._file.seek(0, 2) self._file_length = self._file.tell() os.linesep:self._file.seek(0, 2) self._file_length = self._file.tell() ifself._file.seek(0, 2) self._file_length = self._file.tell() len(stops)self._file.seek(0, 2) self._file_length = self._file.tell() <self._file.seek(0, 2) self._file_length = self._file.tell() len(starts):self._file.seek(0, 2) self._file_length = self._file.tell() stops.append(line_posself._file.seek(0, 2) self._file_length = self._file.tell() -self._file.seek(0, 2) self._file_length = self._file.tell() len(os.linesep))self._file.seek(0, 2) self._file_length = self._file.tell() starts.append(next_pos)self._file.seek(0, 2) self._file_length = self._file.tell() labelsself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() [label.strip()self._file.seek(0, 2) self._file_length = self._file.tell() forself._file.seek(0, 2) self._file_length = self._file.tell() labelself._file.seek(0, 2) self._file_length = self._file.tell() inself._file.seek(0, 2) self._file_length = self._file.tell() self._file.readline()[1:].split(',')self._file.seek(0, 2) self._file_length = self._file.tell() ifself._file.seek(0, 2) self._file_length = self._file.tell() label.strip()self._file.seek(0, 2) self._file_length = self._file.tell() !=self._file.seek(0, 2) self._file_length = self._file.tell() '']self._file.seek(0, 2) self._file_length = self._file.tell() label_lists.append(labels)self._file.seek(0, 2) self._file_length = self._file.tell() elifself._file.seek(0, 2) self._file_length = self._file.tell() lineself._file.seek(0, 2) self._file_length = self._file.tell() ==self._file.seek(0, 2) self._file_length = self._file.tell() '\037'self._file.seek(0, 2) self._file_length = self._file.tell() orself._file.seek(0, 2) self._file_length = self._file.tell() lineself._file.seek(0, 2) self._file_length = self._file.tell() ==self._file.seek(0, 2) self._file_length = self._file.tell() '\037'self._file.seek(0, 2) self._file_length = self._file.tell() +self._file.seek(0, 2) self._file_length = self._file.tell() os.linesep:self._file.seek(0, 2) self._file_length = self._file.tell() ifself._file.seek(0, 2) self._file_length = self._file.tell() len(stops)self._file.seek(0, 2) self._file_length = self._file.tell() <self._file.seek(0, 2) self._file_length = self._file.tell() len(starts):self._file.seek(0, 2) self._file_length = self._file.tell() stops.append(line_posself._file.seek(0, 2) self._file_length = self._file.tell() -self._file.seek(0, 2) self._file_length = self._file.tell() len(os.linesep))self._file.seek(0, 2) self._file_length = self._file.tell() elifself._file.seek(0, 2) self._file_length = self._file.tell() lineself._file.seek(0, 2) self._file_length = self._file.tell() ==self._file.seek(0, 2) self._file_length = self._file.tell() '':self._file.seek(0, 2) self._file_length = self._file.tell() stops.append(line_posself._file.seek(0, 2) self._file_length = self._file.tell() -self._file.seek(0, 2) self._file_length = self._file.tell() len(os.linesep))self._file.seek(0, 2) self._file_length = self._file.tell() breakself._file.seek(0, 2) self._file_length = self._file.tell() self._tocself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() dict(enumerate(zip(starts,self._file.seek(0, 2) self._file_length = self._file.tell() stops)))self._file.seek(0, 2) self._file_length = self._file.tell() self._labelsself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() dict(enumerate(label_lists))self._file.seek(0, 2) self._file_length = self._file.tell() self._next_keyself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() len(self._toc)
| 16,933
|
def do_clear(self, arg): """Three possibilities, tried in this order: clear -> clear all breaks, ask for confirmation clear file:lineno -> clear all breaks at file:lineno clear bpno bpno ... -> clear breakpoints by number""" if not arg: try: reply = raw_input('Clear all breaks? ') except EOFError: reply = 'no' reply = reply.strip().lower() if reply in ('y', 'yes'): self.clear_all_breaks() return if ':' in arg: # Make sure it works for "clear C:\foo\bar.py:12" i = arg.rfind(':') filename = arg[:i] arg = arg[i+1:] try: lineno = int(arg) except: err = "Invalid line number (%s)" % arg else: err = self.clear_break(filename, lineno) if err: print '***', err return numberlist = arg.split() for i in numberlist: err = self.clear_bpbynumber(i) if err: print '***', err else: print 'Deleted breakpoint %s ' % (i,)
|
def do_clear(self, arg): """Three possibilities, tried in this order: clear -> clear all breaks, ask for confirmation clear file:lineno -> clear all breaks at file:lineno clear bpno bpno ... -> clear breakpoints by number""" if not arg: try: reply = raw_input('Clear all breaks? ') except EOFError: reply = 'no' reply = reply.strip().lower() if reply in ('y', 'yes'): self.clear_all_breaks() return if ':' in arg: # Make sure it works for "clear C:\foo\bar.py:12" i = arg.rfind(':') filename = arg[:i] arg = arg[i+1:] try: lineno = int(arg) except: err = "Invalid line number (%s)" % arg else: err = self.clear_break(filename, lineno) if err: print '***', err return numberlist = arg.split() for i in numberlist: err = self.clear_bpbynumber(i) if err: print '***', err else: print 'Deleted breakpoint %s ' % (i,)
| 16,934
|
def quote(s, safe = '/'): safe = always_safe + safe res = [] for c in s: if c in safe: res.append(c) else: res.append('%%%02x' % ord(c)) return string.joinfields(res, '')
|
def quote(s, safe = '/'): safe = always_safe + safe res = list(s) for i in range(len(res)): c = res[i] if c not in safe: res[i] = '%%%02x' % ord(c) return string.joinfields(res, '')
| 16,935
|
def quote_plus(s, safe = '/'): if ' ' in s: # replace ' ' with '+' s = string.join(string.split(s, ' '), '+') return quote(s, safe + '+') else: return quote(s, safe)
|
def quote_plus(s, safe = '/'): if ' ' in s: # replace ' ' with '+' l = string.split(s, ' ') for i in range(len(l)): l[i] = quote(l[i], safe) return string.join(l, '+') else: return quote(s, safe)
| 16,936
|
def prune_file_list (self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS or CVS directories """ build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname()
|
def prune_file_list (self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS, CVS and .svn directories """ build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname()
| 16,937
|
def prune_file_list (self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS or CVS directories """ build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname()
|
def prune_file_list (self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS or CVS directories """ build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname()
| 16,938
|
def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, value)) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, value)) fp.write("\n")
|
def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n")
| 16,939
|
def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, value)) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, value)) fp.write("\n")
|
def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n")
| 16,940
|
def user_call(self, frame, argument_list): """This method is called when there is the remote possibility that we ever need to stop in this function.""" print '--Call--' self.interaction(frame, None)
|
def user_call(self, frame, argument_list): """This method is called when there is the remote possibility that we ever need to stop in this function.""" print '--Call--' self.interaction(frame, None)
| 16,941
|
def search_function(encoding): # Cache lookup entry = _cache.get(encoding, _unknown) if entry is not _unknown: return entry # Import the module: # # First try to find an alias for the normalized encoding # name and lookup the module using the aliased name, then try to # lookup the module using the standard import scheme, i.e. first # try in the encodings package, then at top-level. # norm_encoding = normalize_encoding(encoding) aliased_encoding = _aliases.get(norm_encoding) or \ _aliases.get(norm_encoding.replace('.', '_')) if aliased_encoding is not None: modnames = [aliased_encoding, norm_encoding] else: modnames = [norm_encoding] for modname in modnames: if not modname: continue try: mod = __import__('encodings.' + modname, globals(), locals(), _import_tail) except ImportError: pass else: break else: mod = None try: getregentry = mod.getregentry except AttributeError: # Not a codec module mod = None if mod is None: # Cache misses _cache[encoding] = None return None # Now ask the module for the registry entry entry = getregentry() if not isinstance(entry, codecs.CodecInfo): if not 4 <= len(entry) <= 7: raise CodecRegistryError,\ 'module "%s" (%s) failed to register' % \ (mod.__name__, mod.__file__) if not callable(entry[0]) or \ not callable(entry[1]) or \ (entry[2] is not None and not callable(entry[2])) or \ (entry[3] is not None and not callable(entry[3])) or \ (len(entry) > 4 and entry[4] is not None and not callable(entry[4])) or \ (len(entry) > 5 and entry[5] is not None and not callable(entry[5])): raise CodecRegistryError,\ 'incompatible codecs in module "%s" (%s)' % \ (mod.__name__, mod.__file__) if len(entry)<7 or entry[6] is None: entry += (None,)*(6-len(entry)) + (mod.__name__.split(".", 1)[1],) entry = codecs.CodecInfo(*entry) # Cache the codec registry entry _cache[encoding] = entry # Register its aliases (without overwriting previously registered # aliases) try: codecaliases = mod.getaliases() except AttributeError: pass else: for alias in codecaliases: if not _aliases.has_key(alias): _aliases[alias] = modname # Return the registry entry return entry
|
def search_function(encoding): # Cache lookup entry = _cache.get(encoding, _unknown) if entry is not _unknown: return entry # Import the module: # # First try to find an alias for the normalized encoding # name and lookup the module using the aliased name, then try to # lookup the module using the standard import scheme, i.e. first # try in the encodings package, then at top-level. # norm_encoding = normalize_encoding(encoding) aliased_encoding = _aliases.get(norm_encoding) or \ _aliases.get(norm_encoding.replace('.', '_')) if aliased_encoding is not None: modnames = [aliased_encoding, norm_encoding] else: modnames = [norm_encoding] for modname in modnames: if not modname or '.' in modname: continue try: mod = __import__('encodings.' + modname, globals(), locals(), _import_tail) except ImportError: pass else: break else: mod = None try: getregentry = mod.getregentry except AttributeError: # Not a codec module mod = None if mod is None: # Cache misses _cache[encoding] = None return None # Now ask the module for the registry entry entry = getregentry() if not isinstance(entry, codecs.CodecInfo): if not 4 <= len(entry) <= 7: raise CodecRegistryError,\ 'module "%s" (%s) failed to register' % \ (mod.__name__, mod.__file__) if not callable(entry[0]) or \ not callable(entry[1]) or \ (entry[2] is not None and not callable(entry[2])) or \ (entry[3] is not None and not callable(entry[3])) or \ (len(entry) > 4 and entry[4] is not None and not callable(entry[4])) or \ (len(entry) > 5 and entry[5] is not None and not callable(entry[5])): raise CodecRegistryError,\ 'incompatible codecs in module "%s" (%s)' % \ (mod.__name__, mod.__file__) if len(entry)<7 or entry[6] is None: entry += (None,)*(6-len(entry)) + (mod.__name__.split(".", 1)[1],) entry = codecs.CodecInfo(*entry) # Cache the codec registry entry _cache[encoding] = entry # Register its aliases (without overwriting previously registered # aliases) try: codecaliases = mod.getaliases() except AttributeError: pass else: for alias in codecaliases: if not _aliases.has_key(alias): _aliases[alias] = modname # Return the registry entry return entry
| 16,942
|
def main(): VERBOSE = 0 opts, args = getopt.getopt(sys.argv[1:], 'vq') for k, v in opts: if k == '-v': VERBOSE = 1 visitor.ASTVisitor.VERBOSE = visitor.ASTVisitor.VERBOSE + 1 if k == '-q': f = open('/dev/null', 'wb') sys.stdout = f if not args: print "no files to compile" else: for filename in args: if VERBOSE: print filename compile(filename)
|
def main(): VERBOSE = 0 opts, args = getopt.getopt(sys.argv[1:], 'vq') for k, v in opts: if k == '-v': VERBOSE = 1 visitor.ASTVisitor.VERBOSE = visitor.ASTVisitor.VERBOSE + 1 if k == '-q': if sys.platform[:3]=="win": f = open('nul', 'wb') else: f = open('/dev/null', 'wb') sys.stdout = f if not args: print "no files to compile" else: for filename in args: if VERBOSE: print filename compile(filename)
| 16,943
|
def testParseFromFile(): from StringIO import StringIO dom=parse( StringIO( open( tstfile ).read() ) ) print dom
|
def testParseFromFile(): from StringIO import StringIO dom=parse( StringIO( open( tstfile ).read() ) ) confirm(isinstance(dom,Document))
| 16,944
|
def testClonePIDeep(): pass
|
def testClonePIDeep(): pass
| 16,945
|
def message_from_string(s, _class=_Message): return _Parser(_class).parsestr(s)
|
def message_from_string(s, _class=_Message, strict=1): return _Parser(_class, strict=strict).parsestr(s)
| 16,946
|
def path(path): return test_support.findfile(path)
|
def path(path): return test_support.findfile(path)
| 16,947
|
def test_main(): if gzip: # create testtar.tar.gz gzip.open(tarname("gz"), "wb").write(file(tarname(), "rb").read()) if bz2: # create testtar.tar.bz2 bz2.BZ2File(tarname("bz2"), "wb").write(file(tarname(), "rb").read()) tests = [ ReadTest, ReadStreamTest, WriteTest, WriteStreamTest ] if gzip: tests.extend([ ReadTestGzip, ReadStreamTestGzip, WriteTestGzip, WriteStreamTestGzip ]) if bz2: tests.extend([ ReadTestBzip2, ReadStreamTestBzip2, WriteTestBzip2, WriteStreamTestBzip2 ]) try: test_support.run_unittest(*tests) finally: if gzip: os.remove(tarname("gz")) if bz2: os.remove(tarname("bz2")) if os.path.exists(tempdir): shutil.rmtree(tempdir) if os.path.exists(tempname): os.remove(tempname)
|
def test_main(): if gzip: # create testtar.tar.gz gzip.open(tarname("gz"), "wb").write(file(tarname(), "rb").read()) if bz2: # create testtar.tar.bz2 bz2.BZ2File(tarname("bz2"), "wb").write(file(tarname(), "rb").read()) tests = [ ReadTest, ReadStreamTest, WriteTest, WriteStreamTest ] if gzip: tests.extend([ ReadTestGzip, ReadStreamTestGzip, WriteTestGzip, WriteStreamTestGzip ]) if bz2: tests.extend([ ReadTestBzip2, ReadStreamTestBzip2, WriteTestBzip2, WriteStreamTestBzip2 ]) try: test_support.run_unittest(*tests) finally: if gzip: os.remove(tarname("gz")) if bz2: os.remove(tarname("bz2")) if os.path.exists(dirname()): shutil.rmtree(dirname()) if os.path.exists(tmpname()): os.remove(tmpname())
| 16,948
|
def testformat(formatstr, args, output=None): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(args), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(args)), try: result = formatstr % args except OverflowError: if verbose: print 'overflow (this is fine)' else: if output and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" %\ (repr(formatstr), repr(args), repr(result), repr(output)) else: if verbose: print 'yes'
|
def testformat(formatstr, args, output=None): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(args), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(args)), try: result = formatstr % args except OverflowError: if not overflowok: raise if verbose: print 'overflow (this is fine)' else: if output and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" %\ (repr(formatstr), repr(args), repr(result), repr(output)) else: if verbose: print 'yes'
| 16,949
|
def testboth(formatstr, *args): testformat(formatstr, *args) testformat(unicode(formatstr), *args)
|
def testboth(formatstr, *args): testformat(formatstr, *args) testformat(unicode(formatstr), *args)
| 16,950
|
def parse_multipart(fp, pdict): """Parse multipart input. Arguments: fp : input file pdict: dictionary containing other parameters of conten-type header Returns a dictionary just like parse_qs(): keys are the field names, each value is a list of values for that field. This is easy to use but not much good if you are expecting megabytes to be uploaded -- in that case, use the FieldStorage class instead which is much more flexible. Note that content-type is the raw, unparsed contents of the content-type header. XXX This does not parse nested multipart parts -- use FieldStorage for that. XXX This should really be subsumed by FieldStorage altogether -- no point in having two implementations of the same parsing algorithm. """ if pdict.has_key('boundary'): boundary = pdict['boundary'] else: boundary = "" nextpart = "--" + boundary lastpart = "--" + boundary + "--" partdict = {} terminator = "" while terminator != lastpart: bytes = -1 data = None if terminator: # At start of next part. Read headers first. headers = mimetools.Message(fp) clength = headers.getheader('content-length') if clength: try: bytes = int(clength) except ValueError: pass if bytes > 0: if maxlen and bytes > maxlen: raise ValueError, 'Maximum content length exceeded' data = fp.read(bytes) else: data = "" # Read lines until end of part. lines = [] while 1: line = fp.readline() if not line: terminator = lastpart # End outer loop break if line[:2] == "--": terminator = line.strip() if terminator in (nextpart, lastpart): break lines.append(line) # Done with part. if data is None: continue if bytes < 0: if lines: # Strip final line terminator line = lines[-1] if line[-2:] == "\r\n": line = line[:-2] elif line[-1:] == "\n": line = line[:-1] lines[-1] = line data = "".join(lines) line = headers['content-disposition'] if not line: continue key, params = parse_header(line) if key != 'form-data': continue if params.has_key('name'): name = params['name'] else: continue if partdict.has_key(name): partdict[name].append(data) else: partdict[name] = [data] return partdict
|
def parse_multipart(fp, pdict): """Parse multipart input. Arguments: fp : input file pdict: dictionary containing other parameters of conten-type header Returns a dictionary just like parse_qs(): keys are the field names, each value is a list of values for that field. This is easy to use but not much good if you are expecting megabytes to be uploaded -- in that case, use the FieldStorage class instead which is much more flexible. Note that content-type is the raw, unparsed contents of the content-type header. XXX This does not parse nested multipart parts -- use FieldStorage for that. XXX This should really be subsumed by FieldStorage altogether -- no point in having two implementations of the same parsing algorithm. """ if pdict.has_key('boundary'): boundary = pdict['boundary'] if not valid_boundary(boundary): raise ValueError, ('Invalid boundary in multipart form: %s' % `ib`) nextpart = "--" + boundary lastpart = "--" + boundary + "--" partdict = {} terminator = "" while terminator != lastpart: bytes = -1 data = None if terminator: # At start of next part. Read headers first. headers = mimetools.Message(fp) clength = headers.getheader('content-length') if clength: try: bytes = int(clength) except ValueError: pass if bytes > 0: if maxlen and bytes > maxlen: raise ValueError, 'Maximum content length exceeded' data = fp.read(bytes) else: data = "" # Read lines until end of part. lines = [] while 1: line = fp.readline() if not line: terminator = lastpart # End outer loop break if line[:2] == "--": terminator = line.strip() if terminator in (nextpart, lastpart): break lines.append(line) # Done with part. if data is None: continue if bytes < 0: if lines: # Strip final line terminator line = lines[-1] if line[-2:] == "\r\n": line = line[:-2] elif line[-1:] == "\n": line = line[:-1] lines[-1] = line data = "".join(lines) line = headers['content-disposition'] if not line: continue key, params = parse_header(line) if key != 'form-data': continue if params.has_key('name'): name = params['name'] else: continue if partdict.has_key(name): partdict[name].append(data) else: partdict[name] = [data] return partdict
| 16,951
|
def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" self.list = [] klass = self.FieldStorageClass or self.__class__ part = klass(self.fp, {}, self.innerboundary, environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = klass(self.fp, headers, self.innerboundary, environ, keep_blank_values, strict_parsing) self.list.append(part) self.skip_lines()
|
def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" self.list = [] klass = self.FieldStorageClass or self.__class__ part = klass(self.fp, {}, ib, environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = klass(self.fp, headers, self.innerboundary, environ, keep_blank_values, strict_parsing) self.list.append(part) self.skip_lines()
| 16,952
|
def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" self.list = [] klass = self.FieldStorageClass or self.__class__ part = klass(self.fp, {}, self.innerboundary, environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = klass(self.fp, headers, self.innerboundary, environ, keep_blank_values, strict_parsing) self.list.append(part) self.skip_lines()
|
def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" self.list = [] klass = self.FieldStorageClass or self.__class__ part = klass(self.fp, {}, self.innerboundary, environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = klass(self.fp, headers, ib, environ, keep_blank_values, strict_parsing) self.list.append(part) self.skip_lines()
| 16,953
|
def main(): if os.name == 'mac': import macfs fss, ok = macfs.GetDirectory('Directory to zap pyc files in') if not ok: sys.exit(0) dir = fss.as_pathname() zappyc(dir) else: if not sys.argv[1:]: print 'Usage: zappyc dir ...' sys.exit(1) for dir in sys.argv[1:]: zappyc(dir)
|
def main(): if not sys.argv[1:]: if os.name == 'mac': import macfs fss, ok = macfs.GetDirectory('Directory to zap pyc files in') if not ok: sys.exit(0) dir = fss.as_pathname() zappyc(dir) else: print 'Usage: zappyc dir ...' sys.exit(1) for dir in sys.argv[1:]: zappyc(dir)
| 16,954
|
def main(): if os.name == 'mac': import macfs fss, ok = macfs.GetDirectory('Directory to zap pyc files in') if not ok: sys.exit(0) dir = fss.as_pathname() zappyc(dir) else: if not sys.argv[1:]: print 'Usage: zappyc dir ...' sys.exit(1) for dir in sys.argv[1:]: zappyc(dir)
|
def main(): if os.name == 'mac': import macfs fss, ok = macfs.GetDirectory('Directory to zap pyc files in') if not ok: sys.exit(0) dir = fss.as_pathname() zappyc(dir) else: if not sys.argv[1:]: print 'Usage: zappyc dir ...' sys.exit(1) for dir in sys.argv[1:]: zappyc(dir)
| 16,955
|
def repr_dictionary(self, x, level): n = len(x) if n == 0: return '{}' if level <= 0: return '{...}' s = '' keys = x.keys() keys.sort() for i in range(min(n, self.maxdict)): if s: s = s + ', ' key = keys[i] s = s + self.repr1(key, level-1) s = s + ': ' + self.repr1(x[key], level-1) if n > self.maxlist: s = s + ', ...' return '{' + s + '}'
|
def repr_dictionary(self, x, level): n = len(x) if n == 0: return '{}' if level <= 0: return '{...}' s = '' keys = x.keys() keys.sort() for i in range(min(n, self.maxdict)): if s: s = s + ', ' key = keys[i] s = s + self.repr1(key, level-1) s = s + ': ' + self.repr1(x[key], level-1) if n > self.maxdict: s = s + ', ...' return '{' + s + '}'
| 16,956
|
def assertParseFail(self, cmdline_args, expected_output): """Assert the parser fails with the expected message.""" sys.stderr = StringIO() self.assertRaises(self.parser.parse_args, (cmdline_args,), None, SystemExit, expected_output, self.redirected_stderr) sys.stderr = sys.__stderr__
|
def assertParseFail(self, cmdline_args, expected_output): """Assert the parser fails with the expected message.""" sys.stderr = StringIO() self.assertRaises(self.parser.parse_args, (cmdline_args,), None, SystemExit, expected_output, self.redirected_stderr) sys.stderr = sys.__stderr__
| 16,957
|
def assertStdoutEquals(self, cmdline_args, expected_output): """Assert the parser prints the expected output on stdout.""" sys.stdout = StringIO() self.assertRaises(self.parser.parse_args, (cmdline_args,), None, SystemExit, expected_output, self.redirected_stdout) sys.stdout = sys.__stdout__
|
def assertStdoutEquals(self, cmdline_args, expected_output): """Assert the parser prints the expected output on stdout.""" sys.stdout = StringIO() self.assertRaises(self.parser.parse_args, (cmdline_args,), None, SystemExit, expected_output, self.redirected_stdout) sys.stdout = sys.__stdout__
| 16,958
|
def test_default_progname(self): # Make sure that program name taken from sys.argv[0] by default. sys.argv[0] = "/foo/bar/baz.py" parser = OptionParser("usage: %prog ...", version="%prog 1.2") expected_usage = "usage: baz.py ...\n" self.assertUsage(parser, expected_usage) self.assertVersion(parser, "baz.py 1.2") self.assertHelp(parser, expected_usage + "\n" + "options:\n" " --version show program's version number and exit\n" " -h, --help show this help message and exit\n")
|
def test_default_progname(self): # Make sure that program name taken from sys.argv[0] by default. sys.argv[0] = "/foo/bar/baz.py" parser = OptionParser("usage: %prog ...", version="%prog 1.2") expected_usage = "usage: baz.py ...\n" self.assertUsage(parser, expected_usage) self.assertVersion(parser, "baz.py 1.2") self.assertHelp(parser, expected_usage + "\n" + "options:\n" " --version show program's version number and exit\n" " -h, --help show this help message and exit\n")
| 16,959
|
def do_activate(self, onoff, event): if onoff: onoff = 0 else: onoff = 255 if self.barx: self.barx.HiliteControl(onoff) if self.bary: self.bary.HiliteControl(onoff)
|
def do_activate(self, onoff, event): if onoff: if self.barx and self.barx_enabled: self.barx.HiliteControl(0) if self.bary and self.bary_enabled: self.bary.HiliteControl(0) else: if self.barx: self.barx.HiliteControl(255) if self.bary: self.bary.HiliteControl(255)
| 16,960
|
def updatescrollbars(self): SetPort(self.wid) vx, vy = self.getscrollbarvalues() if self.barx: self.barx.SetControlValue(vx) if self.bary: self.bary.SetControlValue(vy)
|
def updatescrollbars(self): SetPort(self.wid) vx, vy = self.getscrollbarvalues() if self.barx: if vx == None: self.barx.HiliteControl(255) self.barx_enabled = 0 else: if not self.barx_enabled: self.barx_enabled = 1 if self.activated: self.barx.HiliteControl(0) self.barx.SetControlValue(vx) if self.bary: self.bary.SetControlValue(vy)
| 16,961
|
def updatescrollbars(self): SetPort(self.wid) vx, vy = self.getscrollbarvalues() if self.barx: self.barx.SetControlValue(vx) if self.bary: self.bary.SetControlValue(vy)
|
def updatescrollbars(self): SetPort(self.wid) vx, vy = self.getscrollbarvalues() if self.barx: self.barx.SetControlValue(vx) if self.bary: if vy == None: self.bary.HiliteControl(255) self.bary_enabled = 0 else: if not self.bary_enabled: self.bary_enabled = 1 if self.activated: self.bary.HiliteControl(0) self.bary.SetControlValue(vy) def scalebarvalue(self, absmin, absmax, curmin, curmax): if curmin <= absmin and curmax >= absmax: return None if curmin <= absmin: return 0 if curmax >= absmax: return 32767 perc = float(curmin-absmin)/float(absmax-absmin) return int(perc*32767)
| 16,962
|
def checkline(self, filename, lineno): """Return line number of first line at or after input argument such that if the input points to a 'def', the returned line number is the first non-blank/non-comment line to follow. If the input points to a blank or comment line, return 0. At end of file, also return 0."""
|
def checkline(self, filename, lineno): """Return line number of first line at or after input argument such that if the input points to a 'def', the returned line number is the first non-blank/non-comment line to follow. If the input points to a blank or comment line, return 0. At end of file, also return 0."""
| 16,963
|
def checkline(self, filename, lineno): """Return line number of first line at or after input argument such that if the input points to a 'def', the returned line number is the first non-blank/non-comment line to follow. If the input points to a blank or comment line, return 0. At end of file, also return 0."""
|
def checkline(self, filename, lineno): """Return line number of first line at or after input argument such that if the input points to a 'def', the returned line number is the first non-blank/non-comment line to follow. If the input points to a blank or comment line, return 0. At end of file, also return 0."""
| 16,964
|
def checkline(self, filename, lineno): """Return line number of first line at or after input argument such that if the input points to a 'def', the returned line number is the first non-blank/non-comment line to follow. If the input points to a blank or comment line, return 0. At end of file, also return 0."""
|
def checkline(self, filename, lineno): """Return line number of first line at or after input argument such that if the input points to a 'def', the returned line number is the first non-blank/non-comment line to follow. If the input points to a blank or comment line, return 0. At end of file, also return 0."""
| 16,965
|
def readmodule(module, path=[]): '''Backwards compatible interface. Call readmodule_ex() and then only keep Class objects from the resulting dictionary.''' dict = readmodule_ex(module, path) res = {} for key, value in dict.items(): if isinstance(value, Class): res[key] = value return res
|
def readmodule(module, path=[]): '''Backwards compatible interface. Call readmodule_ex() and then only keep Class objects from the resulting dictionary.''' dict = _readmodule(module, path) res = {} for key, value in dict.items(): if isinstance(value, Class): res[key] = value return res
| 16,966
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[]): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,967
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
defreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path=[],return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage=None):return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '''Readreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' filereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictionaryreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classes.return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Searchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' MODULEreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' PATHreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' sys.path,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parsereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictionaryreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' withreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' onereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' entryreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' eachreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' foundreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module.return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' INPACKAGEreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' isreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' true,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' itreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mustreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' bereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dottedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' packagereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whichreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' arereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' searchingreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' submodule,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' PATHreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mustreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' bereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' packagereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' searchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path;return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' otherwise,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' arereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' searchingreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' top-levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' PATHreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' isreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' combinedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' withreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' sys.path.return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '''return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Computereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' fullreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (prependingreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackagereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' set)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' fullmodulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' "%s.%s"return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' %return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (inpackage,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' fullmodulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Checkreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' cachereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' fullmodulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules[fullmodule]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Initializereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module'sreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' contentsreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' {}return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Checkreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' itreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' isreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' built-inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module;return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' don'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' doreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' muchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thesereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' sys.builtin_module_namesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules[module]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Checkreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dottedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ireturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module.rfind('.')return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ireturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' >=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 0:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' packagereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module[:i]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' submodulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module[i+1:]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parentreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(package,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' packagereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' "%s.%s"return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' %return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (inpackage,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' package)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(submodule,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parent['__path__'],return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' package)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Searchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' pathreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' freturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Nonereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' f,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' file,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (suff,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mode,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' type)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' imp.find_module(module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' f,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' file,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (suff,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mode,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' type)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' imp.find_module(module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' pathreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' +return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' sys.path)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' typereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' imp.PKG_DIRECTORY:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict['__path__']return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' [file]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' pathreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' [file]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' +return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' pathreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' f,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' file,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (suff,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mode,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' type)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' imp.find_module('__init__',return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' [file])return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules[fullmodule]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' typereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' !=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' imp.PY_SOURCE:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Pythonreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' source,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' can'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' doreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' anythingreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' withreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' f.close()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstackreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' []return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' stackreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (class,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' indent)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' pairsreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' greturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenize.generate_tokens(f.readline)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' try:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentype,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' token,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' end,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' linereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' g:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 'def':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lineno,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisindentreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' startreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentype,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' meth_name,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' end,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' linereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' g.next()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentypereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' !=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' NAME:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' continuereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Syntaxreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' errorreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' closereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' allreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' indentedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' atreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' leastreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' asreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' muchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whilereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstackreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' \return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack[-1][1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' >=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisindent:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' delreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack[-1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' it'sreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' methodreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' cur_classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack[-1][0]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' cur_class._addmethod(meth_name,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lineno)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' it'sreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' functionreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict[meth_name]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Function(module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' meth_name,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' file,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lineno)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 'class':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lineno,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisindentreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' startreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentype,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' class_name,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' end,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' linereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' g.next()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentypereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' !=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' NAME:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' continuereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Syntaxreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' errorreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' closereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' allreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' indentedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' atreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' leastreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' asreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' muchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whilereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstackreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' \return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack[-1][1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' >=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisindent:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' delreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack[-1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parsereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whatreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' followsreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentype,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' token,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' end,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' linereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' g.next()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inheritreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Nonereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '(':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' []return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Listreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superclassesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' there'sreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' listreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superclassesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' []return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Tokensreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' makingreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' upreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' currentreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superclassreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whilereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' True:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentype,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' token,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' end,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' linereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' g.next()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (')',return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ',')return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' "".join(super)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' knowreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict[n]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' creturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' n.split('.')return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' len(c)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' >return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' isreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' formreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module.class:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lookreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' c[-2]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' creturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' c[-1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules[m]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' creturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d[c]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' names.append(n)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '(':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' +=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ')':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' -=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 0:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' breakreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ','return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' passreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' super.append(token)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inheritreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' cur_classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Class(module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' class_name,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inherit,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' file,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lineno)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict[class_name]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' cur_classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack.append((cur_class,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisindent))return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 'import'return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start[1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 0:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _getnamelist(g)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mod,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mod2return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modules:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' try:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Recursivelyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' importedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(mod,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' try:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(mod,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' exceptreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ImportError:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(mod)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' except:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' can'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' findreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' orreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parsereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' importedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tooreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' badreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' --return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' don'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' diereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' here.return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' passreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 'from'return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start[1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 0:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mod,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _getname(g)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' orreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' !=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' "import":return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' continuereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _getnamelist(g)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' try:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Recursivelyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' importedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(mod,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' except:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' can'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' findreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' orreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parsereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' importedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tooreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' badreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' --return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' don'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' diereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' here.return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' continuereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' addreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' anyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thatreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' werereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' definedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' importedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' toreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ourreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' spacereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' theyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' werereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mentionedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' listreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' n,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' n2return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' names:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict[n2return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' orreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' n]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d[n]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '*':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' onlyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' addreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' alreadyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' therereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (toreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mimicreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whatreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Pythonreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' doesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' internally)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' alsoreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' don'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' addreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thatreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' startreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' withreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' n[0]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' !=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '_'return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict[n]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d[n]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' exceptreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' StopIteration:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' passreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' f.close()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].'''
| 16,968
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = _readmodule(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,969
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return _readmodule(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,970
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict stack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,971
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if tokentype == DEDENT: lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,972
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,973
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as muchif classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much# parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,974
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) if not stack: dict[class_name] = cur_class stack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,975
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: _readmodule(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,976
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: _readmodule(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = _readmodule(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,977
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: _readmodule(mod, []) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,978
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = _readmodule(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,979
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,980
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
|
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_': dict[n] = d[n] except StopIteration: pass f.close() return dict
| 16,981
|
def __init__(self, input_charset=DEFAULT_CHARSET): # RFC 2046, $4.1.2 says charsets are not case sensitive input_charset = input_charset.lower() # Set the input charset after filtering through the aliases self.input_charset = ALIASES.get(input_charset, input_charset) # We can try to guess which encoding and conversion to use by the # charset_map dictionary. Try that first, but let the user override # it. henc, benc, conv = CHARSETS.get(self.input_charset, (SHORTEST, BASE64, None)) if not conv: conv = self.input_charset # Set the attributes, allowing the arguments to override the default. self.header_encoding = henc self.body_encoding = benc self.output_charset = ALIASES.get(conv, conv) # Now set the codecs. If one isn't defined for input_charset, # guess and try a Unicode codec with the same name as input_codec. self.input_codec = CODEC_MAP.get(self.input_charset, self.input_charset) self.output_codec = CODEC_MAP.get(self.output_charset, self.output_charset)
|
def __init__(self, input_charset=DEFAULT_CHARSET): # RFC 2046, $4.1.2 says charsets are not case sensitive input_charset = unicode(input_charset, 'ascii').lower() # Set the input charset after filtering through the aliases self.input_charset = ALIASES.get(input_charset, input_charset) # We can try to guess which encoding and conversion to use by the # charset_map dictionary. Try that first, but let the user override # it. henc, benc, conv = CHARSETS.get(self.input_charset, (SHORTEST, BASE64, None)) if not conv: conv = self.input_charset # Set the attributes, allowing the arguments to override the default. self.header_encoding = henc self.body_encoding = benc self.output_charset = ALIASES.get(conv, conv) # Now set the codecs. If one isn't defined for input_charset, # guess and try a Unicode codec with the same name as input_codec. self.input_codec = CODEC_MAP.get(self.input_charset, self.input_charset) self.output_codec = CODEC_MAP.get(self.output_charset, self.output_charset)
| 16,982
|
def atof(s): """atof(s) -> float Return the floating point number represented by the string s. """ if type(s) == _StringType: return _float(s) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
|
def atof(s): """atof(s) -> float Return the floating point number represented by the string s. """ if type(s) == _StringType: return _float(s) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
| 16,983
|
def atof(s): """atof(s) -> float Return the floating point number represented by the string s. """ if type(s) == _StringType: return _float(s) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
|
def atof(s): """atof(s) -> float Return the floating point number represented by the string s. """ if type(s) == _StringType: return _float(s) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
| 16,984
|
def atoi(*args): """atoi(s [,base]) -> int Return the integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to int(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_int, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
|
def atoi(*args): """atoi(s [,base]) -> int Return the integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to int(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_int, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
| 16,985
|
def atoi(*args): """atoi(s [,base]) -> int Return the integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to int(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_int, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
|
def atoi(*args): """atoi(s [,base]) -> int Return the integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to int(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_int, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
| 16,986
|
def atoi(*args): """atoi(s [,base]) -> int Return the integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to int(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_int, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
|
def atoi(*args): """atoi(s [,base]) -> int Return the integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to int(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_int, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
| 16,987
|
def atoi(*args): """atoi(s [,base]) -> int Return the integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to int(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_int, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
|
def atoi(*args): """atoi(s [,base]) -> int Return the integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to int(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_int, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
| 16,988
|
def atol(*args): """atol(s [,base]) -> long Return the long integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. A trailing L or l is not accepted, unless base is 0. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to long(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_long, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
|
def atol(*args): """atol(s [,base]) -> long Return the long integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. A trailing L or l is not accepted, unless base is 0. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to long(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_long, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
| 16,989
|
def atol(*args): """atol(s [,base]) -> long Return the long integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. A trailing L or l is not accepted, unless base is 0. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to long(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_long, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
|
def atol(*args): """atol(s [,base]) -> long Return the long integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. A trailing L or l is not accepted, unless base is 0. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to long(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_long, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
| 16,990
|
def atol(*args): """atol(s [,base]) -> long Return the long integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. A trailing L or l is not accepted, unless base is 0. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to long(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_long, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
|
def atol(*args): """atol(s [,base]) -> long Return the long integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. A trailing L or l is not accepted, unless base is 0. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to long(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_long, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
| 16,991
|
def atol(*args): """atol(s [,base]) -> long Return the long integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. A trailing L or l is not accepted, unless base is 0. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to long(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_long, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
|
def atol(*args): """atol(s [,base]) -> long Return the long integer represented by the string s in the given base, which defaults to 10. The string s must consist of one or more digits, possibly preceded by a sign. If base is 0, it is chosen from the leading characters of s, 0 for octal, 0x or 0X for hexadecimal. If base is 16, a preceding 0x or 0X is accepted. A trailing L or l is not accepted, unless base is 0. """ try: s = args[0] except IndexError: raise TypeError('function requires at least 1 argument: %d given' % len(args)) # Don't catch type error resulting from too many arguments to long(). The # error message isn't compatible but the error type is, and this function # is complicated enough already. if type(s) == _StringType: return _apply(_long, args) else: raise TypeError('argument 1: expected string, %s found' % type(s).__name__)
| 16,992
|
def center(s, width): """center(s, width) -> string Return a center version of s, in a field of the specified width. padded with spaces as needed. The string is never truncated. """ n = width - len(s) if n <= 0: return s half = n/2 if n%2 and width%2: # This ensures that center(center(s, i), j) = center(s, j) half = half+1 return ' '*half + s + ' '*(n-half)
|
def center(s, width): """center(s, width) -> string Return a center version of s, in a field of the specified width. padded with spaces as needed. The string is never truncated. """ n = width - len(s) if n <= 0: return s half = n/2 if n%2 and width%2: # This ensures that center(center(s, i), j) = center(s, j) half = half+1 return ' '*half + s + ' '*(n-half)
| 16,993
|
def zfill(x, width): """zfill(x, width) -> string Pad a numeric string x with zeros on the left, to fill a field of the specified width. The string x is never truncated. """ if type(x) == type(''): s = x else: s = `x` n = len(s) if n >= width: return s sign = '' if s[0] in ('-', '+'): sign, s = s[0], s[1:] return sign + '0'*(width-n) + s
|
def zfill(x, width): """zfill(x, width) -> string Pad a numeric string x with zeros on the left, to fill a field of the specified width. The string x is never truncated. """ if type(x) == type(''): s = x else: s = `x` n = len(s) if n >= width: return s sign = '' if s[0] in ('-', '+'): sign, s = s[0], s[1:] return sign + '0'*(width-n) + s
| 16,994
|
def expandtabs(s, tabsize=8): """expandtabs(s [,tabsize]) -> string Return a copy of the string s with all tab characters replaced by the appropriate number of spaces, depending on the current column, and the tabsize (default 8). """ res = line = '' for c in s: if c == '\t': c = ' '*(tabsize - len(line) % tabsize) line = line + c if c == '\n': res = res + line line = '' return res + line
|
def expandtabs(s, tabsize=8): """expandtabs(s [,tabsize]) -> string Return a copy of the string s with all tab characters replaced by the appropriate number of spaces, depending on the current column, and the tabsize (default 8). """ res = line = '' for c in s: if c == '\t': c = ' '*(tabsize - len(line) % tabsize) line = line + c if c == '\n': res = res + line line = '' return res + line
| 16,995
|
def maketrans(fromstr, tostr): """maketrans(frm, to) -> string Return a translation table (a string of 256 bytes long) suitable for use in string.translate. The strings frm and to must be of the same length. """ if len(fromstr) != len(tostr): raise ValueError, "maketrans arguments must have same length" global _idmapL if not _idmapL: _idmapL = map(None, _idmap) L = _idmapL[:] fromstr = map(ord, fromstr) for i in range(len(fromstr)): L[fromstr[i]] = tostr[i] return joinfields(L, "")
|
def maketrans(fromstr, tostr): """maketrans(frm, to) -> string Return a translation table (a string of 256 bytes long) suitable for use in string.translate. The strings frm and to must be of the same length. """ if len(fromstr) != len(tostr): raise ValueError, "maketrans arguments must have same length" global _idmapL if not _idmapL: _idmapL = map(None, _idmap) L = _idmapL[:] fromstr = map(ord, fromstr) for i in range(len(fromstr)): L[fromstr[i]] = tostr[i] return joinfields(L, "")
| 16,996
|
def maketrans(fromstr, tostr): """maketrans(frm, to) -> string Return a translation table (a string of 256 bytes long) suitable for use in string.translate. The strings frm and to must be of the same length. """ if len(fromstr) != len(tostr): raise ValueError, "maketrans arguments must have same length" global _idmapL if not _idmapL: _idmapL = map(None, _idmap) L = _idmapL[:] fromstr = map(ord, fromstr) for i in range(len(fromstr)): L[fromstr[i]] = tostr[i] return joinfields(L, "")
|
def maketrans(fromstr, tostr): """maketrans(frm, to) -> string Return a translation table (a string of 256 bytes long) suitable for use in string.translate. The strings frm and to must be of the same length. """ if len(fromstr) != len(tostr): raise ValueError, "maketrans arguments must have same length" global _idmapL if not _idmapL: _idmapL = map(None, _idmap) L = _idmapL[:] fromstr = map(ord, fromstr) for i in range(len(fromstr)): L[fromstr[i]] = tostr[i] return joinfields(L, "")
| 16,997
|
def maketrans(fromstr, tostr): """maketrans(frm, to) -> string Return a translation table (a string of 256 bytes long) suitable for use in string.translate. The strings frm and to must be of the same length. """ if len(fromstr) != len(tostr): raise ValueError, "maketrans arguments must have same length" global _idmapL if not _idmapL: _idmapL = map(None, _idmap) L = _idmapL[:] fromstr = map(ord, fromstr) for i in range(len(fromstr)): L[fromstr[i]] = tostr[i] return joinfields(L, "")
|
def maketrans(fromstr, tostr): """maketrans(frm, to) -> string Return a translation table (a string of 256 bytes long) suitable for use in string.translate. The strings frm and to must be of the same length. """ if len(fromstr) != len(tostr): raise ValueError, "maketrans arguments must have same length" global _idmapL if not _idmapL: _idmapL = map(None, _idmap) L = _idmapL[:] fromstr = map(ord, fromstr) for i in range(len(fromstr)): L[fromstr[i]] = tostr[i] return joinfields(L, "")
| 16,998
|
def replace(s, old, new, maxsplit=0): """replace (str, old, new[, maxsplit]) -> string Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxsplit is given, only the first maxsplit occurrences are replaced. """ return s.replace(old, new, maxsplit)
|
def replace(s, old, new, maxsplit=0): """replace (str, old, new[, maxsplit]) -> string Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxsplit is given, only the first maxsplit occurrences are replaced. """ return s.replace(old, new, maxsplit)
| 16,999
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.