Пример #1
0
def init_lilv():
    global world
    world = lilv.World()
    world.load_all()

    world.ns.ev = lilv.Namespace(world, "http://lv2plug.in/ns/ext/event#")
    world.ns.presets = lilv.Namespace(world,
                                      "http://lv2plug.in/ns/ext/presets#")
Пример #2
0
def get_presets(world, plugin):
    ns_presets = lilv.Namespace(world, NS_PRESETS)
    presets = plugin.get_related(ns_presets.Preset)
    preset_list = []

    for preset in presets:
        world.load_resource(preset)
        labels = world.find_nodes(preset, world.ns.rdfs.label, None)

        if labels:
            label = str(labels[0])
        else:
            label = None

        preset_list.append((label, str(preset)))

    return preset_list
Пример #3
0
    def generate_all_plugins_config_file(self):
        plugins = OrderedDict()
        self.world.ns.ev = lilv.Namespace(self.world,
                                          'http://lv2plug.in/ns/ext/event#')
        try:
            self.world.load_all()
            for plugin in self.world.get_all_plugins():
                logging.info("Adding '{}'".format(plugin.get_name()))
                plugins[str(plugin.get_name())] = {
                    'URL': str(plugin.get_uri()),
                    'TYPE': self.get_plugin_type(plugin).value,
                    'ENABLED': False
                }
            self.all_plugins = OrderedDict(sorted(plugins.items()))
            with open(self.JALV_ALL_LV2_CONFIG_FILE, 'w') as f:
                json.dump(self.all_plugins, f)

        except Exception as e:
            logging.error('Generating list of all LV2-Plugins failed: %s' % e)
Пример #4
0
def print_presets(uri):
    """Print all presets of an LV2 plugin to stdout."""

    world = lilv.World()
    world.load_all()
    world.ns.presets = lilv.Namespace(world, NS_PRESETS)
    plugins = world.get_all_plugins()
    plugin = plugins[uri]
    presets = plugin.get_related(world.ns.presets.Preset)

    preset_list = []
    for preset in presets:
        world.load_resource(preset)
        label = world.get(preset, world.ns.rdfs.label, None)
        if label is None:
            sys.stderr.write("warning: Preset <%s> has no label\n" % preset)

        preset_list.append((str(preset), str(label)))

    for preset in sorted(preset_list):
        print('<%s> "%s"' % preset)
Пример #5
0
#!/usr/bin/env python3

import lilv
import json
import shutil
import os

world = lilv.World()
modgui = lilv.Namespace(world, "http://moddevices.com/ns/modgui#")
world.load_all()

plugins = []


def get_first(list):
    for i in list:
        return i
    return None


def get_first_value(p, ns):
    return get_first(p.get_value(ns))


def to_str(s):
    if s is None:
        return None


#	return str(str(s).encode('utf-8'))
    return str(s)
Пример #6
0
def _get_plugin_info(ctx, plugin):
    world = ctx.world
    world.ns.mod = lilv.Namespace(world, NS_MOD)
    world.ns.patch = lilv.Namespace(world, NS_PATCH)
    world.ns.pprops = lilv.Namespace(world, NS_PORT_PROPERTIES)
    world.ns.presets = lilv.Namespace(world, NS_PRESET)
    world.ns.units = lilv.Namespace(world, NS_UNITS)

    ctx.errors = errors = []
    ctx.warnings = warnings = []

    # uri
    uri = plugin.get_uri()

    if uri is None:
        errors.append("plugin uri is missing or invalid")
    elif str(uri).startswith("file:"):
        errors.append(
            "plugin uri is local, and thus not suitable for redistribution")

    # load all resources in bundle
    world.load_resource(uri)

    # name
    name = plugin.get_name()

    if name is None:
        errors.append("plugin name is missing")

    # label
    label = getfirst(plugin, world.ns.mod.label)

    if label is None:
        warnings.append("plugin label is missing")
        if name is not None:
            label = str(name)[:16]
    elif len(label) > 16:
        warnings.append("plugin label has more than 16 characters")

    # author
    author_name = plugin.get_author_name()
    author_email = plugin.get_author_email()
    author_homepage = plugin.get_author_homepage()

    # binary
    binary = plugin.get_library_uri()

    if binary is None:
        errors.append("plugin binary is missing")
    else:
        binary = binary.get_path()

    # brand
    brand = getfirst(plugin, world.ns.mod.brand)

    if brand is None:
        warnings.append("plugin brand is missing")
    elif len(brand) > 16:
        warnings.append("plugin brand has more than 11 characters")

    # license
    license = getfirst(plugin, world.ns.doap.license)

    if license is None:
        errors.append("plugin license is missing")

    # comment
    comment = getfirst(plugin, world.ns.rdfs.comment)

    if comment is None:
        errors.append("plugin comment is missing")

    # version
    microver = plugin.get_value(world.ns.lv2.microVersion)
    minorver = plugin.get_value(world.ns.lv2.minorVersion)

    if not microver and not minorver:
        errors.append("plugin is missing version information")
        minor_version = 0
        micro_version = 0
    else:
        if not minorver:
            errors.append("plugin is missing minorVersion")
            minor_version = 0
        else:
            minor_version = int(minorver[0])

        if not microver:
            errors.append("plugin is missing microVersion")
            micro_version = 0
        else:
            micro_version = int(microver[0])

    version = "%d.%d" % (minor_version, micro_version)

    if minor_version == 0:
        # 0.x is experimental
        stability = "experimental"
    elif minor_version % 2 != 0 or micro_version % 2 != 0:
        # odd x.2 or 2.x is testing/development
        stability = "testing"
    else:
        # otherwise it's stable
        stability = "stable"

    # category
    categories = plugin.get_value(world.ns.rdf.type)
    category = set()

    if categories:
        for node in categories:
            category.update(LV2_CATEGORIES.get(
                str(node).split('#', 1)[-1], []))

    # bundles
    bundle = plugin.get_bundle_uri()
    bundlepath = bundle.get_path().rstrip(os.sep)
    bundles = plugin.get_data_uris()

    if bundles:
        bundles = {dirname(node.get_path().rstrip(os.sep)) for node in bundles}
        bundles.add(bundlepath)
        bundles = list(bundles)
    else:
        bundles = [bundlepath]

    # ports
    ports = _get_plugin_ports(ctx, plugin)

    # presets
    presets = _get_plugin_presets(ctx, plugin)

    # properties
    properties = _get_plugin_properties(ctx, uri)

    return {
        'uri': node2str(uri),
        'name': node2str(name),
        'binary': binary,
        'brand': brand,
        'label': label,
        'license': license,
        'comment': comment,
        'category': list(category),
        'microVersion': micro_version,
        'minorVersion': minor_version,
        'version': version,
        'stability': stability,
        'author': {
            'name': node2str(author_name),
            'email': node2str(author_email),
            'homepage': node2str(author_homepage),
        },
        'bundles': sorted(bundles),
        # 'ui': ui,
        'ports': ports,
        'presets': presets,
        'properties': properties,
        'errors': sorted(errors),
        'warnings': sorted(warnings),
    }