diff options
| author | 2012-01-13 23:24:21 +0100 | |
|---|---|---|
| committer | 2012-01-13 23:24:21 +0100 | |
| commit | c7ad1cc5b4a5d190a060e3ddd9274c3065da6708 (patch) | |
| tree | 639062525ddde3b8c785f26a0f4091ec10d9e204 /module/utils/__init__.py | |
| parent | fixed pyflakes and sloccount (diff) | |
| download | pyload-c7ad1cc5b4a5d190a060e3ddd9274c3065da6708.tar.xz | |
Diffstat (limited to 'module/utils/__init__.py')
| -rw-r--r-- | module/utils/__init__.py | 7 | 
1 files changed, 7 insertions, 0 deletions
| diff --git a/module/utils/__init__.py b/module/utils/__init__.py index b68928f04..bf11fbc69 100644 --- a/module/utils/__init__.py +++ b/module/utils/__init__.py @@ -160,6 +160,13 @@ def accumulate(it, inv_map=None):  def to_string(value):      return str(value) if not isinstance(value, basestring) else value +def to_int(string): +    """ return int from string or 0 """ +    try: +        return int(string) +    except ValueError: +        return 0 +  def from_string(value, typ=None):      """ cast value to given type, unicode for strings """ | 
