Ignore:
Timestamp:
03/15/11 15:01:11 (3 years ago)
Author:
markotoplak
Branch:
default
Convert:
07029ab1535e62ba413dc47b8f1fe577ec0c84bb
Message:

serverfiles: update and needs_update take an optional ServerFiles object instead of access_code. orngServerFiles modified for backwards compatibility.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/misc/serverfiles.py

    r7742 r7744  
    559559    return dic 
    560560 
    561 def needs_update(domain, filename, access_code=None): 
     561def needs_update(domain, filename, serverfiles=None): 
    562562    """True if a file does not exist in the local repository 
    563563    or if there is a newer version on the server.""" 
     564    if serverfiles == None: serverfiles = ServerFiles() 
    564565    if filename not in listfiles(domain): 
    565566        return True 
     
    567568    dt_local = datetime.datetime.strptime( 
    568569        info(domain, filename)["datetime"][:19], dt_fmt) 
    569     server = ServerFiles(access_code=access_code) 
    570570    dt_server = datetime.datetime.strptime( 
    571         server.info(domain, filename)["datetime"][:19], dt_fmt) 
     571        serverfiles.info(domain, filename)["datetime"][:19], dt_fmt) 
    572572    return dt_server > dt_local 
    573573 
    574 def update(domain, filename, access_code=None, verbose=True): 
     574def update(domain, filename, serverfiles=None, **kwargs): 
    575575    """Downloads the corresponding file from the server and places it in  
    576576    the local repository, but only if the server copy of the file is newer  
    577     or the local copy does not exist. An optional access_code can be given  
    578     to allow server access if the file is protected. 
    579     """ 
    580     if needs_update(domain, filename, access_code=access_code): 
    581         if not access_code: 
    582             download(domain, filename, verbose=verbose) 
    583         else: 
    584             server = orngServerFiles.ServerFiles(access_code=access_code) 
    585             download(domain, filename, serverfiles=server) 
     577    or the local copy does not exist. An optional  :class:`ServerFiles` object 
     578    can be passed for authenticated access. 
     579    """ 
     580    if serverfiles == None: serverfiles = ServerFiles() 
     581    if needs_update(domain, filename, serverfiles=serverfiles): 
     582        download(domain, filename, serverfiles=serverfiles, **kwargs) 
    586583         
    587584def _searchinfo(): 
Note: See TracChangeset for help on using the changeset viewer.