gpt4 book ai didi

python - 如何转义 MANIFEST.in 文件中目录名称中的空格?

转载 作者:行者123 更新时间:2023-12-01 06:06:31 24 4
gpt4 key购买 nike

我继承了一些目录名称中嵌入空格的代码,并且我没有重命名目录的选项。假设目录的名称是“embedded space”

现在我正在尝试访问 MANIFEST.in 文件中此目录中的一些文件

我尝试过以下方法:

recursive-include 'embedded spaces' *.dat
recursive-include "embedded spaces" *.dat
recursive-include embedded\ spaces *.dat

这些都会给出类似“警告:在目录“embedded”下找不到与“spaces”匹配的文件

我有一个解决方法

recursive-include embedded* *.dat

但我想知道是否有一种不那么黑客的方式来编码 MANIFEST.in 目录名称中的空格。

最佳答案

不,看起来不是。检查distutils.filelist的来源,它负责解析 MANIFEST.in 的工作显示该行纯粹根据空格分割以确定操作及其参数

这是源代码(Python 2,7)

def _parse_template_line(self, line):
words = line.split()
action = words[0]

...

if action in ('include', 'exclude',
'global-include', 'global-exclude'):
...
elif action in ('recursive-include', 'recursive-exclude'):
if len(words) < 3:
raise DistutilsTemplateError, \
"'%s' expects <dir> <pattern1> <pattern2> ..." % action

dir = convert_path(words[1])
patterns = map(convert_path, words[2:])

...

关于python - 如何转义 MANIFEST.in 文件中目录名称中的空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7761130/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com