快乐的老鼠 发表于 2017-4-21 09:55:05

python test3

def main():
usage = 'test - check file types and compare values'
parser = argparse.ArgumentParser(usage)
parser.add_argument('-b', action='store_true', default=False, help='FILE exists and is block special')
parser.add_argument('-c', action='store_true', default=False, help='FILE exists and is character special')
parser.add_argument('-d', action='store_true', default=False, help='FILE exists and is a directory')
parser.add_argument('-e', action='store_true', default=False, help='FILE exists')
parser.add_argument('-f', action='store_true', default=False, help='FILE exists and is a regular file')
parser.add_argument('-g', action='store_true', default=False, help='FILE exists and is set-group-ID')
parser.add_argument('-G', action='store_true', default=False, help='FILE exists and is owned by the effective group ID')
#-h
parser.add_argument('-k', action='store_true', default=False, help='FILE exists and has its sticky bit set')
parser.add_argument('-L', action='store_true', default=False, help='FILE exists and is a symbolic link')
#parser.add_argument('-o', action='store_true', default=False, help='FILE exists and is owned by the effective user ID')
parser.add_argument('-p', action='store_true', default=False, help='FILE exists and is a named pipe')
parser.add_argument('-r', action='store_true', default=False, help='FILE exists and read permission is granted')
# -s
parser.add_argument('-S', action='store_true', default=False, help='FILE exists and is a socket')
# -t
parser.add_argument('-u', action='store_true', default=False, help='FILE exists and its set-user-ID bit is set')   
parser.add_argument('-w', action='store_true', default=False, help='FILE exists and write permission is granted')
parser.add_argument('-x', action='store_true', default=False, help='FILE exists and execute (or search) permission is granted')
parser.add_argument('-z', action='store_true', default=False, help='the length of STRING is zero')
# two file
group = parser.add_mutually_exclusive_group()
group.add_argument("-nt", action="store_true", help='FILE1 and FILE2 have the same device and inode numbers')
group.add_argument("-ot", action="store_true", help='FILE1 is newer (modification date) than FILE2')
group.add_argument("-eq", action="store_true", help='INTEGER1 is equal to INTEGER2')
group.add_argument("-ge", action="store_true", help='INTEGER1 is greater than or equal to INTEGER2')
group.add_argument("-gt", action="store_true", help='INTEGER1 is greater than INTEGER2')
group.add_argument("-le", action="store_true", help='INTEGER1 is less than or equal to INTEGER2')
group.add_argument("-lt", action="store_true", help='INTEGER1 is less than INTEGER2')
group.add_argument("-ne", action="store_true", help='INTEGER1 is not equal to INTEGER2')
#group.add_argument("-ef", "--ef", action="store_true", help='FILE1 and FILE2 have the same device and inode numbers')
group.add_argument("-a", action="store_true", help='both EXPRESSION1 and EXPRESSION2 are true')
# group.add_argument("-o", "--o", action="store_true", help='either EXPRESSION1 or EXPRESSION2 is true')
页: [1]
查看完整版本: python test3