On Tue, Apr 15, 2008 at 12:41 PM, Martin Langhoff
<[EMAIL PROTECTED]> wrote:
>  The usage is the same as above, except that a significant "l" changes to a 
> "y".

Emiliano reports that the script only outputs the contents of _one_ of
the files being concatenated. Alas, it looks like I'm an idiot when it
comes to basic Python scripting. So here is a further bugfix on the
script. Attached is the fixed script, and the patch.

cheers,



martin
-- 
 [EMAIL PROTECTED]
 [EMAIL PROTECTED] -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
#!/usr/bin/python 
#
# Usage:
#
#       cat-leases.pl */lease.sig  > all_leases.sig
#
# cat-leases will concatenate and sort the JSON-encoded
# activation leases (for OLPC XOs of the XO-1 series).
#
#
# NOTE: the json we import here is actually
# "Canonical JSON" reader/writer from the
# bitfrost/util directory.
#
# 
# Blame: Martin Langhoff <[EMAIL PROTECTED]>
# License: GPL v2
#

# if Bitfrost's json.py is in the PYTHONPATH
import json
# if Bitfrost is in the PYTHONPATH
#import bitfrost.util.json as json

import sys

data = {}

# note - we skip the zeroth position
# of argv which has $0
for  n in range(1,len(sys.argv)):
    fn = sys.argv[n]
    file = open(fn, 'r')
    fcontent = file.read()
    file.close()

    # read the data and pull the dict out of the nested
    # structure
    newdata = json.read(fcontent)
    newdata = newdata.pop()
    data.update(newdata)

ordereddata = {}
for k in sorted(data.keys()):
    ordereddata[k] = data[k]

json.write_to_file(sys.stdout, [1, ordereddata])

Attachment: emiliano.patch
Description: Binary data

_______________________________________________
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel

Reply via email to