Configuration

* A configuration file is made if one hasn't been found
* Certain values (currently download category and location) are stored in config file.
This commit is contained in:
ryuslash 2010-01-26 20:20:39 +01:00
parent c737789105
commit 53c7802ae2
2 changed files with 9 additions and 4 deletions

View file

@ -17,7 +17,12 @@ class _Configuration(object):
self.configparser.add_section("locations")
self.configparser.set("locations", "download", self.raw_input_with_default(os.path.join(os.getenv("HOME"), "Pictures"), "Please enter where you would like the downloads to go: "))
with open(self.filename) as configfile:
#with open(self.filename) as configfile:
# self.configparser.write(configfile)
dirname = os.path.dirname(self.filename)
if not os.path.exists(dirname):
os.mkdir(dirname)
configfile = open(self.filename, "w")
self.configparser.write(configfile)
def raw_input_with_default(self, default, prompt):

View file

@ -5,7 +5,7 @@ import htmlparser
import progressbar
import config
savedir = Configuration().get_download_location()
savedir = config.Configuration().get_download_location()
def get_thread_links(baseurl):
myparser = htmlparser.MyParser()
@ -89,7 +89,7 @@ def get_images(t = []):
if __name__ == "__main__":
# Get a file-like object for the 4chan.org w/imgboard
base_url = "http://boards.4chan.org/" + Configuration().get_category() + "/"
base_url = "http://boards.4chan.org/" + config.Configuration().get_category() + "/"
# Get the hyperlinks.
t = get_thread_links(base_url)