Revision: 52650f0b77c8
Author: Janne Härkönen <[email protected]>
Date: Wed Jan 25 02:06:20 2012
Log: parsing: allow dir to be populated without recursion
http://code.google.com/p/robotframework/source/detail?r=52650f0b77c8
Modified:
/src/robot/parsing/model.py
/src/robot/parsing/populators.py
/src/robot/tidy.py
=======================================
--- /src/robot/parsing/model.py Tue Jan 24 20:55:20 2012
+++ /src/robot/parsing/model.py Wed Jan 25 02:06:20 2012
@@ -186,9 +186,9 @@
self.keyword_table = KeywordTable(self)
_TestData.__init__(self, parent, source)
- def populate(self, include_suites=[], warn_on_skipped=False):
+ def populate(self, include_suites=[], warn_on_skipped=False,
recurse=True):
FromDirectoryPopulator().populate(self.source, self,
include_suites,
- warn_on_skipped)
+ warn_on_skipped, recurse)
self.children = [ch for ch in self.children if ch.has_tests()]
return self
=======================================
--- /src/robot/parsing/populators.py Wed Dec 14 05:29:24 2011
+++ /src/robot/parsing/populators.py Wed Jan 25 02:06:20 2012
@@ -106,16 +106,25 @@
ignored_prefixes = ('_', '.')
ignored_dirs = ('CVS',)
- def populate(self, path, datadir, include_suites, warn_on_skipped):
+ def populate(self, path, datadir, include_suites, warn_on_skipped,
+ recurse=True):
LOGGER.info("Parsing test data directory '%s'" % path)
include_suites = self._get_include_suites(path, include_suites)
- initfile, children = self._get_children(path, include_suites)
- datadir.initfile = initfile
- if initfile:
- try:
- FromFilePopulator(datadir).populate(initfile)
- except DataError, err:
- LOGGER.error(unicode(err))
+ init_file, children = self._get_children(path, include_suites)
+ if init_file:
+ self._populate_init_file(datadir, init_file)
+ if recurse:
+ self._populate_chidren(datadir, children, include_suites,
+ warn_on_skipped)
+
+ def _populate_init_file(self, datadir, init_file):
+ datadir.initfile = init_file
+ try:
+ FromFilePopulator(datadir).populate(init_file)
+ except DataError, err:
+ LOGGER.error(unicode(err))
+
+ def _populate_chidren(self, datadir, children, include_suites,
warn_on_skipped):
for child in children:
try:
datadir.add_child(child, include_suites)
@@ -145,19 +154,19 @@
return self._is_in_included_suites(name, incl_suites)
def _get_children(self, dirpath, incl_suites):
- initfile = None
+ init_file = None
children = []
for name, path in self._list_dir(dirpath):
if self._is_init_file(name, path):
- if not initfile:
- initfile = path
+ if not init_file:
+ init_file = path
else:
LOGGER.error("Ignoring second test suite init
file '%s'." % path)
elif self._is_included(name, path, incl_suites):
children.append(path)
else:
LOGGER.info("Ignoring file or directory '%s'." % name)
- return initfile, children
+ return init_file, children
def _list_dir(self, path):
# os.listdir returns Unicode entries when path is Unicode
=======================================
--- /src/robot/tidy.py Tue Jan 24 23:39:37 2012
+++ /src/robot/tidy.py Wed Jan 25 02:06:20 2012
@@ -129,7 +129,8 @@
def _create_datafile(self, source):
if self._is_init_file(source):
- return self._create_init_file(source)
+ dir_ = os.path.dirname(source)
+ return TestDataDirectory(source=dir_).populate(recurse=False)
try:
return TestCaseFile(source=source).populate()
except DataError:
@@ -141,13 +142,6 @@
def _is_init_file(self, source):
return os.path.splitext(os.path.basename(source))[0] == '__init__'
- def _create_init_file(self, source):
- data = TestDataDirectory()
- data.source = os.path.dirname(source)
- data.initfile = source
- FromFilePopulator(data).populate(source)
- return data
-
class TidyCommandLine(object):