1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Rep Power

    Reading & writting *.pkg files


    I am a beginner to python (1 day old)
    I have a file with .pkg extension. I would like to read that file and search a line & delete that line. I found a code in one of the forum. I am able to run that code but my entire my.pkg file is getting corrupted.

    my.pkg file has lot of special charcets in it.

    Is there any way to read a .pkg files and edit that file using python?

    Here is the code which got in one of the forums.

    f = open("my.pkg","r")
    lines = f.readlines()

    f = open("my.pkg","w")
    for line in lines:
    if line!='"acd213211"-"X:\\abcd\\sadadfa\\5656\\7x068686860\\asdfas.xml", GGG, WWWW"' + "\n":


    Kindly help me in resolving this issue.

    Thanks in advance.
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    Originally Posted by wikipedia
    .pkg is a file format used by Apple Inc. on its Macintosh line of computers, and the iPhone. It's also used by Sony's PlayStation 3 on downloadable content over PlayStation Network.
    Since this file format probably stores a directory archive in a compressed format, the file will make sense only as a whole. If you remove or change a byte the whole dang thing is ruined. Unwrap the package, make alterations to the files, then repackage it. Since you intend something else I conclude you're \strikeout{crazy} ill-informed.
    Last edited by b49P23TIvg; August 31st, 2012 at 09:02 AM. Reason: reference the quotation
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo