示例#1
0
文件: main.py 项目: jdevera/subdue
def check_sub_name(name):
    errors = []
    if name != name.rstrip():
        errors.append("Ends with spaces")
    if name != name.lstrip():
        errors.append("Starts with spaces")
    if name.startswith('-'):
        errors.append("Starts with a hyphen")
    if '/' in name or '\\' in name:
        errors.append("Has slashes")
    if not errors and os.path.exists(os.path.abspath(name)):
        errors.append("A file with the same name already exists")
    if errors:
        core.die("Invalid name for sub. Errors: \n - {0}".format(
                 "\n - ".join(errors)))
示例#2
0
文件: main.py 项目: bazl/subdue
def check_sub_name(name):
    errors = []
    if name != name.rstrip():
        errors.append("Ends with spaces")
    if name != name.lstrip():
        errors.append("Starts with spaces")
    if name.startswith('-'):
        errors.append("Starts with a hyphen")
    if '/' in name or '\\' in name:
        errors.append("Has slashes")
    if not errors and os.path.exists(os.path.abspath(name)):
        errors.append("A file with the same name already exists")
    if errors:
        core.die("Invalid name for sub. Errors: \n - {0}".format(
            "\n - ".join(errors)))
示例#3
0
文件: main.py 项目: jdevera/subdue
def check(args):
    root = os.path.abspath(args.subname)

    errors = []
    if not os.path.isdir(root):
        errors.append("Not a directory: {0}".format(args.subname))

    directories = REQUIRED_DIRECTORIES if args.thin else DIRECTORIES

    for d in directories:
        sd = os.path.join(root, d)
        if not os.path.isdir(sd):
            errors.append("Required directory {0} is missing".format(d))
    if args.thin and os.path.isdir(os.path.join(root, 'bin')):
        errors.append("Thin sub should not have a 'bin' directory")

    if errors:
        core.die("Errors found in {0}:\n - {1}".format(
            args.subname, "\n - ".join(errors)))
示例#4
0
文件: main.py 项目: bazl/subdue
def check(args):
    root = os.path.abspath(args.subname)

    errors = []
    if not os.path.isdir(root):
        errors.append("Not a directory: {0}".format(args.subname))

    directories = REQUIRED_DIRECTORIES if args.thin else DIRECTORIES

    for d in directories:
        sd = os.path.join(root, d)
        if not os.path.isdir(sd):
            errors.append("Required directory {0} is missing".format(d))
    if args.thin and os.path.isdir(os.path.join(root, 'bin')):
        errors.append("Thin sub should not have a 'bin' directory")

    if errors:
        core.die("Errors found in {0}:\n - {1}".format(args.subname,
                                                       "\n - ".join(errors)))