From 3a60f746376614664f7a3f48f05fff49e689bfb4 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Sun, 6 May 2012 17:36:32 +0200 Subject: [PATCH] Use INI format instead of JSON for packages The INI format supported by ConfigParser supports variable interpolation which comes in handy for URLs with parametric language and version. --- pkgs/7-zip.ini | 9 +++++++++ pkgs/7-zip.json | 6 ------ pkgs/CDBurnerXP.ini | 10 ++++++++++ pkgs/CDBurnerXP.json | 6 ------ pkgs/evince.ini | 9 +++++++++ pkgs/evince.json | 6 ------ pkgs/gimp.ini | 11 +++++++++++ pkgs/gimp.json | 6 ------ pkgs/inkscape.ini | 11 +++++++++++ pkgs/inkscape.json | 6 ------ pkgs/libreoffice.ini | 10 ++++++++++ pkgs/libreoffice.json | 6 ------ pkgs/libreoffice_helppack.ini | 9 +++++++++ pkgs/libreoffice_helppack.json | 6 ------ pkgs/mozilla_firefox.ini | 11 +++++++++++ pkgs/mozilla_firefox.json | 6 ------ pkgs/mozilla_thunderbird.ini | 10 ++++++++++ pkgs/mozilla_thunderbird.json | 6 ------ pkgs/nonfree_avast.ini | 7 +++++++ pkgs/pidgin.ini | 11 +++++++++++ pkgs/pidgin.json | 6 ------ pkgs/vlc.ini | 11 +++++++++++ pkgs/vlc.json | 6 ------ pkgs/xp-antispy.ini | 8 ++++++++ pkgs/xp-antispy.json | 6 ------ template.ini | 17 +++++++++++++++++ template.json | 10 ---------- winfreed.py | 29 ++++++++++++----------------- 28 files changed, 156 insertions(+), 99 deletions(-) create mode 100644 pkgs/7-zip.ini delete mode 100644 pkgs/7-zip.json create mode 100644 pkgs/CDBurnerXP.ini delete mode 100644 pkgs/CDBurnerXP.json create mode 100644 pkgs/evince.ini delete mode 100644 pkgs/evince.json create mode 100644 pkgs/gimp.ini delete mode 100644 pkgs/gimp.json create mode 100644 pkgs/inkscape.ini delete mode 100644 pkgs/inkscape.json create mode 100644 pkgs/libreoffice.ini delete mode 100644 pkgs/libreoffice.json create mode 100644 pkgs/libreoffice_helppack.ini delete mode 100644 pkgs/libreoffice_helppack.json create mode 100644 pkgs/mozilla_firefox.ini delete mode 100644 pkgs/mozilla_firefox.json create mode 100644 pkgs/mozilla_thunderbird.ini delete mode 100644 pkgs/mozilla_thunderbird.json create mode 100644 pkgs/nonfree_avast.ini create mode 100644 pkgs/pidgin.ini delete mode 100644 pkgs/pidgin.json create mode 100644 pkgs/vlc.ini delete mode 100644 pkgs/vlc.json create mode 100644 pkgs/xp-antispy.ini delete mode 100644 pkgs/xp-antispy.json create mode 100644 template.ini delete mode 100644 template.json diff --git a/pkgs/7-zip.ini b/pkgs/7-zip.ini new file mode 100644 index 0000000..c3e2c0b --- /dev/null +++ b/pkgs/7-zip.ini @@ -0,0 +1,9 @@ +[Package] +name = 7-Zip +homepage = http://www.7-zip.org/ + +description = 7-Zip is a file archiver with a high compression ratio. + +url = http://downloads.sourceforge.net/sevenzip/7z%(version)s.exe + +version = 920 diff --git a/pkgs/7-zip.json b/pkgs/7-zip.json deleted file mode 100644 index 19c09cf..0000000 --- a/pkgs/7-zip.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "7-Zip", - "homepage": "http://www.7-zip.org/", - "description": "7-Zip is a file archiver with a high compression ratio.", - "URL": "http://downloads.sourceforge.net/sevenzip/7z920.exe" -} diff --git a/pkgs/CDBurnerXP.ini b/pkgs/CDBurnerXP.ini new file mode 100644 index 0000000..df21cc4 --- /dev/null +++ b/pkgs/CDBurnerXP.ini @@ -0,0 +1,10 @@ +[Package] +name = CDBurnerXP +homepage = http://cdburnerxp.se/ + +description = CDBurnerXP is a free application to burn CDs and DVDs, + including Blu-Ray and HD-DVDs. + +url = http://download.cdburnerxp.se/msi/cdbxp_setup_%(version)s.msi + +version = 4.4.0.2971 diff --git a/pkgs/CDBurnerXP.json b/pkgs/CDBurnerXP.json deleted file mode 100644 index b8b61e0..0000000 --- a/pkgs/CDBurnerXP.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "CDBurnerXP", - "homepage": "http://cdburnerxp.se/", - "description": "CDBurnerXP is a free application to burn CDs and DVDs, including Blu-Ray and HD-DVDs.", - "URL": "http://download.cdburnerxp.se/msi/cdbxp_setup_4.4.0.2971.msi" -} diff --git a/pkgs/evince.ini b/pkgs/evince.ini new file mode 100644 index 0000000..d04f75e --- /dev/null +++ b/pkgs/evince.ini @@ -0,0 +1,9 @@ +[Package] +name = Evince +homepage = http://projects.gnome.org/evince/ + +description = Evince is a document viewer for multiple document formats. + +url = http://ftp.gnome.org/pub/GNOME/binaries/win32/evince/2.32/evince-%(version)s.msi + +version = 2.32.0.145 diff --git a/pkgs/evince.json b/pkgs/evince.json deleted file mode 100644 index faf7dcf..0000000 --- a/pkgs/evince.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Evince", - "homepage": "http://projects.gnome.org/evince/", - "description": "Evince is a document viewer for multiple document formats.", - "URL": "http://ftp.gnome.org/pub/GNOME/binaries/win32/evince/2.32/evince-2.32.0.145.msi" -} diff --git a/pkgs/gimp.ini b/pkgs/gimp.ini new file mode 100644 index 0000000..4d48f09 --- /dev/null +++ b/pkgs/gimp.ini @@ -0,0 +1,11 @@ +[Package] +name = GIMP +homepage = http://www.gimp.org/ + +description = GIMP is the GNU Image Manipulation Program. It is a freely + distributed piece of software for such tasks as photo retouching, image + composition and image authoring. + +url = http://downloads.sourceforge.net/gimp-win/gimp-%(version)s-setup.exe?use_mirror= + +version = 2.8.0 diff --git a/pkgs/gimp.json b/pkgs/gimp.json deleted file mode 100644 index a3e66b5..0000000 --- a/pkgs/gimp.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "GIMP", - "homepage": "http://www.gimp.org/", - "description": "GIMP is the GNU Image Manipulation Program. It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring.", - "URL": "http://downloads.sourceforge.net/gimp-win/gimp-2.8.0-setup.exe?use_mirror=" -} diff --git a/pkgs/inkscape.ini b/pkgs/inkscape.ini new file mode 100644 index 0000000..053702c --- /dev/null +++ b/pkgs/inkscape.ini @@ -0,0 +1,11 @@ +[Package] +name = Inkscape +homepage = http://inkscape.org/ + +description = An Open Source vector graphics editor, with capabilities + similar to Illustrator, CorelDraw, or Xara X, using the W3C standard + Scalable Vector Graphics (SVG) file format. + +url = http://sourceforge.net/projects/inkscape/files/inkscape/%(version)s/Inkscape-%(version)s-1.exe/download + +version = 0.48.3.1 diff --git a/pkgs/inkscape.json b/pkgs/inkscape.json deleted file mode 100644 index 1e251ee..0000000 --- a/pkgs/inkscape.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Inkscape", - "homepage": "http://inkscape.org/", - "description": "An Open Source vector graphics editor, with capabilities similar to Illustrator, CorelDraw, or Xara X, using the W3C standard Scalable Vector Graphics (SVG) file format.", - "URL": "http://sourceforge.net/projects/inkscape/files/inkscape/0.48.3.1/Inkscape-0.48.3.1-1.exe/download" -} diff --git a/pkgs/libreoffice.ini b/pkgs/libreoffice.ini new file mode 100644 index 0000000..bc4388d --- /dev/null +++ b/pkgs/libreoffice.ini @@ -0,0 +1,10 @@ +[Package] +name = LibreOffice +homepage = http://www.libreoffice.org/ + +description = LibreOffice is the power-packed free, libre and open + source personal productivity suite for Windows, Macintosh and GNU/Linux. + +url = http://download.documentfoundation.org/libreoffice/stable/%(version)s/win/x86/LibO_%(version)s_Win_x86_install_multi.msi + +version = 3.5.3 diff --git a/pkgs/libreoffice.json b/pkgs/libreoffice.json deleted file mode 100644 index 0314cbd..0000000 --- a/pkgs/libreoffice.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "LibreOffice", - "homepage": "http://www.libreoffice.org/", - "description": "LibreOffice is the power-packed free, libre and open source personal productivity suite for Windows, Macintosh and GNU/Linux.", - "URL": "http://download.documentfoundation.org/libreoffice/stable/3.5.3/win/x86/LibO_3.5.3_Win_x86_install_multi.msi" -} diff --git a/pkgs/libreoffice_helppack.ini b/pkgs/libreoffice_helppack.ini new file mode 100644 index 0000000..152aba1 --- /dev/null +++ b/pkgs/libreoffice_helppack.ini @@ -0,0 +1,9 @@ +[Package] +name = LibreOffice Help Pack +homepage = http://www.libreoffice.org/ + +description = Localized Help Pack for LibreOffice + +url = http://download.documentfoundation.org/libreoffice/stable/%(version)s/win/x86/LibO_%(version)s_Win_x86_helppack_%(language)s.msi + +version = 3.5.3 diff --git a/pkgs/libreoffice_helppack.json b/pkgs/libreoffice_helppack.json deleted file mode 100644 index 05300cb..0000000 --- a/pkgs/libreoffice_helppack.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "LibreOffice Help Pack", - "homepage": "http://www.libreoffice.org/", - "description": "Localized Help Pack for LibreOffice", - "URL": "http://download.documentfoundation.org/libreoffice/stable/3.5.3/win/x86/LibO_3.5.3_Win_x86_helppack_%s.msi" -} diff --git a/pkgs/mozilla_firefox.ini b/pkgs/mozilla_firefox.ini new file mode 100644 index 0000000..52afa64 --- /dev/null +++ b/pkgs/mozilla_firefox.ini @@ -0,0 +1,11 @@ +[Package] +name = Mozilla Firefox +homepage = http://www.mozilla.org/firefox/ + +description = The Firefox browser is created by Mozilla, a non-profit + organization whose mission is to promote openness, innovation and + opportunity on the Web. + +url = http://download.mozilla.org/?product=firefox-%(version)s&os=win&lang=%(language)s + +version = 11.0 diff --git a/pkgs/mozilla_firefox.json b/pkgs/mozilla_firefox.json deleted file mode 100644 index e92f5b4..0000000 --- a/pkgs/mozilla_firefox.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Mozilla Firefox", - "homepage": "http://www.mozilla.org/firefox/", - "description": "The Firefox browser is created by Mozilla, a non-profit organization whose mission is to promote openness, innovation and opportunity on the Web.", - "URL": "http://download.mozilla.org/?product=firefox-11.0&os=win&lang=%s" -} diff --git a/pkgs/mozilla_thunderbird.ini b/pkgs/mozilla_thunderbird.ini new file mode 100644 index 0000000..88eee98 --- /dev/null +++ b/pkgs/mozilla_thunderbird.ini @@ -0,0 +1,10 @@ +[Package] +name = Mozilla Thunderbird +homepage = https://www.mozilla.org/thunderbird/ + +description = Thunderbird is a free email application that's easy to set + up and customize - and it's loaded with great features! + +url = http://download.mozilla.org/?product=thunderbird-%(version)s&os=win&lang=%(language)s + +version = 11.0.1 diff --git a/pkgs/mozilla_thunderbird.json b/pkgs/mozilla_thunderbird.json deleted file mode 100644 index 6048671..0000000 --- a/pkgs/mozilla_thunderbird.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Mozilla Thunderbird", - "homepage": "https://www.mozilla.org/thunderbird/", - "description": "Thunderbird is a free email application that's easy to set up and customize - and it's loaded with great features!", - "URL": "http://download.mozilla.org/?product=thunderbird-11.0.1&os=win&lang=%s" -} diff --git a/pkgs/nonfree_avast.ini b/pkgs/nonfree_avast.ini new file mode 100644 index 0000000..a7e90c8 --- /dev/null +++ b/pkgs/nonfree_avast.ini @@ -0,0 +1,7 @@ +[Package] +name = Avast free antivirus +homepage = http://avast.com/ + +description = Avast free antivirus + +url = http://files.avast.com/iavs5x/setup_av_free.exe diff --git a/pkgs/pidgin.ini b/pkgs/pidgin.ini new file mode 100644 index 0000000..1da5895 --- /dev/null +++ b/pkgs/pidgin.ini @@ -0,0 +1,11 @@ +[Package] +name = Pidgin +homepage = http://pidgin.im/ + +description = Pidgin is an easy to use and free chat client used by + millions. Connect to AIM, MSN, Yahoo, and more chat networks all at + once. + +url = http://sourceforge.net/projects/pidgin/files/Pidgin/%(version)s/pidgin-%(version)s.exe + +version = 2.10.3 diff --git a/pkgs/pidgin.json b/pkgs/pidgin.json deleted file mode 100644 index 739aef9..0000000 --- a/pkgs/pidgin.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Pidgin", - "homepage": "http://pidgin.im/", - "description": "Pidgin is an easy to use and free chat client used by millions. Connect to AIM, MSN, Yahoo, and more chat networks all at once.", - "URL": "http://sourceforge.net/projects/pidgin/files/Pidgin/2.10.3/pidgin-2.10.3.exe" -} diff --git a/pkgs/vlc.ini b/pkgs/vlc.ini new file mode 100644 index 0000000..8a5f481 --- /dev/null +++ b/pkgs/vlc.ini @@ -0,0 +1,11 @@ +[Package] +name = VLC Media Player +homepage = http://www.videolan.org/ + +description = VLC is a free and open source cross-platform multimedia + player and framework that plays most multimedia files as well as DVD, + Audio CD, VCD, and various streaming protocols. + +url = http://downloads.sourceforge.net/project/vlc/%(version)s/win32/vlc-%(version)s-win32.exe + +version = 2.0.1 diff --git a/pkgs/vlc.json b/pkgs/vlc.json deleted file mode 100644 index eae5cf7..0000000 --- a/pkgs/vlc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "VLC Media Player", - "homepage": "http://www.videolan.org/", - "description": "VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVD, Audio CD, VCD, and various streaming protocols.", - "URL": "http://downloads.sourceforge.net/project/vlc/2.0.1/win32/vlc-2.0.1-win32.exe" -} diff --git a/pkgs/xp-antispy.ini b/pkgs/xp-antispy.ini new file mode 100644 index 0000000..35acf13 --- /dev/null +++ b/pkgs/xp-antispy.ini @@ -0,0 +1,8 @@ +[Package] +name = XP Antispy +homepage = http://xp-antispy.org/ + +description = The xp-AntiSpy is a little utility that lets you disable + some built-in update and authentication 'features' in WindowsXP. + +url = http://xp-antispy.org/downloads/4 diff --git a/pkgs/xp-antispy.json b/pkgs/xp-antispy.json deleted file mode 100644 index 824627d..0000000 --- a/pkgs/xp-antispy.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "XP Antispy", - "homepage": "http://xp-antispy.org/", - "description": "The xp-AntiSpy is a little utility that lets you disable some built-in update and authentication 'features' in WindowsXP.", - "URL": "http://xp-antispy.org/downloads/4" -} diff --git a/template.ini b/template.ini new file mode 100644 index 0000000..319503f --- /dev/null +++ b/template.ini @@ -0,0 +1,17 @@ +; The DEFAULTS section is not strictly needed, it is here just as an +; example, maybe in a future version it can go in some global config +; file +[DEFAULTS] +language = en-US + +[Package] +name = Example program +homepage = http://example.com/ +description = Example program doesn't do anything useful that we know of. +license = GPL + +; A URL can have parametric language and version +url = http://example.com/program-%(version)s-%(language)s.zip + +version = 1.0 +md5 = 564ad4bb65013635017a04d5e7098b9e diff --git a/template.json b/template.json deleted file mode 100644 index dbf588b..0000000 --- a/template.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "Example program", - "homepage": "http://example.com/", - "description": "Example program doesn't do anything useful that we know of.", - - /* A "%s" in the URL will be replaced with a language code, - * this can be useful for localized downloads. - */ - "URL": "http://example.com/program-0.1-%s.zip" -} diff --git a/winfreed.py b/winfreed.py index a59d78e..362911a 100755 --- a/winfreed.py +++ b/winfreed.py @@ -17,11 +17,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import re import os import sys import glob -import json +import ConfigParser import urllib2 from progressbar import Bar, ETA, FileTransferSpeed, Percentage, ProgressBar @@ -34,10 +33,12 @@ PKG_DIR = 'pkgs' CHUNK_SIZE = 8192 -def get_pkg(json_file): - with open(json_file, mode='r') as f: - pkg = json.load(f) - basename = os.path.basename(json_file) +def get_pkg(pkg_file): + config = ConfigParser.SafeConfigParser({'language': LANGCODE}) + with open(pkg_file, mode='r') as f: + config.readfp(f) + pkg = dict(config.items('Package')) + basename = os.path.basename(pkg_file) package_name = os.path.splitext(basename)[0] pkg['package_name'] = package_name f.close() @@ -47,11 +48,11 @@ def get_pkg(json_file): def process_all(path, cb): - listing = glob.glob(os.path.join(path, '*.json')) - for json_file in listing: - pkg = get_pkg(json_file) + listing = glob.glob(os.path.join(path, '*.ini')) + for pkg_file in listing: + pkg = get_pkg(pkg_file) if not pkg: - sys.stderr.write("Error: cannot get a pkg for: %s\n" % json_file) + sys.stderr.write("Error: cannot get a pkg for: %s\n" % pkg_file) continue cb(pkg) @@ -126,13 +127,7 @@ def download_file(src_url, dest_dir): def download(pkg): - # the "%s" in URLs are meant to be replaced with LANGCODE - try: - pkg_url = pkg['URL'] % LANGCODE - except: - pkg_url = pkg['URL'] - pass - + pkg_url = pkg['url'] download_file(pkg_url, OUTPUT_DIR) -- 2.1.4