File: universalopener.pyx

package info (click to toggle)
obitools 3.0.1~b26%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,788 kB
  • sloc: ansic: 24,299; python: 657; sh: 27; makefile: 20
file content (24 lines) | stat: -rwxr-xr-x 380 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#cython: language_level=3

'''
Created on 25 mars 2016

@author: coissac
'''

from urllib.request import urlopen
from obitools3.utils cimport tostr


cpdef CompressedFile uopen(object name, mode='rb'):
    cdef CompressedFile c
    
    try:
        f = urlopen(tostr(name))
    except:
        f = open(tostr(name),mode) 
        
    c = CompressedFile(f)
    
    return c