src/eric7/Utilities/ModuleParser.py

branch
eric7
changeset 10433
328f3ec4b77a
parent 10258
e7764f992a01
child 10439
21c28b0f9e41
equal deleted inserted replaced
10432:2fe91fe443dd 10433:328f3ec4b77a
53 53
54 def getTypeFromTypeName(name): 54 def getTypeFromTypeName(name):
55 """ 55 """
56 Module function to determine the module type given the module type name. 56 Module function to determine the module type given the module type name.
57 57
58 @param name module type name (string) 58 @param name module type name
59 @return module type or -1 for failure (integer) 59 @type str
60 @return module type or -1 for failure
61 @rtype int
60 """ 62 """
61 if name in TYPE_MAPPING: 63 if name in TYPE_MAPPING:
62 return TYPE_MAPPING[name] 64 return TYPE_MAPPING[name]
63 else: 65 else:
64 return -1 66 return -1
379 381
380 def isPrivate(self): 382 def isPrivate(self):
381 """ 383 """
382 Public method to check, if the visibility is Private. 384 Public method to check, if the visibility is Private.
383 385
384 @return flag indicating Private visibility (boolean) 386 @return flag indicating Private visibility
387 @rtype bool
385 """ 388 """
386 return self.visibility == 0 389 return self.visibility == 0
387 390
388 def isProtected(self): 391 def isProtected(self):
389 """ 392 """
390 Public method to check, if the visibility is Protected. 393 Public method to check, if the visibility is Protected.
391 394
392 @return flag indicating Protected visibility (boolean) 395 @return flag indicating Protected visibility
396 @rtype bool
393 """ 397 """
394 return self.visibility == 1 398 return self.visibility == 1
395 399
396 def isPublic(self): 400 def isPublic(self):
397 """ 401 """
398 Public method to check, if the visibility is Public. 402 Public method to check, if the visibility is Public.
399 403
400 @return flag indicating Public visibility (boolean) 404 @return flag indicating Public visibility
405 @rtype bool
401 """ 406 """
402 return self.visibility == 2 407 return self.visibility == 2
403 408
404 def setPrivate(self): 409 def setPrivate(self):
405 """ 410 """
427 432
428 def __init__(self, name, file=None, moduleType=None): 433 def __init__(self, name, file=None, moduleType=None):
429 """ 434 """
430 Constructor 435 Constructor
431 436
432 @param name name of this module (string) 437 @param name name of this module
433 @param file filename of file containing this module (string) 438 @type str
439 @param file filename of file containing this module
440 @type str
434 @param moduleType type of this module 441 @param moduleType type of this module
442 @type int
435 """ 443 """
436 self.name = name 444 self.name = name
437 self.file = file 445 self.file = file
438 self.modules = {} 446 self.modules = {}
439 self.modules_counts = {} 447 self.modules_counts = {}
456 464
457 def addClass(self, name, _class): 465 def addClass(self, name, _class):
458 """ 466 """
459 Public method to add information about a class. 467 Public method to add information about a class.
460 468
461 @param name name of class to be added (string) 469 @param name name of class to be added
470 @type str
462 @param _class Class object to be added 471 @param _class Class object to be added
472 @type Class
463 """ 473 """
464 if name in self.classes: 474 if name in self.classes:
465 self.classes_counts[name] += 1 475 self.classes_counts[name] += 1
466 name = "{0}_{1:d}".format(name, self.classes_counts[name]) 476 name = "{0}_{1:d}".format(name, self.classes_counts[name])
467 else: 477 else:
470 480
471 def addModule(self, name, module): 481 def addModule(self, name, module):
472 """ 482 """
473 Public method to add information about a Ruby module. 483 Public method to add information about a Ruby module.
474 484
475 @param name name of module to be added (string) 485 @param name name of module to be added
486 @type str
476 @param module Module object to be added 487 @param module Module object to be added
488 @type Module
477 """ 489 """
478 if name in self.modules: 490 if name in self.modules:
479 self.modules_counts[name] += 1 491 self.modules_counts[name] += 1
480 name = "{0}_{1:d}".format(name, self.modules_counts[name]) 492 name = "{0}_{1:d}".format(name, self.modules_counts[name])
481 else: 493 else:
484 496
485 def addFunction(self, name, function): 497 def addFunction(self, name, function):
486 """ 498 """
487 Public method to add information about a function. 499 Public method to add information about a function.
488 500
489 @param name name of function to be added (string) 501 @param name name of function to be added
502 @type str
490 @param function Function object to be added 503 @param function Function object to be added
504 @type Function
491 """ 505 """
492 if name in self.functions: 506 if name in self.functions:
493 self.functions_counts[name] += 1 507 self.functions_counts[name] += 1
494 name = "{0}_{1:d}".format(name, self.functions_counts[name]) 508 name = "{0}_{1:d}".format(name, self.functions_counts[name])
495 else: 509 else:
498 512
499 def addGlobal(self, name, attr): 513 def addGlobal(self, name, attr):
500 """ 514 """
501 Public method to add information about global variables. 515 Public method to add information about global variables.
502 516
503 @param name name of the global to add (string) 517 @param name name of the global to add
518 @type str
504 @param attr Attribute object to be added 519 @param attr Attribute object to be added
520 @type Attribute
505 """ 521 """
506 if name not in self.globals: 522 if name not in self.globals:
507 self.globals[name] = attr 523 self.globals[name] = attr
508 else: 524 else:
509 self.globals[name].addAssignment(attr.lineno) 525 self.globals[name].addAssignment(attr.lineno)
510 526
511 def addDescription(self, description): 527 def addDescription(self, description):
512 """ 528 """
513 Public method to store the modules docstring. 529 Public method to store the modules docstring.
514 530
515 @param description the docstring to be stored (string) 531 @param description the docstring to be stored
532 @type str
516 """ 533 """
517 self.description = description 534 self.description = description
518 535
519 def scan(self, src): 536 def scan(self, src):
520 """ 537 """
521 Public method to scan the source text and retrieve the relevant 538 Public method to scan the source text and retrieve the relevant
522 information. 539 information.
523 540
524 @param src the source text to be scanned (string) 541 @param src the source text to be scanned
542 @type str
525 """ 543 """
526 # convert eol markers the Python style 544 # convert eol markers the Python style
527 src = src.replace("\r\n", "\n").replace("\r", "\n") 545 src = src.replace("\r\n", "\n").replace("\r", "\n")
528 if self.type in [PY_SOURCE, PTL_SOURCE]: 546 if self.type in [PY_SOURCE, PTL_SOURCE]:
529 self.__py_scan(src) 547 self.__py_scan(src)
532 550
533 def __py_setVisibility(self, objectRef): 551 def __py_setVisibility(self, objectRef):
534 """ 552 """
535 Private method to set the visibility of an object. 553 Private method to set the visibility of an object.
536 554
537 @param objectRef reference to the object (Attribute, Class or Function) 555 @param objectRef reference to the object
556 @type Attribute, Class or Function
538 """ 557 """
539 if objectRef.name.startswith("__"): 558 if objectRef.name.startswith("__"):
540 objectRef.setPrivate() 559 objectRef.setPrivate()
541 elif objectRef.name.startswith("_"): 560 elif objectRef.name.startswith("_"):
542 objectRef.setProtected() 561 objectRef.setProtected()
546 def __py_scan(self, src): 565 def __py_scan(self, src):
547 """ 566 """
548 Private method to scan the source text of a Python module and retrieve 567 Private method to scan the source text of a Python module and retrieve
549 the relevant information. 568 the relevant information.
550 569
551 @param src the source text to be scanned (string) 570 @param src the source text to be scanned
571 @type str
552 """ # __IGNORE_WARNING_D234__ 572 """ # __IGNORE_WARNING_D234__
553 573
554 def calculateEndline(lineno, lines, indent): 574 def calculateEndline(lineno, lines, indent):
555 """ 575 """
556 Function to calculate the end line of a class or method/function. 576 Function to calculate the end line of a class or method/function.
1252 """ 1272 """
1253 Public method to build the inheritance hierarchy for all classes of 1273 Public method to build the inheritance hierarchy for all classes of
1254 this module. 1274 this module.
1255 1275
1256 @return A dictionary with inheritance hierarchies. 1276 @return A dictionary with inheritance hierarchies.
1277 @rtype dict
1257 """ 1278 """
1258 hierarchy = {} 1279 hierarchy = {}
1259 for class_ in self.classes: 1280 for class_ in self.classes:
1260 self.assembleHierarchy(class_, self.classes, [class_], hierarchy) 1281 self.assembleHierarchy(class_, self.classes, [class_], hierarchy)
1261 for module in self.modules: 1282 for module in self.modules:
1270 and build up a nested dictionary of super-classes. The result is 1291 and build up a nested dictionary of super-classes. The result is
1271 intended to be inverted, i.e. the highest level are the super classes. 1292 intended to be inverted, i.e. the highest level are the super classes.
1272 1293
1273 This code is borrowed from Boa Constructor. 1294 This code is borrowed from Boa Constructor.
1274 1295
1275 @param name name of class to assemble hierarchy (string) 1296 @param name name of class to assemble hierarchy
1297 @type str
1276 @param classes A dictionary of classes to look in. 1298 @param classes A dictionary of classes to look in.
1277 @param path 1299 @type dict
1300 @param path path of classes
1301 @type list of str
1278 @param result The resultant hierarchy 1302 @param result The resultant hierarchy
1303 @type dict
1279 """ 1304 """
1280 rv = {} 1305 rv = {}
1281 if name in classes: 1306 if name in classes:
1282 for class_ in classes[name].super: 1307 for class_ in classes[name].super:
1283 if class_ not in classes: 1308 if class_ not in classes:
1298 def addPathToHierarchy(self, path, result, fn): 1323 def addPathToHierarchy(self, path, result, fn):
1299 """ 1324 """
1300 Public method to put the exhausted path into the result dictionary. 1325 Public method to put the exhausted path into the result dictionary.
1301 1326
1302 @param path the exhausted path of classes 1327 @param path the exhausted path of classes
1328 @type list of str
1303 @param result the result dictionary 1329 @param result the result dictionary
1330 @type dict
1304 @param fn function to call for classe that are already part of the 1331 @param fn function to call for classe that are already part of the
1305 result dictionary 1332 result dictionary
1333 @type function
1306 """ 1334 """
1307 if path[0] in result: 1335 if path[0] in result:
1308 if len(path) > 1: 1336 if len(path) > 1:
1309 fn(path[1:], result[path[0]], fn) 1337 fn(path[1:], result[path[0]], fn)
1310 else: 1338 else:
1314 1342
1315 def getName(self): 1343 def getName(self):
1316 """ 1344 """
1317 Public method to retrieve the modules name. 1345 Public method to retrieve the modules name.
1318 1346
1319 @return module name (string) 1347 @return module name
1348 @rtype str
1320 """ 1349 """
1321 return self.name 1350 return self.name
1322 1351
1323 def getFileName(self): 1352 def getFileName(self):
1324 """ 1353 """
1325 Public method to retrieve the modules filename. 1354 Public method to retrieve the modules filename.
1326 1355
1327 @return module filename (string) 1356 @return module filename
1357 @rtype str
1328 """ 1358 """
1329 return self.file 1359 return self.file
1330 1360
1331 def getType(self): 1361 def getType(self):
1332 """ 1362 """
1333 Public method to get the type of the module's source. 1363 Public method to get the type of the module's source.
1334 1364
1335 @return type of the modules's source (string) 1365 @return type of the modules's source
1366 @rtype str
1336 """ 1367 """
1337 if self.type in [PY_SOURCE, PTL_SOURCE]: 1368 if self.type in [PY_SOURCE, PTL_SOURCE]:
1338 moduleType = "Python3" 1369 moduleType = "Python3"
1339 elif self.type == RB_SOURCE: 1370 elif self.type == RB_SOURCE:
1340 moduleType = "Ruby" 1371 moduleType = "Ruby"
1350 1381
1351 def __init__(self, module, name, superClasses, file, lineno): 1382 def __init__(self, module, name, superClasses, file, lineno):
1352 """ 1383 """
1353 Constructor 1384 Constructor
1354 1385
1355 @param module name of module containing this class (string) 1386 @param module name of module containing this class
1356 @param name name of the class (string) 1387 @type str
1388 @param name name of the class
1389 @type str
1357 @param superClasses list of classnames this class is inherited from 1390 @param superClasses list of classnames this class is inherited from
1358 (list of strings) 1391 @type list of str
1359 @param file name of file containing this class (string) 1392 @param file name of file containing this class
1360 @param lineno linenumber of the class definition (integer) 1393 @type str
1394 @param lineno linenumber of the class definition
1395 @type int
1361 """ 1396 """
1362 self.module = module 1397 self.module = module
1363 self.name = name 1398 self.name = name
1364 if superClasses is None: 1399 if superClasses is None:
1365 superClasses = [] 1400 superClasses = []
1375 1410
1376 def addMethod(self, name, function): 1411 def addMethod(self, name, function):
1377 """ 1412 """
1378 Public method to add information about a method. 1413 Public method to add information about a method.
1379 1414
1380 @param name name of method to be added (string) 1415 @param name name of method to be added
1416 @type str
1381 @param function Function object to be added 1417 @param function Function object to be added
1418 @type Function
1382 """ 1419 """
1383 self.methods[name] = function 1420 self.methods[name] = function
1384 1421
1385 def getMethod(self, name): 1422 def getMethod(self, name):
1386 """ 1423 """
1387 Public method to retrieve a method by name. 1424 Public method to retrieve a method by name.
1388 1425
1389 @param name name of the method (string) 1426 @param name name of the method
1427 @type str
1390 @return the named method or None 1428 @return the named method or None
1429 @rtype Function
1391 """ 1430 """
1392 try: 1431 try:
1393 return self.methods[name] 1432 return self.methods[name]
1394 except KeyError: 1433 except KeyError:
1395 return None 1434 return None
1396 1435
1397 def addAttribute(self, name, attr): 1436 def addAttribute(self, name, attr):
1398 """ 1437 """
1399 Public method to add information about attributes. 1438 Public method to add information about attributes.
1400 1439
1401 @param name name of the attribute to add (string) 1440 @param name name of the attribute to add
1441 @type str
1402 @param attr Attribute object to be added 1442 @param attr Attribute object to be added
1443 @type Attribute
1403 """ 1444 """
1404 if name not in self.attributes: 1445 if name not in self.attributes:
1405 self.attributes[name] = attr 1446 self.attributes[name] = attr
1406 else: 1447 else:
1407 self.attributes[name].addAssignment(attr.lineno) 1448 self.attributes[name].addAssignment(attr.lineno)
1408 1449
1409 def getAttribute(self, name): 1450 def getAttribute(self, name):
1410 """ 1451 """
1411 Public method to retrieve an attribute by name. 1452 Public method to retrieve an attribute by name.
1412 1453
1413 @param name name of the attribute (string) 1454 @param name name of the attribute
1455 @type str
1414 @return the named attribute or None 1456 @return the named attribute or None
1457 @rtype Attribute
1415 """ 1458 """
1416 try: 1459 try:
1417 return self.attributes[name] 1460 return self.attributes[name]
1418 except KeyError: 1461 except KeyError:
1419 return None 1462 return None
1420 1463
1421 def addGlobal(self, name, attr): 1464 def addGlobal(self, name, attr):
1422 """ 1465 """
1423 Public method to add information about global (class) variables. 1466 Public method to add information about global (class) variables.
1424 1467
1425 @param name name of the global to add (string) 1468 @param name name of the global to add
1469 @type str
1426 @param attr Attribute object to be added 1470 @param attr Attribute object to be added
1471 @type Attribute
1427 """ 1472 """
1428 if name not in self.globals: 1473 if name not in self.globals:
1429 self.globals[name] = attr 1474 self.globals[name] = attr
1430 else: 1475 else:
1431 self.globals[name].addAssignment(attr.lineno) 1476 self.globals[name].addAssignment(attr.lineno)
1432 1477
1433 def addDescription(self, description): 1478 def addDescription(self, description):
1434 """ 1479 """
1435 Public method to store the class docstring. 1480 Public method to store the class docstring.
1436 1481
1437 @param description the docstring to be stored (string) 1482 @param description the docstring to be stored
1483 @type str
1438 """ 1484 """
1439 self.description = description 1485 self.description = description
1440 1486
1441 def setEndLine(self, endLineNo): 1487 def setEndLine(self, endLineNo):
1442 """ 1488 """
1443 Public method to record the number of the last line of a class. 1489 Public method to record the number of the last line of a class.
1444 1490
1445 @param endLineNo number of the last line (integer) 1491 @param endLineNo number of the last line
1492 @type int
1446 """ 1493 """
1447 self.endlineno = endLineNo 1494 self.endlineno = endLineNo
1448 1495
1449 1496
1450 class RbModule(Class): 1497 class RbModule(Class):
1454 1501
1455 def __init__(self, module, name, file, lineno): 1502 def __init__(self, module, name, file, lineno):
1456 """ 1503 """
1457 Constructor 1504 Constructor
1458 1505
1459 @param module name of module containing this class (string) 1506 @param module name of module containing this class
1460 @param name name of the class (string) 1507 @type str
1461 @param file name of file containing this class (string) 1508 @param name name of the class
1462 @param lineno linenumber of the class definition (integer) 1509 @type str
1510 @param file name of file containing this class
1511 @type str
1512 @param lineno linenumber of the class definition
1513 @type int
1463 """ 1514 """
1464 Class.__init__(self, module, name, None, file, lineno) 1515 Class.__init__(self, module, name, None, file, lineno)
1465 self.classes = {} 1516 self.classes = {}
1466 1517
1467 def addClass(self, name, _class): 1518 def addClass(self, name, _class):
1468 """ 1519 """
1469 Public method to add information about a class. 1520 Public method to add information about a class.
1470 1521
1471 @param name name of class to be added (string) 1522 @param name name of class to be added
1523 @type str
1472 @param _class Class object to be added 1524 @param _class Class object to be added
1525 @type Class
1473 """ 1526 """
1474 self.classes[name] = _class 1527 self.classes[name] = _class
1475 1528
1476 1529
1477 class Function(VisibilityBase): 1530 class Function(VisibilityBase):
1495 annotation="", 1548 annotation="",
1496 ): 1549 ):
1497 """ 1550 """
1498 Constructor 1551 Constructor
1499 1552
1500 @param module name of module containing this function (string) 1553 @param module name of module containing this function
1501 @param name name of the function (string) 1554 @type str
1502 @param file name of file containing this function (string) 1555 @param name name of the function
1503 @param lineno linenumber of the function definition (integer) 1556 @type str
1504 @param signature the functions call signature (string) 1557 @param file name of file containing this function
1505 @param pyqtSignature the functions PyQt signature (string) 1558 @type str
1559 @param lineno linenumber of the function definition
1560 @type int
1561 @param signature the functions call signature
1562 @type str
1563 @param pyqtSignature the functions PyQt signature
1564 @type str
1506 @param modifierType type of the function 1565 @param modifierType type of the function
1566 @type int
1507 @param annotation return annotation 1567 @param annotation return annotation
1568 @type str
1508 """ 1569 """
1509 self.module = module 1570 self.module = module
1510 self.name = name 1571 self.name = name
1511 self.file = file 1572 self.file = file
1512 self.lineno = lineno 1573 self.lineno = lineno
1521 1582
1522 def addDescription(self, description): 1583 def addDescription(self, description):
1523 """ 1584 """
1524 Public method to store the functions docstring. 1585 Public method to store the functions docstring.
1525 1586
1526 @param description the docstring to be stored (string) 1587 @param description the docstring to be stored
1588 @type str
1527 """ 1589 """
1528 self.description = description 1590 self.description = description
1529 1591
1530 def setEndLine(self, endLineNo): 1592 def setEndLine(self, endLineNo):
1531 """ 1593 """
1532 Public method to record the number of the last line of a class. 1594 Public method to record the number of the last line of a class.
1533 1595
1534 @param endLineNo number of the last line (integer) 1596 @param endLineNo number of the last line
1597 @type int
1535 """ 1598 """
1536 self.endlineno = endLineNo 1599 self.endlineno = endLineNo
1537 1600
1538 1601
1539 class Attribute(VisibilityBase): 1602 class Attribute(VisibilityBase):
1543 1606
1544 def __init__(self, module, name, file, lineno, isSignal=False): 1607 def __init__(self, module, name, file, lineno, isSignal=False):
1545 """ 1608 """
1546 Constructor 1609 Constructor
1547 1610
1548 @param module name of module containing this function (string) 1611 @param module name of module containing this function
1549 @param name name of the function (string) 1612 @type str
1550 @param file name of file containing this function (string) 1613 @param name name of the function
1551 @param lineno linenumber of the first attribute assignment (integer) 1614 @type str
1552 @param isSignal flag indicating a signal definition (boolean) 1615 @param file name of file containing this function
1616 @type str
1617 @param lineno linenumber of the first attribute assignment
1618 @type int
1619 @param isSignal flag indicating a signal definition
1620 @type bool
1553 """ 1621 """
1554 self.module = module 1622 self.module = module
1555 self.name = name 1623 self.name = name
1556 self.file = file 1624 self.file = file
1557 self.lineno = lineno 1625 self.lineno = lineno
1562 def addAssignment(self, lineno): 1630 def addAssignment(self, lineno):
1563 """ 1631 """
1564 Public method to add another assignment line number. 1632 Public method to add another assignment line number.
1565 1633
1566 @param lineno linenumber of the additional attribute assignment 1634 @param lineno linenumber of the additional attribute assignment
1567 (integer) 1635 @type int
1568 """ 1636 """
1569 if lineno not in self.linenos: 1637 if lineno not in self.linenos:
1570 self.linenos.append(lineno) 1638 self.linenos.append(lineno)
1571 1639
1572 1640
1584 1652
1585 The module is searched in path and sys.path, read and parsed. 1653 The module is searched in path and sys.path, read and parsed.
1586 If the module was parsed before, the information is taken 1654 If the module was parsed before, the information is taken
1587 from a cache in order to speed up processing. 1655 from a cache in order to speed up processing.
1588 1656
1589 @param module name of the module to be parsed (string) 1657 @param module name of the module to be parsed
1590 @param path search path for the module (list of strings) 1658 @type str
1659 @param path search path for the module
1660 @type list of str
1591 @param inpackage flag indicating that module is inside a 1661 @param inpackage flag indicating that module is inside a
1592 package (boolean) 1662 package
1663 @type bool
1593 @param basename a path basename that is deleted from the filename of 1664 @param basename a path basename that is deleted from the filename of
1594 the module file to be read (string) 1665 the module file to be read
1666 @type str
1595 @param extensions list of extensions, which should be considered valid 1667 @param extensions list of extensions, which should be considered valid
1596 source file extensions (list of strings) 1668 source file extensions
1669 @type list of str
1597 @param caching flag indicating that the parsed module should be 1670 @param caching flag indicating that the parsed module should be
1598 cached (boolean) 1671 cached
1672 @type bool
1599 @param ignoreBuiltinModules flag indicating to ignore the builtin modules 1673 @param ignoreBuiltinModules flag indicating to ignore the builtin modules
1600 (boolean) 1674 @type bool
1601 @return reference to a Module object containing the parsed 1675 @return reference to a Module object containing the parsed
1602 module information (Module) 1676 module information
1677 @rtype Module
1603 """ 1678 """
1604 global _modules 1679 global _modules
1605 1680
1606 _extensions = ( 1681 _extensions = (
1607 [".py", ".pyw", ".pyi", ".ptl", ".rb"] if extensions is None else extensions[:] 1682 [".py", ".pyw", ".pyi", ".ptl", ".rb"] if extensions is None else extensions[:]
1677 1752
1678 def _indent(ws): 1753 def _indent(ws):
1679 """ 1754 """
1680 Protected function to determine the indent width of a whitespace string. 1755 Protected function to determine the indent width of a whitespace string.
1681 1756
1682 @param ws The whitespace string to be cheked. (string) 1757 @param ws The whitespace string to be cheked.
1683 @return Length of the whitespace string after tab expansion. 1758 @type str
1759 @return length of the whitespace string after tab expansion
1760 @rtype int
1684 """ 1761 """
1685 return len(ws.expandtabs(TABWIDTH)) 1762 return len(ws.expandtabs(TABWIDTH))
1686 1763
1687 1764
1688 def find_module(name, path, extensions): 1765 def find_module(name, path, extensions):
1692 This function searches for files in the given path. If the filename 1769 This function searches for files in the given path. If the filename
1693 doesn't have an extension or an extension of .py, the normal search 1770 doesn't have an extension or an extension of .py, the normal search
1694 implemented in the imp module is used. For all other supported files 1771 implemented in the imp module is used. For all other supported files
1695 only path is searched. 1772 only path is searched.
1696 1773
1697 @param name filename or modulename to search for (string) 1774 @param name filename or modulename to search for
1698 @param path search path (list of strings) 1775 @type str
1776 @param path search path
1777 @type list of str
1699 @param extensions list of extensions, which should be considered valid 1778 @param extensions list of extensions, which should be considered valid
1700 source file extensions (list of strings) 1779 source file extensions
1780 @type list of str
1701 @return tuple of the open file, pathname and description. Description 1781 @return tuple of the open file, pathname and description. Description
1702 is a tuple of file suffix, file mode and file type) 1782 is a tuple of file suffix, file mode and file type)
1783 @rtype tuple
1703 @exception ImportError The file or module wasn't found. 1784 @exception ImportError The file or module wasn't found.
1704 """ 1785 """
1705 for ext in extensions: 1786 for ext in extensions:
1706 if name.lower().endswith(ext): 1787 if name.lower().endswith(ext):
1707 for p in path: # only search in path 1788 for p in path: # only search in path
1752 1833
1753 def resetParsedModule(module, basename=""): 1834 def resetParsedModule(module, basename=""):
1754 """ 1835 """
1755 Module function to clear one module from the list of parsed modules. 1836 Module function to clear one module from the list of parsed modules.
1756 1837
1757 @param module Name of the module to be parsed (string) 1838 @param module Name of the module to be parsed
1839 @type str
1758 @param basename a path basename. This basename is deleted from 1840 @param basename a path basename. This basename is deleted from
1759 the filename of the module file to be cleared. (string) 1841 the filename of the module file to be cleared.
1842 @type str
1760 """ 1843 """
1761 modname = module 1844 modname = module
1762 1845
1763 if os.path.exists(module): 1846 if os.path.exists(module):
1764 modulePath = [os.path.dirname(module)] 1847 modulePath = [os.path.dirname(module)]

eric ide

mercurial