Skip to content
代码片段 群组 项目
提交 31751884 编辑于 作者: Lzu Tao's avatar Lzu Tao
浏览文件

No need these helpers

上级 0a25b13a
No related branches found
No related tags found
无相关合并请求
#!/usr/bin/env python3
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
import os
import sys
import shutil
def usage():
print('usage: python3 CreateSymlink.py <src> <dst>')
print('Copy the file named src to a file named dst')
sys.exit(1)
def main():
if len(sys.argv) < 3:
usage()
src = sys.argv[1]
dst = sys.argv[2]
if os.path.exists(dst):
print ('File already exists: %r' % (dst))
return
shutil.copy2(src, dst)
if __name__ == '__main__':
main()
#!/usr/bin/env python3
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
import os
import sys
def usage():
print('usage: python3 CreateSymlink.py <src> <dst> [dst is dir: True or False]')
sys.exit(1)
def main():
if len(sys.argv) < 3:
usage()
src = sys.argv[1]
dst = sys.argv[2]
is_dir = False
if len(sys.argv) == 4:
is_dir = bool(sys.argv[3])
if os.path.islink(dst) and os.readlink(dst) == src:
print ('File exists: %r -> %r' % (dst, src))
return
os.symlink(src, dst, is_dir)
if __name__ == '__main__':
main()
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册