Skip to content
This repository was archived by the owner on Nov 9, 2021. It is now read-only.
This repository was archived by the owner on Nov 9, 2021. It is now read-only.

Save target file parameter #3

@kiloforce

Description

@kiloforce

First wanted to say, works beautifully, thanks!

I would like to suggest that the script takes an optional parameter for the target save file. Dumping into the current directory may not always be the desired goal, especially when running from a cronjob.

Example:
/usr/local/bin/dilbert.py /www/dilbert/dilbert.xml

Here is even a suggested patch:

diff --git a/dilbert.py b/dilbert.py
index 74d8c1e..3b3532a 100755
--- a/dilbert.py
+++ b/dilbert.py
@@ -7,7 +7,7 @@ http://github.com/fredley/dilbert-rss

 """

-import urllib2, datetime, PyRSS2Gen
+import urllib2, datetime, sys, PyRSS2Gen
 from BeautifulSoup import BeautifulSoup

 def getDetails(url, baseURL):
@@ -45,5 +45,9 @@ rss = PyRSS2Gen.RSS2(
     lastBuildDate = datetime.datetime.now(),
     items = strips)

-rss.write_xml(open("dilbert.xml", "w"))
+if len(sys.argv) > 1:
+    outfile = sys.argv[1]
+else:
+    outfile = "dilbert.xml"
+rss.write_xml(open(outfile, "w"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions