comparison cutils/treesum.py @ 271:6fe88de236cb

treesum: Implement the --half/-H option: follow symlinks given on the command line but no other symlinks. This a sibling to -P, -L and -p.
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 18 Feb 2025 18:24:16 +0100
parents 42f4ca423ab3
children c72f5b2dbc6f
comparison
equal deleted inserted replaced
270:42f4ca423ab3 271:6fe88de236cb
68 "--follow-directory-symlinks", "-l", action=SymlinkAction, 68 "--follow-directory-symlinks", "-l", action=SymlinkAction,
69 const="follow-directory-symlinks", 69 const="follow-directory-symlinks",
70 default=FollowSymlinkConfig(False, False, True), 70 default=FollowSymlinkConfig(False, False, True),
71 dest="follow_symlinks", 71 dest="follow_symlinks",
72 help="""Follow symbolic links to directories when walking a 72 help="""Follow symbolic links to directories when walking a
73 directory tree. Augments --physical and -p.""") 73 directory tree. Augments --physical, --half and -p.""")
74 gp.add_argument( 74 gp.add_argument(
75 "--follow-file-symlinks", action=SymlinkAction, 75 "--follow-file-symlinks", action=SymlinkAction,
76 const="follow-file-symlinks", 76 const="follow-file-symlinks",
77 default=FollowSymlinkConfig(False, False, True),
78 dest="follow_symlinks", 77 dest="follow_symlinks",
79 help="""Follow symbolic links to files when walking a 78 help="""Follow symbolic links to files when walking a
80 directory tree. Augments --physical.""") 79 directory tree. Augments --physical and --half.""")
81 gp.add_argument( 80 gp.add_argument(
82 "--full-mode", action="store_true", dest="metadata_full_mode", 81 "--full-mode", action="store_true", dest="metadata_full_mode",
83 help="Consider all mode bits as returned from stat(2) when " 82 help="Consider all mode bits as returned from stat(2) when "
84 "computing directory digests. " 83 "computing directory digests. "
85 "Note that mode bits on symbolic links itself are not " 84 "Note that mode bits on symbolic links itself are not "
90 help="""Put a `GENERATOR' line into the output. 89 help="""Put a `GENERATOR' line into the output.
91 `full' prints full Python and OS/platform version information, 90 `full' prints full Python and OS/platform version information,
92 `normal' prints just whether Python 2 or Python 3 is used, and `none' 91 `normal' prints just whether Python 2 or Python 3 is used, and `none'
93 suppresses the output completely. The default is `normal'.""") 92 suppresses the output completely. The default is `normal'.""")
94 gp.add_argument( 93 gp.add_argument(
94 "--half", "-H", action=SymlinkAction, dest="follow_symlinks",
95 const=FollowSymlinkConfig(True, False, False),
96 help="""Follow symbolic links given on the command line but do
97 not follow symlinks while traversing the directory tree.
98 Overwrites any other symlink related options
99 (--physical, --logical, -p, --no-follow-directory-symlinks,
100 --no-follow-file-symlinks, et al.).""")
101 gp.add_argument(
95 "--logical", "-L", action=SymlinkAction, dest="follow_symlinks", 102 "--logical", "-L", action=SymlinkAction, dest="follow_symlinks",
96 const=FollowSymlinkConfig(True, True, True), 103 const=FollowSymlinkConfig(True, True, True),
97 help="""Follow symbolic links everywhere: on command line 104 help="""Follow symbolic links everywhere: on command line
98 arguments and -- while walking -- directory and file symbolic links. 105 arguments and -- while walking -- directory and file symbolic links.
99 Overwrites any other symlink related options 106 Overwrites any other symlink related options
100 (--physical,-p, no-follow-directory-symlinks, no-follow-file-symlinks, 107 (--physical, --half, -p, --no-follow-directory-symlinks,
101 et al.). 108 --no-follow-file-symlinks, et al.).""")
102 """)
103 gp.add_argument( 109 gp.add_argument(
104 "--minimal", nargs="?", const="", default=None, metavar="TAG", 110 "--minimal", nargs="?", const="", default=None, metavar="TAG",
105 help="Produce minimal output only. If a TAG is given and not " 111 help="Produce minimal output only. If a TAG is given and not "
106 "empty use it as the leading \"ROOT (<TAG>)\" output.") 112 "empty use it as the leading \"ROOT (<TAG>)\" output.")
107 gp.add_argument( 113 gp.add_argument(
142 "--physical", "-P", action=SymlinkAction, dest="follow_symlinks", 148 "--physical", "-P", action=SymlinkAction, dest="follow_symlinks",
143 const=FollowSymlinkConfig(False, False, False), 149 const=FollowSymlinkConfig(False, False, False),
144 help="""Do not follow any symbolic links whether they are given 150 help="""Do not follow any symbolic links whether they are given
145 on the command line or when walking the directory tree. 151 on the command line or when walking the directory tree.
146 Overwrites any other symlink related options 152 Overwrites any other symlink related options
147 (--logical, -p, follow-directory-symlinks, follow-file-symlinks, et al.). 153 (--logical, --half, -p, --follow-directory-symlinks, --follow-file-symlinks,
148 This is the default.""") 154 et al.).""")
149 gp.add_argument( 155 gp.add_argument(
150 "-p", action=SymlinkAction, dest="follow_symlinks", 156 "-p", action=SymlinkAction, dest="follow_symlinks",
151 const=FollowSymlinkConfig(False, False, True), 157 const=FollowSymlinkConfig(False, False, True),
152 help="""Do not follow any symbolic links to directories, 158 help="""Do not follow any symbolic links to directories,
153 whether they are given on the command line or when walking the directory tree, 159 whether they are given on the command line or when walking the directory tree,
154 but follow symbolic links to files. 160 but follow symbolic links to files.
155 Overwrites any other symlink related options 161 Overwrites any other symlink related options
156 (--logical, --physical, follow-directory-symlinks, no-follow-file-symlinks, 162 (--logical, --half, --physical, --follow-directory-symlinks,
157 et al.). 163 --no-follow-file-symlinks, et al.).
158 This is the default.""") 164 This is the default.""")
159 gp.add_argument( 165 gp.add_argument(
160 "--print-size", action="store_true", 166 "--print-size", action="store_true",
161 help="""Print the size of a file or the accumulated sizes of 167 help="""Print the size of a file or the accumulated sizes of
162 directory content into the output also. 168 directory content into the output also.