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

为了改进git-pandas的用户体验,作者引入了新的ignore_globs参数,允许用户通过glob语法更灵活地指定要包含或排除的文件。即将添加的include_globs将进一步简化多文件类型的扩展名匹配。此更改提高了git-pandas处理存储库中文件选择的灵活性。
摘要由CSDN通过智能技术生成

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语法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值