Commits

Tobias Pape committed 3da1c62

rename forceencoded to tryencode (as suggested by bdkearns)

  • Participants
  • Parent commits fc1de55

Comments (0)

Files changed (3)

File dotviewer/msgstruct.py

 import sys, os
 from struct import pack, unpack, calcsize
-from strunicode import forceencoded
+from strunicode import tryencode
 
 MAGIC = -0x3b83728b
 
 def message(tp, *values):
     #print >> sys.stderr, tp, values
     typecodes = ['']
-    values = map(forceencoded, values)
+    values = map(tryencode, values)
     for v in values:
         if type(v) is str:
             typecodes.append('%ds' % len(v))

File dotviewer/strunicode.py

     """ returns `name` as (possibly `RAW_ENCODING` encoded) string, even if it wasn't before  """
     return name if isinstance(name, str) else name.encode(RAW_ENCODING, ENCODING_ERROR_HANDLING)
 
-def forceencoded(name):
+def tryencode(name):
     """ returns `name` as encoded string if it was unicode before """
     return name.encode(RAW_ENCODING, ENCODING_ERROR_HANDLING) if isinstance(name, unicode) else name

File dotviewer/test/test_unicode_util.py

 #
 import py
 import codecs
-from dotviewer.strunicode import RAW_ENCODING, forcestr, forceunicode, forceencoded
+from dotviewer.strunicode import RAW_ENCODING, forcestr, forceunicode, tryencode
 
 SOURCE1 = u"""digraph G{
 λ -> b
         sut =      [1,   u"a", "miau", u"λ"]
         expected = [int, str,  str   , str ]
 
-        results = map(forceencoded, sut)
+        results = map(tryencode, sut)
 
 
         for result, expected_type in zip(results, expected):