repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
devassistant/devassistant | devassistant/gui/run_window.py | RunWindow.dev_assistant_start | def dev_assistant_start(self):
"""
Thread executes devassistant API.
"""
#logger_gui.info("Thread run")
path = self.top_assistant.get_selected_subassistant_path(**self.kwargs)
kwargs_decoded = dict()
for k, v in self.kwargs.items():
kwargs_decoded[k] =... | python | def dev_assistant_start(self):
"""
Thread executes devassistant API.
"""
#logger_gui.info("Thread run")
path = self.top_assistant.get_selected_subassistant_path(**self.kwargs)
kwargs_decoded = dict()
for k, v in self.kwargs.items():
kwargs_decoded[k] =... | [
"def",
"dev_assistant_start",
"(",
"self",
")",
":",
"#logger_gui.info(\"Thread run\")",
"path",
"=",
"self",
".",
"top_assistant",
".",
"get_selected_subassistant_path",
"(",
"*",
"*",
"self",
".",
"kwargs",
")",
"kwargs_decoded",
"=",
"dict",
"(",
")",
"for",
... | Thread executes devassistant API. | [
"Thread",
"executes",
"devassistant",
"API",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L257-L298 |
devassistant/devassistant | devassistant/gui/run_window.py | RunWindow.debug_btn_clicked | def debug_btn_clicked(self, widget, data=None):
"""
Event in case that debug button is pressed.
"""
self.store.clear()
self.thread = threading.Thread(target=self.logs_update)
self.thread.start() | python | def debug_btn_clicked(self, widget, data=None):
"""
Event in case that debug button is pressed.
"""
self.store.clear()
self.thread = threading.Thread(target=self.logs_update)
self.thread.start() | [
"def",
"debug_btn_clicked",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"store",
".",
"clear",
"(",
")",
"self",
".",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"logs_update",
")",
"se... | Event in case that debug button is pressed. | [
"Event",
"in",
"case",
"that",
"debug",
"button",
"is",
"pressed",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L300-L306 |
devassistant/devassistant | devassistant/gui/run_window.py | RunWindow.logs_update | def logs_update(self):
"""
Function updates logs.
"""
Gdk.threads_enter()
if not self.debugging:
self.debugging = True
self.debug_btn.set_label('Info logs')
else:
self.debugging = False
self.debug_btn.set_label('Debug logs')... | python | def logs_update(self):
"""
Function updates logs.
"""
Gdk.threads_enter()
if not self.debugging:
self.debugging = True
self.debug_btn.set_label('Info logs')
else:
self.debugging = False
self.debug_btn.set_label('Debug logs')... | [
"def",
"logs_update",
"(",
"self",
")",
":",
"Gdk",
".",
"threads_enter",
"(",
")",
"if",
"not",
"self",
".",
"debugging",
":",
"self",
".",
"debugging",
"=",
"True",
"self",
".",
"debug_btn",
".",
"set_label",
"(",
"'Info logs'",
")",
"else",
":",
"se... | Function updates logs. | [
"Function",
"updates",
"logs",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L308-L327 |
devassistant/devassistant | devassistant/gui/run_window.py | RunWindow.clipboard_btn_clicked | def clipboard_btn_clicked(self, widget, data=None):
"""
Function copies logs to clipboard.
"""
_clipboard_text = []
for record in self.debug_logs['logs']:
if self.debugging:
_clipboard_text.append(format_entry(record, show_level=True))
else... | python | def clipboard_btn_clicked(self, widget, data=None):
"""
Function copies logs to clipboard.
"""
_clipboard_text = []
for record in self.debug_logs['logs']:
if self.debugging:
_clipboard_text.append(format_entry(record, show_level=True))
else... | [
"def",
"clipboard_btn_clicked",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"_clipboard_text",
"=",
"[",
"]",
"for",
"record",
"in",
"self",
".",
"debug_logs",
"[",
"'logs'",
"]",
":",
"if",
"self",
".",
"debugging",
":",
"_clipboard_... | Function copies logs to clipboard. | [
"Function",
"copies",
"logs",
"to",
"clipboard",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L330-L345 |
devassistant/devassistant | devassistant/gui/run_window.py | RunWindow.back_btn_clicked | def back_btn_clicked(self, widget, data=None):
"""
Event for back button.
This occurs in case of devassistant fail.
"""
self.remove_link_button()
self.run_window.hide()
self.parent.path_window.path_window.show() | python | def back_btn_clicked(self, widget, data=None):
"""
Event for back button.
This occurs in case of devassistant fail.
"""
self.remove_link_button()
self.run_window.hide()
self.parent.path_window.path_window.show() | [
"def",
"back_btn_clicked",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"remove_link_button",
"(",
")",
"self",
".",
"run_window",
".",
"hide",
"(",
")",
"self",
".",
"parent",
".",
"path_window",
".",
"path_window",
".",
... | Event for back button.
This occurs in case of devassistant fail. | [
"Event",
"for",
"back",
"button",
".",
"This",
"occurs",
"in",
"case",
"of",
"devassistant",
"fail",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L347-L354 |
devassistant/devassistant | devassistant/gui/run_window.py | RunWindow.main_btn_clicked | def main_btn_clicked(self, widget, data=None):
"""
Button switches to Dev Assistant GUI main window
"""
self.remove_link_button()
data = dict()
data['debugging'] = self.debugging
self.run_window.hide()
self.parent.open_window(widget, data) | python | def main_btn_clicked(self, widget, data=None):
"""
Button switches to Dev Assistant GUI main window
"""
self.remove_link_button()
data = dict()
data['debugging'] = self.debugging
self.run_window.hide()
self.parent.open_window(widget, data) | [
"def",
"main_btn_clicked",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"remove_link_button",
"(",
")",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"'debugging'",
"]",
"=",
"self",
".",
"debugging",
"self",
".",
"run_win... | Button switches to Dev Assistant GUI main window | [
"Button",
"switches",
"to",
"Dev",
"Assistant",
"GUI",
"main",
"window"
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L356-L364 |
devassistant/devassistant | devassistant/gui/run_window.py | RunWindow.list_view_row_clicked | def list_view_row_clicked(self, list_view, path, view_column):
"""
Function opens the firefox window with relevant link
"""
model = list_view.get_model()
text = model[path][0]
match = URL_FINDER.search(text)
if match is not None:
url = match.group(1)
... | python | def list_view_row_clicked(self, list_view, path, view_column):
"""
Function opens the firefox window with relevant link
"""
model = list_view.get_model()
text = model[path][0]
match = URL_FINDER.search(text)
if match is not None:
url = match.group(1)
... | [
"def",
"list_view_row_clicked",
"(",
"self",
",",
"list_view",
",",
"path",
",",
"view_column",
")",
":",
"model",
"=",
"list_view",
".",
"get_model",
"(",
")",
"text",
"=",
"model",
"[",
"path",
"]",
"[",
"0",
"]",
"match",
"=",
"URL_FINDER",
".",
"se... | Function opens the firefox window with relevant link | [
"Function",
"opens",
"the",
"firefox",
"window",
"with",
"relevant",
"link"
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/run_window.py#L366-L377 |
devassistant/devassistant | devassistant/remote_auth.py | GitHubAuth._github_create_twofactor_authorization | def _github_create_twofactor_authorization(cls, ui):
"""Create an authorization for a GitHub user using two-factor
authentication. Unlike its non-two-factor counterpart, this method
does not traverse the available authentications as they are not
visible until the user logs in.
... | python | def _github_create_twofactor_authorization(cls, ui):
"""Create an authorization for a GitHub user using two-factor
authentication. Unlike its non-two-factor counterpart, this method
does not traverse the available authentications as they are not
visible until the user logs in.
... | [
"def",
"_github_create_twofactor_authorization",
"(",
"cls",
",",
"ui",
")",
":",
"try",
":",
"try",
":",
"# This is necessary to trigger sending a 2FA key to the user",
"auth",
"=",
"cls",
".",
"_user",
".",
"create_authorization",
"(",
")",
"except",
"cls",
".",
"... | Create an authorization for a GitHub user using two-factor
authentication. Unlike its non-two-factor counterpart, this method
does not traverse the available authentications as they are not
visible until the user logs in.
Please note: cls._user's attributes are not accessibl... | [
"Create",
"an",
"authorization",
"for",
"a",
"GitHub",
"user",
"using",
"two",
"-",
"factor",
"authentication",
".",
"Unlike",
"its",
"non",
"-",
"two",
"-",
"factor",
"counterpart",
"this",
"method",
"does",
"not",
"traverse",
"the",
"available",
"authenticat... | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L105-L127 |
devassistant/devassistant | devassistant/remote_auth.py | GitHubAuth._github_create_simple_authorization | def _github_create_simple_authorization(cls):
"""Create a GitHub authorization for the given user in case they don't
already have one.
"""
try:
auth = None
for a in cls._user.get_authorizations():
if a.note == 'DevAssistant':
... | python | def _github_create_simple_authorization(cls):
"""Create a GitHub authorization for the given user in case they don't
already have one.
"""
try:
auth = None
for a in cls._user.get_authorizations():
if a.note == 'DevAssistant':
... | [
"def",
"_github_create_simple_authorization",
"(",
"cls",
")",
":",
"try",
":",
"auth",
"=",
"None",
"for",
"a",
"in",
"cls",
".",
"_user",
".",
"get_authorizations",
"(",
")",
":",
"if",
"a",
".",
"note",
"==",
"'DevAssistant'",
":",
"auth",
"=",
"a",
... | Create a GitHub authorization for the given user in case they don't
already have one. | [
"Create",
"a",
"GitHub",
"authorization",
"for",
"the",
"given",
"user",
"in",
"case",
"they",
"don",
"t",
"already",
"have",
"one",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L131-L146 |
devassistant/devassistant | devassistant/remote_auth.py | GitHubAuth._github_store_authorization | def _github_store_authorization(cls, user, auth):
"""Store an authorization token for the given GitHub user in the git
global config file.
"""
ClHelper.run_command("git config --global github.token.{login} {token}".format(
login=user.login, token=auth.token), log_secret=Tr... | python | def _github_store_authorization(cls, user, auth):
"""Store an authorization token for the given GitHub user in the git
global config file.
"""
ClHelper.run_command("git config --global github.token.{login} {token}".format(
login=user.login, token=auth.token), log_secret=Tr... | [
"def",
"_github_store_authorization",
"(",
"cls",
",",
"user",
",",
"auth",
")",
":",
"ClHelper",
".",
"run_command",
"(",
"\"git config --global github.token.{login} {token}\"",
".",
"format",
"(",
"login",
"=",
"user",
".",
"login",
",",
"token",
"=",
"auth",
... | Store an authorization token for the given GitHub user in the git
global config file. | [
"Store",
"an",
"authorization",
"token",
"for",
"the",
"given",
"GitHub",
"user",
"in",
"the",
"git",
"global",
"config",
"file",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L149-L156 |
devassistant/devassistant | devassistant/remote_auth.py | GitHubAuth._start_ssh_agent | def _start_ssh_agent(cls):
"""Starts ssh-agent and returns the environment variables related to it"""
env = dict()
stdout = ClHelper.run_command('ssh-agent -s')
lines = stdout.split('\n')
for line in lines:
if not line or line.startswith('echo '):
cont... | python | def _start_ssh_agent(cls):
"""Starts ssh-agent and returns the environment variables related to it"""
env = dict()
stdout = ClHelper.run_command('ssh-agent -s')
lines = stdout.split('\n')
for line in lines:
if not line or line.startswith('echo '):
cont... | [
"def",
"_start_ssh_agent",
"(",
"cls",
")",
":",
"env",
"=",
"dict",
"(",
")",
"stdout",
"=",
"ClHelper",
".",
"run_command",
"(",
"'ssh-agent -s'",
")",
"lines",
"=",
"stdout",
".",
"split",
"(",
"'\\n'",
")",
"for",
"line",
"in",
"lines",
":",
"if",
... | Starts ssh-agent and returns the environment variables related to it | [
"Starts",
"ssh",
"-",
"agent",
"and",
"returns",
"the",
"environment",
"variables",
"related",
"to",
"it"
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L159-L171 |
devassistant/devassistant | devassistant/remote_auth.py | GitHubAuth._github_create_ssh_key | def _github_create_ssh_key(cls):
"""Creates a local ssh key, if it doesn't exist already, and uploads it to Github."""
try:
login = cls._user.login
pkey_path = '{home}/.ssh/{keyname}'.format(
home=os.path.expanduser('~'),
keyname=settings.GITHUB_SS... | python | def _github_create_ssh_key(cls):
"""Creates a local ssh key, if it doesn't exist already, and uploads it to Github."""
try:
login = cls._user.login
pkey_path = '{home}/.ssh/{keyname}'.format(
home=os.path.expanduser('~'),
keyname=settings.GITHUB_SS... | [
"def",
"_github_create_ssh_key",
"(",
"cls",
")",
":",
"try",
":",
"login",
"=",
"cls",
".",
"_user",
".",
"login",
"pkey_path",
"=",
"'{home}/.ssh/{keyname}'",
".",
"format",
"(",
"home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
",",
... | Creates a local ssh key, if it doesn't exist already, and uploads it to Github. | [
"Creates",
"a",
"local",
"ssh",
"key",
"if",
"it",
"doesn",
"t",
"exist",
"already",
"and",
"uploads",
"it",
"to",
"Github",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L174-L196 |
devassistant/devassistant | devassistant/remote_auth.py | GitHubAuth._github_ssh_key_exists | def _github_ssh_key_exists(cls):
"""Returns True if any key on Github matches a local key, else False."""
remote_keys = map(lambda k: k._key, cls._user.get_keys())
found = False
pubkey_files = glob.glob(os.path.expanduser('~/.ssh/*.pub'))
for rk in remote_keys:
for pk... | python | def _github_ssh_key_exists(cls):
"""Returns True if any key on Github matches a local key, else False."""
remote_keys = map(lambda k: k._key, cls._user.get_keys())
found = False
pubkey_files = glob.glob(os.path.expanduser('~/.ssh/*.pub'))
for rk in remote_keys:
for pk... | [
"def",
"_github_ssh_key_exists",
"(",
"cls",
")",
":",
"remote_keys",
"=",
"map",
"(",
"lambda",
"k",
":",
"k",
".",
"_key",
",",
"cls",
".",
"_user",
".",
"get_keys",
"(",
")",
")",
"found",
"=",
"False",
"pubkey_files",
"=",
"glob",
".",
"glob",
"(... | Returns True if any key on Github matches a local key, else False. | [
"Returns",
"True",
"if",
"any",
"key",
"on",
"Github",
"matches",
"a",
"local",
"key",
"else",
"False",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L208-L222 |
devassistant/devassistant | devassistant/remote_auth.py | GitHubAuth.github_authenticated | def github_authenticated(cls, func):
"""Does user authentication, creates SSH keys if needed and injects "_user" attribute
into class/object bound to the decorated function.
Don't call any other methods of this class manually, this should be everything you need.
"""
def inner(fun... | python | def github_authenticated(cls, func):
"""Does user authentication, creates SSH keys if needed and injects "_user" attribute
into class/object bound to the decorated function.
Don't call any other methods of this class manually, this should be everything you need.
"""
def inner(fun... | [
"def",
"github_authenticated",
"(",
"cls",
",",
"func",
")",
":",
"def",
"inner",
"(",
"func_cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"cls",
".",
"_gh_module",
":",
"logger",
".",
"warning",
"(",
"'PyGithub not installed, s... | Does user authentication, creates SSH keys if needed and injects "_user" attribute
into class/object bound to the decorated function.
Don't call any other methods of this class manually, this should be everything you need. | [
"Does",
"user",
"authentication",
"creates",
"SSH",
"keys",
"if",
"needed",
"and",
"injects",
"_user",
"attribute",
"into",
"class",
"/",
"object",
"bound",
"to",
"the",
"decorated",
"function",
".",
"Don",
"t",
"call",
"any",
"other",
"methods",
"of",
"this... | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/remote_auth.py#L241-L265 |
devassistant/devassistant | devassistant/yaml_assistant_loader.py | YamlAssistantLoader.get_assistants | def get_assistants(cls, superassistants):
"""Returns list of assistants that are subassistants of given superassistants
(I love this docstring).
Args:
roles: list of names of roles, defaults to all roles
Returns:
list of YamlAssistant instances with specified rol... | python | def get_assistants(cls, superassistants):
"""Returns list of assistants that are subassistants of given superassistants
(I love this docstring).
Args:
roles: list of names of roles, defaults to all roles
Returns:
list of YamlAssistant instances with specified rol... | [
"def",
"get_assistants",
"(",
"cls",
",",
"superassistants",
")",
":",
"_assistants",
"=",
"cls",
".",
"load_all_assistants",
"(",
"superassistants",
")",
"result",
"=",
"[",
"]",
"for",
"supa",
"in",
"superassistants",
":",
"result",
".",
"extend",
"(",
"_a... | Returns list of assistants that are subassistants of given superassistants
(I love this docstring).
Args:
roles: list of names of roles, defaults to all roles
Returns:
list of YamlAssistant instances with specified roles | [
"Returns",
"list",
"of",
"assistants",
"that",
"are",
"subassistants",
"of",
"given",
"superassistants",
"(",
"I",
"love",
"this",
"docstring",
")",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L16-L30 |
devassistant/devassistant | devassistant/yaml_assistant_loader.py | YamlAssistantLoader.load_all_assistants | def load_all_assistants(cls, superassistants):
"""Fills self._assistants with loaded YamlAssistant instances of requested roles.
Tries to use cache (updated/created if needed). If cache is unusable, it
falls back to loading all assistants.
Args:
roles: list of required assi... | python | def load_all_assistants(cls, superassistants):
"""Fills self._assistants with loaded YamlAssistant instances of requested roles.
Tries to use cache (updated/created if needed). If cache is unusable, it
falls back to loading all assistants.
Args:
roles: list of required assi... | [
"def",
"load_all_assistants",
"(",
"cls",
",",
"superassistants",
")",
":",
"# mapping of assistant roles to lists of top-level assistant instances",
"_assistants",
"=",
"{",
"}",
"# {'crt': CreatorAssistant, ...}",
"superas_dict",
"=",
"dict",
"(",
"map",
"(",
"lambda",
"a... | Fills self._assistants with loaded YamlAssistant instances of requested roles.
Tries to use cache (updated/created if needed). If cache is unusable, it
falls back to loading all assistants.
Args:
roles: list of required assistant roles | [
"Fills",
"self",
".",
"_assistants",
"with",
"loaded",
"YamlAssistant",
"instances",
"of",
"requested",
"roles",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L33-L67 |
devassistant/devassistant | devassistant/yaml_assistant_loader.py | YamlAssistantLoader.get_assistants_from_cache_hierarchy | def get_assistants_from_cache_hierarchy(cls, cache_hierarchy, superassistant,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Accepts cache_hierarch as described in devassistant.cache and returns
instances of YamlAssistant (only with cached attributes) for loaded fi... | python | def get_assistants_from_cache_hierarchy(cls, cache_hierarchy, superassistant,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Accepts cache_hierarch as described in devassistant.cache and returns
instances of YamlAssistant (only with cached attributes) for loaded fi... | [
"def",
"get_assistants_from_cache_hierarchy",
"(",
"cls",
",",
"cache_hierarchy",
",",
"superassistant",
",",
"role",
"=",
"settings",
".",
"DEFAULT_ASSISTANT_ROLE",
")",
":",
"result",
"=",
"[",
"]",
"for",
"name",
",",
"attrs",
"in",
"cache_hierarchy",
".",
"i... | Accepts cache_hierarch as described in devassistant.cache and returns
instances of YamlAssistant (only with cached attributes) for loaded files
Args:
cache_hierarchy: structure as described in devassistant.cache
role: role of all assistants in this hierarchy (we could find
... | [
"Accepts",
"cache_hierarch",
"as",
"described",
"in",
"devassistant",
".",
"cache",
"and",
"returns",
"instances",
"of",
"YamlAssistant",
"(",
"only",
"with",
"cached",
"attributes",
")",
"for",
"loaded",
"files"
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L70-L97 |
devassistant/devassistant | devassistant/yaml_assistant_loader.py | YamlAssistantLoader.get_assistants_from_file_hierarchy | def get_assistants_from_file_hierarchy(cls, file_hierarchy, superassistant,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Accepts file_hierarch as returned by cls.get_assistant_file_hierarchy and returns
instances of YamlAssistant for loaded files
Args:
... | python | def get_assistants_from_file_hierarchy(cls, file_hierarchy, superassistant,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Accepts file_hierarch as returned by cls.get_assistant_file_hierarchy and returns
instances of YamlAssistant for loaded files
Args:
... | [
"def",
"get_assistants_from_file_hierarchy",
"(",
"cls",
",",
"file_hierarchy",
",",
"superassistant",
",",
"role",
"=",
"settings",
".",
"DEFAULT_ASSISTANT_ROLE",
")",
":",
"result",
"=",
"[",
"]",
"warn_msg",
"=",
"'Failed to load assistant {source}, skipping subassista... | Accepts file_hierarch as returned by cls.get_assistant_file_hierarchy and returns
instances of YamlAssistant for loaded files
Args:
file_hierarchy: structure as described in cls.get_assistants_file_hierarchy
role: role of all assistants in this hierarchy (we could find
... | [
"Accepts",
"file_hierarch",
"as",
"returned",
"by",
"cls",
".",
"get_assistant_file_hierarchy",
"and",
"returns",
"instances",
"of",
"YamlAssistant",
"for",
"loaded",
"files"
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L100-L134 |
devassistant/devassistant | devassistant/yaml_assistant_loader.py | YamlAssistantLoader.get_assistants_file_hierarchy | def get_assistants_file_hierarchy(cls, dirs):
"""Returns assistants file hierarchy structure (see below) representing assistant
hierarchy in given directories.
It works like this:
1. It goes through all *.yaml files in all given directories and adds them into
hierarchy (if th... | python | def get_assistants_file_hierarchy(cls, dirs):
"""Returns assistants file hierarchy structure (see below) representing assistant
hierarchy in given directories.
It works like this:
1. It goes through all *.yaml files in all given directories and adds them into
hierarchy (if th... | [
"def",
"get_assistants_file_hierarchy",
"(",
"cls",
",",
"dirs",
")",
":",
"result",
"=",
"{",
"}",
"for",
"d",
"in",
"filter",
"(",
"lambda",
"d",
":",
"os",
".",
"path",
".",
"exists",
"(",
"d",
")",
",",
"dirs",
")",
":",
"for",
"f",
"in",
"fi... | Returns assistants file hierarchy structure (see below) representing assistant
hierarchy in given directories.
It works like this:
1. It goes through all *.yaml files in all given directories and adds them into
hierarchy (if there are two files with same name in more directories, the... | [
"Returns",
"assistants",
"file",
"hierarchy",
"structure",
"(",
"see",
"below",
")",
"representing",
"assistant",
"hierarchy",
"in",
"given",
"directories",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L137-L170 |
devassistant/devassistant | devassistant/yaml_assistant_loader.py | YamlAssistantLoader.assistant_from_yaml | def assistant_from_yaml(cls, source, y, superassistant, fully_loaded=True,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Constructs instance of YamlAssistant loaded from given structure y, loaded
from source file source.
Args:
source: path to assistant source... | python | def assistant_from_yaml(cls, source, y, superassistant, fully_loaded=True,
role=settings.DEFAULT_ASSISTANT_ROLE):
"""Constructs instance of YamlAssistant loaded from given structure y, loaded
from source file source.
Args:
source: path to assistant source... | [
"def",
"assistant_from_yaml",
"(",
"cls",
",",
"source",
",",
"y",
",",
"superassistant",
",",
"fully_loaded",
"=",
"True",
",",
"role",
"=",
"settings",
".",
"DEFAULT_ASSISTANT_ROLE",
")",
":",
"# In pre-0.9.0, we required assistant to be a mapping of {name: assistant_at... | Constructs instance of YamlAssistant loaded from given structure y, loaded
from source file source.
Args:
source: path to assistant source file
y: loaded yaml structure
superassistant: superassistant of this assistant
Returns:
YamlAssistant instan... | [
"Constructs",
"instance",
"of",
"YamlAssistant",
"loaded",
"from",
"given",
"structure",
"y",
"loaded",
"from",
"source",
"file",
"source",
"."
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_assistant_loader.py#L173-L195 |
devassistant/devassistant | devassistant/yaml_snippet_loader.py | YamlSnippetLoader.get_snippet_by_name | def get_snippet_by_name(cls, name):
"""name is in dotted format, e.g. topsnippet.something.wantedsnippet"""
name_with_dir_separators = name.replace('.', os.path.sep)
loaded = yaml_loader.YamlLoader.load_yaml_by_relpath(cls.snippets_dirs,
... | python | def get_snippet_by_name(cls, name):
"""name is in dotted format, e.g. topsnippet.something.wantedsnippet"""
name_with_dir_separators = name.replace('.', os.path.sep)
loaded = yaml_loader.YamlLoader.load_yaml_by_relpath(cls.snippets_dirs,
... | [
"def",
"get_snippet_by_name",
"(",
"cls",
",",
"name",
")",
":",
"name_with_dir_separators",
"=",
"name",
".",
"replace",
"(",
"'.'",
",",
"os",
".",
"path",
".",
"sep",
")",
"loaded",
"=",
"yaml_loader",
".",
"YamlLoader",
".",
"load_yaml_by_relpath",
"(",
... | name is in dotted format, e.g. topsnippet.something.wantedsnippet | [
"name",
"is",
"in",
"dotted",
"format",
"e",
".",
"g",
".",
"topsnippet",
".",
"something",
".",
"wantedsnippet"
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_snippet_loader.py#L23-L32 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_6_schema_requirements.py | conforms | def conforms(cntxt: Context, n: Node, S: ShExJ.Shape) -> bool:
""" `5.6.1 Schema Validation Requirement <http://shex.io/shex-semantics/#validation-requirement>`_
A graph G is said to conform with a schema S with a ShapeMap m when:
Every, SemAct in the startActs of S has a successful evaluation of semA... | python | def conforms(cntxt: Context, n: Node, S: ShExJ.Shape) -> bool:
""" `5.6.1 Schema Validation Requirement <http://shex.io/shex-semantics/#validation-requirement>`_
A graph G is said to conform with a schema S with a ShapeMap m when:
Every, SemAct in the startActs of S has a successful evaluation of semA... | [
"def",
"conforms",
"(",
"cntxt",
":",
"Context",
",",
"n",
":",
"Node",
",",
"S",
":",
"ShExJ",
".",
"Shape",
")",
"->",
"bool",
":",
"# return semActsSatisfied(cntxt.schema.startActs, cntxt) and \\",
"# all(reference_of(cntxt.schema, sa.shapeLabel) is not None and",
... | `5.6.1 Schema Validation Requirement <http://shex.io/shex-semantics/#validation-requirement>`_
A graph G is said to conform with a schema S with a ShapeMap m when:
Every, SemAct in the startActs of S has a successful evaluation of semActsSatisfied.
Every node n in m conforms to its associated shapeExp... | [
"5",
".",
"6",
".",
"1",
"Schema",
"Validation",
"Requirement",
"<http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#validation",
"-",
"requirement",
">",
"_",
"A",
"graph",
"G",
"is",
"said",
"to",
"conform",
"with",
"a",
"sc... | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_6_schema_requirements.py#L14-L29 |
gak/pygooglechart | pygooglechart.py | Chart.set_legend | def set_legend(self, legend):
"""legend needs to be a list, tuple or None"""
assert(isinstance(legend, list) or isinstance(legend, tuple) or
legend is None)
if legend:
self.legend = [quote(a) for a in legend]
else:
self.legend = None | python | def set_legend(self, legend):
"""legend needs to be a list, tuple or None"""
assert(isinstance(legend, list) or isinstance(legend, tuple) or
legend is None)
if legend:
self.legend = [quote(a) for a in legend]
else:
self.legend = None | [
"def",
"set_legend",
"(",
"self",
",",
"legend",
")",
":",
"assert",
"(",
"isinstance",
"(",
"legend",
",",
"list",
")",
"or",
"isinstance",
"(",
"legend",
",",
"tuple",
")",
"or",
"legend",
"is",
"None",
")",
"if",
"legend",
":",
"self",
".",
"legen... | legend needs to be a list, tuple or None | [
"legend",
"needs",
"to",
"be",
"a",
"list",
"tuple",
"or",
"None"
] | train | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L434-L441 |
gak/pygooglechart | pygooglechart.py | Chart.set_legend_position | def set_legend_position(self, legend_position):
"""Sets legend position. Default is 'r'.
b - At the bottom of the chart, legend entries in a horizontal row.
bv - At the bottom of the chart, legend entries in a vertical column.
t - At the top of the chart, legend entries in a horizontal ... | python | def set_legend_position(self, legend_position):
"""Sets legend position. Default is 'r'.
b - At the bottom of the chart, legend entries in a horizontal row.
bv - At the bottom of the chart, legend entries in a vertical column.
t - At the top of the chart, legend entries in a horizontal ... | [
"def",
"set_legend_position",
"(",
"self",
",",
"legend_position",
")",
":",
"if",
"legend_position",
":",
"self",
".",
"legend_position",
"=",
"quote",
"(",
"legend_position",
")",
"else",
":",
"self",
".",
"legend_position",
"=",
"None"
] | Sets legend position. Default is 'r'.
b - At the bottom of the chart, legend entries in a horizontal row.
bv - At the bottom of the chart, legend entries in a vertical column.
t - At the top of the chart, legend entries in a horizontal row.
tv - At the top of the chart, legend entries i... | [
"Sets",
"legend",
"position",
".",
"Default",
"is",
"r",
"."
] | train | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L443-L456 |
gak/pygooglechart | pygooglechart.py | Chart.data_class_detection | def data_class_detection(self, data):
"""Determines the appropriate data encoding type to give satisfactory
resolution (http://code.google.com/apis/chart/#chart_data).
"""
assert(isinstance(data, list) or isinstance(data, tuple))
if not isinstance(self, (LineChart, BarChart, Scat... | python | def data_class_detection(self, data):
"""Determines the appropriate data encoding type to give satisfactory
resolution (http://code.google.com/apis/chart/#chart_data).
"""
assert(isinstance(data, list) or isinstance(data, tuple))
if not isinstance(self, (LineChart, BarChart, Scat... | [
"def",
"data_class_detection",
"(",
"self",
",",
"data",
")",
":",
"assert",
"(",
"isinstance",
"(",
"data",
",",
"list",
")",
"or",
"isinstance",
"(",
"data",
",",
"tuple",
")",
")",
"if",
"not",
"isinstance",
"(",
"self",
",",
"(",
"LineChart",
",",
... | Determines the appropriate data encoding type to give satisfactory
resolution (http://code.google.com/apis/chart/#chart_data). | [
"Determines",
"the",
"appropriate",
"data",
"encoding",
"type",
"to",
"give",
"satisfactory",
"resolution",
"(",
"http",
":",
"//",
"code",
".",
"google",
".",
"com",
"/",
"apis",
"/",
"chart",
"/",
"#chart_data",
")",
"."
] | train | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L527-L544 |
gak/pygooglechart | pygooglechart.py | Chart.data_x_range | def data_x_range(self):
"""Return a 2-tuple giving the minimum and maximum x-axis
data range.
"""
try:
lower = min([min(self._filter_none(s))
for type, s in self.annotated_data()
if type == 'x'])
upper = max([max(s... | python | def data_x_range(self):
"""Return a 2-tuple giving the minimum and maximum x-axis
data range.
"""
try:
lower = min([min(self._filter_none(s))
for type, s in self.annotated_data()
if type == 'x'])
upper = max([max(s... | [
"def",
"data_x_range",
"(",
"self",
")",
":",
"try",
":",
"lower",
"=",
"min",
"(",
"[",
"min",
"(",
"self",
".",
"_filter_none",
"(",
"s",
")",
")",
"for",
"type",
",",
"s",
"in",
"self",
".",
"annotated_data",
"(",
")",
"if",
"type",
"==",
"'x'... | Return a 2-tuple giving the minimum and maximum x-axis
data range. | [
"Return",
"a",
"2",
"-",
"tuple",
"giving",
"the",
"minimum",
"and",
"maximum",
"x",
"-",
"axis",
"data",
"range",
"."
] | train | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L549-L562 |
gak/pygooglechart | pygooglechart.py | Chart.scaled_data | def scaled_data(self, data_class, x_range=None, y_range=None):
"""Scale `self.data` as appropriate for the given data encoding
(data_class) and return it.
An optional `y_range` -- a 2-tuple (lower, upper) -- can be
given to specify the y-axis bounds. If not given, the range is
i... | python | def scaled_data(self, data_class, x_range=None, y_range=None):
"""Scale `self.data` as appropriate for the given data encoding
(data_class) and return it.
An optional `y_range` -- a 2-tuple (lower, upper) -- can be
given to specify the y-axis bounds. If not given, the range is
i... | [
"def",
"scaled_data",
"(",
"self",
",",
"data_class",
",",
"x_range",
"=",
"None",
",",
"y_range",
"=",
"None",
")",
":",
"self",
".",
"scaled_data_class",
"=",
"data_class",
"# Determine the x-axis range for scaling.",
"if",
"x_range",
"is",
"None",
":",
"x_ran... | Scale `self.data` as appropriate for the given data encoding
(data_class) and return it.
An optional `y_range` -- a 2-tuple (lower, upper) -- can be
given to specify the y-axis bounds. If not given, the range is
inferred from the data: (0, <max-value>) presuming no negative
valu... | [
"Scale",
"self",
".",
"data",
"as",
"appropriate",
"for",
"the",
"given",
"data",
"encoding",
"(",
"data_class",
")",
"and",
"return",
"it",
"."
] | train | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L579-L625 |
gak/pygooglechart | pygooglechart.py | MapChart.set_codes | def set_codes(self, codes):
'''Set the country code map for the data.
Codes given in a list.
i.e. DE - Germany
AT - Austria
US - United States
'''
codemap = ''
for cc in codes:
cc = cc.upper()
if cc in self.__cc... | python | def set_codes(self, codes):
'''Set the country code map for the data.
Codes given in a list.
i.e. DE - Germany
AT - Austria
US - United States
'''
codemap = ''
for cc in codes:
cc = cc.upper()
if cc in self.__cc... | [
"def",
"set_codes",
"(",
"self",
",",
"codes",
")",
":",
"codemap",
"=",
"''",
"for",
"cc",
"in",
"codes",
":",
"cc",
"=",
"cc",
".",
"upper",
"(",
")",
"if",
"cc",
"in",
"self",
".",
"__ccodes",
":",
"codemap",
"+=",
"cc",
"else",
":",
"raise",
... | Set the country code map for the data.
Codes given in a list.
i.e. DE - Germany
AT - Austria
US - United States | [
"Set",
"the",
"country",
"code",
"map",
"for",
"the",
"data",
".",
"Codes",
"given",
"in",
"a",
"list",
"."
] | train | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L1021-L1039 |
gak/pygooglechart | pygooglechart.py | MapChart.set_geo_area | def set_geo_area(self, area):
'''Sets the geo area for the map.
* africa
* asia
* europe
* middle_east
* south_america
* usa
* world
'''
if area in self.__areas:
self.geo_area = area
else:
raise Unk... | python | def set_geo_area(self, area):
'''Sets the geo area for the map.
* africa
* asia
* europe
* middle_east
* south_america
* usa
* world
'''
if area in self.__areas:
self.geo_area = area
else:
raise Unk... | [
"def",
"set_geo_area",
"(",
"self",
",",
"area",
")",
":",
"if",
"area",
"in",
"self",
".",
"__areas",
":",
"self",
".",
"geo_area",
"=",
"area",
"else",
":",
"raise",
"UnknownChartType",
"(",
"'Unknown chart type for maps: %s'",
"%",
"area",
")"
] | Sets the geo area for the map.
* africa
* asia
* europe
* middle_east
* south_america
* usa
* world | [
"Sets",
"the",
"geo",
"area",
"for",
"the",
"map",
"."
] | train | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L1041-L1056 |
gak/pygooglechart | pygooglechart.py | MapChart.add_data_dict | def add_data_dict(self, datadict):
'''Sets the data and country codes via a dictionary.
i.e. {'DE': 50, 'GB': 30, 'AT': 70}
'''
self.set_codes(list(datadict.keys()))
self.add_data(list(datadict.values())) | python | def add_data_dict(self, datadict):
'''Sets the data and country codes via a dictionary.
i.e. {'DE': 50, 'GB': 30, 'AT': 70}
'''
self.set_codes(list(datadict.keys()))
self.add_data(list(datadict.values())) | [
"def",
"add_data_dict",
"(",
"self",
",",
"datadict",
")",
":",
"self",
".",
"set_codes",
"(",
"list",
"(",
"datadict",
".",
"keys",
"(",
")",
")",
")",
"self",
".",
"add_data",
"(",
"list",
"(",
"datadict",
".",
"values",
"(",
")",
")",
")"
] | Sets the data and country codes via a dictionary.
i.e. {'DE': 50, 'GB': 30, 'AT': 70} | [
"Sets",
"the",
"data",
"and",
"country",
"codes",
"via",
"a",
"dictionary",
"."
] | train | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/pygooglechart.py#L1065-L1072 |
hsolbrig/PyShEx | pyshex/utils/datatype_utils.py | can_cast_to | def can_cast_to(v: Literal, dt: str) -> bool:
""" 5.4.3 Datatype Constraints
Determine whether "a value of the lexical form of n can be cast to the target type v per
XPath Functions 3.1 section 19 Casting[xpath-functions]."
"""
# TODO: rdflib doesn't appear to pay any attention to lengths (e.g. 257... | python | def can_cast_to(v: Literal, dt: str) -> bool:
""" 5.4.3 Datatype Constraints
Determine whether "a value of the lexical form of n can be cast to the target type v per
XPath Functions 3.1 section 19 Casting[xpath-functions]."
"""
# TODO: rdflib doesn't appear to pay any attention to lengths (e.g. 257... | [
"def",
"can_cast_to",
"(",
"v",
":",
"Literal",
",",
"dt",
":",
"str",
")",
"->",
"bool",
":",
"# TODO: rdflib doesn't appear to pay any attention to lengths (e.g. 257 is a valid XSD.byte)",
"return",
"v",
".",
"value",
"is",
"not",
"None",
"and",
"Literal",
"(",
"s... | 5.4.3 Datatype Constraints
Determine whether "a value of the lexical form of n can be cast to the target type v per
XPath Functions 3.1 section 19 Casting[xpath-functions]." | [
"5",
".",
"4",
".",
"3",
"Datatype",
"Constraints"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/datatype_utils.py#L12-L19 |
hsolbrig/PyShEx | pyshex/utils/datatype_utils.py | total_digits | def total_digits(n: Literal) -> Optional[int]:
""" 5.4.5 XML Schema Numberic Facet Constraints
totaldigits and fractiondigits constraints on values not derived from xsd:decimal fail.
"""
return len(str(abs(int(n.value)))) + fraction_digits(n) if is_numeric(n) and n.value is not None else None | python | def total_digits(n: Literal) -> Optional[int]:
""" 5.4.5 XML Schema Numberic Facet Constraints
totaldigits and fractiondigits constraints on values not derived from xsd:decimal fail.
"""
return len(str(abs(int(n.value)))) + fraction_digits(n) if is_numeric(n) and n.value is not None else None | [
"def",
"total_digits",
"(",
"n",
":",
"Literal",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"return",
"len",
"(",
"str",
"(",
"abs",
"(",
"int",
"(",
"n",
".",
"value",
")",
")",
")",
")",
"+",
"fraction_digits",
"(",
"n",
")",
"if",
"is_numeri... | 5.4.5 XML Schema Numberic Facet Constraints
totaldigits and fractiondigits constraints on values not derived from xsd:decimal fail. | [
"5",
".",
"4",
".",
"5",
"XML",
"Schema",
"Numberic",
"Facet",
"Constraints"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/datatype_utils.py#L22-L27 |
hsolbrig/PyShEx | pyshex/utils/datatype_utils.py | fraction_digits | def fraction_digits(n: Literal) -> Optional[int]:
""" 5.4.5 XML Schema Numeric Facet Constraints
for "fractiondigits" constraints, v is less than or equals the number of digits to the right of the decimal place
in the XML Schema canonical form[xmlschema-2] of the value of n, ignoring trailing zeros.
""... | python | def fraction_digits(n: Literal) -> Optional[int]:
""" 5.4.5 XML Schema Numeric Facet Constraints
for "fractiondigits" constraints, v is less than or equals the number of digits to the right of the decimal place
in the XML Schema canonical form[xmlschema-2] of the value of n, ignoring trailing zeros.
""... | [
"def",
"fraction_digits",
"(",
"n",
":",
"Literal",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"# Note - the last expression below isolates the fractional portion, reverses it (e.g. 017320 --> 023710) and",
"# converts it to an integer and back to a string",
"return",
"None"... | 5.4.5 XML Schema Numeric Facet Constraints
for "fractiondigits" constraints, v is less than or equals the number of digits to the right of the decimal place
in the XML Schema canonical form[xmlschema-2] of the value of n, ignoring trailing zeros. | [
"5",
".",
"4",
".",
"5",
"XML",
"Schema",
"Numeric",
"Facet",
"Constraints"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/datatype_utils.py#L30-L40 |
hsolbrig/PyShEx | pyshex/utils/datatype_utils.py | _map_xpath_flags_to_re | def _map_xpath_flags_to_re(expr: str, xpath_flags: str) -> Tuple[int, str]:
""" Map `5.6.2 Flags <https://www.w3.org/TR/xpath-functions-31/#flags>`_ to python
:param expr: match pattern
:param xpath_flags: xpath flags
:returns: python flags / modified match pattern
"""
python_flags: int = 0
... | python | def _map_xpath_flags_to_re(expr: str, xpath_flags: str) -> Tuple[int, str]:
""" Map `5.6.2 Flags <https://www.w3.org/TR/xpath-functions-31/#flags>`_ to python
:param expr: match pattern
:param xpath_flags: xpath flags
:returns: python flags / modified match pattern
"""
python_flags: int = 0
... | [
"def",
"_map_xpath_flags_to_re",
"(",
"expr",
":",
"str",
",",
"xpath_flags",
":",
"str",
")",
"->",
"Tuple",
"[",
"int",
",",
"str",
"]",
":",
"python_flags",
":",
"int",
"=",
"0",
"modified_expr",
"=",
"expr",
"if",
"xpath_flags",
"is",
"None",
":",
... | Map `5.6.2 Flags <https://www.w3.org/TR/xpath-functions-31/#flags>`_ to python
:param expr: match pattern
:param xpath_flags: xpath flags
:returns: python flags / modified match pattern | [
"Map",
"5",
".",
"6",
".",
"2",
"Flags",
"<https",
":",
"//",
"www",
".",
"w3",
".",
"org",
"/",
"TR",
"/",
"xpath",
"-",
"functions",
"-",
"31",
"/",
"#flags",
">",
"_",
"to",
"python"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/datatype_utils.py#L61-L84 |
hsolbrig/PyShEx | pyshex/utils/datatype_utils.py | map_object_literal | def map_object_literal(v: Union[str, jsonasobj.JsonObj]) -> ShExJ.ObjectLiteral:
""" `PyShEx.jsg <https://github.com/hsolbrig/ShExJSG/ShExJSG/ShExJ.jsg>`_ does not add identifying
types to ObjectLiterals. This routine re-identifies the types
"""
# TODO: isinstance(v, JSGString) should work here, but it... | python | def map_object_literal(v: Union[str, jsonasobj.JsonObj]) -> ShExJ.ObjectLiteral:
""" `PyShEx.jsg <https://github.com/hsolbrig/ShExJSG/ShExJSG/ShExJ.jsg>`_ does not add identifying
types to ObjectLiterals. This routine re-identifies the types
"""
# TODO: isinstance(v, JSGString) should work here, but it... | [
"def",
"map_object_literal",
"(",
"v",
":",
"Union",
"[",
"str",
",",
"jsonasobj",
".",
"JsonObj",
"]",
")",
"->",
"ShExJ",
".",
"ObjectLiteral",
":",
"# TODO: isinstance(v, JSGString) should work here, but it doesn't with IRIREF(http://a.example/v1)",
"return",
"v",
"if"... | `PyShEx.jsg <https://github.com/hsolbrig/ShExJSG/ShExJSG/ShExJ.jsg>`_ does not add identifying
types to ObjectLiterals. This routine re-identifies the types | [
"PyShEx",
".",
"jsg",
"<https",
":",
"//",
"github",
".",
"com",
"/",
"hsolbrig",
"/",
"ShExJSG",
"/",
"ShExJSG",
"/",
"ShExJ",
".",
"jsg",
">",
"_",
"does",
"not",
"add",
"identifying",
"types",
"to",
"ObjectLiterals",
".",
"This",
"routine",
"re",
"-... | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/datatype_utils.py#L95-L101 |
stuaxo/vext | vext/cmdline/__init__.py | do_enable | def do_enable():
"""
Uncomment any lines that start with #import in the .pth file
"""
try:
_lines = []
with open(vext_pth, mode='r') as f:
for line in f.readlines():
if line.startswith('#') and line[1:].lstrip().startswith('import '):
_line... | python | def do_enable():
"""
Uncomment any lines that start with #import in the .pth file
"""
try:
_lines = []
with open(vext_pth, mode='r') as f:
for line in f.readlines():
if line.startswith('#') and line[1:].lstrip().startswith('import '):
_line... | [
"def",
"do_enable",
"(",
")",
":",
"try",
":",
"_lines",
"=",
"[",
"]",
"with",
"open",
"(",
"vext_pth",
",",
"mode",
"=",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
".",
"readlines",
"(",
")",
":",
"if",
"line",
".",
"startswith",
"... | Uncomment any lines that start with #import in the .pth file | [
"Uncomment",
"any",
"lines",
"that",
"start",
"with",
"#import",
"in",
"the",
".",
"pth",
"file"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/cmdline/__init__.py#L32-L63 |
stuaxo/vext | vext/cmdline/__init__.py | do_disable | def do_disable():
"""
Comment any lines that start with import in the .pth file
"""
from vext import vext_pth
try:
_lines = []
with open(vext_pth, mode='r') as f:
for line in f.readlines():
if not line.startswith('#') and line.startswith('import '):
... | python | def do_disable():
"""
Comment any lines that start with import in the .pth file
"""
from vext import vext_pth
try:
_lines = []
with open(vext_pth, mode='r') as f:
for line in f.readlines():
if not line.startswith('#') and line.startswith('import '):
... | [
"def",
"do_disable",
"(",
")",
":",
"from",
"vext",
"import",
"vext_pth",
"try",
":",
"_lines",
"=",
"[",
"]",
"with",
"open",
"(",
"vext_pth",
",",
"mode",
"=",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
".",
"readlines",
"(",
")",
":... | Comment any lines that start with import in the .pth file | [
"Comment",
"any",
"lines",
"that",
"start",
"with",
"import",
"in",
"the",
".",
"pth",
"file"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/cmdline/__init__.py#L67-L99 |
stuaxo/vext | vext/cmdline/__init__.py | do_check | def do_check(vext_files):
"""
Attempt to import everything in the 'test-imports' section of specified
vext_files
:param: list of vext filenames (without paths), '*' matches all.
:return: True if test_imports was successful from all files
"""
import vext
# not efficient ... but then ther... | python | def do_check(vext_files):
"""
Attempt to import everything in the 'test-imports' section of specified
vext_files
:param: list of vext filenames (without paths), '*' matches all.
:return: True if test_imports was successful from all files
"""
import vext
# not efficient ... but then ther... | [
"def",
"do_check",
"(",
"vext_files",
")",
":",
"import",
"vext",
"# not efficient ... but then there shouldn't be many of these",
"all_specs",
"=",
"set",
"(",
"vext",
".",
"gatekeeper",
".",
"spec_files_flat",
"(",
")",
")",
"if",
"vext_files",
"==",
"[",
"'*'",
... | Attempt to import everything in the 'test-imports' section of specified
vext_files
:param: list of vext filenames (without paths), '*' matches all.
:return: True if test_imports was successful from all files | [
"Attempt",
"to",
"import",
"everything",
"in",
"the",
"test",
"-",
"imports",
"section",
"of",
"specified",
"vext_files"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/cmdline/__init__.py#L116-L148 |
stuaxo/vext | vext/gatekeeper/__init__.py | fix_path | def fix_path(p):
"""
Convert path pointing subdirectory of virtualenv site-packages
to system site-packages.
Destination directory must exist for this to work.
>>> fix_path('C:\\some-venv\\Lib\\site-packages\\gnome')
'C:\\Python27\\lib\\site-packages\\gnome'
"""
venv_lib = get_python_l... | python | def fix_path(p):
"""
Convert path pointing subdirectory of virtualenv site-packages
to system site-packages.
Destination directory must exist for this to work.
>>> fix_path('C:\\some-venv\\Lib\\site-packages\\gnome')
'C:\\Python27\\lib\\site-packages\\gnome'
"""
venv_lib = get_python_l... | [
"def",
"fix_path",
"(",
"p",
")",
":",
"venv_lib",
"=",
"get_python_lib",
"(",
")",
"if",
"p",
".",
"startswith",
"(",
"venv_lib",
")",
":",
"subdir",
"=",
"p",
"[",
"len",
"(",
"venv_lib",
")",
"+",
"1",
":",
"]",
"for",
"sitedir",
"in",
"getsyssi... | Convert path pointing subdirectory of virtualenv site-packages
to system site-packages.
Destination directory must exist for this to work.
>>> fix_path('C:\\some-venv\\Lib\\site-packages\\gnome')
'C:\\Python27\\lib\\site-packages\\gnome' | [
"Convert",
"path",
"pointing",
"subdirectory",
"of",
"virtualenv",
"site",
"-",
"packages",
"to",
"system",
"site",
"-",
"packages",
"."
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L56-L76 |
stuaxo/vext | vext/gatekeeper/__init__.py | fixup_paths | def fixup_paths():
"""
Fixup paths added in .pth file that point to the virtualenv
instead of the system site packages.
In depth: .PTH can execute arbitrary code, which might
manipulate the PATH or sys.path
:return:
"""
original_paths = os.environ.get('PATH', "").split(os.path.pathsep... | python | def fixup_paths():
"""
Fixup paths added in .pth file that point to the virtualenv
instead of the system site packages.
In depth: .PTH can execute arbitrary code, which might
manipulate the PATH or sys.path
:return:
"""
original_paths = os.environ.get('PATH', "").split(os.path.pathsep... | [
"def",
"fixup_paths",
"(",
")",
":",
"original_paths",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'PATH'",
",",
"\"\"",
")",
".",
"split",
"(",
"os",
".",
"path",
".",
"pathsep",
")",
"original_dirs",
"=",
"set",
"(",
"added_dirs",
")",
"yield",
"#... | Fixup paths added in .pth file that point to the virtualenv
instead of the system site packages.
In depth: .PTH can execute arbitrary code, which might
manipulate the PATH or sys.path
:return: | [
"Fixup",
"paths",
"added",
"in",
".",
"pth",
"file",
"that",
"point",
"to",
"the",
"virtualenv",
"instead",
"of",
"the",
"system",
"site",
"packages",
"."
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L80-L120 |
stuaxo/vext | vext/gatekeeper/__init__.py | addpackage | def addpackage(sys_sitedir, pthfile, known_dirs):
"""
Wrapper for site.addpackage
Try and work out which directories are added by
the .pth and add them to the known_dirs set
:param sys_sitedir: system site-packages directory
:param pthfile: path file to add
:param known_dirs: set of known ... | python | def addpackage(sys_sitedir, pthfile, known_dirs):
"""
Wrapper for site.addpackage
Try and work out which directories are added by
the .pth and add them to the known_dirs set
:param sys_sitedir: system site-packages directory
:param pthfile: path file to add
:param known_dirs: set of known ... | [
"def",
"addpackage",
"(",
"sys_sitedir",
",",
"pthfile",
",",
"known_dirs",
")",
":",
"with",
"open",
"(",
"join",
"(",
"sys_sitedir",
",",
"pthfile",
")",
")",
"as",
"f",
":",
"for",
"n",
",",
"line",
"in",
"enumerate",
"(",
"f",
")",
":",
"if",
"... | Wrapper for site.addpackage
Try and work out which directories are added by
the .pth and add them to the known_dirs set
:param sys_sitedir: system site-packages directory
:param pthfile: path file to add
:param known_dirs: set of known directories | [
"Wrapper",
"for",
"site",
".",
"addpackage"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L123-L158 |
stuaxo/vext | vext/gatekeeper/__init__.py | filename_to_module | def filename_to_module(filename):
"""
convert a filename like html5lib-0.999.egg-info to html5lib
"""
find = re.compile(r"^[^.|-]*")
name = re.search(find, filename).group(0)
return name | python | def filename_to_module(filename):
"""
convert a filename like html5lib-0.999.egg-info to html5lib
"""
find = re.compile(r"^[^.|-]*")
name = re.search(find, filename).group(0)
return name | [
"def",
"filename_to_module",
"(",
"filename",
")",
":",
"find",
"=",
"re",
".",
"compile",
"(",
"r\"^[^.|-]*\"",
")",
"name",
"=",
"re",
".",
"search",
"(",
"find",
",",
"filename",
")",
".",
"group",
"(",
"0",
")",
"return",
"name"
] | convert a filename like html5lib-0.999.egg-info to html5lib | [
"convert",
"a",
"filename",
"like",
"html5lib",
"-",
"0",
".",
"999",
".",
"egg",
"-",
"info",
"to",
"html5lib"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L166-L172 |
stuaxo/vext | vext/gatekeeper/__init__.py | init_path | def init_path():
"""
Add any new modules that are directories to the PATH
"""
sitedirs = getsyssitepackages()
for sitedir in sitedirs:
env_path = os.environ['PATH'].split(os.pathsep)
for module in allowed_modules:
p = join(sitedir, module)
if isdir(p) and not ... | python | def init_path():
"""
Add any new modules that are directories to the PATH
"""
sitedirs = getsyssitepackages()
for sitedir in sitedirs:
env_path = os.environ['PATH'].split(os.pathsep)
for module in allowed_modules:
p = join(sitedir, module)
if isdir(p) and not ... | [
"def",
"init_path",
"(",
")",
":",
"sitedirs",
"=",
"getsyssitepackages",
"(",
")",
"for",
"sitedir",
"in",
"sitedirs",
":",
"env_path",
"=",
"os",
".",
"environ",
"[",
"'PATH'",
"]",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
"for",
"module",
"in",... | Add any new modules that are directories to the PATH | [
"Add",
"any",
"new",
"modules",
"that",
"are",
"directories",
"to",
"the",
"PATH"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L275-L285 |
stuaxo/vext | vext/gatekeeper/__init__.py | install_importer | def install_importer():
"""
If in a virtualenv then load spec files to decide which
modules can be imported from system site-packages and
install path hook.
"""
logging.debug('install_importer')
if not in_venv():
logging.debug('No virtualenv active py:[%s]', sys.executable)
r... | python | def install_importer():
"""
If in a virtualenv then load spec files to decide which
modules can be imported from system site-packages and
install path hook.
"""
logging.debug('install_importer')
if not in_venv():
logging.debug('No virtualenv active py:[%s]', sys.executable)
r... | [
"def",
"install_importer",
"(",
")",
":",
"logging",
".",
"debug",
"(",
"'install_importer'",
")",
"if",
"not",
"in_venv",
"(",
")",
":",
"logging",
".",
"debug",
"(",
"'No virtualenv active py:[%s]'",
",",
"sys",
".",
"executable",
")",
"return",
"False",
"... | If in a virtualenv then load spec files to decide which
modules can be imported from system site-packages and
install path hook. | [
"If",
"in",
"a",
"virtualenv",
"then",
"load",
"spec",
"files",
"to",
"decide",
"which",
"modules",
"can",
"be",
"imported",
"from",
"system",
"site",
"-",
"packages",
"and",
"install",
"path",
"hook",
"."
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L377-L406 |
stuaxo/vext | vext/gatekeeper/__init__.py | GateKeeperLoader.load_module | def load_module(self, name):
"""
Only lets modules in allowed_modules be loaded, others
will get an ImportError
"""
# Get the name relative to SITEDIR ..
filepath = self.module_info[1]
fullname = splitext( \
relpath(filepath, self.sitedir) \
... | python | def load_module(self, name):
"""
Only lets modules in allowed_modules be loaded, others
will get an ImportError
"""
# Get the name relative to SITEDIR ..
filepath = self.module_info[1]
fullname = splitext( \
relpath(filepath, self.sitedir) \
... | [
"def",
"load_module",
"(",
"self",
",",
"name",
")",
":",
"# Get the name relative to SITEDIR ..",
"filepath",
"=",
"self",
".",
"module_info",
"[",
"1",
"]",
"fullname",
"=",
"splitext",
"(",
"relpath",
"(",
"filepath",
",",
"self",
".",
"sitedir",
")",
")"... | Only lets modules in allowed_modules be loaded, others
will get an ImportError | [
"Only",
"lets",
"modules",
"in",
"allowed_modules",
"be",
"loaded",
"others",
"will",
"get",
"an",
"ImportError"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/gatekeeper/__init__.py#L184-L215 |
stuaxo/vext | vext/helpers/sip.py | extra_paths | def extra_paths():
"""
:return: extra paths
"""
# TODO - this is only tested on Ubuntu for now
# there must be a better way of getting
# the sip directory.
dirs = {}
try:
@vext.env.run_in_syspy
def run(*args):
import sipconfig
config ... | python | def extra_paths():
"""
:return: extra paths
"""
# TODO - this is only tested on Ubuntu for now
# there must be a better way of getting
# the sip directory.
dirs = {}
try:
@vext.env.run_in_syspy
def run(*args):
import sipconfig
config ... | [
"def",
"extra_paths",
"(",
")",
":",
"# TODO - this is only tested on Ubuntu for now",
"# there must be a better way of getting",
"# the sip directory.",
"dirs",
"=",
"{",
"}",
"try",
":",
"@",
"vext",
".",
"env",
".",
"run_in_syspy",
"def",
"run",
"(",
"*... | :return: extra paths | [
":",
"return",
":",
"extra",
"paths"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/helpers/sip.py#L10-L30 |
jaysonsantos/python-binary-memcached | bmemcached/utils.py | str_to_bytes | def str_to_bytes(value):
"""
Simply convert a string type to bytes if the value is a string
and is an instance of six.string_types but not of six.binary_type
in python2 struct.pack("<Q") is both string_types and binary_type but
in python3 struct.pack("<Q") is binary_type but not a string_types
:... | python | def str_to_bytes(value):
"""
Simply convert a string type to bytes if the value is a string
and is an instance of six.string_types but not of six.binary_type
in python2 struct.pack("<Q") is both string_types and binary_type but
in python3 struct.pack("<Q") is binary_type but not a string_types
:... | [
"def",
"str_to_bytes",
"(",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"binary_type",
")",
"and",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"return",
"value",
".",
"encode",
"(",
")",
"retu... | Simply convert a string type to bytes if the value is a string
and is an instance of six.string_types but not of six.binary_type
in python2 struct.pack("<Q") is both string_types and binary_type but
in python3 struct.pack("<Q") is binary_type but not a string_types
:param value:
:param binary:
:... | [
"Simply",
"convert",
"a",
"string",
"type",
"to",
"bytes",
"if",
"the",
"value",
"is",
"a",
"string",
"and",
"is",
"an",
"instance",
"of",
"six",
".",
"string_types",
"but",
"not",
"of",
"six",
".",
"binary_type",
"in",
"python2",
"struct",
".",
"pack",
... | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/utils.py#L6-L18 |
hsolbrig/PyShEx | pyshex/evaluate.py | evaluate | def evaluate(g: Graph,
schema: Union[str, ShExJ.Schema],
focus: Optional[Union[str, URIRef, IRIREF]],
start: Optional[Union[str, URIRef, IRIREF, START, START_TYPE]]=None,
debug_trace: bool = False) -> Tuple[bool, Optional[str]]:
""" Evaluate focus node `focus` in ... | python | def evaluate(g: Graph,
schema: Union[str, ShExJ.Schema],
focus: Optional[Union[str, URIRef, IRIREF]],
start: Optional[Union[str, URIRef, IRIREF, START, START_TYPE]]=None,
debug_trace: bool = False) -> Tuple[bool, Optional[str]]:
""" Evaluate focus node `focus` in ... | [
"def",
"evaluate",
"(",
"g",
":",
"Graph",
",",
"schema",
":",
"Union",
"[",
"str",
",",
"ShExJ",
".",
"Schema",
"]",
",",
"focus",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"URIRef",
",",
"IRIREF",
"]",
"]",
",",
"start",
":",
"Optional",
... | Evaluate focus node `focus` in graph `g` against shape `shape` in ShEx schema `schema`
:param g: Graph containing RDF
:param schema: ShEx Schema -- if str, it will be parsed
:param focus: focus node in g. If not specified, all URI subjects in G will be evaluated.
:param start: Starting shape. If omitt... | [
"Evaluate",
"focus",
"node",
"focus",
"in",
"graph",
"g",
"against",
"shape",
"shape",
"in",
"ShEx",
"schema",
"schema"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/evaluate.py#L14-L45 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_2_validation_definition.py | isValid | def isValid(cntxt: Context, m: FixedShapeMap) -> Tuple[bool, List[str]]:
"""`5.2 Validation Definition <http://shex.io/shex-semantics/#validation>`_
The expression isValid(G, m) indicates that for every nodeSelector/shapeLabel pair (n, s) in m, s has a
corresponding shape expression se and satisfies(n,... | python | def isValid(cntxt: Context, m: FixedShapeMap) -> Tuple[bool, List[str]]:
"""`5.2 Validation Definition <http://shex.io/shex-semantics/#validation>`_
The expression isValid(G, m) indicates that for every nodeSelector/shapeLabel pair (n, s) in m, s has a
corresponding shape expression se and satisfies(n,... | [
"def",
"isValid",
"(",
"cntxt",
":",
"Context",
",",
"m",
":",
"FixedShapeMap",
")",
"->",
"Tuple",
"[",
"bool",
",",
"List",
"[",
"str",
"]",
"]",
":",
"if",
"not",
"cntxt",
".",
"is_valid",
":",
"return",
"False",
",",
"cntxt",
".",
"error_list",
... | `5.2 Validation Definition <http://shex.io/shex-semantics/#validation>`_
The expression isValid(G, m) indicates that for every nodeSelector/shapeLabel pair (n, s) in m, s has a
corresponding shape expression se and satisfies(n, se, G, m). satisfies is defined below for each form
of shape expression... | [
"5",
".",
"2",
"Validation",
"Definition",
"<http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#validation",
">",
"_"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_2_validation_definition.py#L14-L53 |
stuaxo/vext | vext/install/__init__.py | check_sysdeps | def check_sysdeps(vext_files):
"""
Check that imports in 'test_imports' succeed
otherwise display message in 'install_hints'
"""
@run_in_syspy
def run(*modules):
result = {}
for m in modules:
if m:
try:
__import__(m)
... | python | def check_sysdeps(vext_files):
"""
Check that imports in 'test_imports' succeed
otherwise display message in 'install_hints'
"""
@run_in_syspy
def run(*modules):
result = {}
for m in modules:
if m:
try:
__import__(m)
... | [
"def",
"check_sysdeps",
"(",
"vext_files",
")",
":",
"@",
"run_in_syspy",
"def",
"run",
"(",
"*",
"modules",
")",
":",
"result",
"=",
"{",
"}",
"for",
"m",
"in",
"modules",
":",
"if",
"m",
":",
"try",
":",
"__import__",
"(",
"m",
")",
"result",
"["... | Check that imports in 'test_imports' succeed
otherwise display message in 'install_hints' | [
"Check",
"that",
"imports",
"in",
"test_imports",
"succeed",
"otherwise",
"display",
"message",
"in",
"install_hints"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/install/__init__.py#L24-L57 |
stuaxo/vext | vext/install/__init__.py | install_vexts | def install_vexts(vext_files, verify=True):
"""
copy vext_file to sys.prefix + '/share/vext/specs'
(PIP7 seems to remove data_files so we recreate something similar here)
"""
if verify and not check_sysdeps(vext_files):
return
spec_dir = join(prefix, 'share/vext/specs')
try:
... | python | def install_vexts(vext_files, verify=True):
"""
copy vext_file to sys.prefix + '/share/vext/specs'
(PIP7 seems to remove data_files so we recreate something similar here)
"""
if verify and not check_sysdeps(vext_files):
return
spec_dir = join(prefix, 'share/vext/specs')
try:
... | [
"def",
"install_vexts",
"(",
"vext_files",
",",
"verify",
"=",
"True",
")",
":",
"if",
"verify",
"and",
"not",
"check_sysdeps",
"(",
"vext_files",
")",
":",
"return",
"spec_dir",
"=",
"join",
"(",
"prefix",
",",
"'share/vext/specs'",
")",
"try",
":",
"make... | copy vext_file to sys.prefix + '/share/vext/specs'
(PIP7 seems to remove data_files so we recreate something similar here) | [
"copy",
"vext_file",
"to",
"sys",
".",
"prefix",
"+",
"/",
"share",
"/",
"vext",
"/",
"specs"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/install/__init__.py#L60-L83 |
stuaxo/vext | vext/install/__init__.py | create_pth | def create_pth():
"""
Create the default PTH file
:return:
"""
if prefix == '/usr':
print("Not creating PTH in real prefix: %s" % prefix)
return False
with open(vext_pth, 'w') as f:
f.write(DEFAULT_PTH_CONTENT)
return True | python | def create_pth():
"""
Create the default PTH file
:return:
"""
if prefix == '/usr':
print("Not creating PTH in real prefix: %s" % prefix)
return False
with open(vext_pth, 'w') as f:
f.write(DEFAULT_PTH_CONTENT)
return True | [
"def",
"create_pth",
"(",
")",
":",
"if",
"prefix",
"==",
"'/usr'",
":",
"print",
"(",
"\"Not creating PTH in real prefix: %s\"",
"%",
"prefix",
")",
"return",
"False",
"with",
"open",
"(",
"vext_pth",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
... | Create the default PTH file
:return: | [
"Create",
"the",
"default",
"PTH",
"file",
":",
"return",
":"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/install/__init__.py#L86-L96 |
hsolbrig/PyShEx | pyshex/utils/collection_utils.py | format_collection | def format_collection(g: Graph, subj: Union[URIRef, BNode], max_entries: int = None, nentries: int = 0) -> Optional[List[str]]:
"""
Return the turtle representation of subj as a collection
:param g: Graph containing subj
:param subj: subject of list
:param max_entries: maximum number of list elemen... | python | def format_collection(g: Graph, subj: Union[URIRef, BNode], max_entries: int = None, nentries: int = 0) -> Optional[List[str]]:
"""
Return the turtle representation of subj as a collection
:param g: Graph containing subj
:param subj: subject of list
:param max_entries: maximum number of list elemen... | [
"def",
"format_collection",
"(",
"g",
":",
"Graph",
",",
"subj",
":",
"Union",
"[",
"URIRef",
",",
"BNode",
"]",
",",
"max_entries",
":",
"int",
"=",
"None",
",",
"nentries",
":",
"int",
"=",
"0",
")",
"->",
"Optional",
"[",
"List",
"[",
"str",
"]"... | Return the turtle representation of subj as a collection
:param g: Graph containing subj
:param subj: subject of list
:param max_entries: maximum number of list elements to return, None means all
:param nentries: used for recursion
:return: List of formatted entries if subj heads a well formed col... | [
"Return",
"the",
"turtle",
"representation",
"of",
"subj",
"as",
"a",
"collection"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/collection_utils.py#L6-L36 |
stuaxo/vext | vext/helpers/__init__.py | get_extra_path | def get_extra_path(name):
"""
:param name: name in format helper.path_name
sip.default_sip_dir
"""
# Paths are cached in path_cache
helper_name, _, key = name.partition(".")
helper = path_helpers.get(helper_name)
if not helper:
raise ValueError("Helper '{0}' not found.".format(h... | python | def get_extra_path(name):
"""
:param name: name in format helper.path_name
sip.default_sip_dir
"""
# Paths are cached in path_cache
helper_name, _, key = name.partition(".")
helper = path_helpers.get(helper_name)
if not helper:
raise ValueError("Helper '{0}' not found.".format(h... | [
"def",
"get_extra_path",
"(",
"name",
")",
":",
"# Paths are cached in path_cache",
"helper_name",
",",
"_",
",",
"key",
"=",
"name",
".",
"partition",
"(",
"\".\"",
")",
"helper",
"=",
"path_helpers",
".",
"get",
"(",
"helper_name",
")",
"if",
"not",
"helpe... | :param name: name in format helper.path_name
sip.default_sip_dir | [
":",
"param",
"name",
":",
"name",
"in",
"format",
"helper",
".",
"path_name"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/helpers/__init__.py#L12-L29 |
stuaxo/vext | setup.py | upgrade_setuptools | def upgrade_setuptools():
"""
setuptools 12.2 can trigger a really nasty bug
that eats all memory, so upgrade it to
18.8, which is known to be good.
"""
# Note - I tried including the higher version in
# setup_requires, but was still able to trigger
# the bug. - stu.axon
global MIN_S... | python | def upgrade_setuptools():
"""
setuptools 12.2 can trigger a really nasty bug
that eats all memory, so upgrade it to
18.8, which is known to be good.
"""
# Note - I tried including the higher version in
# setup_requires, but was still able to trigger
# the bug. - stu.axon
global MIN_S... | [
"def",
"upgrade_setuptools",
"(",
")",
":",
"# Note - I tried including the higher version in",
"# setup_requires, but was still able to trigger",
"# the bug. - stu.axon",
"global",
"MIN_SETUPTOOLS",
"r",
"=",
"None",
"try",
":",
"r",
"=",
"pkg_resources",
".",
"require",
"("... | setuptools 12.2 can trigger a really nasty bug
that eats all memory, so upgrade it to
18.8, which is known to be good. | [
"setuptools",
"12",
".",
"2",
"can",
"trigger",
"a",
"really",
"nasty",
"bug",
"that",
"eats",
"all",
"memory",
"so",
"upgrade",
"it",
"to",
"18",
".",
"8",
"which",
"is",
"known",
"to",
"be",
"good",
"."
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/setup.py#L28-L49 |
stuaxo/vext | setup.py | InstallLib.installed_packages | def installed_packages(self):
""" :return: list of installed packages """
packages = []
CMDLINE = [sys.executable, "-mpip", "freeze"]
try:
for package in subprocess.check_output(CMDLINE) \
.decode('utf-8'). \
splitlines():
... | python | def installed_packages(self):
""" :return: list of installed packages """
packages = []
CMDLINE = [sys.executable, "-mpip", "freeze"]
try:
for package in subprocess.check_output(CMDLINE) \
.decode('utf-8'). \
splitlines():
... | [
"def",
"installed_packages",
"(",
"self",
")",
":",
"packages",
"=",
"[",
"]",
"CMDLINE",
"=",
"[",
"sys",
".",
"executable",
",",
"\"-mpip\"",
",",
"\"freeze\"",
"]",
"try",
":",
"for",
"package",
"in",
"subprocess",
".",
"check_output",
"(",
"CMDLINE",
... | :return: list of installed packages | [
":",
"return",
":",
"list",
"of",
"installed",
"packages"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/setup.py#L127-L149 |
stuaxo/vext | setup.py | InstallLib.package_info | def package_info(self):
"""
:return: list of package info on installed packages
"""
import subprocess
# create a commandline like pip show Pillow show
package_names = self.installed_packages()
if not package_names:
# No installed packages yet, so noth... | python | def package_info(self):
"""
:return: list of package info on installed packages
"""
import subprocess
# create a commandline like pip show Pillow show
package_names = self.installed_packages()
if not package_names:
# No installed packages yet, so noth... | [
"def",
"package_info",
"(",
"self",
")",
":",
"import",
"subprocess",
"# create a commandline like pip show Pillow show",
"package_names",
"=",
"self",
".",
"installed_packages",
"(",
")",
"if",
"not",
"package_names",
":",
"# No installed packages yet, so nothign to do here... | :return: list of package info on installed packages | [
":",
"return",
":",
"list",
"of",
"package",
"info",
"on",
"installed",
"packages"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/setup.py#L151-L197 |
stuaxo/vext | setup.py | InstallLib.depends_on | def depends_on(self, dependency):
"""
List of packages that depend on dependency
:param dependency: package name, e.g. 'vext' or 'Pillow'
"""
packages = self.package_info()
return [package for package in packages if dependency in package.get("requires", "")] | python | def depends_on(self, dependency):
"""
List of packages that depend on dependency
:param dependency: package name, e.g. 'vext' or 'Pillow'
"""
packages = self.package_info()
return [package for package in packages if dependency in package.get("requires", "")] | [
"def",
"depends_on",
"(",
"self",
",",
"dependency",
")",
":",
"packages",
"=",
"self",
".",
"package_info",
"(",
")",
"return",
"[",
"package",
"for",
"package",
"in",
"packages",
"if",
"dependency",
"in",
"package",
".",
"get",
"(",
"\"requires\"",
",",
... | List of packages that depend on dependency
:param dependency: package name, e.g. 'vext' or 'Pillow' | [
"List",
"of",
"packages",
"that",
"depend",
"on",
"dependency",
":",
"param",
"dependency",
":",
"package",
"name",
"e",
".",
"g",
".",
"vext",
"or",
"Pillow"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/setup.py#L199-L205 |
stuaxo/vext | setup.py | InstallLib.find_vext_files | def find_vext_files(self):
"""
:return: Absolute paths to any provided vext files
"""
packages = self.depends_on("vext")
vext_files = []
for location in [package.get("location") for package in packages]:
if not location:
continue
v... | python | def find_vext_files(self):
"""
:return: Absolute paths to any provided vext files
"""
packages = self.depends_on("vext")
vext_files = []
for location in [package.get("location") for package in packages]:
if not location:
continue
v... | [
"def",
"find_vext_files",
"(",
"self",
")",
":",
"packages",
"=",
"self",
".",
"depends_on",
"(",
"\"vext\"",
")",
"vext_files",
"=",
"[",
"]",
"for",
"location",
"in",
"[",
"package",
".",
"get",
"(",
"\"location\"",
")",
"for",
"package",
"in",
"packag... | :return: Absolute paths to any provided vext files | [
":",
"return",
":",
"Absolute",
"paths",
"to",
"any",
"provided",
"vext",
"files"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/setup.py#L207-L217 |
stuaxo/vext | setup.py | InstallLib.run | def run(self):
"""
Need to find any pre-existing vext contained in dependent packages
and install them
example:
you create a setup.py with install_requires["vext.gi"]:
- vext.gi gets installed using bdist_egg
- vext itself is now called with bdist_egg and we en... | python | def run(self):
"""
Need to find any pre-existing vext contained in dependent packages
and install them
example:
you create a setup.py with install_requires["vext.gi"]:
- vext.gi gets installed using bdist_egg
- vext itself is now called with bdist_egg and we en... | [
"def",
"run",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"vext InstallLib [started]\"",
")",
"# Find packages that depend on vext and check for .vext files...",
"logger",
".",
"debug",
"(",
"\"find_vext_files\"",
")",
"vext_files",
"=",
"self",
".",
"find_vex... | Need to find any pre-existing vext contained in dependent packages
and install them
example:
you create a setup.py with install_requires["vext.gi"]:
- vext.gi gets installed using bdist_egg
- vext itself is now called with bdist_egg and we end up here
Vext now needs t... | [
"Need",
"to",
"find",
"any",
"pre",
"-",
"existing",
"vext",
"contained",
"in",
"dependent",
"packages",
"and",
"install",
"them"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/setup.py#L244-L273 |
jaysonsantos/python-binary-memcached | bmemcached/client/mixin.py | ClientMixin.set_servers | def set_servers(self, servers):
"""
Iter to a list of servers and instantiate Protocol class.
:param servers: A list of servers
:type servers: list
:return: Returns nothing
:rtype: None
"""
if isinstance(servers, six.string_types):
servers = [... | python | def set_servers(self, servers):
"""
Iter to a list of servers and instantiate Protocol class.
:param servers: A list of servers
:type servers: list
:return: Returns nothing
:rtype: None
"""
if isinstance(servers, six.string_types):
servers = [... | [
"def",
"set_servers",
"(",
"self",
",",
"servers",
")",
":",
"if",
"isinstance",
"(",
"servers",
",",
"six",
".",
"string_types",
")",
":",
"servers",
"=",
"[",
"servers",
"]",
"assert",
"servers",
",",
"\"No memcached servers supplied\"",
"self",
".",
"_ser... | Iter to a list of servers and instantiate Protocol class.
:param servers: A list of servers
:type servers: list
:return: Returns nothing
:rtype: None | [
"Iter",
"to",
"a",
"list",
"of",
"servers",
"and",
"instantiate",
"Protocol",
"class",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/mixin.py#L48-L70 |
jaysonsantos/python-binary-memcached | bmemcached/client/mixin.py | ClientMixin.flush_all | def flush_all(self, time=0):
"""
Send a command to server flush|delete all keys.
:param time: Time to wait until flush in seconds.
:type time: int
:return: True in case of success, False in case of failure
:rtype: bool
"""
returns = []
for server ... | python | def flush_all(self, time=0):
"""
Send a command to server flush|delete all keys.
:param time: Time to wait until flush in seconds.
:type time: int
:return: True in case of success, False in case of failure
:rtype: bool
"""
returns = []
for server ... | [
"def",
"flush_all",
"(",
"self",
",",
"time",
"=",
"0",
")",
":",
"returns",
"=",
"[",
"]",
"for",
"server",
"in",
"self",
".",
"servers",
":",
"returns",
".",
"append",
"(",
"server",
".",
"flush_all",
"(",
"time",
")",
")",
"return",
"any",
"(",
... | Send a command to server flush|delete all keys.
:param time: Time to wait until flush in seconds.
:type time: int
:return: True in case of success, False in case of failure
:rtype: bool | [
"Send",
"a",
"command",
"to",
"server",
"flush|delete",
"all",
"keys",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/mixin.py#L72-L85 |
jaysonsantos/python-binary-memcached | bmemcached/client/mixin.py | ClientMixin.stats | def stats(self, key=None):
"""
Return server stats.
:param key: Optional if you want status from a key.
:type key: six.string_types
:return: A dict with server stats
:rtype: dict
"""
# TODO: Stats with key is not working.
returns = {}
for... | python | def stats(self, key=None):
"""
Return server stats.
:param key: Optional if you want status from a key.
:type key: six.string_types
:return: A dict with server stats
:rtype: dict
"""
# TODO: Stats with key is not working.
returns = {}
for... | [
"def",
"stats",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"# TODO: Stats with key is not working.",
"returns",
"=",
"{",
"}",
"for",
"server",
"in",
"self",
".",
"servers",
":",
"returns",
"[",
"server",
".",
"server",
"]",
"=",
"server",
".",
"sta... | Return server stats.
:param key: Optional if you want status from a key.
:type key: six.string_types
:return: A dict with server stats
:rtype: dict | [
"Return",
"server",
"stats",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/mixin.py#L87-L102 |
gak/pygooglechart | examples/pie.py | house_explosions | def house_explosions():
"""
Data from http://indexed.blogspot.com/2007/12/meltdown-indeed.html
"""
chart = PieChart2D(int(settings.width * 1.7), settings.height)
chart.add_data([10, 10, 30, 200])
chart.set_pie_labels([
'Budding Chemists',
'Propane issues',
'Meth Labs',
... | python | def house_explosions():
"""
Data from http://indexed.blogspot.com/2007/12/meltdown-indeed.html
"""
chart = PieChart2D(int(settings.width * 1.7), settings.height)
chart.add_data([10, 10, 30, 200])
chart.set_pie_labels([
'Budding Chemists',
'Propane issues',
'Meth Labs',
... | [
"def",
"house_explosions",
"(",
")",
":",
"chart",
"=",
"PieChart2D",
"(",
"int",
"(",
"settings",
".",
"width",
"*",
"1.7",
")",
",",
"settings",
".",
"height",
")",
"chart",
".",
"add_data",
"(",
"[",
"10",
",",
"10",
",",
"30",
",",
"200",
"]",
... | Data from http://indexed.blogspot.com/2007/12/meltdown-indeed.html | [
"Data",
"from",
"http",
":",
"//",
"indexed",
".",
"blogspot",
".",
"com",
"/",
"2007",
"/",
"12",
"/",
"meltdown",
"-",
"indeed",
".",
"html"
] | train | https://github.com/gak/pygooglechart/blob/25234bb63127a7e5e057c0b98ab841f3f1d93b21/examples/pie.py#L45-L57 |
hsolbrig/PyShEx | pyshex/utils/value_set_utils.py | objectValueMatches | def objectValueMatches(n: Node, vsv: ShExJ.objectValue) -> bool:
""" http://shex.io/shex-semantics/#values
Implements "n = vsv" where vsv is an objectValue and n is a Node
Note that IRIREF is a string pattern, so the matching type is str
"""
return \
(isinstance(vsv, IRIREF) and isinstance... | python | def objectValueMatches(n: Node, vsv: ShExJ.objectValue) -> bool:
""" http://shex.io/shex-semantics/#values
Implements "n = vsv" where vsv is an objectValue and n is a Node
Note that IRIREF is a string pattern, so the matching type is str
"""
return \
(isinstance(vsv, IRIREF) and isinstance... | [
"def",
"objectValueMatches",
"(",
"n",
":",
"Node",
",",
"vsv",
":",
"ShExJ",
".",
"objectValue",
")",
"->",
"bool",
":",
"return",
"(",
"isinstance",
"(",
"vsv",
",",
"IRIREF",
")",
"and",
"isinstance",
"(",
"n",
",",
"URIRef",
")",
"and",
"uriref_mat... | http://shex.io/shex-semantics/#values
Implements "n = vsv" where vsv is an objectValue and n is a Node
Note that IRIREF is a string pattern, so the matching type is str | [
"http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#values"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/value_set_utils.py#L10-L19 |
hsolbrig/PyShEx | pyshex/utils/value_set_utils.py | uriref_matches_iriref | def uriref_matches_iriref(v1: URIRef, v2: Union[str, ShExJ.IRIREF]) -> bool:
""" Compare :py:class:`rdflib.URIRef` value with :py:class:`ShExJ.IRIREF` value """
return str(v1) == str(v2) | python | def uriref_matches_iriref(v1: URIRef, v2: Union[str, ShExJ.IRIREF]) -> bool:
""" Compare :py:class:`rdflib.URIRef` value with :py:class:`ShExJ.IRIREF` value """
return str(v1) == str(v2) | [
"def",
"uriref_matches_iriref",
"(",
"v1",
":",
"URIRef",
",",
"v2",
":",
"Union",
"[",
"str",
",",
"ShExJ",
".",
"IRIREF",
"]",
")",
"->",
"bool",
":",
"return",
"str",
"(",
"v1",
")",
"==",
"str",
"(",
"v2",
")"
] | Compare :py:class:`rdflib.URIRef` value with :py:class:`ShExJ.IRIREF` value | [
"Compare",
":",
"py",
":",
"class",
":",
"rdflib",
".",
"URIRef",
"value",
"with",
":",
"py",
":",
"class",
":",
"ShExJ",
".",
"IRIREF",
"value"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/value_set_utils.py#L22-L24 |
hsolbrig/PyShEx | pyshex/utils/value_set_utils.py | uriref_startswith_iriref | def uriref_startswith_iriref(v1: URIRef, v2: Union[str, ShExJ.IRIREF]) -> bool:
""" Determine whether a :py:class:`rdflib.URIRef` value starts with the text of a :py:class:`ShExJ.IRIREF` value """
return str(v1).startswith(str(v2)) | python | def uriref_startswith_iriref(v1: URIRef, v2: Union[str, ShExJ.IRIREF]) -> bool:
""" Determine whether a :py:class:`rdflib.URIRef` value starts with the text of a :py:class:`ShExJ.IRIREF` value """
return str(v1).startswith(str(v2)) | [
"def",
"uriref_startswith_iriref",
"(",
"v1",
":",
"URIRef",
",",
"v2",
":",
"Union",
"[",
"str",
",",
"ShExJ",
".",
"IRIREF",
"]",
")",
"->",
"bool",
":",
"return",
"str",
"(",
"v1",
")",
".",
"startswith",
"(",
"str",
"(",
"v2",
")",
")"
] | Determine whether a :py:class:`rdflib.URIRef` value starts with the text of a :py:class:`ShExJ.IRIREF` value | [
"Determine",
"whether",
"a",
":",
"py",
":",
"class",
":",
"rdflib",
".",
"URIRef",
"value",
"starts",
"with",
"the",
"text",
"of",
"a",
":",
"py",
":",
"class",
":",
"ShExJ",
".",
"IRIREF",
"value"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/value_set_utils.py#L27-L29 |
hsolbrig/PyShEx | pyshex/utils/value_set_utils.py | literal_matches_objectliteral | def literal_matches_objectliteral(v1: Literal, v2: ShExJ.ObjectLiteral) -> bool:
""" Compare :py:class:`rdflib.Literal` with :py:class:`ShExJ.objectLiteral` """
v2_lit = Literal(str(v2.value), datatype=iriref_to_uriref(v2.type), lang=str(v2.language) if v2.language else None)
return v1 == v2_lit | python | def literal_matches_objectliteral(v1: Literal, v2: ShExJ.ObjectLiteral) -> bool:
""" Compare :py:class:`rdflib.Literal` with :py:class:`ShExJ.objectLiteral` """
v2_lit = Literal(str(v2.value), datatype=iriref_to_uriref(v2.type), lang=str(v2.language) if v2.language else None)
return v1 == v2_lit | [
"def",
"literal_matches_objectliteral",
"(",
"v1",
":",
"Literal",
",",
"v2",
":",
"ShExJ",
".",
"ObjectLiteral",
")",
"->",
"bool",
":",
"v2_lit",
"=",
"Literal",
"(",
"str",
"(",
"v2",
".",
"value",
")",
",",
"datatype",
"=",
"iriref_to_uriref",
"(",
"... | Compare :py:class:`rdflib.Literal` with :py:class:`ShExJ.objectLiteral` | [
"Compare",
":",
"py",
":",
"class",
":",
"rdflib",
".",
"Literal",
"with",
":",
"py",
":",
"class",
":",
"ShExJ",
".",
"objectLiteral"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/utils/value_set_utils.py#L32-L35 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_4_node_constraints.py | satisfiesNodeConstraint | def satisfiesNodeConstraint(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, _: DebugContext) -> bool:
""" `5.4.1 Semantics <http://shex.io/shex-semantics/#node-constraint-semantics>`_
For a node n and constraint nc, satisfies2(n, nc) if and only if for every nodeKind, datatype, xsFacet and
values constr... | python | def satisfiesNodeConstraint(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, _: DebugContext) -> bool:
""" `5.4.1 Semantics <http://shex.io/shex-semantics/#node-constraint-semantics>`_
For a node n and constraint nc, satisfies2(n, nc) if and only if for every nodeKind, datatype, xsFacet and
values constr... | [
"def",
"satisfiesNodeConstraint",
"(",
"cntxt",
":",
"Context",
",",
"n",
":",
"Node",
",",
"nc",
":",
"ShExJ",
".",
"NodeConstraint",
",",
"_",
":",
"DebugContext",
")",
"->",
"bool",
":",
"return",
"nodeSatisfiesNodeKind",
"(",
"cntxt",
",",
"n",
",",
... | `5.4.1 Semantics <http://shex.io/shex-semantics/#node-constraint-semantics>`_
For a node n and constraint nc, satisfies2(n, nc) if and only if for every nodeKind, datatype, xsFacet and
values constraint value v present in nc nodeSatisfies(n, v). The following sections define nodeSatisfies for
each of these... | [
"5",
".",
"4",
".",
"1",
"Semantics",
"<http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#node",
"-",
"constraint",
"-",
"semantics",
">",
"_"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L20-L29 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_4_node_constraints.py | nodeSatisfiesNodeKind | def nodeSatisfiesNodeKind(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, c: DebugContext) -> bool:
""" `5.4.2 Node Kind Constraints <http://shex.io/shex-semantics/#nodeKind>`_
For a node n and constraint value v, nodeSatisfies(n, v) if:
* v = "iri" and n is an IRI.
* v = "bnode" and n is a... | python | def nodeSatisfiesNodeKind(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, c: DebugContext) -> bool:
""" `5.4.2 Node Kind Constraints <http://shex.io/shex-semantics/#nodeKind>`_
For a node n and constraint value v, nodeSatisfies(n, v) if:
* v = "iri" and n is an IRI.
* v = "bnode" and n is a... | [
"def",
"nodeSatisfiesNodeKind",
"(",
"cntxt",
":",
"Context",
",",
"n",
":",
"Node",
",",
"nc",
":",
"ShExJ",
".",
"NodeConstraint",
",",
"c",
":",
"DebugContext",
")",
"->",
"bool",
":",
"if",
"c",
".",
"debug",
"and",
"nc",
".",
"nodeKind",
"is",
"... | `5.4.2 Node Kind Constraints <http://shex.io/shex-semantics/#nodeKind>`_
For a node n and constraint value v, nodeSatisfies(n, v) if:
* v = "iri" and n is an IRI.
* v = "bnode" and n is a blank node.
* v = "literal" and n is a Literal.
* v = "nonliteral" and n is an IRI or blank no... | [
"5",
".",
"4",
".",
"2",
"Node",
"Kind",
"Constraints",
"<http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#nodeKind",
">",
"_"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L33-L52 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_4_node_constraints.py | nodeSatisfiesDataType | def nodeSatisfiesDataType(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, c: DebugContext) -> bool:
""" `5.4.3 Datatype Constraints <http://shex.io/shex-semantics/#datatype>`_
For a node n and constraint value v, nodeSatisfies(n, v) if n is an Literal with the datatype v and, if v is in
the set of SPARQ... | python | def nodeSatisfiesDataType(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, c: DebugContext) -> bool:
""" `5.4.3 Datatype Constraints <http://shex.io/shex-semantics/#datatype>`_
For a node n and constraint value v, nodeSatisfies(n, v) if n is an Literal with the datatype v and, if v is in
the set of SPARQ... | [
"def",
"nodeSatisfiesDataType",
"(",
"cntxt",
":",
"Context",
",",
"n",
":",
"Node",
",",
"nc",
":",
"ShExJ",
".",
"NodeConstraint",
",",
"c",
":",
"DebugContext",
")",
"->",
"bool",
":",
"if",
"nc",
".",
"datatype",
"is",
"None",
":",
"return",
"True"... | `5.4.3 Datatype Constraints <http://shex.io/shex-semantics/#datatype>`_
For a node n and constraint value v, nodeSatisfies(n, v) if n is an Literal with the datatype v and, if v is in
the set of SPARQL operand data types[sparql11-query], an XML schema string with a value of the lexical form of
n can be cas... | [
"5",
".",
"4",
".",
"3",
"Datatype",
"Constraints",
"<http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#datatype",
">",
"_"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L56-L78 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_4_node_constraints.py | nodeSatisfiesStringFacet | def nodeSatisfiesStringFacet(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, _c: DebugContext) -> bool:
""" `5.4.5 XML Schema String Facet Constraints <ttp://shex.io/shex-semantics/#xs-string>`_
String facet constraints apply to the lexical form of the RDF Literals and IRIs and blank node
identifiers ... | python | def nodeSatisfiesStringFacet(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, _c: DebugContext) -> bool:
""" `5.4.5 XML Schema String Facet Constraints <ttp://shex.io/shex-semantics/#xs-string>`_
String facet constraints apply to the lexical form of the RDF Literals and IRIs and blank node
identifiers ... | [
"def",
"nodeSatisfiesStringFacet",
"(",
"cntxt",
":",
"Context",
",",
"n",
":",
"Node",
",",
"nc",
":",
"ShExJ",
".",
"NodeConstraint",
",",
"_c",
":",
"DebugContext",
")",
"->",
"bool",
":",
"# Let lex =",
"#",
"# * if the value n is an RDF Literal, the lexical ... | `5.4.5 XML Schema String Facet Constraints <ttp://shex.io/shex-semantics/#xs-string>`_
String facet constraints apply to the lexical form of the RDF Literals and IRIs and blank node
identifiers (see note below regarding access to blank node identifiers). | [
"5",
".",
"4",
".",
"5",
"XML",
"Schema",
"String",
"Facet",
"Constraints",
"<ttp",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#xs",
"-",
"string",
">",
"_"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L89-L139 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_4_node_constraints.py | nodeSatisfiesNumericFacet | def nodeSatisfiesNumericFacet(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, _c: DebugContext) -> bool:
""" `5.4.5 XML Schema Numeric Facet Constraints <http://shex.io/shex-semantics/#xs-numeric>`_
Numeric facet constraints apply to the numeric value of RDF Literals with datatypes listed in SPARQL 1.1
... | python | def nodeSatisfiesNumericFacet(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, _c: DebugContext) -> bool:
""" `5.4.5 XML Schema Numeric Facet Constraints <http://shex.io/shex-semantics/#xs-numeric>`_
Numeric facet constraints apply to the numeric value of RDF Literals with datatypes listed in SPARQL 1.1
... | [
"def",
"nodeSatisfiesNumericFacet",
"(",
"cntxt",
":",
"Context",
",",
"n",
":",
"Node",
",",
"nc",
":",
"ShExJ",
".",
"NodeConstraint",
",",
"_c",
":",
"DebugContext",
")",
"->",
"bool",
":",
"if",
"nc",
".",
"mininclusive",
"is",
"not",
"None",
"or",
... | `5.4.5 XML Schema Numeric Facet Constraints <http://shex.io/shex-semantics/#xs-numeric>`_
Numeric facet constraints apply to the numeric value of RDF Literals with datatypes listed in SPARQL 1.1
Operand Data Types[sparql11-query]. Numeric constraints on non-numeric values fail. totaldigits and
fractiondigi... | [
"5",
".",
"4",
".",
"5",
"XML",
"Schema",
"Numeric",
"Facet",
"Constraints",
"<http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#xs",
"-",
"numeric",
">",
"_"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L145-L196 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_4_node_constraints.py | nodeSatisfiesValues | def nodeSatisfiesValues(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, _c: DebugContext) -> bool:
""" `5.4.5 Values Constraint <http://shex.io/shex-semantics/#values>`_
For a node n and constraint value v, nodeSatisfies(n, v) if n matches some valueSetValue vsv in v.
"""
if nc.values is None:
... | python | def nodeSatisfiesValues(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, _c: DebugContext) -> bool:
""" `5.4.5 Values Constraint <http://shex.io/shex-semantics/#values>`_
For a node n and constraint value v, nodeSatisfies(n, v) if n matches some valueSetValue vsv in v.
"""
if nc.values is None:
... | [
"def",
"nodeSatisfiesValues",
"(",
"cntxt",
":",
"Context",
",",
"n",
":",
"Node",
",",
"nc",
":",
"ShExJ",
".",
"NodeConstraint",
",",
"_c",
":",
"DebugContext",
")",
"->",
"bool",
":",
"if",
"nc",
".",
"values",
"is",
"None",
":",
"return",
"True",
... | `5.4.5 Values Constraint <http://shex.io/shex-semantics/#values>`_
For a node n and constraint value v, nodeSatisfies(n, v) if n matches some valueSetValue vsv in v. | [
"5",
".",
"4",
".",
"5",
"Values",
"Constraint",
"<http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#values",
">",
"_"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L200-L213 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_4_node_constraints.py | _nodeSatisfiesValue | def _nodeSatisfiesValue(cntxt: Context, n: Node, vsv: ShExJ.valueSetValue) -> bool:
"""
A term matches a valueSetValue if:
* vsv is an objectValue and n = vsv.
* vsv is a Language with langTag lt and n is a language-tagged string with a language tag l and l = lt.
* vsv is a IriStem, Lite... | python | def _nodeSatisfiesValue(cntxt: Context, n: Node, vsv: ShExJ.valueSetValue) -> bool:
"""
A term matches a valueSetValue if:
* vsv is an objectValue and n = vsv.
* vsv is a Language with langTag lt and n is a language-tagged string with a language tag l and l = lt.
* vsv is a IriStem, Lite... | [
"def",
"_nodeSatisfiesValue",
"(",
"cntxt",
":",
"Context",
",",
"n",
":",
"Node",
",",
"vsv",
":",
"ShExJ",
".",
"valueSetValue",
")",
"->",
"bool",
":",
"vsv",
"=",
"map_object_literal",
"(",
"vsv",
")",
"if",
"isinstance_",
"(",
"vsv",
",",
"ShExJ",
... | A term matches a valueSetValue if:
* vsv is an objectValue and n = vsv.
* vsv is a Language with langTag lt and n is a language-tagged string with a language tag l and l = lt.
* vsv is a IriStem, LiteralStem or LanguageStem with stem st and nodeIn(n, st).
* vsv is a IriStemRange, Literal... | [
"A",
"term",
"matches",
"a",
"valueSetValue",
"if",
":",
"*",
"vsv",
"is",
"an",
"objectValue",
"and",
"n",
"=",
"vsv",
".",
"*",
"vsv",
"is",
"a",
"Language",
"with",
"langTag",
"lt",
"and",
"n",
"is",
"a",
"language",
"-",
"tagged",
"string",
"with... | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L216-L269 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_4_node_constraints.py | nodeInIriStem | def nodeInIriStem(_: Context, n: Node, s: ShExJ.IriStem) -> bool:
"""
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`.
The expression `nodeInIriStem(n, s)` is satisfied i... | python | def nodeInIriStem(_: Context, n: Node, s: ShExJ.IriStem) -> bool:
"""
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`.
The expression `nodeInIriStem(n, s)` is satisfied i... | [
"def",
"nodeInIriStem",
"(",
"_",
":",
"Context",
",",
"n",
":",
"Node",
",",
"s",
":",
"ShExJ",
".",
"IriStem",
")",
"->",
"bool",
":",
"return",
"isinstance",
"(",
"s",
",",
"ShExJ",
".",
"Wildcard",
")",
"or",
"(",
"isinstance",
"(",
"n",
",",
... | **nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`.
The expression `nodeInIriStem(n, s)` is satisfied iff:
#) `s` is a :py:class:`ShExJ.WildCard` or
#) `n` is an :py:cl... | [
"**",
"nodeIn",
"**",
":",
"asserts",
"that",
"an",
"RDF",
"node",
"n",
"is",
"equal",
"to",
"an",
"RDF",
"term",
"s",
"or",
"is",
"in",
"a",
"set",
"defined",
"by",
"a",
":",
"py",
":",
"class",
":",
"ShExJ",
".",
"IriStem",
":",
"py",
":",
"c... | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L272-L282 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_4_node_constraints.py | nodeInLiteralStem | def nodeInLiteralStem(_: Context, n: Node, s: ShExJ.LiteralStem) -> bool:
""" http://shex.io/shex-semantics/#values
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`.
T... | python | def nodeInLiteralStem(_: Context, n: Node, s: ShExJ.LiteralStem) -> bool:
""" http://shex.io/shex-semantics/#values
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`.
T... | [
"def",
"nodeInLiteralStem",
"(",
"_",
":",
"Context",
",",
"n",
":",
"Node",
",",
"s",
":",
"ShExJ",
".",
"LiteralStem",
")",
"->",
"bool",
":",
"return",
"isinstance",
"(",
"s",
",",
"ShExJ",
".",
"Wildcard",
")",
"or",
"(",
"isinstance",
"(",
"n",
... | http://shex.io/shex-semantics/#values
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`.
The expression `nodeInLiteralStem(n, s)` is satisfied iff:
#) `s` is a :py... | [
"http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#values"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L285-L296 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_4_node_constraints.py | nodeInLanguageStem | def nodeInLanguageStem(_: Context, n: Node, s: ShExJ.LanguageStem) -> bool:
""" http://shex.io/shex-semantics/#values
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`.
... | python | def nodeInLanguageStem(_: Context, n: Node, s: ShExJ.LanguageStem) -> bool:
""" http://shex.io/shex-semantics/#values
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`.
... | [
"def",
"nodeInLanguageStem",
"(",
"_",
":",
"Context",
",",
"n",
":",
"Node",
",",
"s",
":",
"ShExJ",
".",
"LanguageStem",
")",
"->",
"bool",
":",
"return",
"isinstance",
"(",
"s",
",",
"ShExJ",
".",
"Wildcard",
")",
"or",
"(",
"isinstance",
"(",
"n"... | http://shex.io/shex-semantics/#values
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`.
The expression `nodeInLanguageStem(n, s)` is satisfied iff:
#) `s` is a :p... | [
"http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#values"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L299-L310 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_4_node_constraints.py | nodeInBnodeStem | def nodeInBnodeStem(_cntxt: Context, _n: Node, _s: Union[str, ShExJ.Wildcard]) -> bool:
""" http://shex.io/shex-semantics/#values
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageSte... | python | def nodeInBnodeStem(_cntxt: Context, _n: Node, _s: Union[str, ShExJ.Wildcard]) -> bool:
""" http://shex.io/shex-semantics/#values
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageSte... | [
"def",
"nodeInBnodeStem",
"(",
"_cntxt",
":",
"Context",
",",
"_n",
":",
"Node",
",",
"_s",
":",
"Union",
"[",
"str",
",",
"ShExJ",
".",
"Wildcard",
"]",
")",
"->",
"bool",
":",
"# TODO: resolve issue #79 to figure out how to do this",
"return",
"False"
] | http://shex.io/shex-semantics/#values
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a
:py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`.
The expression `nodeInBnodeStem(n, s)` is satisfied iff:
#) `s` is a :py:c... | [
"http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#values"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L313-L325 |
stuaxo/vext | vext/env/__init__.py | run_in_syspy | def run_in_syspy(f):
"""
Decorator to run a function in the system python
:param f:
:return:
"""
fname = f.__name__
code_lines = inspect.getsource(f).splitlines()
code = dedent("\n".join(code_lines[1:])) # strip this decorator
# add call to the function and print it's result
... | python | def run_in_syspy(f):
"""
Decorator to run a function in the system python
:param f:
:return:
"""
fname = f.__name__
code_lines = inspect.getsource(f).splitlines()
code = dedent("\n".join(code_lines[1:])) # strip this decorator
# add call to the function and print it's result
... | [
"def",
"run_in_syspy",
"(",
"f",
")",
":",
"fname",
"=",
"f",
".",
"__name__",
"code_lines",
"=",
"inspect",
".",
"getsource",
"(",
"f",
")",
".",
"splitlines",
"(",
")",
"code",
"=",
"dedent",
"(",
"\"\\n\"",
".",
"join",
"(",
"code_lines",
"[",
"1"... | Decorator to run a function in the system python
:param f:
:return: | [
"Decorator",
"to",
"run",
"a",
"function",
"in",
"the",
"system",
"python"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/env/__init__.py#L16-L46 |
stuaxo/vext | vext/env/__init__.py | in_venv | def in_venv():
"""
:return: True if in running from a virtualenv
Has to detect the case where the python binary is run
directly, so VIRTUAL_ENV may not be set
"""
global _in_venv
if _in_venv is not None:
return _in_venv
if not (os.path.isfile(ORIG_PREFIX_TXT) or os.path.isfile(... | python | def in_venv():
"""
:return: True if in running from a virtualenv
Has to detect the case where the python binary is run
directly, so VIRTUAL_ENV may not be set
"""
global _in_venv
if _in_venv is not None:
return _in_venv
if not (os.path.isfile(ORIG_PREFIX_TXT) or os.path.isfile(... | [
"def",
"in_venv",
"(",
")",
":",
"global",
"_in_venv",
"if",
"_in_venv",
"is",
"not",
"None",
":",
"return",
"_in_venv",
"if",
"not",
"(",
"os",
".",
"path",
".",
"isfile",
"(",
"ORIG_PREFIX_TXT",
")",
"or",
"os",
".",
"path",
".",
"isfile",
"(",
"PY... | :return: True if in running from a virtualenv
Has to detect the case where the python binary is run
directly, so VIRTUAL_ENV may not be set | [
":",
"return",
":",
"True",
"if",
"in",
"running",
"from",
"a",
"virtualenv"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/env/__init__.py#L49-L81 |
stuaxo/vext | vext/env/__init__.py | getsyssitepackages | def getsyssitepackages():
"""
:return: list of site-packages from system python
"""
global _syssitepackages
if not _syssitepackages:
if not in_venv():
_syssitepackages = get_python_lib()
return _syssitepackages
@run_in_syspy
def run(*args):
... | python | def getsyssitepackages():
"""
:return: list of site-packages from system python
"""
global _syssitepackages
if not _syssitepackages:
if not in_venv():
_syssitepackages = get_python_lib()
return _syssitepackages
@run_in_syspy
def run(*args):
... | [
"def",
"getsyssitepackages",
"(",
")",
":",
"global",
"_syssitepackages",
"if",
"not",
"_syssitepackages",
":",
"if",
"not",
"in_venv",
"(",
")",
":",
"_syssitepackages",
"=",
"get_python_lib",
"(",
")",
"return",
"_syssitepackages",
"@",
"run_in_syspy",
"def",
... | :return: list of site-packages from system python | [
":",
"return",
":",
"list",
"of",
"site",
"-",
"packages",
"from",
"system",
"python"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/env/__init__.py#L84-L102 |
stuaxo/vext | vext/env/__init__.py | findsyspy | def findsyspy():
"""
:return: system python executable
"""
if not in_venv():
return sys.executable
python = basename(realpath(sys.executable))
prefix = None
if HAS_ORIG_PREFIX_TXT:
with open(ORIG_PREFIX_TXT) as op:
prefix = op.read()
elif HAS_PY_VENV_CFG:
... | python | def findsyspy():
"""
:return: system python executable
"""
if not in_venv():
return sys.executable
python = basename(realpath(sys.executable))
prefix = None
if HAS_ORIG_PREFIX_TXT:
with open(ORIG_PREFIX_TXT) as op:
prefix = op.read()
elif HAS_PY_VENV_CFG:
... | [
"def",
"findsyspy",
"(",
")",
":",
"if",
"not",
"in_venv",
"(",
")",
":",
"return",
"sys",
".",
"executable",
"python",
"=",
"basename",
"(",
"realpath",
"(",
"sys",
".",
"executable",
")",
")",
"prefix",
"=",
"None",
"if",
"HAS_ORIG_PREFIX_TXT",
":",
... | :return: system python executable | [
":",
"return",
":",
"system",
"python",
"executable"
] | train | https://github.com/stuaxo/vext/blob/fa98a21ecfbbc1c3d1b84085d69ec42defdd2f69/vext/env/__init__.py#L105-L131 |
jaysonsantos/python-binary-memcached | bmemcached/client/distributed.py | DistributedClient.delete | def delete(self, key, cas=0):
"""
Delete a key/value from server. If key does not exist, it returns True.
:param key: Key's name to be deleted
:param cas: CAS of the key
:return: True in case o success and False in case of failure.
"""
server = self._get_server(k... | python | def delete(self, key, cas=0):
"""
Delete a key/value from server. If key does not exist, it returns True.
:param key: Key's name to be deleted
:param cas: CAS of the key
:return: True in case o success and False in case of failure.
"""
server = self._get_server(k... | [
"def",
"delete",
"(",
"self",
",",
"key",
",",
"cas",
"=",
"0",
")",
":",
"server",
"=",
"self",
".",
"_get_server",
"(",
"key",
")",
"return",
"server",
".",
"delete",
"(",
"key",
",",
"cas",
")"
] | Delete a key/value from server. If key does not exist, it returns True.
:param key: Key's name to be deleted
:param cas: CAS of the key
:return: True in case o success and False in case of failure. | [
"Delete",
"a",
"key",
"/",
"value",
"from",
"server",
".",
"If",
"key",
"does",
"not",
"exist",
"it",
"returns",
"True",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/distributed.py#L23-L32 |
jaysonsantos/python-binary-memcached | bmemcached/client/distributed.py | DistributedClient.set | def set(self, key, value, time=0, compress_level=-1):
"""
Set a value for a key on server.
:param key: Key's name
:type key: str
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds that your key will expire.
:typ... | python | def set(self, key, value, time=0, compress_level=-1):
"""
Set a value for a key on server.
:param key: Key's name
:type key: str
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds that your key will expire.
:typ... | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
",",
"time",
"=",
"0",
",",
"compress_level",
"=",
"-",
"1",
")",
":",
"server",
"=",
"self",
".",
"_get_server",
"(",
"key",
")",
"return",
"server",
".",
"set",
"(",
"key",
",",
"value",
",",... | Set a value for a key on server.
:param key: Key's name
:type key: str
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds that your key will expire.
:type time: int
:param compress_level: How much to compress.
... | [
"Set",
"a",
"value",
"for",
"a",
"key",
"on",
"server",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/distributed.py#L41-L59 |
jaysonsantos/python-binary-memcached | bmemcached/client/distributed.py | DistributedClient.set_multi | def set_multi(self, mappings, time=0, compress_level=-1):
"""
Set multiple keys with it's values on server.
:param mappings: A dict with keys/values
:type mappings: dict
:param time: Time in seconds that your key will expire.
:type time: int
:param compress_level... | python | def set_multi(self, mappings, time=0, compress_level=-1):
"""
Set multiple keys with it's values on server.
:param mappings: A dict with keys/values
:type mappings: dict
:param time: Time in seconds that your key will expire.
:type time: int
:param compress_level... | [
"def",
"set_multi",
"(",
"self",
",",
"mappings",
",",
"time",
"=",
"0",
",",
"compress_level",
"=",
"-",
"1",
")",
":",
"returns",
"=",
"[",
"]",
"if",
"not",
"mappings",
":",
"return",
"False",
"server_mappings",
"=",
"defaultdict",
"(",
"dict",
")",... | Set multiple keys with it's values on server.
:param mappings: A dict with keys/values
:type mappings: dict
:param time: Time in seconds that your key will expire.
:type time: int
:param compress_level: How much to compress.
0 = no compression, 1 = fastest, 9 = slowe... | [
"Set",
"multiple",
"keys",
"with",
"it",
"s",
"values",
"on",
"server",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/distributed.py#L61-L86 |
jaysonsantos/python-binary-memcached | bmemcached/client/distributed.py | DistributedClient.add | def add(self, key, value, time=0, compress_level=-1):
"""
Add a key/value to server ony if it does not exist.
:param key: Key's name
:type key: six.string_types
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds that yo... | python | def add(self, key, value, time=0, compress_level=-1):
"""
Add a key/value to server ony if it does not exist.
:param key: Key's name
:type key: six.string_types
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds that yo... | [
"def",
"add",
"(",
"self",
",",
"key",
",",
"value",
",",
"time",
"=",
"0",
",",
"compress_level",
"=",
"-",
"1",
")",
":",
"server",
"=",
"self",
".",
"_get_server",
"(",
"key",
")",
"return",
"server",
".",
"add",
"(",
"key",
",",
"value",
",",... | Add a key/value to server ony if it does not exist.
:param key: Key's name
:type key: six.string_types
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds that your key will expire.
:type time: int
:param compress_level:... | [
"Add",
"a",
"key",
"/",
"value",
"to",
"server",
"ony",
"if",
"it",
"does",
"not",
"exist",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/distributed.py#L88-L106 |
jaysonsantos/python-binary-memcached | bmemcached/client/distributed.py | DistributedClient.replace | def replace(self, key, value, time=0, compress_level=-1):
"""
Replace a key/value to server ony if it does exist.
:param key: Key's name
:type key: six.string_types
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds tha... | python | def replace(self, key, value, time=0, compress_level=-1):
"""
Replace a key/value to server ony if it does exist.
:param key: Key's name
:type key: six.string_types
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds tha... | [
"def",
"replace",
"(",
"self",
",",
"key",
",",
"value",
",",
"time",
"=",
"0",
",",
"compress_level",
"=",
"-",
"1",
")",
":",
"server",
"=",
"self",
".",
"_get_server",
"(",
"key",
")",
"return",
"server",
".",
"replace",
"(",
"key",
",",
"value"... | Replace a key/value to server ony if it does exist.
:param key: Key's name
:type key: six.string_types
:param value: A value to be stored on server.
:type value: object
:param time: Time in seconds that your key will expire.
:type time: int
:param compress_level:... | [
"Replace",
"a",
"key",
"/",
"value",
"to",
"server",
"ony",
"if",
"it",
"does",
"exist",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/distributed.py#L108-L126 |
jaysonsantos/python-binary-memcached | bmemcached/client/distributed.py | DistributedClient.get_multi | def get_multi(self, keys, get_cas=False):
"""
Get multiple keys from server.
:param keys: A list of keys to from server.
:type keys: list
:param get_cas: If get_cas is true, each value is (data, cas), with each result's CAS value.
:type get_cas: boolean
:return: ... | python | def get_multi(self, keys, get_cas=False):
"""
Get multiple keys from server.
:param keys: A list of keys to from server.
:type keys: list
:param get_cas: If get_cas is true, each value is (data, cas), with each result's CAS value.
:type get_cas: boolean
:return: ... | [
"def",
"get_multi",
"(",
"self",
",",
"keys",
",",
"get_cas",
"=",
"False",
")",
":",
"servers",
"=",
"defaultdict",
"(",
"list",
")",
"d",
"=",
"{",
"}",
"for",
"key",
"in",
"keys",
":",
"server_key",
"=",
"self",
".",
"_get_server",
"(",
"key",
"... | Get multiple keys from server.
:param keys: A list of keys to from server.
:type keys: list
:param get_cas: If get_cas is true, each value is (data, cas), with each result's CAS value.
:type get_cas: boolean
:return: A dict with all requested keys.
:rtype: dict | [
"Get",
"multiple",
"keys",
"from",
"server",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/distributed.py#L149-L172 |
jaysonsantos/python-binary-memcached | bmemcached/client/distributed.py | DistributedClient.cas | def cas(self, key, value, cas, time=0, compress_level=-1):
"""
Set a value for a key on server if its CAS value matches cas.
:param key: Key's name
:type key: six.string_types
:param value: A value to be stored on server.
:type value: object
:param cas: The CAS v... | python | def cas(self, key, value, cas, time=0, compress_level=-1):
"""
Set a value for a key on server if its CAS value matches cas.
:param key: Key's name
:type key: six.string_types
:param value: A value to be stored on server.
:type value: object
:param cas: The CAS v... | [
"def",
"cas",
"(",
"self",
",",
"key",
",",
"value",
",",
"cas",
",",
"time",
"=",
"0",
",",
"compress_level",
"=",
"-",
"1",
")",
":",
"server",
"=",
"self",
".",
"_get_server",
"(",
"key",
")",
"return",
"server",
".",
"cas",
"(",
"key",
",",
... | Set a value for a key on server if its CAS value matches cas.
:param key: Key's name
:type key: six.string_types
:param value: A value to be stored on server.
:type value: object
:param cas: The CAS value previously obtained from a call to get*.
:type cas: int
:p... | [
"Set",
"a",
"value",
"for",
"a",
"key",
"on",
"server",
"if",
"its",
"CAS",
"value",
"matches",
"cas",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/distributed.py#L178-L198 |
jaysonsantos/python-binary-memcached | bmemcached/client/distributed.py | DistributedClient.incr | def incr(self, key, value):
"""
Increment a key, if it exists, returns it's actual value, if it don't, return 0.
:param key: Key's name
:type key: six.string_types
:param value: Number to be incremented
:type value: int
:return: Actual value of the key on server
... | python | def incr(self, key, value):
"""
Increment a key, if it exists, returns it's actual value, if it don't, return 0.
:param key: Key's name
:type key: six.string_types
:param value: Number to be incremented
:type value: int
:return: Actual value of the key on server
... | [
"def",
"incr",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"server",
"=",
"self",
".",
"_get_server",
"(",
"key",
")",
"return",
"server",
".",
"incr",
"(",
"key",
",",
"value",
")"
] | Increment a key, if it exists, returns it's actual value, if it don't, return 0.
:param key: Key's name
:type key: six.string_types
:param value: Number to be incremented
:type value: int
:return: Actual value of the key on server
:rtype: int | [
"Increment",
"a",
"key",
"if",
"it",
"exists",
"returns",
"it",
"s",
"actual",
"value",
"if",
"it",
"don",
"t",
"return",
"0",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/distributed.py#L200-L212 |
jaysonsantos/python-binary-memcached | bmemcached/client/distributed.py | DistributedClient.decr | def decr(self, key, value):
"""
Decrement a key, if it exists, returns it's actual value, if it don't, return 0.
Minimum value of decrement return is 0.
:param key: Key's name
:type key: six.string_types
:param value: Number to be decremented
:type value: int
... | python | def decr(self, key, value):
"""
Decrement a key, if it exists, returns it's actual value, if it don't, return 0.
Minimum value of decrement return is 0.
:param key: Key's name
:type key: six.string_types
:param value: Number to be decremented
:type value: int
... | [
"def",
"decr",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"server",
"=",
"self",
".",
"_get_server",
"(",
"key",
")",
"return",
"server",
".",
"decr",
"(",
"key",
",",
"value",
")"
] | Decrement a key, if it exists, returns it's actual value, if it don't, return 0.
Minimum value of decrement return is 0.
:param key: Key's name
:type key: six.string_types
:param value: Number to be decremented
:type value: int
:return: Actual value of the key on server
... | [
"Decrement",
"a",
"key",
"if",
"it",
"exists",
"returns",
"it",
"s",
"actual",
"value",
"if",
"it",
"don",
"t",
"return",
"0",
".",
"Minimum",
"value",
"of",
"decrement",
"return",
"is",
"0",
"."
] | train | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/client/distributed.py#L214-L227 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py | satisfiesShape | def satisfiesShape(cntxt: Context, n: Node, S: ShExJ.Shape, c: DebugContext) -> bool:
""" `5.5.2 Semantics <http://shex.io/shex-semantics/#triple-expressions-semantics>`_
For a node `n`, shape `S`, graph `G`, and shapeMap `m`, `satisfies(n, S, G, m)` if and only if:
* `neigh(G, n)` can be partitioned into... | python | def satisfiesShape(cntxt: Context, n: Node, S: ShExJ.Shape, c: DebugContext) -> bool:
""" `5.5.2 Semantics <http://shex.io/shex-semantics/#triple-expressions-semantics>`_
For a node `n`, shape `S`, graph `G`, and shapeMap `m`, `satisfies(n, S, G, m)` if and only if:
* `neigh(G, n)` can be partitioned into... | [
"def",
"satisfiesShape",
"(",
"cntxt",
":",
"Context",
",",
"n",
":",
"Node",
",",
"S",
":",
"ShExJ",
".",
"Shape",
",",
"c",
":",
"DebugContext",
")",
"->",
"bool",
":",
"# Recursion detection. If start_evaluating returns a boolean value, this is the assumed result ... | `5.5.2 Semantics <http://shex.io/shex-semantics/#triple-expressions-semantics>`_
For a node `n`, shape `S`, graph `G`, and shapeMap `m`, `satisfies(n, S, G, m)` if and only if:
* `neigh(G, n)` can be partitioned into two sets matched and remainder such that
`matches(matched, expression, m)`. If expressi... | [
"5",
".",
"5",
".",
"2",
"Semantics",
"<http",
":",
"//",
"shex",
".",
"io",
"/",
"shex",
"-",
"semantics",
"/",
"#triple",
"-",
"expressions",
"-",
"semantics",
">",
"_"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py#L23-L107 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py | valid_remainder | def valid_remainder(cntxt: Context, n: Node, matchables: RDFGraph, S: ShExJ.Shape) -> bool:
"""
Let **outs** be the arcsOut in remainder: `outs = remainder ∩ arcsOut(G, n)`.
Let **matchables** be the triples in outs whose predicate appears in a TripleConstraint in `expression`. If
`expression` is absen... | python | def valid_remainder(cntxt: Context, n: Node, matchables: RDFGraph, S: ShExJ.Shape) -> bool:
"""
Let **outs** be the arcsOut in remainder: `outs = remainder ∩ arcsOut(G, n)`.
Let **matchables** be the triples in outs whose predicate appears in a TripleConstraint in `expression`. If
`expression` is absen... | [
"def",
"valid_remainder",
"(",
"cntxt",
":",
"Context",
",",
"n",
":",
"Node",
",",
"matchables",
":",
"RDFGraph",
",",
"S",
":",
"ShExJ",
".",
"Shape",
")",
"->",
"bool",
":",
"# TODO: Update this and satisfies to address the new algorithm",
"# Let **outs** be the ... | Let **outs** be the arcsOut in remainder: `outs = remainder ∩ arcsOut(G, n)`.
Let **matchables** be the triples in outs whose predicate appears in a TripleConstraint in `expression`. If
`expression` is absent, matchables = Ø (the empty set).
* There is no triple in **matchables** which matches a TripleCon... | [
"Let",
"**",
"outs",
"**",
"be",
"the",
"arcsOut",
"in",
"remainder",
":",
"outs",
"=",
"remainder",
"∩",
"arcsOut",
"(",
"G",
"n",
")",
"."
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py#L110-L153 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py | matches | def matches(cntxt: Context, T: RDFGraph, expr: ShExJ.tripleExpr) -> bool:
"""
**matches**: asserts that a triple expression is matched by a set of triples that come from the neighbourhood of a
node in an RDF graph. The expression `matches(T, expr, m)` indicates that a set of triples `T` can satisfy these
... | python | def matches(cntxt: Context, T: RDFGraph, expr: ShExJ.tripleExpr) -> bool:
"""
**matches**: asserts that a triple expression is matched by a set of triples that come from the neighbourhood of a
node in an RDF graph. The expression `matches(T, expr, m)` indicates that a set of triples `T` can satisfy these
... | [
"def",
"matches",
"(",
"cntxt",
":",
"Context",
",",
"T",
":",
"RDFGraph",
",",
"expr",
":",
"ShExJ",
".",
"tripleExpr",
")",
"->",
"bool",
":",
"if",
"isinstance_",
"(",
"expr",
",",
"ShExJ",
".",
"tripleExprLabel",
")",
":",
"return",
"matchesExpr",
... | **matches**: asserts that a triple expression is matched by a set of triples that come from the neighbourhood of a
node in an RDF graph. The expression `matches(T, expr, m)` indicates that a set of triples `T` can satisfy these
rules:
* expr has semActs and `matches(T, expr, m)` by the remaining rules in t... | [
"**",
"matches",
"**",
":",
"asserts",
"that",
"a",
"triple",
"expression",
"is",
"matched",
"by",
"a",
"set",
"of",
"triples",
"that",
"come",
"from",
"the",
"neighbourhood",
"of",
"a",
"node",
"in",
"an",
"RDF",
"graph",
".",
"The",
"expression",
"matc... | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py#L156-L181 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py | matchesCardinality | def matchesCardinality(cntxt: Context, T: RDFGraph, expr: Union[ShExJ.tripleExpr, ShExJ.tripleExprLabel],
c: DebugContext) -> bool:
""" Evaluate cardinality expression
expr has a cardinality of min and/or max not equal to 1, where a max of -1 is treated as unbounded, and
T can be par... | python | def matchesCardinality(cntxt: Context, T: RDFGraph, expr: Union[ShExJ.tripleExpr, ShExJ.tripleExprLabel],
c: DebugContext) -> bool:
""" Evaluate cardinality expression
expr has a cardinality of min and/or max not equal to 1, where a max of -1 is treated as unbounded, and
T can be par... | [
"def",
"matchesCardinality",
"(",
"cntxt",
":",
"Context",
",",
"T",
":",
"RDFGraph",
",",
"expr",
":",
"Union",
"[",
"ShExJ",
".",
"tripleExpr",
",",
"ShExJ",
".",
"tripleExprLabel",
"]",
",",
"c",
":",
"DebugContext",
")",
"->",
"bool",
":",
"# TODO: C... | Evaluate cardinality expression
expr has a cardinality of min and/or max not equal to 1, where a max of -1 is treated as unbounded, and
T can be partitioned into k subsets T1, T2,…Tk such that min ≤ k ≤ max and for each Tn,
matches(Tn, expr, m) by the remaining rules in this list. | [
"Evaluate",
"cardinality",
"expression"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py#L196-L234 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py | matchesExpr | def matchesExpr(cntxt: Context, T: RDFGraph, expr: ShExJ.tripleExpr, _: DebugContext) -> bool:
""" Evaluate the expression
"""
if isinstance(expr, ShExJ.OneOf):
return matchesOneOf(cntxt, T, expr)
elif isinstance(expr, ShExJ.EachOf):
return matchesEachOf(cntxt, T, expr)
elif isinst... | python | def matchesExpr(cntxt: Context, T: RDFGraph, expr: ShExJ.tripleExpr, _: DebugContext) -> bool:
""" Evaluate the expression
"""
if isinstance(expr, ShExJ.OneOf):
return matchesOneOf(cntxt, T, expr)
elif isinstance(expr, ShExJ.EachOf):
return matchesEachOf(cntxt, T, expr)
elif isinst... | [
"def",
"matchesExpr",
"(",
"cntxt",
":",
"Context",
",",
"T",
":",
"RDFGraph",
",",
"expr",
":",
"ShExJ",
".",
"tripleExpr",
",",
"_",
":",
"DebugContext",
")",
"->",
"bool",
":",
"if",
"isinstance",
"(",
"expr",
",",
"ShExJ",
".",
"OneOf",
")",
":",... | Evaluate the expression | [
"Evaluate",
"the",
"expression"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py#L257-L271 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py | matchesOneOf | def matchesOneOf(cntxt: Context, T: RDFGraph, expr: ShExJ.OneOf, _: DebugContext) -> bool:
"""
expr is a OneOf and there is some shape expression se2 in shapeExprs such that a matches(T, se2, m).
"""
return any(matches(cntxt, T, e) for e in expr.expressions) | python | def matchesOneOf(cntxt: Context, T: RDFGraph, expr: ShExJ.OneOf, _: DebugContext) -> bool:
"""
expr is a OneOf and there is some shape expression se2 in shapeExprs such that a matches(T, se2, m).
"""
return any(matches(cntxt, T, e) for e in expr.expressions) | [
"def",
"matchesOneOf",
"(",
"cntxt",
":",
"Context",
",",
"T",
":",
"RDFGraph",
",",
"expr",
":",
"ShExJ",
".",
"OneOf",
",",
"_",
":",
"DebugContext",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"matches",
"(",
"cntxt",
",",
"T",
",",
"e",
")",
... | expr is a OneOf and there is some shape expression se2 in shapeExprs such that a matches(T, se2, m). | [
"expr",
"is",
"a",
"OneOf",
"and",
"there",
"is",
"some",
"shape",
"expression",
"se2",
"in",
"shapeExprs",
"such",
"that",
"a",
"matches",
"(",
"T",
"se2",
"m",
")",
"."
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py#L275-L279 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py | matchesEachOf | def matchesEachOf(cntxt: Context, T: RDFGraph, expr: ShExJ.EachOf, _: DebugContext) -> bool:
""" expr is an EachOf and there is some partition of T into T1, T2,… such that for every expression
expr1, expr2,… in shapeExprs, matches(Tn, exprn, m).
"""
return EachOfEvaluator(cntxt, T, expr).evaluate(cnt... | python | def matchesEachOf(cntxt: Context, T: RDFGraph, expr: ShExJ.EachOf, _: DebugContext) -> bool:
""" expr is an EachOf and there is some partition of T into T1, T2,… such that for every expression
expr1, expr2,… in shapeExprs, matches(Tn, exprn, m).
"""
return EachOfEvaluator(cntxt, T, expr).evaluate(cnt... | [
"def",
"matchesEachOf",
"(",
"cntxt",
":",
"Context",
",",
"T",
":",
"RDFGraph",
",",
"expr",
":",
"ShExJ",
".",
"EachOf",
",",
"_",
":",
"DebugContext",
")",
"->",
"bool",
":",
"return",
"EachOfEvaluator",
"(",
"cntxt",
",",
"T",
",",
"expr",
")",
"... | expr is an EachOf and there is some partition of T into T1, T2,… such that for every expression
expr1, expr2,… in shapeExprs, matches(Tn, exprn, m). | [
"expr",
"is",
"an",
"EachOf",
"and",
"there",
"is",
"some",
"partition",
"of",
"T",
"into",
"T1",
"T2",
"…",
"such",
"that",
"for",
"every",
"expression",
"expr1",
"expr2",
"…",
"in",
"shapeExprs",
"matches",
"(",
"Tn",
"exprn",
"m",
")",
"."
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py#L283-L288 |
hsolbrig/PyShEx | pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py | matchesTripleConstraint | def matchesTripleConstraint(cntxt: Context, t: RDFTriple, expr: ShExJ.TripleConstraint, c: DebugContext) -> bool:
"""
expr is a TripleConstraint and:
* t is a triple
* t's predicate equals expr's predicate.
Let value be t's subject if inverse is true, else t's object.
* if inverse is true, t ... | python | def matchesTripleConstraint(cntxt: Context, t: RDFTriple, expr: ShExJ.TripleConstraint, c: DebugContext) -> bool:
"""
expr is a TripleConstraint and:
* t is a triple
* t's predicate equals expr's predicate.
Let value be t's subject if inverse is true, else t's object.
* if inverse is true, t ... | [
"def",
"matchesTripleConstraint",
"(",
"cntxt",
":",
"Context",
",",
"t",
":",
"RDFTriple",
",",
"expr",
":",
"ShExJ",
".",
"TripleConstraint",
",",
"c",
":",
"DebugContext",
")",
"->",
"bool",
":",
"from",
"pyshex",
".",
"shape_expressions_language",
".",
"... | expr is a TripleConstraint and:
* t is a triple
* t's predicate equals expr's predicate.
Let value be t's subject if inverse is true, else t's object.
* if inverse is true, t is in arcsIn, else t is in arcsOut. | [
"expr",
"is",
"a",
"TripleConstraint",
"and",
":"
] | train | https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_5_shapes_and_triple_expressions.py#L292-L313 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.