Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose package_metadata_reader to allzparkconfig #35

Closed
mottosso opened this issue Jul 9, 2019 · 2 comments
Closed

expose package_metadata_reader to allzparkconfig #35

mottosso opened this issue Jul 9, 2019 · 2 comments
Labels

Comments

@mottosso
Copy link
Owner

mottosso commented Jul 9, 2019

Goal

Enable customisation of how metadata is gathered from a given package.

Motivation

Metadata is currently presumed to exist within a package as a _data dictionary variable.

name = "maya"
version = "2018"
_data = {
  "label": "Autodesk Maya",
  "icon": "maya_{width}_{height}"
}

There are a few issues with that.

  1. We can't assume _data is free for us to claim; the user may already be using it for something else.
  2. We can't assume metadata is present in the package itself, or even package.py. It may come from a side-car file or database, in which case the package may be be used as merely an indicator of where to find it (e.g. by name/version combination)
  3. We can't assume all metadata is equal. For example, project metadata like icon and backdrop may come from a database, whereas the icon for Maya may reside in the package.

Implementation

Expose the current reader to allzparkconfig.py.

def package_metadata_reader(package):
  return {
    "label": package._data["label"],
    "icon": database.query({"key": package.name, "value": "icon"})
  }

To facilitate lengthy queries, make the call asynchronous from within Allzpark.

@mottosso mottosso added the ui label Jul 9, 2019
mottosso added a commit that referenced this issue Jul 10, 2019
Custom package data reader
@mottosso
Copy link
Owner Author

Implemented. For example, implementing backwards compatibility can be done like so:

~/marcus/allzparkconfig.py

def read_package_data(package):
    # Augment existing data
    data = allzparkconfig._read_package_data(package)

    # Backwards compatibility with old system
    backwards_icon = getattr(package, "_icons", {}).get("32x32")
    backwards_icon = backwards_icon or data.get("icons", {}).get("32x32")
    data["icon"] = data["icon"] or backwards_icon or ""

    return data

@mottosso
Copy link
Owner Author

Icons are currently presumed to be a string template, with 3 keys.

Example

icon = "{root}/any/path/{width}x{height}.png"
icon = "{root}/any/path/{w}x{h}.png"  # Alternatively

It's questionable whether we need to override at this level of granularity, but in case icons are coming from elsewhere or integrating with a third-party system then odds are Allzpark would need to conform to it rather than vice versa. That's open for discussion should that happen. There could alternatively be a specific mechanism for returning a fully qualified QIcon, such that it doesn't need to be a file (e.g. an icon from a database like Shotgun/ftrack).

mottosso added a commit that referenced this issue Jul 10, 2019
Also refactor #35, to align naming convention for better discoverability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant