Skip to content

Commit

Permalink
python3: Iso8601 print_function
Browse files Browse the repository at this point in the history
Moves Iso8601 to using the print_function.
NOTE(should not use print at all here)

partial: vmware#55
  • Loading branch information
hartsock committed Jul 28, 2014
1 parent 8ee385a commit a8c1be6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pyVmomi/Iso8601.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# 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 __future__ import print_function
# TODO (hartsocks): Introduce logging to remove the need for print function.
"""
This module is for ISO 8601 parsing
"""
Expand Down Expand Up @@ -253,7 +254,7 @@ def ISO8601Format(dt):
]:
dt = ParseISO8601(testStr)
if dt == None:
print 'Failed to parse (%s)' % testStr
print('Failed to parse ({0})'.format(testStr))
assert(False)

# Make sure we can translate back
Expand All @@ -262,16 +263,16 @@ def ISO8601Format(dt):
if dt.tzinfo is None:
dt = dt.replace(tzinfo=dt1.tzinfo)
if dt1 != dt:
print 'ParseISO8601 -> ISO8601Format -> ParseISO8601 failed (%s)' % testStr
print('ParseISO8601 -> ISO8601Format -> ParseISO8601 failed ({0})'.format(testStr))
assert(False)

# Make sure we can parse python isoformat()
dt2 = ParseISO8601(dt.isoformat())
if dt2 == None:
print 'ParseISO8601("%s".isoformat()) failed' % testStr
print('ParseISO8601("{0}".isoformat()) failed'.format(testStr))
assert(False)

print testStr, '->', dt, isoformat
print(testStr, '->', dt, isoformat)

# Basic form
for testStr in [
Expand All @@ -293,7 +294,7 @@ def ISO8601Format(dt):
# Reject for now
dt = ParseISO8601(testStr)
if dt != None:
print 'ParseISO8601 (%s) should fail, but it did not' % testStr
print('ParseISO8601 ({0}) should fail, but it did not'.format(testStr))
assert(False)
#print testStr, '->', dt
#assert(dt != None)
Expand Down Expand Up @@ -352,5 +353,5 @@ def ISO8601Format(dt):
]:
dt = ParseISO8601(testStr)
if dt != None:
print 'ParseISO8601 (%s) should fail, but it did not' % testStr
print('ParseISO8601 ({0}) should fail, but it did not'.format(testStr))
assert(False)

0 comments on commit a8c1be6

Please sign in to comment.