How to use fbs - 10 common examples

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 init_fbs(self, platform_name=None):
        if platform_name is not None:
            runtime_state.restore(platform_name, None, None)
        fbs.init(self._project_dir)
    def tearDown(self):
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 / tests / test_fbs / test_freeze.py View on Github external
def test_generate_resources(self):
        self.init_fbs('Mac')
        _generate_resources()
        info_plist = path('${freeze_dir}/Contents/Info.plist')
        self.assertTrue(exists(info_plist))
        with open(info_plist) as f:
            self.assertIn(
                'MyApp', f.read(), "Did not replace '${app_name}' by 'MyApp'"
            )
github dnkorpushov / libro / build.py View on Github external
@command
def locale():
    for pro_file in glob('*.pro'):
        call('pylupdate5 -translate-function _tr {}'.format(pro_file), shell=True)

    for ts_file in glob(os.path.join(LOCALE_SRCPATH, '*.ts')):
        dst_file = os.path.join(LOCALE_DSTPATH, os.path.splitext(os.path.split(ts_file)[1])[0] + '.qm')
        call('lrelease {} -qm {}'.format(ts_file, dst_file), shell=True)
github dnkorpushov / libro / build.py View on Github external
@command
def ui():
    for ui_file in glob(os.path.join(UI_SRCPATH, '*.ui')):
        py_file = os.path.join(UI_DESTPATH, os.path.splitext(os.path.split(ui_file)[1])[0] + '_ui.py')
        ui_file = os.path.normpath(ui_file)
        py_file = os.path.normpath(py_file)
        call('pyuic5 --from-imports {} -o {}'.format(ui_file, py_file), shell=True)
github mherrmann / fbs / fbs / builtin_commands / __init__.py View on Github external
@command
def startproject():
    """
    Start a new fbs project in the current directory
    """
    if exists('src'):
        _LOG.warning('The src/ directory already exists. Aborting.')
        return
    try:
        app = _prompt_for_value('App name [MyApp] : ', default='MyApp')
        user = getuser().title()
        author = _prompt_for_value('Author [%s] : ' % user, default=user)
        version = \
            _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())
        )
github mherrmann / fbs / fbs / builtin_commands / __init__.py View on Github external
@command
def test():
    """
    Execute your automated tests
    """
    sys.path.append(path('src/main/python'))
    suite = TestSuite()
    test_dirs = SETTINGS['test_dirs']
    for test_dir in map(path, test_dirs):
        sys.path.append(test_dir)
        try:
            dir_names = listdir(test_dir)
        except FileNotFoundError:
            continue
        for dir_name in dir_names:
            dir_path = join(test_dir, dir_name)
            if isfile(join(dir_path, '__init__.py')):
github mherrmann / fbs / fbs / builtin_commands / __init__.py View on Github external
def test():
    """
    Execute your automated tests
    """
    require_existing_project()
    sys.path.append(path('src/main/python'))
    suite = TestSuite()
    test_dirs = SETTINGS['test_dirs']
    for test_dir in map(path, test_dirs):
        sys.path.append(test_dir)
        try:
            dir_names = listdir(test_dir)
        except FileNotFoundError:
            continue
        for dir_name in dir_names:
            dir_path = join(test_dir, dir_name)
            if isfile(join(dir_path, '__init__.py')):
                suite.addTest(defaultTestLoader.discover(
                    dir_name, top_level_dir=test_dir
                ))
    has_tests = bool(list(suite))
github mherrmann / fbs / fbs / builtin_commands / __init__.py View on Github external
"""
    Start a new project in the current directory
    """
    if exists('src'):
        raise FbsError('The src/ directory already exists. Aborting.')
    app = prompt_for_value('App name', default='MyApp')
    user = getuser().title()
    author = prompt_for_value('Author', default=user)
    has_pyqt = _has_module('PyQt5')
    has_pyside = _has_module('PySide2')
    if has_pyqt and not has_pyside:
        python_bindings = 'PyQt5'
    elif not has_pyqt and has_pyside:
        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,
github mherrmann / fbs / fbs / builtin_commands / __init__.py View on Github external
user = getuser().title()
    author = prompt_for_value('Author', default=user)
    has_pyqt = _has_module('PyQt5')
    has_pyside = _has_module('PySide2')
    if has_pyqt and not has_pyside:
        python_bindings = 'PyQt5'
    elif not has_pyqt and has_pyside:
        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'),