From 4cb54d3819d8a58d0bd07b8da0c4a978807c44ec Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 3 Dec 2009 20:05:48 +0100 Subject: translated mime type db generator into python --- data/generate.py | 16 ++++++++++++++++ data/generate.rb | 21 --------------------- data/mime.dat | Bin 10452 -> 15082 bytes 3 files changed, 16 insertions(+), 21 deletions(-) create mode 100755 data/generate.py delete mode 100755 data/generate.rb (limited to 'data') diff --git a/data/generate.py b/data/generate.py new file mode 100755 index 00000000..61309259 --- /dev/null +++ b/data/generate.py @@ -0,0 +1,16 @@ +#!/usr/bin/python3 +# coding=utf-8 + +protocol = 0 + +import sys, pickle + +table = {} +for line in open(len(sys.argv) > 1 and sys.argv[1] or "mime.types"): + if len(line) > 3 and line[0] != '#' and '\t' in line: + name, *extensions = line.split() + for ext in extensions: + table[ext] = name + +pickle.dump(table, open('mime.dat', 'wb'), protocol) + diff --git a/data/generate.rb b/data/generate.rb deleted file mode 100755 index 52a4c8e4..00000000 --- a/data/generate.rb +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/ruby -## Parses mime.types and creates mime.dat - -file = File.read(ARGV.first || "mime.types") - -table = {} -for line in file.lines - next if line[0] == ?# or - line.size <= 3 or - !line.include?( ?\t ) - - name, *extensions = line.split(/\s+/) - for ext in extensions - table[ext] = name - end -end - -File.open( 'mime.dat', 'w' ) do |f| - f.write Marshal.dump( table ) -end - diff --git a/data/mime.dat b/data/mime.dat index 78b0de8c..ddfca976 100644 Binary files a/data/mime.dat and b/data/mime.dat differ -- cgit 1.4.1-2-gfad0