Revision: 2923
Author: pekka.klarck
Date: Mon Apr 12 03:46:44 2010
Log: ignore bom in tsv and txt files
http://code.google.com/p/robotframework/source/detail?r=2923

Added:
 /trunk/atest/robot/parsing/ignore_bom.txt
 /trunk/atest/testdata/parsing/bom.tsv
 /trunk/atest/testdata/parsing/bom.txt
Modified:
 /trunk/src/robot/parsing/tsvreader.py

=======================================
--- /dev/null
+++ /trunk/atest/robot/parsing/ignore_bom.txt   Mon Apr 12 03:46:44 2010
@@ -0,0 +1,15 @@
+*** Settings ***
+Documentation Verify that byte order mark (BOM) is igored in TXT and TSV files
+Suite Setup    Run Tests  --include bomelo  parsing/bom.t??
+Force Tags     regression   pybot  jybot
+Resource       ../../resources/resource.txt
+
+
+*** Test Cases ***
+
+Byte order mark in plain text file
+    Check test case  ${TESTNAME}
+
+
+Byte order mark in TSV file
+    Check test case  ${TESTNAME}
=======================================
--- /dev/null
+++ /trunk/atest/testdata/parsing/bom.tsv       Mon Apr 12 03:46:44 2010
@@ -0,0 +1,10 @@
+*** Settings ***
+Documentation Example file in UTF-8 format with byte order mark (BOM) in the beginning. No RIDE!
+Library        Operating System
+Force Tags     bomelo
+
+*** Test Cases ***
+
+Byte order mark in TSV file
+       Log     Hyvää päivää €åppa!
+       Directory Should Exist  .
=======================================
--- /dev/null
+++ /trunk/atest/testdata/parsing/bom.txt       Mon Apr 12 03:46:44 2010
@@ -0,0 +1,11 @@
+*** Settings ***
+Documentation Example file in UTF-8 format with byte order mark (BOM) in the beginning. No RIDE!
+Library        Operating System
+Force Tags     bomelo
+
+
+*** Test Cases ***
+
+Byte order mark in plain text file
+    Log  Hyvää päivää €åppa!
+    Directory Should Exist  .
=======================================
--- /trunk/src/robot/parsing/tsvreader.py       Tue Mar 23 04:15:41 2010
+++ /trunk/src/robot/parsing/tsvreader.py       Mon Apr 12 03:46:44 2010
@@ -12,12 +12,16 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

+from codecs import BOM_UTF8
+

 class TsvReader:

     def read(self, tsvfile, rawdata):
         process = False
-        for row in tsvfile.readlines():
+        for index, row in enumerate(tsvfile.readlines()):
+            if index == 0 and row.startswith(BOM_UTF8):
+                row = row[len(BOM_UTF8):]
cells = [ self._process(cell) for cell in self._split_row(row) ]
             name = cells and cells[0].strip() or ''
if name.startswith('*') and rawdata.start_table(name.replace('*','')):


--
To unsubscribe, reply using "remove me" as the subject.

Reply via email to