File: Utilities.py

package info (click to toggle)
cain 1.10%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 29,856 kB
  • sloc: cpp: 49,612; python: 14,988; xml: 11,654; ansic: 3,644; makefile: 133; sh: 2
file content (25 lines) | stat: -rw-r--r-- 479 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Implements utility functions."""

def isFloat(x):
    try:
        float(x)
    except:
        return False
    return True

def getNewIntegerString(strings):
    n = 0
    while True:
        n += 1
        if not str(n) in strings:
            return str(n)

def getUniqueName(base, strings):
    if not base in strings:
        return base
    n = 0
    while True:
        n += 1
        result = base + str(n)
        if not result in strings:
            return result