X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=utils%2Fmacos_dmg%2Fjalview_customise_dsstore.py;fp=utils%2Fmacos_dmg%2Fjalview_customise_dsstore.py;h=167c4c8fd888e44e00b5a6fbab29af762af5d086;hb=cbee9978721e4efff9e0741ba6933fb090d3aa23;hp=2343fd869fd1b2b4be8d8124ebf9ed1a652126a9;hpb=72e22d79767010318a6de03d9f30d9ec8768dc45;p=jalview.git diff --git a/utils/macos_dmg/jalview_customise_dsstore.py b/utils/macos_dmg/jalview_customise_dsstore.py index 2343fd8..167c4c8 100755 --- a/utils/macos_dmg/jalview_customise_dsstore.py +++ b/utils/macos_dmg/jalview_customise_dsstore.py @@ -22,7 +22,9 @@ parser.add_argument("-c", "--config", help="YAML configuration for window and ic parser.add_argument("-m", "--dmg", help="The filename of the DMG file", dest="dmg", default="Jalview_macos.dmg") parser.add_argument("--dump", help="Display contents of the input DS_Store to stdout", action="store_true", dest="dump") parser.add_argument("-q", "--quiet", help="Don't print messages to stdout", action="store_true", dest="quiet") -parser.add_argument("-f", "--filenames", help="List of comma-separated filenames to show information for --dump", dest="filenames", default="") +parser.add_argument("--appname", help="Filename of the application on the DMG (including '.app')", dest="appname") +parser.add_argument("--appxpos", help="x position of the application icon", dest="appxpos", type=int) +parser.add_argument("--appypos", help="y position of the application icon", dest="appypos", type=int) args = parser.parse_args() @@ -39,13 +41,9 @@ if (args.dump and not args.input): if (args.dump): with ds_store.DSStore.open(args.input, 'r') as d: - print(f"d=") - print(pprint.pformat(d['.']['bwsp'], width=1)) - for key in ["bwsp", "icvp","Iloc"]: try: - print(f"d['.']['{key}']=") - pprint.pprint(str(d['.'][key]), width=1) + print(f"d['.']['{key}'] =\n" + pprint.pformat(d['.'][key], width=4)) except: print(f"No info for d['.']['{key}']") @@ -60,12 +58,6 @@ if (args.dump): pprint.pprint(f"d['{data}']="+d[data], width=1) except: print(f"No info for d['{data}']") -# for filename in args.filenames.split(","): -# if (filename): -# for f in d.find(filename): -# myprint(f"d['{f}']=", d[f]) -# else: -# myprint(f"# No filename '{filename}' found in DS_Store '{args.input}'") exit(0) if (args.output and not (args.input or args.config)): @@ -94,11 +86,15 @@ outputds = ds_store.DSStore.open(args.output, 'w+') bwsp = {} for key in "ShowStatusBar SidebarWidthTenElevenOrLater ShowToolbar ShowTabView ContainerShowSidebar WindowBounds ShowSidebar ShowPathbar".split(): - if key in inputds['.']['bwsp']: - bwsp[key] = inputds['.']['bwsp'][key] - myprint(f"Setting bwsp['{key}'] to '"+str(inputds['.']['bwsp'][key])+"'") + if config and 'bwsp' in config and key in config['bwsp']: + bwsp[key] = config['bwsp'][key] + myprint(f"Setting bwsp['{key}'] to '"+str(bwsp[key])+"' from config") else: - myprint(f"Did not find '{key}' in input bwsp") + if key in inputds['.']['bwsp']: + bwsp[key] = inputds['.']['bwsp'][key] + myprint(f"Setting bwsp['{key}'] to '"+str(bwsp[key])+"' from input DS_Store") + else: + myprint(f"Did not find '{key}' in input bwsp") outputds['.']['bwsp'] = bwsp @@ -115,20 +111,20 @@ alias.target.carbon_path = f'{args.volumename}:{args.backgrounddir}:{args.backgr alias.target.posix_path = f'/{args.backgrounddir}/{args.backgroundfile}' icvp['backgroundImageAlias'] = alias.to_bytes() +myprint(f"Setting icvp['backgroundImageAlias']") for key in "backgroundColorRed backgroundColorBlue backgroundColorGreen gridSpacing gridOffsetX gridOffsetY showItemInfo viewOptionsVersion arrangeBy textSize labelOnBottom backgroundType showIconPreview iconSize".split(): - if key in inputds['.']['icvp']: - icvp[key] = inputds['.']['icvp'][key] - myprint(f"Setting icvp['{key}'] to '"+str(inputds['.']['icvp'][key])+"'") + if config and 'icvp' in config and key in config['icvp']: + icvp[key] = config['icvp'][key] + myprint(f"Setting icvp['{key}'] to '"+str(icvp[key])+"' from config") else: - myprint(f"Did not find '{key}' in input icvp") + if key in inputds['.']['icvp']: + icvp[key] = inputds['.']['icvp'][key] + myprint(f"Setting icvp['{key}'] to '"+str(icvp[key])+"' from input DS_Store") + else: + myprint(f"Did not find '{key}' in input icvp") outputds['.']['icvp'] = icvp - -# copy filenames properties? not working, using JSON config file -#for filename in args.filenames.split(","): -# outputds[filename]['Iloc'] = inputds[filename]['Iloc'] - outputds['.']['vSrn'] = ('long', 1) if config: @@ -136,6 +132,20 @@ if config: outputds[fileinfo['name']]['Iloc'] = (fileinfo['xpos'], fileinfo['ypos']) myprint("Setting icon location for filename '" + fileinfo['name'] + "' to ( " + str(fileinfo['xpos']) + ", " + str(fileinfo['ypos']) + " )") +if args.appname: + + xpos = args.appxpos + if (not xpos) and 'app' in config and 'xpos' in config['app']: + xpos = config['app']['xpos'] + + ypos = args.appypos + if (not ypos) and 'app' in config and 'ypos' in config['app']: + ypos = config['app']['ypos'] + + if xpos != None and ypos != None: + outputds[args.appname]['Iloc'] = (xpos, ypos) + myprint("Setting icon location for filename '" + args.appname + "' to ( " + str(xpos) + ", " + str(ypos) + " )") + outputds.flush() outputds.close() inputds.close()