Opened 5 years ago

Closed 5 years ago

#12400 closed enhancement (fixed)

Rewrite with Python plistlib

Reported by: dcf Owned by: dcf
Priority: Low Milestone:
Component: Applications/Tor bundles/installation Version:
Severity: Keywords:
Cc: mcs, brade Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description uses a sed script to modify an XML file. I looked into ways to programmatically modify a plist file, and found Python plistlib. It will be more robust in case of changes in the input plist file like missing keys. I used plistlib with success in

Child Tickets

Attachments (1)

0001-Port-fix-info-plist-from-shell-to-Python.patch (3.5 KB) - added by dcf 5 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 5 years ago by mcs

Cc: mcs brade added

If brade and I would have known about plistlib we would have used it. The sed script used in is quite complicated (it took a while to get it right) and you are correct that it is somewhat fragile.

comment:2 Changed 5 years ago by dcf

Status: newneeds_review

Here's a patch. plistlib canonicalizes indentation and order, so the before–after diff is not empty, but the meaning is the same. In this diff, directory 1 is built with, and directory is with

diff -Nru 1/Contents/Info.plist 2/Contents/Info.plist
--- 1/Contents/Info.plist       2000-01-01 00:00:00.000000000 +0000
+++ 2/Contents/Info.plist       2000-01-01 00:00:00.000000000 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
 <plist version="1.0">
@@ -51,7 +51,7 @@
-                           <string>text</string>
+                               <string>text</string>
@@ -158,8 +158,6 @@
-       <key>NSHumanReadableCopyright</key>
-       <string>Tor Browser 4.0-alpha1-pre Copyright 2014 The Tor Project</string>
@@ -203,8 +201,6 @@
-       <key>NSAppleScriptEnabled</key>
-       <true/>
@@ -216,10 +212,15 @@
-  <key>NSSupportsAutomaticGraphicsSwitching</key>
-  <true/>
-  <key>NSPrincipalClass</key>
-  <string>GeckoNSApplication</string>
-  <key>NSDisablePersistence</key><true/>
+       <key>NSAppleScriptEnabled</key>
+       <true/>
+       <key>NSDisablePersistence</key>
+       <true/>
+       <key>NSHumanReadableCopyright</key>
+       <string>Tor Browser 4.0-alpha1-pre Copyright 2014 The Tor Project</string>
+       <key>NSPrincipalClass</key>
+       <string>GeckoNSApplication</string>
+       <key>NSSupportsAutomaticGraphicsSwitching</key>
+       <true/>

comment:3 Changed 5 years ago by mcs

Your changes look fine to me.

comment:4 Changed 5 years ago by gk

Resolution: fixed
Status: needs_reviewclosed

I assume writePlist() works deterministically, right? Anyway, we'll see how it goes in the next alpha. Thanks! This is commit eae09200b44e70f45a9bd267912b06bb560f238d in the tor-browser-bundle repo now.

Note: See TracTickets for help on using tickets.