首页 \ 问答 \ 如何组合多个模式进行匹配?(How to combine multiple Pattern for match?)

如何组合多个模式进行匹配?(How to combine multiple Pattern for match?)

我想在posts目录中匹配扩展名为*.md*.tex的文件。

我不能使用"posts/*" :: Pattern的原因是因为posts目录中有文件*.tex.metadata 。 并且site会对该文件给出错误。

[ERROR] Hakyll.Web.readPandocWith: I don't know how to read a file of the type Binary for: posts/2017-06-02-tex.metadata

尝试以下代码并使用空匹配失败(没有html输出)。

match (fromList ["posts/*.md", "posts/*.tex"]) $ do
    route $ setExtension "html"
    compile $ pandocCompiler

let postFiles :: Pattern
    postFiles = fromGlob "posts/*.md" `mappend` fromGlob "posts/*.tex"

match postFiles $ do
    route $ setExtension "html"
    compile $ pandocCompiler

也许我应该使用fromRegex但我不知道如何为此编写正则表达式。

非常欢迎加入学习资源。 文档缺乏样本。


I want to match files with extensions *.md and *.tex in posts directory.

The reason I can't use "posts/*" :: Pattern is because there are files *.tex.metadata in the posts directory. And site will give error on that files.

[ERROR] Hakyll.Web.readPandocWith: I don't know how to read a file of the type Binary for: posts/2017-06-02-tex.metadata

Try following code and fail with empty match (no html output).

match (fromList ["posts/*.md", "posts/*.tex"]) $ do
    route $ setExtension "html"
    compile $ pandocCompiler

let postFiles :: Pattern
    postFiles = fromGlob "posts/*.md" `mappend` fromGlob "posts/*.tex"

match postFiles $ do
    route $ setExtension "html"
    compile $ pandocCompiler

Maybe I should use fromRegex but I have no idea how to write regex for that.

Addition learning resource is very much welcome. The documentation is lack of sample.


原文:https://stackoverflow.com/questions/44325251
更新时间:2023-03-23 11:03

最满意答案

这与python的垃圾收集有关 - 因为(几乎)很快就会引用一个对象而不再引用它,所以我想只要窗口没有被垃圾收集,这个过程就不会终止。

您可以尝试在结束时添加del Programm.window或类似的东西(这可能是一种更好的方法,但我从未编写过QT,所以我在这里无法帮助你)


This has to do with python's garbage collecting - as (almost) soon an object isn't referenced anymore it destroys it, so I guess the process doesn't terminate as long as the window wasn't garbage-collected.

You can try to add at the end del Programm.window or something like that (there's probably a better way of doing this, but I never programmed QT myself so I can't help you here)

相关问答

更多
  • 感谢@ekhumoro,我发布了适用于此情况的回复,以防其他人遇到此问题。 在win2的代码中: def closeWindow(self): self.parent().show() self.close() 这是有效的,因为当win2被创建时,win1将自我传递给win2 Thanks to @ekhumoro, I'm posting the response that worked here in case anyone else has this issue. In the co ...
  • 我认为你需要将点击“x”右上角按钮的事件与杀戮过程线相关联。 这个话题可能有帮助吗? PySide / PyQt检测用户是否试图关闭窗口 I think you need to link the event of clicking the "x" top right button with the killing process lines. This topic may be of help? PySide / PyQt detect if user trying to close window
  • 你试过sys.exit(0)吗? (你需要import sys ,但你可能已经导入了它,因为pyqt sys.exit(app.exec_())需要它) 如果它不起作用,我相信你的问题来自其他地方。 Have you tried sys.exit(0) ? (You need import sys for this, but you probably imported it already as it is required for pyqt sys.exit(app.exec_())) If it doe ...
  • 是的,我得到了解决方案,最初我试图在Linux中使用葡萄酒与python和qt4作为64位创建win应用程序,但当我在Windows操作系统中使用pyinstaller尝试相同的事情时,它创建了一个exe文件....(我仍然不知道之所以) Yeah i got the solution , initially i was trying to create win application in linux using wine with python and qt4 as 64bit but when i t ...
  • 这与python的垃圾收集有关 - 因为(几乎)很快就会引用一个对象而不再引用它,所以我想只要窗口没有被垃圾收集,这个过程就不会终止。 您可以尝试在结束时添加del Programm.window或类似的东西(这可能是一种更好的方法,但我从未编写过QT,所以我在这里无法帮助你) This has to do with python's garbage collecting - as (almost) soon an object isn't referenced anymore it destroys it ...
  • PyQt为字符串提供了两种不同的API:您可以选择使用哪一个代码,如下所示: import sip sip.setapi('QString', 2) from PyQt4 import QtGui 导入PyQt4后,该API已设置且无法更改。 在Python 2上,它默认为版本1以实现向后兼容,但IPython需要API版本2.版本2是Python 3的默认值,PySide的API等同于版本2。 如果您在应用程序中使用了v1 API,则不能使用该应用程序中嵌入的IPython Qt控制台,除非将其移植到v ...
  • 我在macOS Sierra上尝试了你的代码,它可以正常工作。 但是,我会提出一种不同的方法来解决您的问题。 你可以做的是在你的MainWindow类中实现showEvent()函数,只要显示一个小部件(使用.show()或.showMaximized() )就会执行该函数,并触发你的自定义插槽来打开QFileDialog 。 执行此操作时,您可以使用单次触发计时器以最小的延迟触发插槽:这背后的原因是,如果您只是从showEvent()打开对话框,您将看到对话窗口而不是MainWindow在它下面(因为QF ...
  • 你的第二个问题回答了第一个问题。 重新实现的keyPressEvent方法调用close() ,它将QCloseEvent发送到窗口小部件。 随后,将使用该事件作为其参数调用窗口小部件的closeEvent 。 所以你只需要将按钮连接到小部件的close()插槽,一切都将按预期工作: btn.clicked.connect(self.close) Your second question answers the first question. The reimplemented keyPressE ...
  • 你应该发布你的setup.py所以我们可以看看它。 无论如何,这个效果的东西应该适用于你的py2exe setup.py。 您可能必须调整bundle_files和zipfile参数才能使用我们的设置。 确保将'insert qt path here'替换为QT dll的正确路径,并输入'a.dll','b.dll','c.dll'的实际QT dll名称,... setup.py: # USAGE: 'python setup.py py2exe' from distutils.core import se ...
  • 这看起来像IDLE特有的问题。 python bug跟踪器上存在几个密切相关的问题(例如8093和12540 ),但它们现在已关闭并被解析为“已修复”。 由于您似乎使用的是旧版本的python(2.5),因此您应该能够通过升级来解决问题。 This looks like a problem specific to IDLE. There are several issues on the python bug tracker that are closely related (e.g. 8093 and 1 ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)