Changeset 1949:13578f97436a in orange-bioinformatics


Ignore:
Timestamp:
01/07/14 15:55:19 (4 months ago)
Author:
markotoplak
Branch:
default
Message:

OWPIPAx: avoid eval on older Python.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orangecontrib/bio/widgets/OWPIPAx.py

    r1948 r1949  
    3232    from ast import literal_eval 
    3333except ImportError: 
    34     # Compatibility with Python 2.5 
    35     literal_eval = eval 
     34    #avoid eval on older pythons: dates are of lower importance than safety 
     35    literal_eval = lambda x: None 
    3636 
    3737 
     
    744744            d = defaultdict(lambda: "?", r_annot) 
    745745            row_items = [""] + [d.get(key, "?") for key, _ in HEADER[1:]] 
    746             date_string = row_items[DATE_INDEX] 
    747746            try: 
    748                 time_dict = literal_eval(date_string) 
    749             except Exception: 
    750                 time_dict = {} 
    751  
    752             if time_dict and "dateUTC" in time_dict and \ 
    753                     "monthUTC" in time_dict and "fullYearUTC" in time_dict: 
     747                time_dict = literal_eval(row_items[DATE_INDEX]) 
    754748                date_rna = date(time_dict["fullYearUTC"], 
    755749                                time_dict["monthUTC"] + 1,  # Why is month 0 based? 
    756750                                time_dict["dateUTC"]) 
    757  
    758751                row_items[DATE_INDEX] = date_rna.strftime("%x") 
     752            except Exception: 
     753                row_items[DATE_INDEX] = '' 
    759754 
    760755            row_items[ID_INDEX] = mapping_unique_id(r_annot) 
Note: See TracChangeset for help on using the changeset viewer.