Ignore:
Timestamp:
Oct 11, 2018 12:20:56 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
Children:
98b9f32
Parents:
67ed543
Message:

improved support for py37 in sasgui

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/plottools/convert_units.py

    ra1b8fee r5251ec6  
    1313    """ 
    1414    if power != 0: 
    15         if string.find(unit, "^") != -1:  # if the unit contains a powerer ^ 
    16             toks = re.split("\^", unit) 
    17             if string.find(toks[0], "/") != -1 or \ 
    18                 string.find(toks[0], "-") != -1: 
     15        if unit.find("^") != -1:  # if the unit contains a powerer ^ 
     16            toks = re.split(r"\^", unit) 
     17            if toks[0].find("/") != -1 or \ 
     18                toks[0].find("-") != -1: 
    1919                if power == 1: 
    2020                    unit = unit 
     
    2222                    unit = "(" + unit + ")" + "^{" + str(power) + "}" 
    2323            else: 
    24                 if string.find(toks[1], "{") != -1:  # if found a { 
     24                if toks[1].find("{") != -1:  # if found a { 
    2525                    find_power_toks = re.split("{", toks[1]) 
    26                     if string.find(find_power_toks[1], "}") != -1:  # found } 
     26                    if find_power_toks[1].find("}") != -1:  # found } 
    2727                        unit_toks = re.split("}", find_power_toks[1]) 
    28                         if string.find(unit_toks[0], ".") != -1: 
     28                        if unit_toks[0].find(".") != -1: 
    2929                            powerer = float(unit_toks[0]) * power 
    30                         elif string.find(unit_toks[0], "/") != -1: 
     30                        elif unit_toks[0].find("/") != -1: 
    3131                            power_toks = re.split("/", unit_toks[0]) 
    3232                            powerer = power * int(power_toks[0])\ 
     
    4444                            unit = toks[0] + "^{" + str(powerer) + "}" 
    4545                else: 
    46                     raise ValueError, "missing } in unit expression" 
     46                    raise ValueError("missing } in unit expression") 
    4747        else:  # no powerer 
    4848            if  power != 1: 
    4949                unit = "(" + unit + ")" + "^{" + str(power) + "}" 
    5050    else: 
    51         raise ValueError, "empty unit ,enter a powerer different from zero" 
     51        raise ValueError("empty unit, enter a power different from zero") 
    5252    return unit 
    5353 
Note: See TracChangeset for help on using the changeset viewer.