git语法_在git-pandas中引入统一的glob语法

2023年1月5日10:57:39

git语法

In an effort to improve the user interface to git-pandas, I’m introducing a new way of specifying which files in a repository you care about, which will become the sole way of specifying this kind of thing in version 2.0.0.  Currently, for any given function, you can specify a list of extensions you’d like to include, and a list of directories you’d like to exclude.  A toy example would be:

为了改善git-pandas的用户界面,我引入了一种新的方式来指定您关心的存储库中的哪些文件,这将成为在2.0.0版中指定此类内容的唯一方式。 当前,对于任何给定的函数,您都可以指定要包括的扩展名列表以及要排除的目录列表。 一个玩具的例子是:

df = repo.some_method(
    extensions=['py', 'md', 'html'],
    ignore_dir=['docs', 'tests']
)

With this, you’d be looking at python, markdown and HTML files other than those in the docs or tests directories.

这样,您将可以查看docs,tests目录中的python,markdown和HTML文件。

For most use-cases, this is a pretty compact way to express what you need.  But those little edge cases come up increasingly often where a more flexible method is needed. So now you can alternatively pass a parameter to any of these methods called ignore_globs:

对于大多数用例,这是表达所需内容的一种非常紧凑的方法。 但是那些小巧的案例越来越多地出现在需要更灵活的方法的地方。 因此,现在您可以将参数传递给以下任何一种方法,称为ignore_globs:

df = repo.some_method(
    ignore_globs=[
       'docs*',
       'tests*'
    ]
)

Which will ignore any file that matches any single glob passed into that object.  For now, this is limiting, because things like file extension matching for multiple file types is really hard to do in this notation.  To simplify that, the next addition will be a corresponding ‘include_globs’.  A full description of that is in the github issue found here: https://github.com/wdm0006/git-pandas/issues/3

它将忽略与传递给该对象的任何单个glob匹配的任何文件。 目前,这是有限的,因为用这种表示法实际上很难完成诸如针对多种文件类型进行文件扩展名匹配之类的事情。 为简化起见,下一个添加项将是对应的“ include_globs”。 对此的完整描述位于github问题中,网址为: https : //github.com/wdm0006/git-pandas/issues/3

Once added, the logic will be that for any given file, at least one pattern in the include_globs must match, and at most zero patterns from exclude_globs must match.

添加后,逻辑将是对于任何给定文件,include_glob中的至少一个模式必须匹配,exclude_globs中的至多零个模式必须匹配。

In that way, we could replicate the first example above with:

这样,我们可以复制上面的第一个示例:

df = repo.some_method(
    ignore_globs=[
       'docs*',
       'tests*'
    ],
   include_globs=[
       '*.py',
       '*.md',
       '*.html'
   ]
)

Which is about the same level of verbosity, and far more flexible.

冗长程度大致相同,而且更加灵活。

If you’re a user of git-pandas, I would love your feedback on this.  If you’re a developer, I’d love your help.  Any feedback is always welcome on the issue posted above.

如果您是git-pandas的用户,我希望收到您的反馈。 如果您是一名开发人员,我将很乐意为您提供帮助。 始终欢迎您对以上问题发表任何反馈。

翻译自: https://www.pybloggers.com/2016/06/introducing-unified-glob-syntax-in-git-pandas/

git语法

  • 作者:cumei1658
  • 原文链接:https://blog.csdn.net/cumei1658/article/details/107364176
    更新时间:2023年1月5日10:57:39 ,共 2286 字。