Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)

        def sanitize_project_name(name):
    project_name = name.replace('-', '_').lower()

    valid = (not keyword.iskeyword(project_name)) and \
        re.match('^[a-z][a-z0-9_]*$', project_name)

    if not valid:
        raise SbdkError("Invalid project name. Project name must be a valid Python identifier")
    return project_name

src/s/b/sbgsdk-0.5.4/sbdk/tests/test_project.py   sbgsdk(Download)
from sbdk.error import SbdkError
from sbdk.project import destination, sanitize_project_name
def test_sanitize_valid():
    for valid in 'valid', 'val1d', 'va_lid':
        result = sanitize_project_name(valid)
        eq_(valid, result, "Valid name should stay unchanged")
def test_sanitize_minus():
    minus = sanitize_project_name('has-minus')
def test_sanitize_keyword():
    keyword = sanitize_project_name('while')
def test_sanitize_pattern():
    illegal = sanitize_project_name('1asd')