Révision a02c931d modules/dos_input.py

b/modules/dos_input.py
7 7
    list of lists of integers.
8 8
        Group enclosers: '()' '[]' and '{}'
9 9
        separators: ',' ';' and ' '
10
    eg. 128,(135 138;141) 87 {45 68} -> [128, [135, 138, 141], 87, [45, 68]]
10
    eg. '128,(135 138;141] 87 {45, 68}' -> [128, [135, 138, 141], 87, [45, 68]]
11 11
    """
12 12

  
13

  
13
    assert type(cmplx_str) == str, 'parameter should be a string'
14 14
    cmplx_str = cmplx_str.replace(',', ' ').replace(';', ' ').replace(
15 15
        '[', '(').replace(']', ')').replace('{', '(').replace('}', ')')
16
    try:
17
        list(map(int, cmplx_str.replace(')','').replace('(','').split()))
18
    except:
19
        raise ValueError("Method parameter should be composed of integer numbers"
20
                         "\nseparated by ',' ';' or ' ' "
21
                         "grouped in parentheses-like separators")
22
    #TODO: enable superior level of nested lists (eg. '3 ((6 7) 8) 4')
16 23

  
17 24
    init_list = cmplx_str.split()
18 25
    start_group = []

Formats disponibles : Unified diff