def init(project_dir): """ Only call this if you are not running `python -m fbs` or fbs.cmdline.main(). """ SETTINGS['project_dir'] = abspath(project_dir) activate_profile('base') activate_profile(platform.name().lower())
def get_icons(): result = {} for icons_dir in ('src/main/icons/base', 'src/main/icons/' + platform.name().lower()): for icon_path in glob(path(icons_dir + '/*.png')): size = int(splitext(basename(icon_path))[0]) result[size] = icon_path return list(result.items())
def get_icons(): """ Return a list [(size_in_pixels, path)] of available app icons for the current platform. """ result = {} for icons_dir in ('src/main/icons/base', 'src/main/icons/' + platform.name().lower()): for icon_path in glob(path(icons_dir + '/*.png')): size = int(splitext(basename(icon_path))[0]) result[size] = icon_path return list(result.items())
def generate_resources(): freeze_dir = path('${freeze_dir}') if is_mac(): resources_dest_dir = join(freeze_dir, 'Contents', 'Resources') else: resources_dest_dir = freeze_dir kwargs = {'files_to_filter': SETTINGS['resources_to_filter']} resource_dirs = ( path('src/main/resources/base'), path('src/main/resources/' + platform.name().lower()) ) for dir_ in resource_dirs: if exists(dir_): copy_with_filtering(dir_, resources_dest_dir, **kwargs) frozen_resources_dir = dir_ + '-frozen' if exists(frozen_resources_dir): copy_with_filtering(frozen_resources_dir, freeze_dir, **kwargs)
def generate_resources(dest_dir=None, dest_dir_for_base=None, exclude=None): if dest_dir is None: # Set this default here instead of in the function definition # (`def generate_resources(dest_dir=path(...) ...)`) because we can't # call path(...) at the module level. dest_dir = path('target/resources') if dest_dir_for_base is None: dest_dir_for_base = dest_dir if exclude is None: exclude = [] resources_to_filter = SETTINGS['resources_to_filter'] kwargs = {'exclude': exclude, 'files_to_filter': resources_to_filter} copy_with_filtering(path('src/main/resources/base'), dest_dir_for_base, **kwargs) os_resources_dir = path('src/main/resources/' + platform.name().lower()) if exists(os_resources_dir): copy_with_filtering(os_resources_dir, dest_dir, **kwargs)
def generate_resources(): """ Copy the data files from src/main/resources to the target/ directory. Automatically filters files mentioned in the setting resources_to_filter: Placeholders such as ${app_name} are automatically replaced by the corresponding setting in files on that list. """ freeze_dir = path('${freeze_dir}') if is_mac(): resources_dest_dir = join(freeze_dir, 'Contents', 'Resources') else: resources_dest_dir = freeze_dir kwargs = {'files_to_filter': SETTINGS['resources_to_filter']} resource_dirs = (path('src/main/resources/base'), path('src/main/resources/' + platform.name().lower())) for dir_ in resource_dirs: if exists(dir_): copy_with_filtering(dir_, resources_dest_dir, **kwargs) frozen_resources_dir = dir_ + '-frozen' if exists(frozen_resources_dir): copy_with_filtering(frozen_resources_dir, freeze_dir, **kwargs)