Use INI format instead of JSON for packages
authorAntonio Ospite <ospite@studenti.unina.it>
Sun, 6 May 2012 15:36:32 +0000 (17:36 +0200)
committerAntonio Ospite <ospite@studenti.unina.it>
Sun, 6 May 2012 15:36:32 +0000 (17:36 +0200)
The INI format supported by ConfigParser supports variable interpolation
which comes in handy for URLs with parametric language and version.

28 files changed:
pkgs/7-zip.ini [new file with mode: 0644]
pkgs/7-zip.json [deleted file]
pkgs/CDBurnerXP.ini [new file with mode: 0644]
pkgs/CDBurnerXP.json [deleted file]
pkgs/evince.ini [new file with mode: 0644]
pkgs/evince.json [deleted file]
pkgs/gimp.ini [new file with mode: 0644]
pkgs/gimp.json [deleted file]
pkgs/inkscape.ini [new file with mode: 0644]
pkgs/inkscape.json [deleted file]
pkgs/libreoffice.ini [new file with mode: 0644]
pkgs/libreoffice.json [deleted file]
pkgs/libreoffice_helppack.ini [new file with mode: 0644]
pkgs/libreoffice_helppack.json [deleted file]
pkgs/mozilla_firefox.ini [new file with mode: 0644]
pkgs/mozilla_firefox.json [deleted file]
pkgs/mozilla_thunderbird.ini [new file with mode: 0644]
pkgs/mozilla_thunderbird.json [deleted file]
pkgs/nonfree_avast.ini [new file with mode: 0644]
pkgs/pidgin.ini [new file with mode: 0644]
pkgs/pidgin.json [deleted file]
pkgs/vlc.ini [new file with mode: 0644]
pkgs/vlc.json [deleted file]
pkgs/xp-antispy.ini [new file with mode: 0644]
pkgs/xp-antispy.json [deleted file]
template.ini [new file with mode: 0644]
template.json [deleted file]
winfreed.py

diff --git a/pkgs/7-zip.ini b/pkgs/7-zip.ini
new file mode 100644 (file)
index 0000000..c3e2c0b
--- /dev/null
@@ -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 (file)
index 19c09cf..0000000
+++ /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 (file)
index 0000000..df21cc4
--- /dev/null
@@ -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 (file)
index b8b61e0..0000000
+++ /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 (file)
index 0000000..d04f75e
--- /dev/null
@@ -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 (file)
index faf7dcf..0000000
+++ /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 (file)
index 0000000..4d48f09
--- /dev/null
@@ -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 (file)
index a3e66b5..0000000
+++ /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 (file)
index 0000000..053702c
--- /dev/null
@@ -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 (file)
index 1e251ee..0000000
+++ /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 (file)
index 0000000..bc4388d
--- /dev/null
@@ -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 (file)
index 0314cbd..0000000
+++ /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 (file)
index 0000000..152aba1
--- /dev/null
@@ -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 (file)
index 05300cb..0000000
+++ /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 (file)
index 0000000..52afa64
--- /dev/null
@@ -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 (file)
index e92f5b4..0000000
+++ /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 (file)
index 0000000..88eee98
--- /dev/null
@@ -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 (file)
index 6048671..0000000
+++ /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 (file)
index 0000000..a7e90c8
--- /dev/null
@@ -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 (file)
index 0000000..1da5895
--- /dev/null
@@ -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 (file)
index 739aef9..0000000
+++ /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 (file)
index 0000000..8a5f481
--- /dev/null
@@ -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 (file)
index eae5cf7..0000000
+++ /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 (file)
index 0000000..35acf13
--- /dev/null
@@ -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 (file)
index 824627d..0000000
+++ /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 (file)
index 0000000..319503f
--- /dev/null
@@ -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 (file)
index dbf588b..0000000
+++ /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"
-}
index a59d78e..362911a 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-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)