How to use the fbs.resources.copy_with_filtering function in fbs

To help you get started, we’ve selected a few fbs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mherrmann / fbs / tests / test_fbs / __init__.py View on Github external
def setUp(self):
        super().setUp()
        # Copy template project to temporary directory:
        self._tmp_dir = TemporaryDirectory()
        self._project_dir = join(self._tmp_dir.name, 'project')
        project_template = \
            join(dirname(fbs.builtin_commands.__file__), 'project_template')
        replacements = { 'python_bindings': 'PyQt5' }
        filter_ = [join(project_template, 'src', 'main', 'python', 'main.py')]
        copy_with_filtering(
            project_template, self._project_dir, replacements, filter_
        )
        self._update_settings('base.json', {'app_name': 'MyApp'})
        # Save fbs's state:
        self._fbs_state_before = fbs_state.get()
        self._runtime_state_before = runtime_state.get()
    def init_fbs(self, platform_name=None):
github mherrmann / fbs / fbs / builtin_commands / __init__.py View on Github external
_prompt_for_value('Initial version [0.0.1] : ', default='0.0.1')
        eg_bundle_id = 'com.%s.%s' % (
            author.lower().split()[0], ''.join(app.lower().split())
        )
        mac_bundle_identifier = _prompt_for_value(
            'Mac bundle identifier (eg. %s, optional) : ' % eg_bundle_id,
            optional=True
        )
    except KeyboardInterrupt:
        print('')
        return
    print('')
    mkdir('src')
    template_dir = join(dirname(__file__), 'project_template')
    pth = lambda relpath: join(template_dir, *relpath.split('/'))
    copy_with_filtering(
        template_dir, '.', {
            'app_name': app,
            'author': author,
            'version': version,
            'mac_bundle_identifier': mac_bundle_identifier
        },
        files_to_filter=[
            pth('src/build/settings/base.json'),
            pth('src/build/settings/mac.json'),
            pth('src/main/python/main.py')
        ]
    )
    _LOG.info(
        "Created the src/ directory. If you have PyQt5 installed, you can now "
        "do:\n"
github mherrmann / fbs / fbs / builtin_commands / __init__.py View on Github external
python_bindings = 'PySide2'
    else:
        python_bindings = prompt_for_value(
            'Qt bindings', choices=('PyQt5', 'PySide2'), default='PyQt5'
        )
    eg_bundle_id = 'com.%s.%s' % (
        author.lower().split()[0], ''.join(app.lower().split())
    )
    mac_bundle_identifier = prompt_for_value(
        'Mac bundle identifier (eg. %s, optional)' % eg_bundle_id,
        optional=True
    )
    mkdir('src')
    template_dir = join(dirname(__file__), 'project_template')
    template_path = lambda relpath: join(template_dir, *relpath.split('/'))
    copy_with_filtering(
        template_dir, '.', {
            'app_name': app,
            'author': author,
            'mac_bundle_identifier': mac_bundle_identifier,
            'python_bindings': python_bindings
        },
        files_to_filter=[
            template_path('src/build/settings/base.json'),
            template_path('src/build/settings/mac.json'),
            template_path('src/main/python/main.py')
        ]
    )
    print('')
    _LOG.info(
        "Created the src/ directory. If you have %s installed, you can now "
        "do:\n\n    fbs run", python_bindings
github mherrmann / fbs / fbs / repo / fedora.py View on Github external
def create_repo_fedora():
    if exists(path('target/repo')):
        rmtree(path('target/repo'))
    makedirs(path('target/repo/${version}'))
    copy(path('target/${installer}'), path('target/repo/${version}'))
    check_call(['createrepo_c', '.'], cwd=(path('target/repo')), stdout=DEVNULL)
    repo_file = path('src/repo/fedora/${app_name}.repo')
    use_default = not exists(repo_file)
    if use_default:
        repo_file = default_path('src/repo/fedora/AppName.repo')
    copy_with_filtering(
        repo_file, path('target/repo'), files_to_filter=[repo_file]
    )
    if use_default:
        rename(
            path('target/repo/AppName.repo'),
            path('target/repo/${app_name}.repo')
        )
github mherrmann / fbs / fbs / repo / ubuntu.py View on Github external
def create_repo_ubuntu():
    dest_dir = path('target/repo')
    tmp_dir = path('target/repo-tmp')
    if exists(dest_dir):
        rmtree(dest_dir)
    if exists(tmp_dir):
        rmtree(tmp_dir)
    makedirs(tmp_dir)
    distr_file = 'src/repo/ubuntu/distributions'
    distr_path = path(distr_file)
    if not exists(distr_path):
        distr_path = default_path(distr_file)
    copy_with_filtering(distr_path, tmp_dir, files_to_filter=[distr_path])
    preset_gpg_passphrase()
    check_call([
        'reprepro', '-b', dest_dir, '--confdir', tmp_dir,
        'includedeb', 'stable', path('target/${installer}')
    ], stdout=DEVNULL)