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

Resource identifier (RI) abstraction layer #135

Open
sjrct opened this issue Mar 5, 2019 · 2 comments
Open

Resource identifier (RI) abstraction layer #135

sjrct opened this issue Mar 5, 2019 · 2 comments

Comments

@sjrct
Copy link
Member

sjrct commented Mar 5, 2019

RI logic right now is in various places throughout the code base. We split and join on "/" in a bunch of places. We really should have that and other RI-specific logic in an abstract layer. Could be a class that looks like a string, although maybe a module with functions that take strings to interpret as RIs are better.

@richteer
Copy link
Contributor

richteer commented Mar 5, 2019

To add to this, I'd like this kind of behavior represented somehow, either by transparent class, or something else:

match_agent("irc", "irc/##halibot") -> True

match_ri("irc/##halibot", "irc/##halibot") -> True
match_ri("irc", "irc/##halibot") -> False

ri("irc/##halibot").agents() -> "irc"
ri("irc/##halibot").modules() -> ""
ri("irc/##halibot").meta() -> "##halibot"

Largely tossing ideas out there, I don't have anything coherent in mind yet.

@richteer
Copy link
Contributor

richteer commented Mar 6, 2019

Here's another thought: maybe there should be a way to retrieve values from a dict based on an RI, and have it transparently apply any hierarchies:

{
  "filters": {
    "inbound": {
      "irc": ["test"],
      "irc/##halibot": ["foobar"]
    }
  }
}
get_filters(ri="irc/##halibot", childonly=True) # returns ["foobar"]
get_filters(ri="irc/##halibot", parentonly=True) # returns ["test"]
get_filters(ri="irc/##halibot") # returns ["foobar, "test"]
get_filters(ri="irc/##halibot", parentfirst=True) # returns [ "test", "foobar"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants