MCPcopy Create free account
hub / github.com/conda/constructor / modify_xml

Function modify_xml

constructor/osxpkg.py:128–365  ·  view source on GitHub ↗
(xml_path, info)

Source from the content-addressed store, hash-verified

126
127
128def modify_xml(xml_path, info):
129 # See
130 # http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW20
131 # for all the options you can put here.
132
133 tree = ET.parse(xml_path)
134 root = tree.getroot()
135
136 title = ET.Element("title")
137 title.text = f"{info['name']} {info['version']}"
138 root.append(title)
139
140 license = ET.Element("license", file=info.get("license_file", "No license"))
141 root.append(license)
142
143 # -- BACKGROUND -- #
144 # Default setting for the background was using Anaconda's logo
145 # located at ./osx/MacInstaller.png. If `welcome_image` or
146 # `welcome_image_text` are not provided, this will still happen.
147 # However, if the user provides one of those, we will use that instead.
148 # If no background is desired, set `welcome_image` to None
149 if "welcome_image" in info:
150 if not info["welcome_image"]:
151 background_path = None
152 else:
153 write_images(info, PACKAGES_DIR, installer_type="pkg")
154 background_path = os.path.join(PACKAGES_DIR, "welcome.png")
155 elif "welcome_image_text" in info:
156 write_images(info, PACKAGES_DIR, installer_type="pkg")
157 background_path = os.path.join(PACKAGES_DIR, "welcome.png")
158 else:
159 # Default to Anaconda's logo if the keys above were not specified
160 background_path = join(OSX_DIR, "MacInstaller.png")
161
162 if background_path:
163 logger.info("Using background image: %s", background_path)
164 for key in ("background", "background-darkAqua"):
165 background = ET.Element(
166 key, file=background_path, scaling="proportional", alignment="center"
167 )
168 root.append(background)
169
170 # -- WELCOME -- #
171 # The endswith .nsi is for windows specifically. The nsi script will add in
172 # welcome pages if added.
173 if "welcome_file" in info and not info["welcome_file"].endswith(".nsi"):
174 welcome_path = info["welcome_file"]
175 elif "welcome_text" in info and info["welcome_text"]:
176 welcome_path = join(PACKAGES_DIR, "welcome.txt")
177 with open(welcome_path, "w") as f:
178 f.write(info["welcome_text"])
179 else:
180 welcome_path = None
181 if info.get("welcome_file", "").endswith(".nsi"):
182 logger.info("Warning: NSI welcome_file, %s, is ignored.", info["welcome_file"])
183
184 if welcome_path:
185 welcome = ET.Element(

Callers 1

createFunction · 0.85

Calls 7

write_imagesFunction · 0.85
_detect_mimetypeFunction · 0.85
write_readmeFunction · 0.85
parse_virtual_specsFunction · 0.85
approx_size_kbFunction · 0.85
getMethod · 0.80
removeMethod · 0.80

Tested by

no test coverage detected