Source code for canvascli.utils

# -*- coding: utf-8 -*-
"""Test cases."""

# Standard library imports
import argparse


[docs]def check_color(color): """Check color and return cleansed value.""" color = str(color) # Force a string character color_len = len(color) if color_len == 0: raise ValueError("Color cannot be empty!") elif color_len != 1: color = color[0] # Guarantee length of character equal to 1 raise ValueError("Color has to be a single character!") return color
[docs]def positive_int(value): """Check positive integer value types.""" int_value = int(value) if int_value <= 0: raise argparse.ArgumentTypeError( "invalid positive integer value: '{}'".format(value) ) return int_value