Package Bio :: Module _utils
[hide private]
[frames] | no frames]

Module _utils

source code

Common utility functions for various Bio submodules.

Functions [hide private]
 
iterlen(items)
Count the number of items in an iterable.
source code
 
read_forward(handle)
Reads through whitespaces, returns the first non-whitespace line.
source code
 
trim_str(string, max_len, concat_char)
Truncates the given string for display.
source code
 
getattr_str(obj, attr, fmt=None, fallback='?')
Returns a string of the given object's attribute, defaulting to the fallback value if attribute is not present.
source code
 
find_test_dir(start_dir=None)
Finds the absolute path of Biopython's Tests directory.
source code
 
run_doctest(target_dir=None, *args, **kwargs)
Runs doctest for the importing module.
source code
Variables [hide private]
  __package__ = 'Bio'
Function Details [hide private]

iterlen(items)

source code 
Count the number of items in an iterable.

If the argument supports len(items), and some iterators do, then
this returns len(items). Otherwise it will scan over the entries
in order to count them.

Exhausts a generator, but doesn't require creating a full list.

>>> iterlen("abcde")
5
>>> iterlen(iter("abcde"))
5

find_test_dir(start_dir=None)

source code 
Finds the absolute path of Biopython's Tests directory.

Arguments:
start_dir -- Initial directory to begin lookup (default to current dir)

If the directory is not found up the filesystem's root directory, an
exception will be raised.