import os
import shutil
import sys
-
-from manifest_json_parser import ManifestJsonParser
+import tempfile
def CopyToPathWithName(root, name, final_path, rename):
if name == '':
return False
origin_path = os.path.join(root, name)
if not os.path.exists(origin_path):
- print ('Error: \'' + origin_path + '\' not found.' )
+ print('Error: \'' + origin_path + '\' not found.')
sys.exit(6)
if not os.path.exists(final_path):
os.makedirs(final_path)
def CopyDrawables(image_dict, orientation, sanitized_name, name, app_root):
- drawable = os.path.join(sanitized_name, 'res', 'drawable')
+ drawable = os.path.join(tempfile.gettempdir(), sanitized_name, 'res',
+ 'drawable')
if orientation == 'landscape':
drawable = drawable + '-land'
elif orientation == 'portrait':
# If no supported images found, find the closest one as 1x.
if not has_image:
closest = ''
- delta = sys.maxint
- for (k , v) in image_dict.items():
+ delta = sys.maxsize
+ for(k, v) in image_dict.items():
items = k.split('x')
if len(items) == 2:
- float_value = sys.maxint
+ float_value = sys.maxsize
try:
float_value = float(items[0])
except ValueError:
for image_pair in image_list:
items = image_pair.strip().split(' ')
if len(items) >= 2:
- x = items[len(items)-1]
+ x = items[len(items) - 1]
image_item = items[0]
image_dict[x] = image_item
orientation,
sanitized_name,
app_root):
- background_path = os.path.join(sanitized_name, 'res',
+ background_path = os.path.join(tempfile.gettempdir(), sanitized_name, 'res',
'drawable', 'launchscreen_bg.xml')
if not os.path.isfile(background_path):
print('Error: launchscreen_bg.xml is missing in the build tool.')
content = content.replace('<!-- Background Image -->', tmp, 1)
has_background = True
if has_background:
- background_file = file(background_path,'w')
+ background_file = open(background_path, 'w')
background_file.write(content)
background_file.close()
return has_background
-def CustomizeByOrientation(parser, orientation, sanitized_name, app_root):
- background_color = parser.GetLaunchScreenBackgroundColor(orientation)
- background_image = parser.GetLaunchScreenBackgroundImage(orientation)
- image = parser.GetLaunchScreenImage(orientation)
+def CustomizeByOrientation(manifest, orientation, sanitized_name, app_root):
+ background_color = manifest.GetLaunchScreenBackgroundColor(orientation)
+ background_image = manifest.GetLaunchScreenBackgroundImage(orientation)
+ image = manifest.GetLaunchScreenImage(orientation)
# Customize background: background_color, background_image.
has_background = CustomizeBackground(background_color, background_image,
orientation, sanitized_name, app_root)
return has_background
-def CustomizeLaunchScreen(app_manifest, sanitized_name):
- if not app_manifest:
+def CustomizeLaunchScreen(manifest, sanitized_name):
+ if manifest is None:
return False
- parser = ManifestJsonParser(os.path.expanduser(app_manifest))
- app_root = os.path.dirname(app_manifest)
- default = CustomizeByOrientation(parser, 'default',
+ app_root = os.path.dirname(manifest.input_path)
+ default = CustomizeByOrientation(manifest, 'default',
sanitized_name, app_root)
- portrait = CustomizeByOrientation(parser, 'portrait',
+ portrait = CustomizeByOrientation(manifest, 'portrait',
sanitized_name, app_root)
- landscape = CustomizeByOrientation(parser, 'landscape',
+ landscape = CustomizeByOrientation(manifest, 'landscape',
sanitized_name, app_root)
return default or portrait or landscape