Package obitools :: Package utils
[hide private]
[frames] | no frames]

Package utils

source code

Submodules [hide private]

Classes [hide private]
  ColumnFile
  CachedDB
Functions [hide private]
 
universalOpen(file, *options)
Open a file gziped or not.
source code
int
universalTell(file)
Return the position in the file even if it is a gziped one.
source code
int
fileSize(file)
Return the file size even if it is a gziped one.
source code
 
progressBar(pos, max, reset=False, delta=[]) source code
 
endLessIterator(endedlist) source code
an iterotor on str
multiLineWrapper(lineiterator)
Aggregator of strings.
source code
a stream strings
skipWhiteLineIterator(lineiterator)
Curator of stanza.
source code
 
moduleInDevelopment(name) source code
Variables [hide private]
  __package__ = 'obitools.utils'

Imports: sys, time, re, shelve, Lock, warning, urllib2, GzipFile, ZipFile, iterator


Function Details [hide private]

universalOpen(file, *options)

source code 

Open a file gziped or not.

If file is a str instance, file is concidered as a file name. In this case the .gz suffixe is tested to eventually open it a a gziped file.

If file is an other kind of object, it is assumed that this object follow the file interface and it is return as is.

Parameters:
  • file (str or a file like object) - the file to open
Returns:
an iterator on text lines.

universalTell(file)

source code 

Return the position in the file even if it is a gziped one.

Parameters:
  • file (a file like instance) - the file to check
Returns: int
position in the file

fileSize(file)

source code 

Return the file size even if it is a gziped one.

Parameters:
  • file (a file like instance) - the file to check
Returns: int
the size of the file

multiLineWrapper(lineiterator)

source code 

Aggregator of strings.

Parameters:
  • lineiterator (a stream of strings.) - a stream of strings from an opened OBO file.
Returns: an iterotor on str
an aggregated stanza.

Note: The aggregator aggregates strings from an opened OBO file. When the length of a string is < 2, the current stanza is over.

skipWhiteLineIterator(lineiterator)

source code 

Curator of stanza.

Parameters:
  • lineiterator (a stream of strings.) - a stream of strings from an opened OBO file.
Returns: a stream strings
a stream of strings without blank strings.

Note: The curator skip white lines of the current stanza.