[Epydoc-commits] SF.net SVN: epydoc: [1253] trunk/epydoc/src/epydoc
Brought to you by:
edloper
From: <ed...@us...> - 2006-08-21 07:16:21
|
Revision: 1253 Author: edloper Date: 2006-08-21 00:16:15 -0700 (Mon, 21 Aug 2006) ViewCVS: http://svn.sourceforge.net/epydoc/?rev=1253&view=rev Log Message: ----------- - Changed all cases where UNKNOWN was tested with == or != to use "is" and "is not" instead. (UNKNOWN is defined to be a unique value, so it should always be tested by identity, like None). This should fix sf bug #1506850. Modified Paths: -------------- trunk/epydoc/src/epydoc/apidoc.py trunk/epydoc/src/epydoc/cli.py trunk/epydoc/src/epydoc/docbuilder.py trunk/epydoc/src/epydoc/docintrospecter.py trunk/epydoc/src/epydoc/docparser.py trunk/epydoc/src/epydoc/docstringparser.py Modified: trunk/epydoc/src/epydoc/apidoc.py =================================================================== --- trunk/epydoc/src/epydoc/apidoc.py 2006-08-21 07:04:18 UTC (rev 1252) +++ trunk/epydoc/src/epydoc/apidoc.py 2006-08-21 07:16:15 UTC (rev 1253) @@ -722,7 +722,7 @@ or UNKNOWN if we don't succeed. This should probably eventually be replaced by more of a safe-repr variant. """ - if self.pyval == UNKNOWN: + if self.pyval is UNKNOWN: return UNKNOWN try: s = '%r' % self.pyval @@ -798,7 +798,7 @@ def __init__(self, **kwargs): kwargs.setdefault('variables', {}) APIDoc.__init__(self, **kwargs) - assert self.variables != UNKNOWN + assert self.variables is not UNKNOWN def apidoc_links(self, **filters): variables = filters.get('variables', True) @@ -854,7 +854,7 @@ Initialize the L{variable_groups} attribute, based on the L{sorted_variables} and L{group_specs} attributes. """ - if self.sorted_variables == UNKNOWN: + if self.sorted_variables is UNKNOWN: self.init_sorted_variables assert len(self.sorted_variables) == len(self.variables) @@ -1008,8 +1008,8 @@ variables that do not belong to any group. @type group: C{string} """ - if (self.sorted_variables == UNKNOWN or - self.variable_groups == UNKNOWN): + if (self.sorted_variables is UNKNOWN or + self.variable_groups is UNKNOWN): raise ValueError('sorted_variables and variable_groups ' 'must be initialized first.') @@ -1199,8 +1199,8 @@ local variables; if C{True}, then return only inherited variables; if C{False}, then return only local variables. """ - if (self.sorted_variables == UNKNOWN or - self.variable_groups == UNKNOWN): + if (self.sorted_variables is UNKNOWN or + self.variable_groups is UNKNOWN): raise ValueError('sorted_variables and variable_groups ' 'must be initialized first.') @@ -1528,7 +1528,7 @@ child_var = val_doc.variables.get(identifier) if child_var is not None: child_val = child_var.value - if child_val == UNKNOWN: child_val = None + if child_val is UNKNOWN: child_val = None return child_var, child_val # If that fails, then see if it's a submodule. @@ -1627,7 +1627,7 @@ return api_doc.container if len(api_doc.canonical_name) == 1: return None - elif isinstance(api_doc, ModuleDoc) and api_doc.package != UNKNOWN: + elif isinstance(api_doc, ModuleDoc) and api_doc.package is not UNKNOWN: return api_doc.package else: parent = api_doc.canonical_name.container() Modified: trunk/epydoc/src/epydoc/cli.py =================================================================== --- trunk/epydoc/src/epydoc/cli.py 2006-08-21 07:04:18 UTC (rev 1252) +++ trunk/epydoc/src/epydoc/cli.py 2006-08-21 07:16:15 UTC (rev 1253) @@ -939,7 +939,7 @@ p = ((sum(self.stages[:i]) + percent*self.stages[i]) / float(sum(self.stages))) - if message == UNKNOWN: message = None + if message is UNKNOWN: message = None if message: message = '%s: %s' % (self.task, message) ConsoleLogger.progress(self, p, message) Modified: trunk/epydoc/src/epydoc/docbuilder.py =================================================================== --- trunk/epydoc/src/epydoc/docbuilder.py 2006-08-21 07:04:18 UTC (rev 1252) +++ trunk/epydoc/src/epydoc/docbuilder.py 2006-08-21 07:16:15 UTC (rev 1253) @@ -218,7 +218,7 @@ def _report_valdoc_progress(i, val_doc, val_docs): if (isinstance(val_doc, (ModuleDoc, ClassDoc)) and - val_doc.canonical_name != UNKNOWN and + val_doc.canonical_name is not UNKNOWN and not val_doc.canonical_name[0].startswith('??')): log.progress(float(i)/len(val_docs), val_doc.canonical_name) @@ -731,7 +731,7 @@ def _merge_posargs_and_defaults(introspect_doc, parse_doc, path): # If either is unknown, then let merge_attrib handle it. - if introspect_doc.posargs == UNKNOWN or parse_doc.posargs == UNKNOWN: + if introspect_doc.posargs is UNKNOWN or parse_doc.posargs is UNKNOWN: return # If the introspected doc just has '...', then trust the parsed doc. @@ -877,7 +877,7 @@ return defaults def merge_docstring(docstring1, docstring2, precedence, cyclecheck, path): - if docstring1 in (None, UNKNOWN) or precedence=='parse': + if docstring1 is None or docstring1 is UNKNOWN or precedence=='parse': return docstring2 else: return docstring1 @@ -1116,7 +1116,7 @@ # local, then record the fact that it overrides # var_doc. elif (class_doc.variables[name].container==class_doc and - class_doc.variables[name].overrides==UNKNOWN): + class_doc.variables[name].overrides is UNKNOWN): class_doc.variables[name].overrides = var_doc _inherit_info(class_doc.variables[name]) Modified: trunk/epydoc/src/epydoc/docintrospecter.py =================================================================== --- trunk/epydoc/src/epydoc/docintrospecter.py 2006-08-21 07:04:18 UTC (rev 1252) +++ trunk/epydoc/src/epydoc/docintrospecter.py 2006-08-21 07:16:15 UTC (rev 1253) @@ -149,7 +149,7 @@ introspect_func(value, val_doc) # Set canonical name, if it was given - if val_doc.canonical_name == UNKNOWN and name is not None: + if val_doc.canonical_name is UNKNOWN and name is not None: val_doc.canonical_name = DottedName(name) # If we were given a filename, but didn't manage to get a @@ -160,7 +160,7 @@ if is_script and filename is not None: val_doc.canonical_name = DottedName(munge_script_name(str(filename))) - if val_doc.canonical_name == UNKNOWN and filename is not None: + if val_doc.canonical_name is UNKNOWN and filename is not None: shadowed_name = DottedName(value.__name__) log.warning("Module %s is shadowed by a variable with " "the same name." % shadowed_name) @@ -583,7 +583,7 @@ Verify the name. E.g., if it's a nested class, then we won't be able to find it with the name we constructed. """ - if dotted_name == UNKNOWN: return UNKNOWN + if dotted_name is UNKNOWN: return UNKNOWN if len(dotted_name) == 1 and hasattr(__builtin__, dotted_name[0]): return dotted_name named_value = sys.modules.get(dotted_name[0]) @@ -864,7 +864,7 @@ """ if api_doc.docstring_lineno is not UNKNOWN: return api_doc.docstring_lineno - if isinstance(api_doc, ValueDoc) and api_doc.pyval != UNKNOWN: + if isinstance(api_doc, ValueDoc) and api_doc.pyval is not UNKNOWN: try: lines, lineno = inspect.findsource(api_doc.pyval) if not isinstance(api_doc, ModuleDoc): lineno += 1 Modified: trunk/epydoc/src/epydoc/docparser.py =================================================================== --- trunk/epydoc/src/epydoc/docparser.py 2006-08-21 07:04:18 UTC (rev 1252) +++ trunk/epydoc/src/epydoc/docparser.py 2006-08-21 07:16:15 UTC (rev 1253) @@ -234,7 +234,7 @@ "with filename, not with name.") name = DottedName(name) val_doc = _find(name) - if val_doc.canonical_name == UNKNOWN: + if val_doc.canonical_name is UNKNOWN: val_doc.canonical_name = name return val_doc @@ -451,7 +451,7 @@ raise ImportError('Could not find value') def _get_filename(identifier, path=None): - if path == UNKNOWN: path = None + if path is UNKNOWN: path = None try: fp, filename, (s,m,typ) = imp.find_module(identifier, path) if fp is not None: fp.close() @@ -672,7 +672,7 @@ decorators = [] def add_to_group(container, api_doc, group_name): - if container.group_specs == UNKNOWN: + if container.group_specs is UNKNOWN: container.group_specs = [] if isinstance(api_doc, VariableDoc): @@ -1545,7 +1545,7 @@ #raise ParseError("Could not find %s" % name) # If the variable has a value, return that value. - if base_var.value != UNKNOWN: + if base_var.value is not UNKNOWN: return base_var.value # Otherwise, if BASE_HANDLING is 'parse', try parsing the docs for @@ -1766,7 +1766,7 @@ namespace.sort_spec.remove(var_doc.name) old_var_doc = namespace.variables[var_doc.name] if (old_var_doc.is_alias == False and - old_var_doc.value != UNKNOWN): + old_var_doc.value is not UNKNOWN): old_var_doc.value.canonical_name = UNKNOWN if (preserve_docstring and var_doc.docstring in (None, UNKNOWN) and old_var_doc.docstring not in (None, UNKNOWN)): @@ -1860,7 +1860,7 @@ if isinstance(var_doc.value, NamespaceDoc): var_dict = var_doc.value.variables - elif (var_doc.value == UNKNOWN and + elif (var_doc.value is UNKNOWN and var_doc.imported_from not in (None, UNKNOWN)): src_name = var_doc.imported_from + dotted_name[i:] # [xx] do I want to create a proxy here?? Modified: trunk/epydoc/src/epydoc/docstringparser.py =================================================================== --- trunk/epydoc/src/epydoc/docstringparser.py 2006-08-21 07:04:18 UTC (rev 1252) +++ trunk/epydoc/src/epydoc/docstringparser.py 2006-08-21 07:16:15 UTC (rev 1253) @@ -251,7 +251,7 @@ # filename of its containing module. name = api_doc.canonical_name module = api_doc.defining_module - if module != UNKNOWN and module.filename not in (None, UNKNOWN): + if module is not UNKNOWN and module.filename not in (None, UNKNOWN): try: filename = py_src_filename(module.filename) except: filename = module.filename else: @@ -629,7 +629,7 @@ # Find the module that defines api_doc. module = api_doc.defining_module # Look up its docformat. - if module != UNKNOWN and module.docformat not in (None, UNKNOWN): + if module is not UNKNOWN and module.docformat not in (None, UNKNOWN): docformat = module.docformat else: docformat = DEFAULT_DOCFORMAT This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |