From f5b75c1aa86c0204f11ebca138e373c22221dc48 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Wed, 17 Mar 2010 12:11:27 +0000 Subject: moved misplaced methods to tautils --- diff --git a/talogo.py b/talogo.py index 666f9c3..1bc6847 100644 --- a/talogo.py +++ b/talogo.py @@ -36,7 +36,7 @@ from taconstants import PALETTES, PALETTE_NAMES, TAB_LAYER from tagplay import play_audio, play_movie_from_file, stop_media from tajail import myfunc, myfunc_import from tautils import get_pixbuf_from_journal, movie_media_type, convert, \ - audio_media_type, text_media_type, round_int + audio_media_type, text_media_type, round_int, chr_to_ord, strtype from gettext import gettext as _ class noKeyError(UserDict): @@ -71,14 +71,6 @@ def numtype(x): return True return False -def strtype(x): - """ Is x a string type? """ - if type(x) == str: - return True - if type(x) == unicode: - return True - return False - def str_to_num(x): """ Try to comvert a string to a number """ xx = convert(x, float) @@ -91,15 +83,6 @@ def str_to_num(x): else: raise logoerror("#syntaxerror") -def chr_to_ord(x): - """ Try to comvert a string to an ord """ - if strtype(x) and len(x) == 1: - try: - return ord(x[0]), True - except ValueError: - return x, False - return x, False - def taand(x, y): """ Logical and """ return x&y diff --git a/tautils.py b/tautils.py index 12812db..77eb3f5 100644 --- a/tautils.py +++ b/tautils.py @@ -64,6 +64,23 @@ def convert(x, fn, try_ord=True): return fn(xx) return x +def chr_to_ord(x): + """ Try to comvert a string to an ord """ + if strtype(x) and len(x) == 1: + try: + return ord(x[0]), True + except ValueError: + return x, False + return x, False + +def strtype(x): + """ Is x a string type? """ + if type(x) == str: + return True + if type(x) == unicode: + return True + return False + def magnitude(pos): """ Calculate the magnitude of the distance between to blocks. """ x, y = pos -- cgit v0.9.1