Changeset 1719:6e8861564778 in orange-bioinformatics for _bioinformatics/obiGeneMania.py


Ignore:
Timestamp:
08/31/12 14:09:46 (20 months ago)
Author:
markotoplak
Branch:
default
Message:

Fixed update scripts for MeSH, GO, HomoloGene, NCBI_geneinfo, OMIM, PPI. Moved wget to Orange.utils.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _bioinformatics/obiGeneMania.py

    r1636 r1719  
    445445        pass 
    446446 
    447  
    448 def copyfileobj(src, dst, buffer=2**10, content_len=None, progress=None): 
    449     count = 0 
    450     if content_len is None: 
    451         content_len = guess_size(src) or sys.maxint 
    452     while True: 
    453         data = src.read(buffer) 
    454         dst.write(data) 
    455         count += len(data) 
    456         if progress: 
    457             progress(100.0 * count / content_len) 
    458         if not data: 
    459             break 
    460              
    461              
    462 def wget(url, directory=".", dst_obj=None, progress=None): 
    463     """ 
    464     .. todo:: Move to Orange.misc 
    465      
    466     """ 
    467     stream = urllib2.urlopen(url) 
    468     length = stream.headers.get("content-length", None) 
    469     if length is None: 
    470         length = sys.maxint 
    471     else: 
    472         length = int(length) 
    473      
    474     basename = posixpath.basename(url) 
    475          
    476     if dst_obj is None: 
    477         dst_obj = open(os.path.join(directory, basename), "wb") 
    478      
    479     if progress == True: 
    480         from Orange.utils import ConsoleProgressBar 
    481         progress = ConsoleProgressBar("Downloading %r." % basename) 
    482         with finishing(progress): 
    483             copyfileobj(stream, dst_obj, buffer=2**10, content_len=length, 
    484                         progress=progress) 
    485     else: 
    486         copyfileobj(stream, dst_obj, buffer=2**10, content_len=length, 
    487                     progress=progress) 
     447from Orange.utils import wget 
    488448     
    489449from . import obiPPI 
Note: See TracChangeset for help on using the changeset viewer.