3 new revisions:
Revision: 9de8cf8608e2
Author: Janne Härkönen <[email protected]>
Date: Wed Nov 9 06:45:56 2011
Log: parsing.model: added some docstrings
http://code.google.com/p/robotframework/source/detail?r=9de8cf8608e2
Revision: 473ddad20299
Author: Janne Härkönen <[email protected]>
Date: Wed Nov 9 06:47:04 2011
Log: writer.__init__: expose correct public API
http://code.google.com/p/robotframework/source/detail?r=473ddad20299
Revision: f0dabc37d516
Author: Janne Härkönen <[email protected]>
Date: Wed Nov 9 06:47:29 2011
Log: writer: cleanup and docstrings
http://code.google.com/p/robotframework/source/detail?r=f0dabc37d516
==============================================================================
Revision: 9de8cf8608e2
Author: Janne Härkönen <[email protected]>
Date: Wed Nov 9 06:45:56 2011
Log: parsing.model: added some docstrings
http://code.google.com/p/robotframework/source/detail?r=9de8cf8608e2
Modified:
/src/robot/parsing/model.py
=======================================
--- /src/robot/parsing/model.py Tue Nov 8 23:08:46 2011
+++ /src/robot/parsing/model.py Wed Nov 9 06:45:56 2011
@@ -19,16 +19,18 @@
from robot.variables import is_var
from robot.output import LOGGER
from robot import utils
-from robot.writer.serializer import Serializer, SerializationContext
+from robot.writer.serializer import Serializer
from settings import (Documentation, Fixture, Timeout, Tags, Metadata,
Library, Resource, Variables, Arguments, Return, Template, Comment)
from populators import FromFilePopulator, FromDirectoryPopulator
-def TestData(parent=None, source=None, include_suites=[],
warn_on_skipped=False):
+def TestData(parent=None, source=None, include_suites=[],
+ warn_on_skipped=False):
if os.path.isdir(source):
- return TestDataDirectory(parent, source).populate(include_suites,
warn_on_skipped)
+ return TestDataDirectory(parent, source).populate(include_suites,
+ warn_on_skipped)
return TestCaseFile(parent, source).populate()
@@ -94,13 +96,18 @@
def save(self, **options):
"""Serializes this datafile.
- :param **options: Configuration for serialization. Any optional
arguments
- of robot.writer.serializer.SerializationContext can be given.
+ :param options: Configuration for serialization. These arguments
are
+ passed to
+ :py:class:`~robot.writer.serializer.SerializationContext` as
+ keyword arguments.
+
+ See also :py:meth:`robot.writer.serializer.Serializer.serialize`
"""
Serializer().serialize(self, **options)
class TestCaseFile(_TestData):
+ """The parsed test case file object."""
def __init__(self, parent=None, source=None):
self.directory = os.path.dirname(source) if source else None
@@ -132,6 +139,7 @@
class ResourceFile(_TestData):
+ """The parsed resource file object."""
def __init__(self, source=None):
self.directory = os.path.dirname(source) if source else None
@@ -165,6 +173,10 @@
class TestDataDirectory(_TestData):
+ """The parsed test data directory object. Contains hiearchical
structure
+ of other :py:class:`.TestDataDirectory` and :py:class:`.TestCaseFile`
+ objects.
+ """
def __init__(self, parent=None, source=None):
self.directory = source
==============================================================================
Revision: 473ddad20299
Author: Janne Härkönen <[email protected]>
Date: Wed Nov 9 06:47:04 2011
Log: writer.__init__: expose correct public API
http://code.google.com/p/robotframework/source/detail?r=473ddad20299
Modified:
/src/robot/writer/__init__.py
=======================================
--- /src/robot/writer/__init__.py Fri Oct 21 00:37:35 2011
+++ /src/robot/writer/__init__.py Wed Nov 9 06:47:04 2011
@@ -1,16 +1,15 @@
# Copyright 2008-2011 Nokia Siemens Networks Oyj
-#
+#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from writer import FileWriter
+from serializer import Serializer
==============================================================================
Revision: f0dabc37d516
Author: Janne Härkönen <[email protected]>
Date: Wed Nov 9 06:47:29 2011
Log: writer: cleanup and docstrings
http://code.google.com/p/robotframework/source/detail?r=f0dabc37d516
Modified:
/src/robot/writer/serializer.py
/src/robot/writer/writer.py
=======================================
--- /src/robot/writer/serializer.py Tue Nov 8 23:08:46 2011
+++ /src/robot/writer/serializer.py Wed Nov 9 06:47:29 2011
@@ -17,62 +17,16 @@
from writer import FileWriter
-class SerializationContext(object):
-
- def __init__(self, datafile, output=None, format=None,
pipe_separated=False,
- line_separator=os.linesep):
- """The SerializationContext class holds the needed information for
- serializing test data files. It contains a references to the data
file to
- be serialized and to serialization options.
-
- :param datafile: The datafile to be serialized.
- :type datafile: TestCaseFile, ResourceFile, TestDataDirectory
- :param output: An open, file-like object used in serialization. If
not
- given, value of `source` attribute of the given `datafile` is
used
- to construct a new file object.
- :param str format: Serialization format. If not given, read from
the
- extension of the `source` attribute of the given `datafile`.
- :param bool pipe_separated: Whether to use pipes as separator when
- serialization format is txt.
- :param str line_separator: Line separator used in serialization.
- """
- self.datafile = datafile
- self.pipe_separated = pipe_separated
- self.line_separator = line_separator
- self._given_output = output
- self._output = output
- self._format = format
-
- def finish(self):
- if self._given_output is None:
- self._output.close()
-
- @property
- def output(self):
- if not self._output:
- self._output = open(self._get_source(), 'wb')
- return self._output
-
- @property
- def format(self):
- return self._format or self._format_from_file()
-
- def _get_source(self):
- return getattr(self.datafile, 'initfile', self.datafile.source)
-
- def _format_from_file(self):
- return os.path.splitext(self._get_source())[1][1:].lower()
-
-
class Serializer(object):
- """The Serializer class is used to serialize Robot Framework test data
files.
+ """The Serializer object. It is used to serialize Robot Framework test
+ data files.
"""
def serialize(self, datafile, **options):
"""Serializes given `datafile` using `**options`.
:param datafile: A robot.parsing.model.DataFile object to be
serialized
- :param **options: A SerializationContext is initialized based on
these
+ :param options: A :py:class:`.SerializationContext` is initialized
based on these
"""
context = SerializationContext(datafile, **options)
self._writer = FileWriter(context)
@@ -130,3 +84,54 @@
self._writer.start_testcase(tc)
self._serialize_elements(tc)
self._writer.end_testcase()
+
+
+class SerializationContext(object):
+ """The SerializationContext object. It holds needed information for
+ serializing a test data file.
+ """
+
+ def __init__(self, datafile, output=None, format=None,
pipe_separated=False,
+ line_separator=os.linesep):
+ """
+ :param datafile: The datafile to be serialized.
+ :type datafile: :py:class:`~robot.parsing.model.TestCaseFile`,
+ :py:class:`~robot.parsing.model.ResourceFile`,
+ :py:class:`~robot.parsing.model.TestDataDirectory`
+ :param output: An open, file-like object used in serialization. If
not
+ given, value of `source` attribute of the given `datafile` is
used
+ to construct a new file object.
+ :param str format: Serialization format. If not given, read from
the
+ extension of the `source` attribute of the given `datafile`.
+ :param bool pipe_separated: Whether to use pipes as separator when
+ serialization format is txt.
+ :param str line_separator: Line separator used in serialization.
+ """
+ self.datafile = datafile
+ self.pipe_separated = pipe_separated
+ self.line_separator = line_separator
+ self._given_output = output
+ self._output = output
+ self._format = format
+
+ def finish(self):
+ if self._given_output is None:
+ self._output.close()
+
+ @property
+ def output(self):
+ if not self._output:
+ self._output = open(self._get_source(), 'wb')
+ return self._output
+
+ @property
+ def format(self):
+ return self._format or self._format_from_file()
+
+ def _get_source(self):
+ return getattr(self.datafile, 'initfile', self.datafile.source)
+
+ def _format_from_file(self):
+ return os.path.splitext(self._get_source())[1][1:].lower()
+
+
=======================================
--- /src/robot/writer/writer.py Sat Oct 22 23:54:02 2011
+++ /src/robot/writer/writer.py Wed Nov 9 06:47:29 2011
@@ -22,6 +22,13 @@
def FileWriter(serialization_context):
+ """Creates and returns a FileWriter object.
+
+ :param serialization_context: Type of returned
+ FileWriter is determined based on `serialization_context.format`.
+ Is also passed along to created writer for further configuration.
+ :type serialization_context: :py:class:`SerializationContext`
+ """
Writer = {
'tsv': TsvFileWriter,
'txt': TxtFileWriter,