Coverage for pandalone\utils.py : 98%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#! python #-*- coding: utf-8 -*- # # Copyright 2013-2015 European Commission (JRC); # Licensed under the EUPL (the 'Licence'); # You may not use this work except in compliance with the Licence. # You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
# Python-2 compatibility # try: # pragma: no cover FileNotFoundError except NameError: # pragma: no cover FileNotFoundError = IOError # @ReservedAssignment else: # pragma: no cover FileNotFoundError = OSError # @ReservedAssignment
# NOTE: re.match("(?:" + regex + r")\Z", string, flags=flags) try: # pragma: no cover from re import fullmatch # @UnusedImport except ImportError: # pragma: no cover fullmatch = fullmatch_py2
############## # Utilities #
""" Utility for parsing cmd-line args.
:param str v: any of (case insensitive): yes/no, true/false, on/off
Example::
>>> str2bool('ON') True >>> str2bool('no') False
>>> str2bool('') False >>> str2bool(' ') False
>>> str2bool(0) Traceback (most recent call last): ValueError: Invalid str-boolean(0) due to: 'int' object has no attribute 'strip' >>> str2bool(None) Traceback (most recent call last): ValueError: Invalid str-boolean(None) due to: 'NoneType' object has no attribute 'strip'
"""
def is_travis(): # pragma: no cover return 'TRAVIS' in os.environ
else:
i += 1
""" :param str ext: extension with dot(.)
>>> assert ensure_file_ext('foo', '.bar') == 'foo.bar' >>> assert ensure_file_ext('foo.bar', '.bar') == 'foo.bar' >>> assert ensure_file_ext('foo.', '.bar') == 'foo..bar' >>> assert ensure_file_ext('foo.', 'bar') == 'foo.bar'
"""
def open_file_with_os(fpath): # pragma: no cover # From http://stackoverflow.com/questions/434597/open-document-with-default-application-in-python # and http://www.dwheeler.com/essays/open-files-urls.html import subprocess try: os.startfile(fpath) # @UndefinedVariable except AttributeError: if sys.platform.startswith('darwin'): subprocess.call(('open', fpath)) elif os.name == 'posix': subprocess.call(('xdg-open', fpath)) return
"""From http://plumberjack.blogspot.gr/2009/09/how-to-treat-logger-like-output-stream.html"""
raise NotImplementedError |