Skip to content

Commit fdfd96e

Browse files
committed
move s7util to util, fix travis
1 parent bcea3f5 commit fdfd96e

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

example/example.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def show_row(x):
3535

3636
while True:
3737
data = get_db_row(1, 4 + x * row_size, row_size)
38-
row = s7util.db.DB_Row(data, rc_if_db_1_layout,
38+
row = snap7.util.DB_Row(data, rc_if_db_1_layout,
3939
layout_offset=4)
4040
print 'name', row['RC_IF_NAME']
4141
print row['RC_IF_NAME']
@@ -48,7 +48,7 @@ def show_row(x):
4848
def get_row(x):
4949
row_size = 126
5050
data = get_db_row(1, 4 + x * row_size, row_size)
51-
row = s7util.db.DB_Row(data, rc_if_db_1_layout,
51+
row = snap7.util.DB_Row(data, rc_if_db_1_layout,
5252
layout_offset=4)
5353
return row
5454

@@ -154,7 +154,7 @@ def make_item_db(x):
154154
t = time.time()
155155
all_data = client.db_upload(x)
156156
print 'getting all data took: ', time.time() - t
157-
db1 = s7util.db.DB(x, all_data, rc_if_db_1_layout,
157+
db1 = snap7.util.DB(x, all_data, rc_if_db_1_layout,
158158
126, 450, id_field='RC_IF_NAME',
159159
layout_offset=4,
160160
db_offset=4)
@@ -163,7 +163,7 @@ def make_item_db(x):
163163

164164
def make_tank_db():
165165
tank_data = client.db_upload(73)
166-
db73 = s7util.db.DB(73, tank_data, tank_rc_if_db_layout,
166+
db73 = snap7.util.DB(73, tank_data, tank_rc_if_db_layout,
167167
238, 2, id_field='RC_IF_NAME')
168168
return db73
169169

snap7/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
import snap7.error as error
77
import snap7.types as types
88
import snap7.common as common
9-
import snap7.s7util as s7util
9+
import snap7.util as util
1010

1111
__version__ = '0.2'

snap7/s7util/__init__.py

-1
This file was deleted.

snap7/s7util/db.py snap7/util.py

File renamed without changes.

test/test_s7util.py test/test_util.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
2-
from snap7.s7util import db
31
import unittest
42
import re
53

4+
from snap7 import util
5+
6+
67
test_spec = """
78
89
4 ID INT
@@ -38,38 +39,38 @@ def test_get_string(self):
3839
"""
3940
test_array = bytearray(_bytearray)
4041

41-
row = db.DB_Row(test_array, test_spec, layout_offset=4)
42+
row = util.DB_Row(test_array, test_spec, layout_offset=4)
4243
self.assertTrue(row['NAME'] == 'test')
4344

4445
def test_write_string(self):
4546
test_array = bytearray(_bytearray)
46-
row = db.DB_Row(test_array, test_spec, layout_offset=4)
47+
row = util.DB_Row(test_array, test_spec, layout_offset=4)
4748
row['NAME'] = 'abc'
4849
self.assertTrue(row['NAME'] == 'abc')
4950
row['NAME'] = ''
5051
self.assertTrue(row['NAME'] == '')
5152

5253
def test_get_int(self):
5354
test_array = bytearray(_bytearray)
54-
row = db.DB_Row(test_array, test_spec, layout_offset=4)
55+
row = util.DB_Row(test_array, test_spec, layout_offset=4)
5556
x = row['ID']
5657
self.assertTrue(x == 0)
5758

5859
def test_set_int(self):
5960
test_array = bytearray(_bytearray)
60-
row = db.DB_Row(test_array, test_spec, layout_offset=4)
61+
row = util.DB_Row(test_array, test_spec, layout_offset=4)
6162
row['ID'] = 259
6263
self.assertTrue(row['ID'] == 259)
6364

6465
def test_get_bool(self):
6566
test_array = bytearray(_bytearray)
66-
row = db.DB_Row(test_array, test_spec, layout_offset=4)
67+
row = util.DB_Row(test_array, test_spec, layout_offset=4)
6768
self.assertTrue(row['testbool1'] == 1)
6869
self.assertTrue(row['testbool8'] == 0)
6970

7071
def test_set_bool(self):
7172
test_array = bytearray(_bytearray)
72-
row = db.DB_Row(test_array, test_spec, layout_offset=4)
73+
row = util.DB_Row(test_array, test_spec, layout_offset=4)
7374
row['testbool8'] = 1
7475
row['testbool1'] = 0
7576

@@ -79,7 +80,7 @@ def test_set_bool(self):
7980
def test_db_creation(self):
8081
test_array = bytearray(_bytearray * 10)
8182

82-
test_db = db.DB(1, test_array, test_spec,
83+
test_db = util.DB(1, test_array, test_spec,
8384
row_size=len(_bytearray),
8485
size=10,
8586
layout_offset=4,
@@ -102,29 +103,29 @@ def test_db_creation(self):
102103

103104
def test_get_real(self):
104105
test_array = bytearray(_bytearray)
105-
row = db.DB_Row(test_array, test_spec, layout_offset=4)
106+
row = util.DB_Row(test_array, test_spec, layout_offset=4)
106107
self.assertTrue(0.01 > (row['testReal'] - 827.3) > -0.1)
107108

108109
def test_set_real(self):
109110
test_array = bytearray(_bytearray)
110-
row = db.DB_Row(test_array, test_spec, layout_offset=4)
111+
row = util.DB_Row(test_array, test_spec, layout_offset=4)
111112
row['testReal'] = 1337.1337
112113
self.assertTrue(0.01 > (row['testReal'] - 1337.1337) > -0.01)
113114

114115
def test_set_dword(self):
115116
test_array = bytearray(_bytearray)
116-
row = db.DB_Row(test_array, test_spec, layout_offset=4)
117+
row = util.DB_Row(test_array, test_spec, layout_offset=4)
117118
row['testDword'] = 9999999
118119
self.assertTrue(row['testDword'] == 9999999)
119120

120121
def test_get_dword(self):
121122
test_array = bytearray(_bytearray)
122-
row = db.DB_Row(test_array, test_spec, layout_offset=4)
123+
row = util.DB_Row(test_array, test_spec, layout_offset=4)
123124
self.assertTrue(row['testDword'] == 869486148)
124125

125126
def test_export(self):
126127
test_array = bytearray(_bytearray)
127-
row = db.DB_Row(test_array, test_spec, layout_offset=4)
128+
row = util.DB_Row(test_array, test_spec, layout_offset=4)
128129
data = row.export()
129130
self.assertTrue('testDword' in data)
130131
self.assertTrue('testbool1' in data)

0 commit comments

Comments
 (0)