[Checkins] SVN: martian/trunk/ Skip bogus modules and packages when scanning.
Martijn Faassen
faassen at infrae.com
Thu Dec 11 11:30:08 EST 2008
Log message for revision 93911:
Skip bogus modules and packages when scanning.
This should fix: https://bugs.launchpad.net/grok/+bug/275341
Changed:
U martian/trunk/CHANGES.txt
U martian/trunk/src/martian/scan.py
U martian/trunk/src/martian/scan.txt
A martian/trunk/src/martian/tests/withbogusmodules/
A martian/trunk/src/martian/tests/withbogusmodules/.bogus.py
A martian/trunk/src/martian/tests/withbogusmodules/.bogussubpackage/
A martian/trunk/src/martian/tests/withbogusmodules/.bogussubpackage/__init__.py
A martian/trunk/src/martian/tests/withbogusmodules/1alsobogus.py
A martian/trunk/src/martian/tests/withbogusmodules/__init__.py
A martian/trunk/src/martian/tests/withbogusmodules/nonbogus.py
A martian/trunk/src/martian/tests/withbogusmodules/subpackage/
A martian/trunk/src/martian/tests/withbogusmodules/subpackage/__init__.py
-=-
Modified: martian/trunk/CHANGES.txt
===================================================================
--- martian/trunk/CHANGES.txt 2008-12-11 16:09:26 UTC (rev 93910)
+++ martian/trunk/CHANGES.txt 2008-12-11 16:30:08 UTC (rev 93911)
@@ -4,8 +4,13 @@
0.12 (unreleased)
=================
-* ...
+Bugs fixed
+----------
+* Ignore things that look like Python modules and packages but aren't.
+ These are sometimes created by editors, operating systems and
+ network file systems and we don't want to confuse them.
+
0.11 (2008-09-24)
=================
Modified: martian/trunk/src/martian/scan.py
===================================================================
--- martian/trunk/src/martian/scan.py 2008-12-11 16:09:26 UTC (rev 93910)
+++ martian/trunk/src/martian/scan.py 2008-12-11 16:30:08 UTC (rev 93911)
@@ -72,6 +72,11 @@
module_infos = []
seen = []
for entry in sorted(os.listdir(directory)):
+ # we are only interested in things that are potentially
+ # python modules or packages, and therefore start with a
+ # letter or _
+ if not entry[0].isalpha() and entry[0] != '_':
+ continue
entry_path = os.path.join(directory, entry)
name, ext = os.path.splitext(entry)
dotted_name = self.dotted_name + '.' + name
Modified: martian/trunk/src/martian/scan.txt
===================================================================
--- martian/trunk/src/martian/scan.txt 2008-12-11 16:09:26 UTC (rev 93910)
+++ martian/trunk/src/martian/scan.txt 2008-12-11 16:30:08 UTC (rev 93911)
@@ -197,3 +197,22 @@
>>> print module_info.getSubModuleInfos()
[<ModuleInfo object for 'martian.tests.withtestsmodules.subpackage'>]
+Non-modules that look like modules
+----------------------------------
+
+Sometimes the environment (an editor or network file system, for
+instance) will create a situation where there is a file or directory
+that looks like a Python module or package but is in fact not really
+one (file name starts with a dot, for instance). Module and package
+names must be valid Python identifiers.
+
+The package ``martian.tests.withbogusmodules`` contains only one real
+module and one real package. The rest are almost right, but do not
+start with an underscore and a letter and are therefore not valid. We
+will see that Martian will ignore these other things::
+
+ >>> module_info = module_info_from_dotted_name(
+ ... 'martian.tests.withbogusmodules')
+ >>> module_info.getSubModuleInfos()
+ [<ModuleInfo object for 'martian.tests.withbogusmodules.nonbogus'>,
+ <ModuleInfo object for 'martian.tests.withbogusmodules.subpackage'>]
Added: martian/trunk/src/martian/tests/withbogusmodules/.bogus.py
===================================================================
--- martian/trunk/src/martian/tests/withbogusmodules/.bogus.py (rev 0)
+++ martian/trunk/src/martian/tests/withbogusmodules/.bogus.py 2008-12-11 16:30:08 UTC (rev 93911)
@@ -0,0 +1,2 @@
+# starts with a dot so not really a python module
+
Added: martian/trunk/src/martian/tests/withbogusmodules/1alsobogus.py
===================================================================
--- martian/trunk/src/martian/tests/withbogusmodules/1alsobogus.py (rev 0)
+++ martian/trunk/src/martian/tests/withbogusmodules/1alsobogus.py 2008-12-11 16:30:08 UTC (rev 93911)
@@ -0,0 +1,2 @@
+# also bogus
+
Added: martian/trunk/src/martian/tests/withbogusmodules/nonbogus.py
===================================================================
--- martian/trunk/src/martian/tests/withbogusmodules/nonbogus.py (rev 0)
+++ martian/trunk/src/martian/tests/withbogusmodules/nonbogus.py 2008-12-11 16:30:08 UTC (rev 93911)
@@ -0,0 +1 @@
+# really a python module.
More information about the Checkins
mailing list