Skip to content

Commit

Permalink
fixed #47
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBender committed Aug 25, 2015
2 parents 5867420 + a0535f6 commit cda30b3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
10 changes: 7 additions & 3 deletions py25/bacpypes/primitivedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,11 +1248,15 @@ def __init__(self, arg=None, hour=255, minute=255, second=255, hundredth=255):
raise ValueError("invalid time pattern")

tup_list = []
for s in tup_match:
tup_items = list(tup_match.groups())
for s in tup_items:
if s == '*':
tup_list.append(255)
elif s in None:
tup_list.append(0)
elif s is None:
if '*' in tup_items:
tup_list.append(255)
else:
tup_list.append(0)
else:
tup_list.append(int(s))

Expand Down
10 changes: 7 additions & 3 deletions py27/bacpypes/primitivedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,11 +1248,15 @@ def __init__(self, arg=None, hour=255, minute=255, second=255, hundredth=255):
raise ValueError("invalid time pattern")

tup_list = []
for s in tup_match:
tup_items = list(tup_match.groups())
for s in tup_items:
if s == '*':
tup_list.append(255)
elif s in None:
tup_list.append(0)
elif s is None:
if '*' in tup_items:
tup_list.append(255)
else:
tup_list.append(0)
else:
tup_list.append(int(s))

Expand Down
10 changes: 7 additions & 3 deletions py34/bacpypes/primitivedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,11 +1259,15 @@ def __init__(self, arg=None, hour=255, minute=255, second=255, hundredth=255):
raise ValueError("invalid time pattern")

tup_list = []
for s in tup_match:
tup_items = list(tup_match.groups())
for s in tup_items:
if s == '*':
tup_list.append(255)
elif s in None:
tup_list.append(0)
elif s is None:
if '*' in tup_items:
tup_list.append(255)
else:
tup_list.append(0)
else:
tup_list.append(int(s))

Expand Down
9 changes: 6 additions & 3 deletions tests/test_primitive_data/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,12 @@ def test_time_tuple(self):
assert obj.value == (1, 2, 3, 4)
assert str(obj) == "Time(01:02:03.04)"

### issue-47
# obj = Time("01:02:03.04")
# assert obj.value == (1, 2, 3, 4)
assert Time("1:2").value == (1, 2, 0, 0)
assert Time("1:2:3").value == (1, 2, 3, 0)
assert Time("1:2:3.4").value == (1, 2, 3, 40)
assert Time("1:*").value == (1, 255, 255, 255)
assert Time("1:2:*").value == (1, 2, 255, 255)
assert Time("1:2:3.*").value == (1, 2, 3, 255)

def test_time_tag(self):
if _debug: TestTime._debug("test_time_tag")
Expand Down

0 comments on commit cda30b3

Please sign in to comment.