Changeset 468

Show
Ignore:
Timestamp:
03/05/03 18:08:53 (6 years ago)
Author:
sholloway
Message:

*** empty log message ***

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBFoundation/RBFoundation/Utilities.py

    r290 r468  
    6161    return cleanupstrlst(data.split(splitchar), *args, **kw) 
    6262 
     63#~ iso formated time information ~~~~~~~~~~~~~~~~~~~~ 
     64 
     65def fromisoformat(strtime, sectionsep='T', datesep='-', timesep=':'): 
     66    """ISO 8601 format, YYYY-MM-DDTHH:MM:SS 
     67    returns (YYYY, MM, DD, HH, MM, SS, -1, -1, -1) 
     68    compatible with time module's mktime method.""" 
     69    datesent, timesent = strtime.split(sectionsep)[:2] 
     70    datesent = map(int, datesent.split(datesep)[:3]) 
     71    timesent = map(int, timesent.split(timesep)[:3]) 
     72    return tuple(datesent + timesent + (-1,-1,-1)) 
     73 
     74def fromisoformat_date(strtime, datesep='-'): 
     75    """ISO 8601 format, YYYY-MM-DDTHH:MM:SS 
     76    returns (YYYY, MM, DD)""" 
     77    datesent = map(int, datesent.split(datesep)[:3]) 
     78    return tuple(datesent) 
     79 
     80def fromisoformat_time(strtime, timesep=':'): 
     81    """ISO 8601 format, YYYY-MM-DDTHH:MM:SS 
     82    returns (HH, MM, SS)""" 
     83    timesent = map(int, timesent.split(timesep)[:3]) 
     84    return tuple(datesent) 
    6385 
    6486#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBFoundation/RBFoundation/XMLNode.py

    r459 r468  
    237237            return self.addnode(*elem) 
    238238 
     239    def insertelem(self, idx, elem): 
     240        if isinstance(elem, basestring): 
     241            return self.insertdata(elem) 
     242        elif isinstance(elem, xmlnodebase): 
     243            # For elements that are prebuilt 
     244            self.elems.insert(idx, elem) 
     245            return elem 
     246        else:  
     247            # For building from tuples and lists 
     248            return self.insertnode(*elem) 
     249 
    239250    def setxmlns(self, *args, **kw): 
    240251        return self.namespaces.setxmlns(*args, **kw) 
     
    273284        for idx in dellist: 
    274285            del self.elems[idx] 
     286 
     287    def data(self, joinstr=''): 
     288        return joinstr.join(map(type(joinstr), self.iterdata(None))) 
    275289 
    276290    def hasdata(self, *args, **kw): 
  • trunk/RBTelepathy/RBTelepathy/Packet/URIAddress.py

    r442 r468  
    5050    """ 
    5151 
     52    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     53    #~ Special  
     54    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     55 
     56    def __cmp__(self, other): 
     57        return cmp(self.astuple(), other.astuple()) 
     58 
     59    def astuple(self): 
     60        return (self.scheme, self.network, self.acount, self.path, self.query, self.fragment) 
     61 
     62    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     63    #~ Protected Methods  
     64    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     65 
    5266    def _getAuthority(self): 
    5367        if self.network is not None: