repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
Pylons/hupper
src/hupper/worker.py
iter_module_paths
def iter_module_paths(modules=None): """ Yield paths of all imported modules.""" modules = modules or list(sys.modules.values()) for module in modules: try: filename = module.__file__ except (AttributeError, ImportError): # pragma: no cover continue if filena...
python
def iter_module_paths(modules=None): """ Yield paths of all imported modules.""" modules = modules or list(sys.modules.values()) for module in modules: try: filename = module.__file__ except (AttributeError, ImportError): # pragma: no cover continue if filena...
[ "def", "iter_module_paths", "(", "modules", "=", "None", ")", ":", "modules", "=", "modules", "or", "list", "(", "sys", ".", "modules", ".", "values", "(", ")", ")", "for", "module", "in", "modules", ":", "try", ":", "filename", "=", "module", ".", "...
Yield paths of all imported modules.
[ "Yield", "paths", "of", "all", "imported", "modules", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/worker.py#L97-L108
train
Pylons/hupper
src/hupper/worker.py
WatchSysModules.update_paths
def update_paths(self): """ Check sys.modules for paths to add to our path set.""" new_paths = [] with self.lock: for path in expand_source_paths(iter_module_paths()): if path not in self.paths: self.paths.add(path) new_paths.ap...
python
def update_paths(self): """ Check sys.modules for paths to add to our path set.""" new_paths = [] with self.lock: for path in expand_source_paths(iter_module_paths()): if path not in self.paths: self.paths.add(path) new_paths.ap...
[ "def", "update_paths", "(", "self", ")", ":", "new_paths", "=", "[", "]", "with", "self", ".", "lock", ":", "for", "path", "in", "expand_source_paths", "(", "iter_module_paths", "(", ")", ")", ":", "if", "path", "not", "in", "self", ".", "paths", ":", ...
Check sys.modules for paths to add to our path set.
[ "Check", "sys", ".", "modules", "for", "paths", "to", "add", "to", "our", "path", "set", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/worker.py#L39-L48
train
Pylons/hupper
src/hupper/worker.py
WatchSysModules.search_traceback
def search_traceback(self, tb): """ Inspect a traceback for new paths to add to our path set.""" new_paths = [] with self.lock: for filename, line, funcname, txt in traceback.extract_tb(tb): path = os.path.abspath(filename) if path not in self.paths: ...
python
def search_traceback(self, tb): """ Inspect a traceback for new paths to add to our path set.""" new_paths = [] with self.lock: for filename, line, funcname, txt in traceback.extract_tb(tb): path = os.path.abspath(filename) if path not in self.paths: ...
[ "def", "search_traceback", "(", "self", ",", "tb", ")", ":", "new_paths", "=", "[", "]", "with", "self", ".", "lock", ":", "for", "filename", ",", "line", ",", "funcname", ",", "txt", "in", "traceback", ".", "extract_tb", "(", "tb", ")", ":", "path",...
Inspect a traceback for new paths to add to our path set.
[ "Inspect", "a", "traceback", "for", "new", "paths", "to", "add", "to", "our", "path", "set", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/worker.py#L50-L60
train
Pylons/hupper
src/hupper/ipc.py
args_from_interpreter_flags
def args_from_interpreter_flags(): """ Return a list of command-line arguments reproducing the current settings in sys.flags and sys.warnoptions. """ flag_opt_map = { 'debug': 'd', 'dont_write_bytecode': 'B', 'no_user_site': 's', 'no_site': 'S', 'ignore_envir...
python
def args_from_interpreter_flags(): """ Return a list of command-line arguments reproducing the current settings in sys.flags and sys.warnoptions. """ flag_opt_map = { 'debug': 'd', 'dont_write_bytecode': 'B', 'no_user_site': 's', 'no_site': 'S', 'ignore_envir...
[ "def", "args_from_interpreter_flags", "(", ")", ":", "flag_opt_map", "=", "{", "'debug'", ":", "'d'", ",", "'dont_write_bytecode'", ":", "'B'", ",", "'no_user_site'", ":", "'s'", ",", "'no_site'", ":", "'S'", ",", "'ignore_environment'", ":", "'E'", ",", "'ver...
Return a list of command-line arguments reproducing the current settings in sys.flags and sys.warnoptions.
[ "Return", "a", "list", "of", "command", "-", "line", "arguments", "reproducing", "the", "current", "settings", "in", "sys", ".", "flags", "and", "sys", ".", "warnoptions", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/ipc.py#L221-L245
train
Pylons/hupper
src/hupper/ipc.py
spawn
def spawn(spec, kwargs, pass_fds=()): """ Invoke a python function in a subprocess. """ r, w = os.pipe() for fd in [r] + list(pass_fds): set_inheritable(fd, True) preparation_data = get_preparation_data() r_handle = get_handle(r) args, env = get_command_line(pipe_handle=r_hand...
python
def spawn(spec, kwargs, pass_fds=()): """ Invoke a python function in a subprocess. """ r, w = os.pipe() for fd in [r] + list(pass_fds): set_inheritable(fd, True) preparation_data = get_preparation_data() r_handle = get_handle(r) args, env = get_command_line(pipe_handle=r_hand...
[ "def", "spawn", "(", "spec", ",", "kwargs", ",", "pass_fds", "=", "(", ")", ")", ":", "r", ",", "w", "=", "os", ".", "pipe", "(", ")", "for", "fd", "in", "[", "r", "]", "+", "list", "(", "pass_fds", ")", ":", "set_inheritable", "(", "fd", ","...
Invoke a python function in a subprocess.
[ "Invoke", "a", "python", "function", "in", "a", "subprocess", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/ipc.py#L287-L306
train
Pylons/hupper
src/hupper/utils.py
get_watchman_sockpath
def get_watchman_sockpath(binpath='watchman'): """ Find the watchman socket or raise.""" path = os.getenv('WATCHMAN_SOCK') if path: return path cmd = [binpath, '--output-encoding=json', 'get-sockname'] result = subprocess.check_output(cmd) result = json.loads(result) return result['...
python
def get_watchman_sockpath(binpath='watchman'): """ Find the watchman socket or raise.""" path = os.getenv('WATCHMAN_SOCK') if path: return path cmd = [binpath, '--output-encoding=json', 'get-sockname'] result = subprocess.check_output(cmd) result = json.loads(result) return result['...
[ "def", "get_watchman_sockpath", "(", "binpath", "=", "'watchman'", ")", ":", "path", "=", "os", ".", "getenv", "(", "'WATCHMAN_SOCK'", ")", "if", "path", ":", "return", "path", "cmd", "=", "[", "binpath", ",", "'--output-encoding=json'", ",", "'get-sockname'",...
Find the watchman socket or raise.
[ "Find", "the", "watchman", "socket", "or", "raise", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/utils.py#L49-L58
train
Pylons/hupper
src/hupper/reloader.py
start_reloader
def start_reloader( worker_path, reload_interval=1, shutdown_interval=default, verbose=1, logger=None, monitor_factory=None, worker_args=None, worker_kwargs=None, ignore_files=None, ): """ Start a monitor and then fork a worker process which starts by executing the import...
python
def start_reloader( worker_path, reload_interval=1, shutdown_interval=default, verbose=1, logger=None, monitor_factory=None, worker_args=None, worker_kwargs=None, ignore_files=None, ): """ Start a monitor and then fork a worker process which starts by executing the import...
[ "def", "start_reloader", "(", "worker_path", ",", "reload_interval", "=", "1", ",", "shutdown_interval", "=", "default", ",", "verbose", "=", "1", ",", "logger", "=", "None", ",", "monitor_factory", "=", "None", ",", "worker_args", "=", "None", ",", "worker_...
Start a monitor and then fork a worker process which starts by executing the importable function at ``worker_path``. If this function is called from a worker process that is already being monitored then it will return a reference to the current :class:`hupper.interfaces.IReloaderProxy` which can be use...
[ "Start", "a", "monitor", "and", "then", "fork", "a", "worker", "process", "which", "starts", "by", "executing", "the", "importable", "function", "at", "worker_path", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/reloader.py#L289-L364
train
Pylons/hupper
src/hupper/reloader.py
Reloader.run
def run(self): """ Execute the reloader forever, blocking the current thread. This will invoke ``sys.exit(1)`` if interrupted. """ self._capture_signals() self._start_monitor() try: while True: if not self._run_worker(): ...
python
def run(self): """ Execute the reloader forever, blocking the current thread. This will invoke ``sys.exit(1)`` if interrupted. """ self._capture_signals() self._start_monitor() try: while True: if not self._run_worker(): ...
[ "def", "run", "(", "self", ")", ":", "self", ".", "_capture_signals", "(", ")", "self", ".", "_start_monitor", "(", ")", "try", ":", "while", "True", ":", "if", "not", "self", ".", "_run_worker", "(", ")", ":", "self", ".", "_wait_for_changes", "(", ...
Execute the reloader forever, blocking the current thread. This will invoke ``sys.exit(1)`` if interrupted.
[ "Execute", "the", "reloader", "forever", "blocking", "the", "current", "thread", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/reloader.py#L102-L121
train
Pylons/hupper
src/hupper/reloader.py
Reloader.run_once
def run_once(self): """ Execute the worker once. This method will return after a file change is detected. """ self._capture_signals() self._start_monitor() try: self._run_worker() except KeyboardInterrupt: return finally: ...
python
def run_once(self): """ Execute the worker once. This method will return after a file change is detected. """ self._capture_signals() self._start_monitor() try: self._run_worker() except KeyboardInterrupt: return finally: ...
[ "def", "run_once", "(", "self", ")", ":", "self", ".", "_capture_signals", "(", ")", "self", ".", "_start_monitor", "(", ")", "try", ":", "self", ".", "_run_worker", "(", ")", "except", "KeyboardInterrupt", ":", "return", "finally", ":", "self", ".", "_s...
Execute the worker once. This method will return after a file change is detected.
[ "Execute", "the", "worker", "once", "." ]
197173c09e775b66c148468b6299c571e736c381
https://github.com/Pylons/hupper/blob/197173c09e775b66c148468b6299c571e736c381/src/hupper/reloader.py#L123-L138
train
BYU-PCCL/holodeck
holodeck/holodeckclient.py
HolodeckClient.malloc
def malloc(self, key, shape, dtype): """Allocates a block of shared memory, and returns a numpy array whose data corresponds with that block. Args: key (str): The key to identify the block. shape (list of int): The shape of the numpy array to allocate. dtype (type): ...
python
def malloc(self, key, shape, dtype): """Allocates a block of shared memory, and returns a numpy array whose data corresponds with that block. Args: key (str): The key to identify the block. shape (list of int): The shape of the numpy array to allocate. dtype (type): ...
[ "def", "malloc", "(", "self", ",", "key", ",", "shape", ",", "dtype", ")", ":", "if", "key", "not", "in", "self", ".", "_memory", "or", "self", ".", "_memory", "[", "key", "]", ".", "shape", "!=", "shape", "or", "self", ".", "_memory", "[", "key"...
Allocates a block of shared memory, and returns a numpy array whose data corresponds with that block. Args: key (str): The key to identify the block. shape (list of int): The shape of the numpy array to allocate. dtype (type): The numpy data type (e.g. np.float32). ...
[ "Allocates", "a", "block", "of", "shared", "memory", "and", "returns", "a", "numpy", "array", "whose", "data", "corresponds", "with", "that", "block", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/holodeckclient.py#L88-L102
train
BYU-PCCL/holodeck
holodeck/packagemanager.py
package_info
def package_info(pkg_name): """Prints the information of a package. Args: pkg_name (str): The name of the desired package to get information """ indent = " " for config, _ in _iter_packages(): if pkg_name == config["name"]: print("Package:", pkg_name) print(...
python
def package_info(pkg_name): """Prints the information of a package. Args: pkg_name (str): The name of the desired package to get information """ indent = " " for config, _ in _iter_packages(): if pkg_name == config["name"]: print("Package:", pkg_name) print(...
[ "def", "package_info", "(", "pkg_name", ")", ":", "indent", "=", "\" \"", "for", "config", ",", "_", "in", "_iter_packages", "(", ")", ":", "if", "pkg_name", "==", "config", "[", "\"name\"", "]", ":", "print", "(", "\"Package:\"", ",", "pkg_name", ")", ...
Prints the information of a package. Args: pkg_name (str): The name of the desired package to get information
[ "Prints", "the", "information", "of", "a", "package", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/packagemanager.py#L38-L53
train
BYU-PCCL/holodeck
holodeck/packagemanager.py
world_info
def world_info(world_name, world_config=None, initial_indent="", next_indent=" "): """Gets and prints the information of a world. Args: world_name (str): the name of the world to retrieve information for world_config (dict optional): A dictionary containing the world's configuration. Will find...
python
def world_info(world_name, world_config=None, initial_indent="", next_indent=" "): """Gets and prints the information of a world. Args: world_name (str): the name of the world to retrieve information for world_config (dict optional): A dictionary containing the world's configuration. Will find...
[ "def", "world_info", "(", "world_name", ",", "world_config", "=", "None", ",", "initial_indent", "=", "\"\"", ",", "next_indent", "=", "\" \"", ")", ":", "if", "world_config", "is", "None", ":", "for", "config", ",", "_", "in", "_iter_packages", "(", ")",...
Gets and prints the information of a world. Args: world_name (str): the name of the world to retrieve information for world_config (dict optional): A dictionary containing the world's configuration. Will find the config if None. Defaults to None. initial_indent (str optional): This indent w...
[ "Gets", "and", "prints", "the", "information", "of", "a", "world", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/packagemanager.py#L56-L86
train
BYU-PCCL/holodeck
holodeck/packagemanager.py
install
def install(package_name): """Installs a holodeck package. Args: package_name (str): The name of the package to install """ holodeck_path = util.get_holodeck_path() binary_website = "https://s3.amazonaws.com/holodeckworlds/" if package_name not in packages: raise HolodeckExcept...
python
def install(package_name): """Installs a holodeck package. Args: package_name (str): The name of the package to install """ holodeck_path = util.get_holodeck_path() binary_website = "https://s3.amazonaws.com/holodeckworlds/" if package_name not in packages: raise HolodeckExcept...
[ "def", "install", "(", "package_name", ")", ":", "holodeck_path", "=", "util", ".", "get_holodeck_path", "(", ")", "binary_website", "=", "\"https://s3.amazonaws.com/holodeckworlds/\"", "if", "package_name", "not", "in", "packages", ":", "raise", "HolodeckException", ...
Installs a holodeck package. Args: package_name (str): The name of the package to install
[ "Installs", "a", "holodeck", "package", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/packagemanager.py#L89-L107
train
BYU-PCCL/holodeck
holodeck/packagemanager.py
remove
def remove(package_name): """Removes a holodeck package. Args: package_name (str): the name of the package to remove """ if package_name not in packages: raise HolodeckException("Unknown package name " + package_name) for config, path in _iter_packages(): if config["name"] =...
python
def remove(package_name): """Removes a holodeck package. Args: package_name (str): the name of the package to remove """ if package_name not in packages: raise HolodeckException("Unknown package name " + package_name) for config, path in _iter_packages(): if config["name"] =...
[ "def", "remove", "(", "package_name", ")", ":", "if", "package_name", "not", "in", "packages", ":", "raise", "HolodeckException", "(", "\"Unknown package name \"", "+", "package_name", ")", "for", "config", ",", "path", "in", "_iter_packages", "(", ")", ":", "...
Removes a holodeck package. Args: package_name (str): the name of the package to remove
[ "Removes", "a", "holodeck", "package", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/packagemanager.py#L110-L120
train
BYU-PCCL/holodeck
holodeck/holodeck.py
make
def make(world_name, gl_version=GL_VERSION.OPENGL4, window_res=None, cam_res=None, verbose=False): """Creates a holodeck environment using the supplied world name. Args: world_name (str): The name of the world to load as an environment. Must match the name of a world in an installed package...
python
def make(world_name, gl_version=GL_VERSION.OPENGL4, window_res=None, cam_res=None, verbose=False): """Creates a holodeck environment using the supplied world name. Args: world_name (str): The name of the world to load as an environment. Must match the name of a world in an installed package...
[ "def", "make", "(", "world_name", ",", "gl_version", "=", "GL_VERSION", ".", "OPENGL4", ",", "window_res", "=", "None", ",", "cam_res", "=", "None", ",", "verbose", "=", "False", ")", ":", "holodeck_worlds", "=", "_get_worlds_map", "(", ")", "if", "world_n...
Creates a holodeck environment using the supplied world name. Args: world_name (str): The name of the world to load as an environment. Must match the name of a world in an installed package. gl_version (int, optional): The OpenGL version to use (Linux only). Defaults to GL_VERSION.OPENG...
[ "Creates", "a", "holodeck", "environment", "using", "the", "supplied", "world", "name", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/holodeck.py#L22-L54
train
BYU-PCCL/holodeck
holodeck/shmem.py
Shmem.unlink
def unlink(self): """unlinks the shared memory""" if os.name == "posix": self.__linux_unlink__() elif os.name == "nt": self.__windows_unlink__() else: raise HolodeckException("Currently unsupported os: " + os.name)
python
def unlink(self): """unlinks the shared memory""" if os.name == "posix": self.__linux_unlink__() elif os.name == "nt": self.__windows_unlink__() else: raise HolodeckException("Currently unsupported os: " + os.name)
[ "def", "unlink", "(", "self", ")", ":", "if", "os", ".", "name", "==", "\"posix\"", ":", "self", ".", "__linux_unlink__", "(", ")", "elif", "os", ".", "name", "==", "\"nt\"", ":", "self", ".", "__windows_unlink__", "(", ")", "else", ":", "raise", "Ho...
unlinks the shared memory
[ "unlinks", "the", "shared", "memory" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/shmem.py#L51-L58
train
BYU-PCCL/holodeck
holodeck/command.py
Command.add_number_parameters
def add_number_parameters(self, number): """Add given number parameters to the internal list. Args: number (list of int or list of float): A number or list of numbers to add to the parameters. """ if isinstance(number, list): for x in number: self...
python
def add_number_parameters(self, number): """Add given number parameters to the internal list. Args: number (list of int or list of float): A number or list of numbers to add to the parameters. """ if isinstance(number, list): for x in number: self...
[ "def", "add_number_parameters", "(", "self", ",", "number", ")", ":", "if", "isinstance", "(", "number", ",", "list", ")", ":", "for", "x", "in", "number", ":", "self", ".", "add_number_parameters", "(", "x", ")", "return", "self", ".", "_parameters", "....
Add given number parameters to the internal list. Args: number (list of int or list of float): A number or list of numbers to add to the parameters.
[ "Add", "given", "number", "parameters", "to", "the", "internal", "list", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/command.py#L49-L59
train
BYU-PCCL/holodeck
holodeck/command.py
Command.add_string_parameters
def add_string_parameters(self, string): """Add given string parameters to the internal list. Args: string (list of str or str): A string or list of strings to add to the parameters. """ if isinstance(string, list): for x in string: self.add_strin...
python
def add_string_parameters(self, string): """Add given string parameters to the internal list. Args: string (list of str or str): A string or list of strings to add to the parameters. """ if isinstance(string, list): for x in string: self.add_strin...
[ "def", "add_string_parameters", "(", "self", ",", "string", ")", ":", "if", "isinstance", "(", "string", ",", "list", ")", ":", "for", "x", "in", "string", ":", "self", ".", "add_string_parameters", "(", "x", ")", "return", "self", ".", "_parameters", "....
Add given string parameters to the internal list. Args: string (list of str or str): A string or list of strings to add to the parameters.
[ "Add", "given", "string", "parameters", "to", "the", "internal", "list", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/command.py#L61-L71
train
BYU-PCCL/holodeck
holodeck/command.py
SetWeatherCommand.set_type
def set_type(self, weather_type): """Set the weather type. Args: weather_type (str): The weather type. """ weather_type.lower() exists = self.has_type(weather_type) if exists: self.add_string_parameters(weather_type)
python
def set_type(self, weather_type): """Set the weather type. Args: weather_type (str): The weather type. """ weather_type.lower() exists = self.has_type(weather_type) if exists: self.add_string_parameters(weather_type)
[ "def", "set_type", "(", "self", ",", "weather_type", ")", ":", "weather_type", ".", "lower", "(", ")", "exists", "=", "self", ".", "has_type", "(", "weather_type", ")", "if", "exists", ":", "self", ".", "add_string_parameters", "(", "weather_type", ")" ]
Set the weather type. Args: weather_type (str): The weather type.
[ "Set", "the", "weather", "type", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/command.py#L227-L236
train
BYU-PCCL/holodeck
example.py
uav_example
def uav_example(): """A basic example of how to use the UAV agent.""" env = holodeck.make("UrbanCity") # This changes the control scheme for the uav env.set_control_scheme("uav0", ControlSchemes.UAV_ROLL_PITCH_YAW_RATE_ALT) for i in range(10): env.reset() # This command tells the ...
python
def uav_example(): """A basic example of how to use the UAV agent.""" env = holodeck.make("UrbanCity") # This changes the control scheme for the uav env.set_control_scheme("uav0", ControlSchemes.UAV_ROLL_PITCH_YAW_RATE_ALT) for i in range(10): env.reset() # This command tells the ...
[ "def", "uav_example", "(", ")", ":", "env", "=", "holodeck", ".", "make", "(", "\"UrbanCity\"", ")", "env", ".", "set_control_scheme", "(", "\"uav0\"", ",", "ControlSchemes", ".", "UAV_ROLL_PITCH_YAW_RATE_ALT", ")", "for", "i", "in", "range", "(", "10", ")",...
A basic example of how to use the UAV agent.
[ "A", "basic", "example", "of", "how", "to", "use", "the", "UAV", "agent", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L10-L27
train
BYU-PCCL/holodeck
example.py
sphere_example
def sphere_example(): """A basic example of how to use the sphere agent.""" env = holodeck.make("MazeWorld") # This command is to constantly rotate to the right command = 2 for i in range(10): env.reset() for _ in range(1000): state, reward, terminal, _ = env.step(comman...
python
def sphere_example(): """A basic example of how to use the sphere agent.""" env = holodeck.make("MazeWorld") # This command is to constantly rotate to the right command = 2 for i in range(10): env.reset() for _ in range(1000): state, reward, terminal, _ = env.step(comman...
[ "def", "sphere_example", "(", ")", ":", "env", "=", "holodeck", ".", "make", "(", "\"MazeWorld\"", ")", "command", "=", "2", "for", "i", "in", "range", "(", "10", ")", ":", "env", ".", "reset", "(", ")", "for", "_", "in", "range", "(", "1000", ")...
A basic example of how to use the sphere agent.
[ "A", "basic", "example", "of", "how", "to", "use", "the", "sphere", "agent", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L36-L49
train
BYU-PCCL/holodeck
example.py
android_example
def android_example(): """A basic example of how to use the android agent.""" env = holodeck.make("AndroidPlayground") # The Android's command is a 94 length vector representing torques to be applied at each of his joints command = np.ones(94) * 10 for i in range(10): env.reset() fo...
python
def android_example(): """A basic example of how to use the android agent.""" env = holodeck.make("AndroidPlayground") # The Android's command is a 94 length vector representing torques to be applied at each of his joints command = np.ones(94) * 10 for i in range(10): env.reset() fo...
[ "def", "android_example", "(", ")", ":", "env", "=", "holodeck", ".", "make", "(", "\"AndroidPlayground\"", ")", "command", "=", "np", ".", "ones", "(", "94", ")", "*", "10", "for", "i", "in", "range", "(", "10", ")", ":", "env", ".", "reset", "(",...
A basic example of how to use the android agent.
[ "A", "basic", "example", "of", "how", "to", "use", "the", "android", "agent", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L53-L69
train
BYU-PCCL/holodeck
example.py
multi_agent_example
def multi_agent_example(): """A basic example of using multiple agents""" env = holodeck.make("UrbanCity") cmd0 = np.array([0, 0, -2, 10]) cmd1 = np.array([0, 0, 5, 10]) for i in range(10): env.reset() # This will queue up a new agent to spawn into the environment, given that the co...
python
def multi_agent_example(): """A basic example of using multiple agents""" env = holodeck.make("UrbanCity") cmd0 = np.array([0, 0, -2, 10]) cmd1 = np.array([0, 0, 5, 10]) for i in range(10): env.reset() # This will queue up a new agent to spawn into the environment, given that the co...
[ "def", "multi_agent_example", "(", ")", ":", "env", "=", "holodeck", ".", "make", "(", "\"UrbanCity\"", ")", "cmd0", "=", "np", ".", "array", "(", "[", "0", ",", "0", ",", "-", "2", ",", "10", "]", ")", "cmd1", "=", "np", ".", "array", "(", "["...
A basic example of using multiple agents
[ "A", "basic", "example", "of", "using", "multiple", "agents" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L73-L96
train
BYU-PCCL/holodeck
example.py
world_command_examples
def world_command_examples(): """A few examples to showcase commands for manipulating the worlds.""" env = holodeck.make("MazeWorld") # This is the unaltered MazeWorld for _ in range(300): _ = env.tick() env.reset() # The set_day_time_command sets the hour between 0 and 23 (military ti...
python
def world_command_examples(): """A few examples to showcase commands for manipulating the worlds.""" env = holodeck.make("MazeWorld") # This is the unaltered MazeWorld for _ in range(300): _ = env.tick() env.reset() # The set_day_time_command sets the hour between 0 and 23 (military ti...
[ "def", "world_command_examples", "(", ")", ":", "env", "=", "holodeck", ".", "make", "(", "\"MazeWorld\"", ")", "for", "_", "in", "range", "(", "300", ")", ":", "_", "=", "env", ".", "tick", "(", ")", "env", ".", "reset", "(", ")", "env", ".", "s...
A few examples to showcase commands for manipulating the worlds.
[ "A", "few", "examples", "to", "showcase", "commands", "for", "manipulating", "the", "worlds", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L99-L143
train
BYU-PCCL/holodeck
example.py
editor_example
def editor_example(): """This editor example shows how to interact with holodeck worlds while they are being built in the Unreal Engine. Most people that use holodeck will not need this. """ sensors = [Sensors.PIXEL_CAMERA, Sensors.LOCATION_SENSOR, Sensors.VELOCITY_SENSOR] agent = AgentDefinition("u...
python
def editor_example(): """This editor example shows how to interact with holodeck worlds while they are being built in the Unreal Engine. Most people that use holodeck will not need this. """ sensors = [Sensors.PIXEL_CAMERA, Sensors.LOCATION_SENSOR, Sensors.VELOCITY_SENSOR] agent = AgentDefinition("u...
[ "def", "editor_example", "(", ")", ":", "sensors", "=", "[", "Sensors", ".", "PIXEL_CAMERA", ",", "Sensors", ".", "LOCATION_SENSOR", ",", "Sensors", ".", "VELOCITY_SENSOR", "]", "agent", "=", "AgentDefinition", "(", "\"uav0\"", ",", "agents", ".", "UavAgent", ...
This editor example shows how to interact with holodeck worlds while they are being built in the Unreal Engine. Most people that use holodeck will not need this.
[ "This", "editor", "example", "shows", "how", "to", "interact", "with", "holodeck", "worlds", "while", "they", "are", "being", "built", "in", "the", "Unreal", "Engine", ".", "Most", "people", "that", "use", "holodeck", "will", "not", "need", "this", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L146-L159
train
BYU-PCCL/holodeck
example.py
editor_multi_agent_example
def editor_multi_agent_example(): """This editor example shows how to interact with holodeck worlds that have multiple agents. This is specifically for when working with UE4 directly and not a prebuilt binary. """ agent_definitions = [ AgentDefinition("uav0", agents.UavAgent, [Sensors.PIXEL_CAME...
python
def editor_multi_agent_example(): """This editor example shows how to interact with holodeck worlds that have multiple agents. This is specifically for when working with UE4 directly and not a prebuilt binary. """ agent_definitions = [ AgentDefinition("uav0", agents.UavAgent, [Sensors.PIXEL_CAME...
[ "def", "editor_multi_agent_example", "(", ")", ":", "agent_definitions", "=", "[", "AgentDefinition", "(", "\"uav0\"", ",", "agents", ".", "UavAgent", ",", "[", "Sensors", ".", "PIXEL_CAMERA", ",", "Sensors", ".", "LOCATION_SENSOR", "]", ")", ",", "AgentDefiniti...
This editor example shows how to interact with holodeck worlds that have multiple agents. This is specifically for when working with UE4 directly and not a prebuilt binary.
[ "This", "editor", "example", "shows", "how", "to", "interact", "with", "holodeck", "worlds", "that", "have", "multiple", "agents", ".", "This", "is", "specifically", "for", "when", "working", "with", "UE4", "directly", "and", "not", "a", "prebuilt", "binary", ...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/example.py#L162-L183
train
BYU-PCCL/holodeck
holodeck/util.py
get_holodeck_path
def get_holodeck_path(): """Gets the path of the holodeck environment Returns: (str): path to the current holodeck environment """ if "HOLODECKPATH" in os.environ and os.environ["HOLODECKPATH"] != "": return os.environ["HOLODECKPATH"] if os.name == "posix": return os.path.ex...
python
def get_holodeck_path(): """Gets the path of the holodeck environment Returns: (str): path to the current holodeck environment """ if "HOLODECKPATH" in os.environ and os.environ["HOLODECKPATH"] != "": return os.environ["HOLODECKPATH"] if os.name == "posix": return os.path.ex...
[ "def", "get_holodeck_path", "(", ")", ":", "if", "\"HOLODECKPATH\"", "in", "os", ".", "environ", "and", "os", ".", "environ", "[", "\"HOLODECKPATH\"", "]", "!=", "\"\"", ":", "return", "os", ".", "environ", "[", "\"HOLODECKPATH\"", "]", "if", "os", ".", ...
Gets the path of the holodeck environment Returns: (str): path to the current holodeck environment
[ "Gets", "the", "path", "of", "the", "holodeck", "environment" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/util.py#L11-L24
train
BYU-PCCL/holodeck
holodeck/util.py
convert_unicode
def convert_unicode(value): """Resolves python 2 issue with json loading in unicode instead of string Args: value (str): Unicode value to be converted Returns: (str): converted string """ if isinstance(value, dict): return {convert_unicode(key): convert_unicode(value) ...
python
def convert_unicode(value): """Resolves python 2 issue with json loading in unicode instead of string Args: value (str): Unicode value to be converted Returns: (str): converted string """ if isinstance(value, dict): return {convert_unicode(key): convert_unicode(value) ...
[ "def", "convert_unicode", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "return", "{", "convert_unicode", "(", "key", ")", ":", "convert_unicode", "(", "value", ")", "for", "key", ",", "value", "in", "value", ".", "it...
Resolves python 2 issue with json loading in unicode instead of string Args: value (str): Unicode value to be converted Returns: (str): converted string
[ "Resolves", "python", "2", "issue", "with", "json", "loading", "in", "unicode", "instead", "of", "string" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/util.py#L27-L45
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.info
def info(self): """Returns a string with specific information about the environment. This information includes which agents are in the environment and which sensors they have. Returns: str: The information in a string format. """ result = list() result.append...
python
def info(self): """Returns a string with specific information about the environment. This information includes which agents are in the environment and which sensors they have. Returns: str: The information in a string format. """ result = list() result.append...
[ "def", "info", "(", "self", ")", ":", "result", "=", "list", "(", ")", "result", ".", "append", "(", "\"Agents:\\n\"", ")", "for", "agent", "in", "self", ".", "_all_agents", ":", "result", ".", "append", "(", "\"\\tName: \"", ")", "result", ".", "appen...
Returns a string with specific information about the environment. This information includes which agents are in the environment and which sensors they have. Returns: str: The information in a string format.
[ "Returns", "a", "string", "with", "specific", "information", "about", "the", "environment", ".", "This", "information", "includes", "which", "agents", "are", "in", "the", "environment", "and", "which", "sensors", "they", "have", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L142-L162
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.reset
def reset(self): """Resets the environment, and returns the state. If it is a single agent environment, it returns that state for that agent. Otherwise, it returns a dict from agent name to state. Returns: tuple or dict: For single agent environment, returns the same as `ste...
python
def reset(self): """Resets the environment, and returns the state. If it is a single agent environment, it returns that state for that agent. Otherwise, it returns a dict from agent name to state. Returns: tuple or dict: For single agent environment, returns the same as `ste...
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_reset_ptr", "[", "0", "]", "=", "True", "self", ".", "_commands", ".", "clear", "(", ")", "for", "_", "in", "range", "(", "self", ".", "_pre_start_steps", "+", "1", ")", ":", "self", ".", "tic...
Resets the environment, and returns the state. If it is a single agent environment, it returns that state for that agent. Otherwise, it returns a dict from agent name to state. Returns: tuple or dict: For single agent environment, returns the same as `step`. For mult...
[ "Resets", "the", "environment", "and", "returns", "the", "state", ".", "If", "it", "is", "a", "single", "agent", "environment", "it", "returns", "that", "state", "for", "that", "agent", ".", "Otherwise", "it", "returns", "a", "dict", "from", "agent", "name...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L164-L179
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.step
def step(self, action): """Supplies an action to the main agent and tells the environment to tick once. Primary mode of interaction for single agent environments. Args: action (np.ndarray): An action for the main agent to carry out on the next tick. Returns: tup...
python
def step(self, action): """Supplies an action to the main agent and tells the environment to tick once. Primary mode of interaction for single agent environments. Args: action (np.ndarray): An action for the main agent to carry out on the next tick. Returns: tup...
[ "def", "step", "(", "self", ",", "action", ")", ":", "self", ".", "_agent", ".", "act", "(", "action", ")", "self", ".", "_handle_command_buffer", "(", ")", "self", ".", "_client", ".", "release", "(", ")", "self", ".", "_client", ".", "acquire", "("...
Supplies an action to the main agent and tells the environment to tick once. Primary mode of interaction for single agent environments. Args: action (np.ndarray): An action for the main agent to carry out on the next tick. Returns: tuple: The (state, reward, terminal, i...
[ "Supplies", "an", "action", "to", "the", "main", "agent", "and", "tells", "the", "environment", "to", "tick", "once", ".", "Primary", "mode", "of", "interaction", "for", "single", "agent", "environments", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L181-L202
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.teleport
def teleport(self, agent_name, location=None, rotation=None): """Teleports the target agent to any given location, and applies a specific rotation. Args: agent_name (str): The name of the agent to teleport. location (np.ndarray or list): XYZ coordinates (in meters) for the agent...
python
def teleport(self, agent_name, location=None, rotation=None): """Teleports the target agent to any given location, and applies a specific rotation. Args: agent_name (str): The name of the agent to teleport. location (np.ndarray or list): XYZ coordinates (in meters) for the agent...
[ "def", "teleport", "(", "self", ",", "agent_name", ",", "location", "=", "None", ",", "rotation", "=", "None", ")", ":", "self", ".", "agents", "[", "agent_name", "]", ".", "teleport", "(", "location", "*", "100", ",", "rotation", ")", "self", ".", "...
Teleports the target agent to any given location, and applies a specific rotation. Args: agent_name (str): The name of the agent to teleport. location (np.ndarray or list): XYZ coordinates (in meters) for the agent to be teleported to. If no location is given, it isn't t...
[ "Teleports", "the", "target", "agent", "to", "any", "given", "location", "and", "applies", "a", "specific", "rotation", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L204-L215
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.tick
def tick(self): """Ticks the environment once. Normally used for multi-agent environments. Returns: dict: A dictionary from agent name to its full state. The full state is another dictionary from :obj:`holodeck.sensors.Sensors` enum to np.ndarray, containing the sensors informat...
python
def tick(self): """Ticks the environment once. Normally used for multi-agent environments. Returns: dict: A dictionary from agent name to its full state. The full state is another dictionary from :obj:`holodeck.sensors.Sensors` enum to np.ndarray, containing the sensors informat...
[ "def", "tick", "(", "self", ")", ":", "self", ".", "_handle_command_buffer", "(", ")", "self", ".", "_client", ".", "release", "(", ")", "self", ".", "_client", ".", "acquire", "(", ")", "return", "self", ".", "_get_full_state", "(", ")" ]
Ticks the environment once. Normally used for multi-agent environments. Returns: dict: A dictionary from agent name to its full state. The full state is another dictionary from :obj:`holodeck.sensors.Sensors` enum to np.ndarray, containing the sensors information for each se...
[ "Ticks", "the", "environment", "once", ".", "Normally", "used", "for", "multi", "-", "agent", "environments", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L229-L240
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.add_state_sensors
def add_state_sensors(self, agent_name, sensors): """Adds a sensor to a particular agent. This only works if the world you are running also includes that particular sensor on the agent. Args: agent_name (str): The name of the agent to add the sensor to. sensors (:obj:`Ho...
python
def add_state_sensors(self, agent_name, sensors): """Adds a sensor to a particular agent. This only works if the world you are running also includes that particular sensor on the agent. Args: agent_name (str): The name of the agent to add the sensor to. sensors (:obj:`Ho...
[ "def", "add_state_sensors", "(", "self", ",", "agent_name", ",", "sensors", ")", ":", "if", "isinstance", "(", "sensors", ",", "list", ")", ":", "for", "sensor", "in", "sensors", ":", "self", ".", "add_state_sensors", "(", "agent_name", ",", "sensor", ")",...
Adds a sensor to a particular agent. This only works if the world you are running also includes that particular sensor on the agent. Args: agent_name (str): The name of the agent to add the sensor to. sensors (:obj:`HolodeckSensor` or list of :obj:`HolodeckSensor`): Sensors to a...
[ "Adds", "a", "sensor", "to", "a", "particular", "agent", ".", "This", "only", "works", "if", "the", "world", "you", "are", "running", "also", "includes", "that", "particular", "sensor", "on", "the", "agent", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L242-L260
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.spawn_agent
def spawn_agent(self, agent_definition, location): """Queues a spawn agent command. It will be applied when `tick` or `step` is called next. The agent won't be able to be used until the next frame. Args: agent_definition (:obj:`AgentDefinition`): The definition of the agent to spawn...
python
def spawn_agent(self, agent_definition, location): """Queues a spawn agent command. It will be applied when `tick` or `step` is called next. The agent won't be able to be used until the next frame. Args: agent_definition (:obj:`AgentDefinition`): The definition of the agent to spawn...
[ "def", "spawn_agent", "(", "self", ",", "agent_definition", ",", "location", ")", ":", "self", ".", "_should_write_to_command_buffer", "=", "True", "self", ".", "_add_agents", "(", "agent_definition", ")", "command_to_send", "=", "SpawnAgentCommand", "(", "location"...
Queues a spawn agent command. It will be applied when `tick` or `step` is called next. The agent won't be able to be used until the next frame. Args: agent_definition (:obj:`AgentDefinition`): The definition of the agent to spawn. location (np.ndarray or list): The position to s...
[ "Queues", "a", "spawn", "agent", "command", ".", "It", "will", "be", "applied", "when", "tick", "or", "step", "is", "called", "next", ".", "The", "agent", "won", "t", "be", "able", "to", "be", "used", "until", "the", "next", "frame", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L262-L273
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.set_fog_density
def set_fog_density(self, density): """Queue up a change fog density command. It will be applied when `tick` or `step` is called next. By the next tick, the exponential height fog in the world will have the new density. If there is no fog in the world, it will be automatically created with the g...
python
def set_fog_density(self, density): """Queue up a change fog density command. It will be applied when `tick` or `step` is called next. By the next tick, the exponential height fog in the world will have the new density. If there is no fog in the world, it will be automatically created with the g...
[ "def", "set_fog_density", "(", "self", ",", "density", ")", ":", "if", "density", "<", "0", "or", "density", ">", "1", ":", "raise", "HolodeckException", "(", "\"Fog density should be between 0 and 1\"", ")", "self", ".", "_should_write_to_command_buffer", "=", "T...
Queue up a change fog density command. It will be applied when `tick` or `step` is called next. By the next tick, the exponential height fog in the world will have the new density. If there is no fog in the world, it will be automatically created with the given density. Args: densit...
[ "Queue", "up", "a", "change", "fog", "density", "command", ".", "It", "will", "be", "applied", "when", "tick", "or", "step", "is", "called", "next", ".", "By", "the", "next", "tick", "the", "exponential", "height", "fog", "in", "the", "world", "will", ...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L275-L289
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.set_day_time
def set_day_time(self, hour): """Queue up a change day time command. It will be applied when `tick` or `step` is called next. By the next tick, the lighting and the skysphere will be updated with the new hour. If there is no skysphere or directional light in the world, the command will not funct...
python
def set_day_time(self, hour): """Queue up a change day time command. It will be applied when `tick` or `step` is called next. By the next tick, the lighting and the skysphere will be updated with the new hour. If there is no skysphere or directional light in the world, the command will not funct...
[ "def", "set_day_time", "(", "self", ",", "hour", ")", ":", "self", ".", "_should_write_to_command_buffer", "=", "True", "command_to_send", "=", "DayTimeCommand", "(", "hour", "%", "24", ")", "self", ".", "_commands", ".", "add_command", "(", "command_to_send", ...
Queue up a change day time command. It will be applied when `tick` or `step` is called next. By the next tick, the lighting and the skysphere will be updated with the new hour. If there is no skysphere or directional light in the world, the command will not function properly but will not cause a crash. ...
[ "Queue", "up", "a", "change", "day", "time", "command", ".", "It", "will", "be", "applied", "when", "tick", "or", "step", "is", "called", "next", ".", "By", "the", "next", "tick", "the", "lighting", "and", "the", "skysphere", "will", "be", "updated", "...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L291-L301
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.start_day_cycle
def start_day_cycle(self, day_length): """Queue up a day cycle command to start the day cycle. It will be applied when `tick` or `step` is called next. The sky sphere will now update each tick with an updated sun angle as it moves about the sky. The length of a day will be roughly equivalent to ...
python
def start_day_cycle(self, day_length): """Queue up a day cycle command to start the day cycle. It will be applied when `tick` or `step` is called next. The sky sphere will now update each tick with an updated sun angle as it moves about the sky. The length of a day will be roughly equivalent to ...
[ "def", "start_day_cycle", "(", "self", ",", "day_length", ")", ":", "if", "day_length", "<=", "0", ":", "raise", "HolodeckException", "(", "\"The given day length should be between above 0!\"", ")", "self", ".", "_should_write_to_command_buffer", "=", "True", "command_t...
Queue up a day cycle command to start the day cycle. It will be applied when `tick` or `step` is called next. The sky sphere will now update each tick with an updated sun angle as it moves about the sky. The length of a day will be roughly equivalent to the number of minutes given. Args: ...
[ "Queue", "up", "a", "day", "cycle", "command", "to", "start", "the", "day", "cycle", ".", "It", "will", "be", "applied", "when", "tick", "or", "step", "is", "called", "next", ".", "The", "sky", "sphere", "will", "now", "update", "each", "tick", "with",...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L303-L317
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.stop_day_cycle
def stop_day_cycle(self): """Queue up a day cycle command to stop the day cycle. It will be applied when `tick` or `step` is called next. By the next tick, day cycle will stop where it is. """ self._should_write_to_command_buffer = True command_to_send = DayCycleCommand(False) ...
python
def stop_day_cycle(self): """Queue up a day cycle command to stop the day cycle. It will be applied when `tick` or `step` is called next. By the next tick, day cycle will stop where it is. """ self._should_write_to_command_buffer = True command_to_send = DayCycleCommand(False) ...
[ "def", "stop_day_cycle", "(", "self", ")", ":", "self", ".", "_should_write_to_command_buffer", "=", "True", "command_to_send", "=", "DayCycleCommand", "(", "False", ")", "self", ".", "_commands", ".", "add_command", "(", "command_to_send", ")" ]
Queue up a day cycle command to stop the day cycle. It will be applied when `tick` or `step` is called next. By the next tick, day cycle will stop where it is.
[ "Queue", "up", "a", "day", "cycle", "command", "to", "stop", "the", "day", "cycle", ".", "It", "will", "be", "applied", "when", "tick", "or", "step", "is", "called", "next", ".", "By", "the", "next", "tick", "day", "cycle", "will", "stop", "where", "...
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L319-L325
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.teleport_camera
def teleport_camera(self, location, rotation): """Queue up a teleport camera command to stop the day cycle. By the next tick, the camera's location and rotation will be updated """ self._should_write_to_command_buffer = True command_to_send = TeleportCameraCommand(location, rotat...
python
def teleport_camera(self, location, rotation): """Queue up a teleport camera command to stop the day cycle. By the next tick, the camera's location and rotation will be updated """ self._should_write_to_command_buffer = True command_to_send = TeleportCameraCommand(location, rotat...
[ "def", "teleport_camera", "(", "self", ",", "location", ",", "rotation", ")", ":", "self", ".", "_should_write_to_command_buffer", "=", "True", "command_to_send", "=", "TeleportCameraCommand", "(", "location", ",", "rotation", ")", "self", ".", "_commands", ".", ...
Queue up a teleport camera command to stop the day cycle. By the next tick, the camera's location and rotation will be updated
[ "Queue", "up", "a", "teleport", "camera", "command", "to", "stop", "the", "day", "cycle", ".", "By", "the", "next", "tick", "the", "camera", "s", "location", "and", "rotation", "will", "be", "updated" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L327-L333
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment.set_control_scheme
def set_control_scheme(self, agent_name, control_scheme): """Set the control scheme for a specific agent. Args: agent_name (str): The name of the agent to set the control scheme for. control_scheme (int): A control scheme value (see :obj:`holodeck.agents.ControlSchemes`) ...
python
def set_control_scheme(self, agent_name, control_scheme): """Set the control scheme for a specific agent. Args: agent_name (str): The name of the agent to set the control scheme for. control_scheme (int): A control scheme value (see :obj:`holodeck.agents.ControlSchemes`) ...
[ "def", "set_control_scheme", "(", "self", ",", "agent_name", ",", "control_scheme", ")", ":", "if", "agent_name", "not", "in", "self", ".", "agents", ":", "print", "(", "\"No such agent %s\"", "%", "agent_name", ")", "else", ":", "self", ".", "agents", "[", ...
Set the control scheme for a specific agent. Args: agent_name (str): The name of the agent to set the control scheme for. control_scheme (int): A control scheme value (see :obj:`holodeck.agents.ControlSchemes`)
[ "Set", "the", "control", "scheme", "for", "a", "specific", "agent", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L357-L367
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment._handle_command_buffer
def _handle_command_buffer(self): """Checks if we should write to the command buffer, writes all of the queued commands to the buffer, and then clears the contents of the self._commands list""" if self._should_write_to_command_buffer: self._write_to_command_buffer(self._commands.to_j...
python
def _handle_command_buffer(self): """Checks if we should write to the command buffer, writes all of the queued commands to the buffer, and then clears the contents of the self._commands list""" if self._should_write_to_command_buffer: self._write_to_command_buffer(self._commands.to_j...
[ "def", "_handle_command_buffer", "(", "self", ")", ":", "if", "self", ".", "_should_write_to_command_buffer", ":", "self", ".", "_write_to_command_buffer", "(", "self", ".", "_commands", ".", "to_json", "(", ")", ")", "self", ".", "_should_write_to_command_buffer", ...
Checks if we should write to the command buffer, writes all of the queued commands to the buffer, and then clears the contents of the self._commands list
[ "Checks", "if", "we", "should", "write", "to", "the", "command", "buffer", "writes", "all", "of", "the", "queued", "commands", "to", "the", "buffer", "and", "then", "clears", "the", "contents", "of", "the", "self", ".", "_commands", "list" ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L423-L429
train
BYU-PCCL/holodeck
holodeck/environments.py
HolodeckEnvironment._write_to_command_buffer
def _write_to_command_buffer(self, to_write): """Write input to the command buffer. Reformat input string to the correct format. Args: to_write (str): The string to write to the command buffer. """ # TODO(mitch): Handle the edge case of writing too much data to the buffer. ...
python
def _write_to_command_buffer(self, to_write): """Write input to the command buffer. Reformat input string to the correct format. Args: to_write (str): The string to write to the command buffer. """ # TODO(mitch): Handle the edge case of writing too much data to the buffer. ...
[ "def", "_write_to_command_buffer", "(", "self", ",", "to_write", ")", ":", "np", ".", "copyto", "(", "self", ".", "_command_bool_ptr", ",", "True", ")", "to_write", "+=", "'0'", "input_bytes", "=", "str", ".", "encode", "(", "to_write", ")", "for", "index"...
Write input to the command buffer. Reformat input string to the correct format. Args: to_write (str): The string to write to the command buffer.
[ "Write", "input", "to", "the", "command", "buffer", ".", "Reformat", "input", "string", "to", "the", "correct", "format", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L453-L464
train
BYU-PCCL/holodeck
holodeck/agents.py
HolodeckAgent.teleport
def teleport(self, location=None, rotation=None): """Teleports the agent to a specific location, with a specific rotation. Args: location (np.ndarray, optional): An array with three elements specifying the target world coordinate in meters. If None, keeps the current location. D...
python
def teleport(self, location=None, rotation=None): """Teleports the agent to a specific location, with a specific rotation. Args: location (np.ndarray, optional): An array with three elements specifying the target world coordinate in meters. If None, keeps the current location. D...
[ "def", "teleport", "(", "self", ",", "location", "=", "None", ",", "rotation", "=", "None", ")", ":", "val", "=", "0", "if", "location", "is", "not", "None", ":", "val", "+=", "1", "np", ".", "copyto", "(", "self", ".", "_teleport_buffer", ",", "lo...
Teleports the agent to a specific location, with a specific rotation. Args: location (np.ndarray, optional): An array with three elements specifying the target world coordinate in meters. If None, keeps the current location. Defaults to None. rotation (np.ndarray, optional):...
[ "Teleports", "the", "agent", "to", "a", "specific", "location", "with", "a", "specific", "rotation", "." ]
01acd4013f5acbd9f61fbc9caaafe19975e8b121
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/agents.py#L79-L98
train
browniebroke/deezer-python
deezer/client.py
Client.url
def url(self, request=""): """Build the url with the appended request if provided.""" if request.startswith("/"): request = request[1:] return "{}://{}/{}".format(self.scheme, self.host, request)
python
def url(self, request=""): """Build the url with the appended request if provided.""" if request.startswith("/"): request = request[1:] return "{}://{}/{}".format(self.scheme, self.host, request)
[ "def", "url", "(", "self", ",", "request", "=", "\"\"", ")", ":", "if", "request", ".", "startswith", "(", "\"/\"", ")", ":", "request", "=", "request", "[", "1", ":", "]", "return", "\"{}://{}/{}\"", ".", "format", "(", "self", ".", "scheme", ",", ...
Build the url with the appended request if provided.
[ "Build", "the", "url", "with", "the", "appended", "request", "if", "provided", "." ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L95-L99
train
browniebroke/deezer-python
deezer/client.py
Client.object_url
def object_url(self, object_t, object_id=None, relation=None, **kwargs): """ Helper method to build the url to query to access the object passed as parameter :raises TypeError: if the object type is invalid """ if object_t not in self.objects_types: raise Typ...
python
def object_url(self, object_t, object_id=None, relation=None, **kwargs): """ Helper method to build the url to query to access the object passed as parameter :raises TypeError: if the object type is invalid """ if object_t not in self.objects_types: raise Typ...
[ "def", "object_url", "(", "self", ",", "object_t", ",", "object_id", "=", "None", ",", "relation", "=", "None", ",", "**", "kwargs", ")", ":", "if", "object_t", "not", "in", "self", ".", "objects_types", ":", "raise", "TypeError", "(", "\"{} is not a valid...
Helper method to build the url to query to access the object passed as parameter :raises TypeError: if the object type is invalid
[ "Helper", "method", "to", "build", "the", "url", "to", "query", "to", "access", "the", "object", "passed", "as", "parameter" ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L101-L126
train
browniebroke/deezer-python
deezer/client.py
Client.get_album
def get_album(self, object_id, relation=None, **kwargs): """ Get the album with the provided id :returns: an :class:`~deezer.resources.Album` object """ return self.get_object("album", object_id, relation=relation, **kwargs)
python
def get_album(self, object_id, relation=None, **kwargs): """ Get the album with the provided id :returns: an :class:`~deezer.resources.Album` object """ return self.get_object("album", object_id, relation=relation, **kwargs)
[ "def", "get_album", "(", "self", ",", "object_id", ",", "relation", "=", "None", ",", "**", "kwargs", ")", ":", "return", "self", ".", "get_object", "(", "\"album\"", ",", "object_id", ",", "relation", "=", "relation", ",", "**", "kwargs", ")" ]
Get the album with the provided id :returns: an :class:`~deezer.resources.Album` object
[ "Get", "the", "album", "with", "the", "provided", "id" ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L150-L156
train
browniebroke/deezer-python
deezer/client.py
Client.get_artist
def get_artist(self, object_id, relation=None, **kwargs): """ Get the artist with the provided id :returns: an :class:`~deezer.resources.Artist` object """ return self.get_object("artist", object_id, relation=relation, **kwargs)
python
def get_artist(self, object_id, relation=None, **kwargs): """ Get the artist with the provided id :returns: an :class:`~deezer.resources.Artist` object """ return self.get_object("artist", object_id, relation=relation, **kwargs)
[ "def", "get_artist", "(", "self", ",", "object_id", ",", "relation", "=", "None", ",", "**", "kwargs", ")", ":", "return", "self", ".", "get_object", "(", "\"artist\"", ",", "object_id", ",", "relation", "=", "relation", ",", "**", "kwargs", ")" ]
Get the artist with the provided id :returns: an :class:`~deezer.resources.Artist` object
[ "Get", "the", "artist", "with", "the", "provided", "id" ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L158-L164
train
browniebroke/deezer-python
deezer/client.py
Client.search
def search(self, query, relation=None, index=0, limit=25, **kwargs): """ Search track, album, artist or user :returns: a list of :class:`~deezer.resources.Resource` objects. """ return self.get_object( "search", relation=relation, q=query, index=index, limit=limit, *...
python
def search(self, query, relation=None, index=0, limit=25, **kwargs): """ Search track, album, artist or user :returns: a list of :class:`~deezer.resources.Resource` objects. """ return self.get_object( "search", relation=relation, q=query, index=index, limit=limit, *...
[ "def", "search", "(", "self", ",", "query", ",", "relation", "=", "None", ",", "index", "=", "0", ",", "limit", "=", "25", ",", "**", "kwargs", ")", ":", "return", "self", ".", "get_object", "(", "\"search\"", ",", "relation", "=", "relation", ",", ...
Search track, album, artist or user :returns: a list of :class:`~deezer.resources.Resource` objects.
[ "Search", "track", "album", "artist", "or", "user" ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L236-L244
train
browniebroke/deezer-python
deezer/client.py
Client.advanced_search
def advanced_search(self, terms, relation=None, index=0, limit=25, **kwargs): """ Advanced search of track, album or artist. See `Search section of Deezer API <https://developers.deezer.com/api/search>`_ for search terms. :returns: a list of :class:`~deezer.resources.Resource` ...
python
def advanced_search(self, terms, relation=None, index=0, limit=25, **kwargs): """ Advanced search of track, album or artist. See `Search section of Deezer API <https://developers.deezer.com/api/search>`_ for search terms. :returns: a list of :class:`~deezer.resources.Resource` ...
[ "def", "advanced_search", "(", "self", ",", "terms", ",", "relation", "=", "None", ",", "index", "=", "0", ",", "limit", "=", "25", ",", "**", "kwargs", ")", ":", "assert", "isinstance", "(", "terms", ",", "dict", ")", ",", "\"terms must be a dict\"", ...
Advanced search of track, album or artist. See `Search section of Deezer API <https://developers.deezer.com/api/search>`_ for search terms. :returns: a list of :class:`~deezer.resources.Resource` objects. >>> client.advanced_search({"artist": "Daft Punk", "album": "Homework"}) ...
[ "Advanced", "search", "of", "track", "album", "or", "artist", "." ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/client.py#L246-L264
train
browniebroke/deezer-python
deezer/resources.py
Resource.asdict
def asdict(self): """ Convert resource to dictionary """ result = {} for key in self._fields: value = getattr(self, key) if isinstance(value, list): value = [i.asdict() if isinstance(i, Resource) else i for i in value] if isinst...
python
def asdict(self): """ Convert resource to dictionary """ result = {} for key in self._fields: value = getattr(self, key) if isinstance(value, list): value = [i.asdict() if isinstance(i, Resource) else i for i in value] if isinst...
[ "def", "asdict", "(", "self", ")", ":", "result", "=", "{", "}", "for", "key", "in", "self", ".", "_fields", ":", "value", "=", "getattr", "(", "self", ",", "key", ")", "if", "isinstance", "(", "value", ",", "list", ")", ":", "value", "=", "[", ...
Convert resource to dictionary
[ "Convert", "resource", "to", "dictionary" ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/resources.py#L28-L40
train
browniebroke/deezer-python
deezer/resources.py
Resource.get_relation
def get_relation(self, relation, **kwargs): """ Generic method to load the relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helpe...
python
def get_relation(self, relation, **kwargs): """ Generic method to load the relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helpe...
[ "def", "get_relation", "(", "self", ",", "relation", ",", "**", "kwargs", ")", ":", "return", "self", ".", "client", ".", "get_object", "(", "self", ".", "type", ",", "self", ".", "id", ",", "relation", ",", "self", ",", "**", "kwargs", ")" ]
Generic method to load the relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helper method for the child objects.
[ "Generic", "method", "to", "load", "the", "relation", "from", "any", "resource", "." ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/resources.py#L42-L52
train
browniebroke/deezer-python
deezer/resources.py
Resource.iter_relation
def iter_relation(self, relation, **kwargs): """ Generic method to iterate relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helpe...
python
def iter_relation(self, relation, **kwargs): """ Generic method to iterate relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helpe...
[ "def", "iter_relation", "(", "self", ",", "relation", ",", "**", "kwargs", ")", ":", "index", "=", "0", "while", "1", ":", "items", "=", "self", ".", "get_relation", "(", "relation", ",", "index", "=", "index", ",", "**", "kwargs", ")", "for", "item"...
Generic method to iterate relation from any resource. Query the client with the object's known parameters and try to retrieve the provided relation type. This is not meant to be used directly by a client, it's more a helper method for the child objects.
[ "Generic", "method", "to", "iterate", "relation", "from", "any", "resource", "." ]
fb869c3617045b22e7124e4b783ec1a68d283ac3
https://github.com/browniebroke/deezer-python/blob/fb869c3617045b22e7124e4b783ec1a68d283ac3/deezer/resources.py#L54-L72
train
lambdamusic/Ontospy
ontospy/ontodocs/viz/viz_sigmajs.py
run
def run(graph, save_on_github=False, main_entity=None): """ 2016-11-30 """ try: ontology = graph.all_ontologies[0] uri = ontology.uri except: ontology = None uri = ";".join([s for s in graph.sources]) # ontotemplate = open("template.html", "r") ontotemplate ...
python
def run(graph, save_on_github=False, main_entity=None): """ 2016-11-30 """ try: ontology = graph.all_ontologies[0] uri = ontology.uri except: ontology = None uri = ";".join([s for s in graph.sources]) # ontotemplate = open("template.html", "r") ontotemplate ...
[ "def", "run", "(", "graph", ",", "save_on_github", "=", "False", ",", "main_entity", "=", "None", ")", ":", "try", ":", "ontology", "=", "graph", ".", "all_ontologies", "[", "0", "]", "uri", "=", "ontology", ".", "uri", "except", ":", "ontology", "=", ...
2016-11-30
[ "2016", "-", "11", "-", "30" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/viz/viz_sigmajs.py#L149-L204
train
lambdamusic/Ontospy
ontospy/core/rdf_loader.py
RDFLoader._debugGraph
def _debugGraph(self): """internal util to print out contents of graph""" print("Len of graph: ", len(self.rdflib_graph)) for x, y, z in self.rdflib_graph: print(x, y, z)
python
def _debugGraph(self): """internal util to print out contents of graph""" print("Len of graph: ", len(self.rdflib_graph)) for x, y, z in self.rdflib_graph: print(x, y, z)
[ "def", "_debugGraph", "(", "self", ")", ":", "print", "(", "\"Len of graph: \"", ",", "len", "(", "self", ".", "rdflib_graph", ")", ")", "for", "x", ",", "y", ",", "z", "in", "self", ".", "rdflib_graph", ":", "print", "(", "x", ",", "y", ",", "z", ...
internal util to print out contents of graph
[ "internal", "util", "to", "print", "out", "contents", "of", "graph" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/rdf_loader.py#L61-L65
train
lambdamusic/Ontospy
ontospy/core/rdf_loader.py
RDFLoader.load_uri
def load_uri(self, uri): """ Load a single resource into the graph for this object. Approach: try loading into a temporary graph first, if that succeeds merge it into the main graph. This allows to deal with the JSONLD loading issues which can solved only by using a ConjunctiveGraph (https://...
python
def load_uri(self, uri): """ Load a single resource into the graph for this object. Approach: try loading into a temporary graph first, if that succeeds merge it into the main graph. This allows to deal with the JSONLD loading issues which can solved only by using a ConjunctiveGraph (https://...
[ "def", "load_uri", "(", "self", ",", "uri", ")", ":", "if", "self", ".", "verbose", ":", "printDebug", "(", "\"Reading: <%s>\"", "%", "uri", ",", "fg", "=", "\"green\"", ")", "success", "=", "False", "sorted_fmt_opts", "=", "try_sort_fmt_opts", "(", "self"...
Load a single resource into the graph for this object. Approach: try loading into a temporary graph first, if that succeeds merge it into the main graph. This allows to deal with the JSONLD loading issues which can solved only by using a ConjunctiveGraph (https://github.com/RDFLib/rdflib/issues/436). Also it...
[ "Load", "a", "single", "resource", "into", "the", "graph", "for", "this", "object", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/rdf_loader.py#L114-L158
train
lambdamusic/Ontospy
ontospy/core/rdf_loader.py
RDFLoader.print_summary
def print_summary(self): """ print out stats about loading operation """ if self.sources_valid: printDebug( "----------\nLoaded %d triples.\n----------" % len( self.rdflib_graph), fg='white') printDebug( ...
python
def print_summary(self): """ print out stats about loading operation """ if self.sources_valid: printDebug( "----------\nLoaded %d triples.\n----------" % len( self.rdflib_graph), fg='white') printDebug( ...
[ "def", "print_summary", "(", "self", ")", ":", "if", "self", ".", "sources_valid", ":", "printDebug", "(", "\"----------\\nLoaded %d triples.\\n----------\"", "%", "len", "(", "self", ".", "rdflib_graph", ")", ",", "fg", "=", "'white'", ")", "printDebug", "(", ...
print out stats about loading operation
[ "print", "out", "stats", "about", "loading", "operation" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/rdf_loader.py#L225-L251
train
lambdamusic/Ontospy
ontospy/core/rdf_loader.py
RDFLoader.loading_failed
def loading_failed(self, rdf_format_opts, uri=""): """default message if we need to abort loading""" if uri: uri = " <%s>" % str(uri) printDebug( "----------\nFatal error parsing graph%s\n(using RDF serializations: %s)" % (uri, str(rdf_format_opts)), "red") ...
python
def loading_failed(self, rdf_format_opts, uri=""): """default message if we need to abort loading""" if uri: uri = " <%s>" % str(uri) printDebug( "----------\nFatal error parsing graph%s\n(using RDF serializations: %s)" % (uri, str(rdf_format_opts)), "red") ...
[ "def", "loading_failed", "(", "self", ",", "rdf_format_opts", ",", "uri", "=", "\"\"", ")", ":", "if", "uri", ":", "uri", "=", "\" <%s>\"", "%", "str", "(", "uri", ")", "printDebug", "(", "\"----------\\nFatal error parsing graph%s\\n(using RDF serializations: %s)\"...
default message if we need to abort loading
[ "default", "message", "if", "we", "need", "to", "abort", "loading" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/rdf_loader.py#L253-L264
train
lambdamusic/Ontospy
ontospy/core/entities.py
RDF_Entity._build_qname
def _build_qname(self, uri=None, namespaces=None): """ extracts a qualified name for a uri """ if not uri: uri = self.uri if not namespaces: namespaces = self.namespaces return uri2niceString(uri, namespaces)
python
def _build_qname(self, uri=None, namespaces=None): """ extracts a qualified name for a uri """ if not uri: uri = self.uri if not namespaces: namespaces = self.namespaces return uri2niceString(uri, namespaces)
[ "def", "_build_qname", "(", "self", ",", "uri", "=", "None", ",", "namespaces", "=", "None", ")", ":", "if", "not", "uri", ":", "uri", "=", "self", ".", "uri", "if", "not", "namespaces", ":", "namespaces", "=", "self", ".", "namespaces", "return", "u...
extracts a qualified name for a uri
[ "extracts", "a", "qualified", "name", "for", "a", "uri" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/entities.py#L93-L99
train
lambdamusic/Ontospy
ontospy/core/entities.py
RDF_Entity.ancestors
def ancestors(self, cl=None, noduplicates=True): """ returns all ancestors in the taxonomy """ if not cl: cl = self if cl.parents(): bag = [] for x in cl.parents(): if x.uri != cl.uri: # avoid circular relationships bag += ...
python
def ancestors(self, cl=None, noduplicates=True): """ returns all ancestors in the taxonomy """ if not cl: cl = self if cl.parents(): bag = [] for x in cl.parents(): if x.uri != cl.uri: # avoid circular relationships bag += ...
[ "def", "ancestors", "(", "self", ",", "cl", "=", "None", ",", "noduplicates", "=", "True", ")", ":", "if", "not", "cl", ":", "cl", "=", "self", "if", "cl", ".", "parents", "(", ")", ":", "bag", "=", "[", "]", "for", "x", "in", "cl", ".", "par...
returns all ancestors in the taxonomy
[ "returns", "all", "ancestors", "in", "the", "taxonomy" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/entities.py#L114-L131
train
lambdamusic/Ontospy
ontospy/core/entities.py
RDF_Entity.descendants
def descendants(self, cl=None, noduplicates=True): """ returns all descendants in the taxonomy """ if not cl: cl = self if cl.children(): bag = [] for x in cl.children(): if x.uri != cl.uri: # avoid circular relationships b...
python
def descendants(self, cl=None, noduplicates=True): """ returns all descendants in the taxonomy """ if not cl: cl = self if cl.children(): bag = [] for x in cl.children(): if x.uri != cl.uri: # avoid circular relationships b...
[ "def", "descendants", "(", "self", ",", "cl", "=", "None", ",", "noduplicates", "=", "True", ")", ":", "if", "not", "cl", ":", "cl", "=", "self", "if", "cl", ".", "children", "(", ")", ":", "bag", "=", "[", "]", "for", "x", "in", "cl", ".", "...
returns all descendants in the taxonomy
[ "returns", "all", "descendants", "in", "the", "taxonomy" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/entities.py#L133-L150
train
lambdamusic/Ontospy
ontospy/core/entities.py
Ontology.annotations
def annotations(self, qname=True): """ wrapper that returns all triples for an onto. By default resources URIs are transformed into qnames """ if qname: return sorted([(uri2niceString(x, self.namespaces) ), (uri2niceString(y, self.namespace...
python
def annotations(self, qname=True): """ wrapper that returns all triples for an onto. By default resources URIs are transformed into qnames """ if qname: return sorted([(uri2niceString(x, self.namespaces) ), (uri2niceString(y, self.namespace...
[ "def", "annotations", "(", "self", ",", "qname", "=", "True", ")", ":", "if", "qname", ":", "return", "sorted", "(", "[", "(", "uri2niceString", "(", "x", ",", "self", ".", "namespaces", ")", ")", ",", "(", "uri2niceString", "(", "y", ",", "self", ...
wrapper that returns all triples for an onto. By default resources URIs are transformed into qnames
[ "wrapper", "that", "returns", "all", "triples", "for", "an", "onto", ".", "By", "default", "resources", "URIs", "are", "transformed", "into", "qnames" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/entities.py#L243-L253
train
lambdamusic/Ontospy
ontospy/core/entities.py
OntoClass.printStats
def printStats(self): """ shortcut to pull out useful info for interactive use """ printDebug("----------------") printDebug("Parents......: %d" % len(self.parents())) printDebug("Children.....: %d" % len(self.children())) printDebug("Ancestors....: %d" % len(self.ancestors())) ...
python
def printStats(self): """ shortcut to pull out useful info for interactive use """ printDebug("----------------") printDebug("Parents......: %d" % len(self.parents())) printDebug("Children.....: %d" % len(self.children())) printDebug("Ancestors....: %d" % len(self.ancestors())) ...
[ "def", "printStats", "(", "self", ")", ":", "printDebug", "(", "\"----------------\"", ")", "printDebug", "(", "\"Parents......: %d\"", "%", "len", "(", "self", ".", "parents", "(", ")", ")", ")", "printDebug", "(", "\"Children.....: %d\"", "%", "len", "(", ...
shortcut to pull out useful info for interactive use
[ "shortcut", "to", "pull", "out", "useful", "info", "for", "interactive", "use" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/entities.py#L325-L335
train
lambdamusic/Ontospy
ontospy/core/ontospy.py
Ontospy.load_sparql
def load_sparql(self, sparql_endpoint, verbose=False, hide_base_schemas=True, hide_implicit_types=True, hide_implicit_preds=True, credentials=None): """ Set up a SPARQLStore backend as a virtual ontospy g...
python
def load_sparql(self, sparql_endpoint, verbose=False, hide_base_schemas=True, hide_implicit_types=True, hide_implicit_preds=True, credentials=None): """ Set up a SPARQLStore backend as a virtual ontospy g...
[ "def", "load_sparql", "(", "self", ",", "sparql_endpoint", ",", "verbose", "=", "False", ",", "hide_base_schemas", "=", "True", ",", "hide_implicit_types", "=", "True", ",", "hide_implicit_preds", "=", "True", ",", "credentials", "=", "None", ")", ":", "try", ...
Set up a SPARQLStore backend as a virtual ontospy graph Note: we're using a 'SPARQLUpdateStore' backend instead of 'SPARQLStore' cause otherwise authentication fails (https://github.com/RDFLib/rdflib/issues/755) @TODO this error seems to be fixed in upcoming rdflib versions https://github.com/...
[ "Set", "up", "a", "SPARQLStore", "backend", "as", "a", "virtual", "ontospy", "graph" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/ontospy.py#L144-L177
train
lambdamusic/Ontospy
ontospy/core/ontospy.py
Ontospy.build_all
def build_all(self, verbose=False, hide_base_schemas=True, hide_implicit_types=True, hide_implicit_preds=True): """ Extract all ontology entities from an RDF graph and construct Python representations of them. """ if...
python
def build_all(self, verbose=False, hide_base_schemas=True, hide_implicit_types=True, hide_implicit_preds=True): """ Extract all ontology entities from an RDF graph and construct Python representations of them. """ if...
[ "def", "build_all", "(", "self", ",", "verbose", "=", "False", ",", "hide_base_schemas", "=", "True", ",", "hide_implicit_types", "=", "True", ",", "hide_implicit_preds", "=", "True", ")", ":", "if", "verbose", ":", "printDebug", "(", "\"Scanning entities...\"",...
Extract all ontology entities from an RDF graph and construct Python representations of them.
[ "Extract", "all", "ontology", "entities", "from", "an", "RDF", "graph", "and", "construct", "Python", "representations", "of", "them", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/ontospy.py#L185-L228
train
lambdamusic/Ontospy
ontospy/core/ontospy.py
Ontospy.build_ontologies
def build_ontologies(self, exclude_BNodes=False, return_string=False): """ Extract ontology instances info from the graph, then creates python objects for them. Note: often ontology info is nested in structures like this: [ a owl:Ontology ; vann:preferredNamespacePrefix "bs...
python
def build_ontologies(self, exclude_BNodes=False, return_string=False): """ Extract ontology instances info from the graph, then creates python objects for them. Note: often ontology info is nested in structures like this: [ a owl:Ontology ; vann:preferredNamespacePrefix "bs...
[ "def", "build_ontologies", "(", "self", ",", "exclude_BNodes", "=", "False", ",", "return_string", "=", "False", ")", ":", "out", "=", "[", "]", "qres", "=", "self", ".", "sparqlHelper", ".", "getOntology", "(", ")", "if", "qres", ":", "for", "candidate"...
Extract ontology instances info from the graph, then creates python objects for them. Note: often ontology info is nested in structures like this: [ a owl:Ontology ; vann:preferredNamespacePrefix "bsym" ; vann:preferredNamespaceUri "http://bsym.bloomberg.com/sym/" ] He...
[ "Extract", "ontology", "instances", "info", "from", "the", "graph", "then", "creates", "python", "objects", "for", "them", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/ontospy.py#L230-L286
train
lambdamusic/Ontospy
ontospy/core/ontospy.py
Ontospy.build_entity_from_uri
def build_entity_from_uri(self, uri, ontospyClass=None): """ Extract RDF statements having a URI as subject, then instantiate the RDF_Entity Python object so that it can be queried further. Passing <ontospyClass> allows to instantiate a user-defined RDF_Entity subclass. NOTE: the entit...
python
def build_entity_from_uri(self, uri, ontospyClass=None): """ Extract RDF statements having a URI as subject, then instantiate the RDF_Entity Python object so that it can be queried further. Passing <ontospyClass> allows to instantiate a user-defined RDF_Entity subclass. NOTE: the entit...
[ "def", "build_entity_from_uri", "(", "self", ",", "uri", ",", "ontospyClass", "=", "None", ")", ":", "if", "not", "ontospyClass", ":", "ontospyClass", "=", "RDF_Entity", "elif", "not", "issubclass", "(", "ontospyClass", ",", "RDF_Entity", ")", ":", "click", ...
Extract RDF statements having a URI as subject, then instantiate the RDF_Entity Python object so that it can be queried further. Passing <ontospyClass> allows to instantiate a user-defined RDF_Entity subclass. NOTE: the entity is not attached to any index. In future version we may create an index for ...
[ "Extract", "RDF", "statements", "having", "a", "URI", "as", "subject", "then", "instantiate", "the", "RDF_Entity", "Python", "object", "so", "that", "it", "can", "be", "queried", "further", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/ontospy.py#L561-L588
train
lambdamusic/Ontospy
ontospy/core/ontospy.py
Ontospy.printClassTree
def printClassTree(self, element=None, showids=False, labels=False, showtype=False): """ Print nicely into stdout the class tree of an ontology Note: indentation is made so that ids up to 3 digits fit in, plus a space. [123]1-- [1]123-- [12]12-- """ TYPE_...
python
def printClassTree(self, element=None, showids=False, labels=False, showtype=False): """ Print nicely into stdout the class tree of an ontology Note: indentation is made so that ids up to 3 digits fit in, plus a space. [123]1-- [1]123-- [12]12-- """ TYPE_...
[ "def", "printClassTree", "(", "self", ",", "element", "=", "None", ",", "showids", "=", "False", ",", "labels", "=", "False", ",", "showtype", "=", "False", ")", ":", "TYPE_MARGIN", "=", "11", "if", "not", "element", ":", "for", "x", "in", "self", "....
Print nicely into stdout the class tree of an ontology Note: indentation is made so that ids up to 3 digits fit in, plus a space. [123]1-- [1]123-- [12]12--
[ "Print", "nicely", "into", "stdout", "the", "class", "tree", "of", "an", "ontology" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/ontospy.py#L1073-L1089
train
lambdamusic/Ontospy
ontospy/core/ontospy.py
Ontospy.printPropertyTree
def printPropertyTree(self, element=None, showids=False, labels=False, showtype=False): """ Print nicely into stdout the property tree of an ontology Note: indentation is made so that ids up to 3 digits fit in, plus a space. [123]1-- [1]123-- [12]12-- """ ...
python
def printPropertyTree(self, element=None, showids=False, labels=False, showtype=False): """ Print nicely into stdout the property tree of an ontology Note: indentation is made so that ids up to 3 digits fit in, plus a space. [123]1-- [1]123-- [12]12-- """ ...
[ "def", "printPropertyTree", "(", "self", ",", "element", "=", "None", ",", "showids", "=", "False", ",", "labels", "=", "False", ",", "showtype", "=", "False", ")", ":", "TYPE_MARGIN", "=", "18", "if", "not", "element", ":", "for", "x", "in", "self", ...
Print nicely into stdout the property tree of an ontology Note: indentation is made so that ids up to 3 digits fit in, plus a space. [123]1-- [1]123-- [12]12--
[ "Print", "nicely", "into", "stdout", "the", "property", "tree", "of", "an", "ontology" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/ontospy.py#L1091-L1107
train
lambdamusic/Ontospy
ontospy/extras/hacks/sketch.py
Sketch.add
def add(self, text="", default_continuousAdd=True): """add some turtle text""" if not text and default_continuousAdd: self.continuousAdd() else: pprefix = "" for x,y in self.rdflib_graph.namespaces(): pprefix += "@prefix %s: <%s> . \n" % (x, y) # add final . if missing if text and (not text.str...
python
def add(self, text="", default_continuousAdd=True): """add some turtle text""" if not text and default_continuousAdd: self.continuousAdd() else: pprefix = "" for x,y in self.rdflib_graph.namespaces(): pprefix += "@prefix %s: <%s> . \n" % (x, y) # add final . if missing if text and (not text.str...
[ "def", "add", "(", "self", ",", "text", "=", "\"\"", ",", "default_continuousAdd", "=", "True", ")", ":", "if", "not", "text", "and", "default_continuousAdd", ":", "self", ".", "continuousAdd", "(", ")", "else", ":", "pprefix", "=", "\"\"", "for", "x", ...
add some turtle text
[ "add", "some", "turtle", "text" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/hacks/sketch.py#L79-L94
train
lambdamusic/Ontospy
ontospy/extras/hacks/sketch.py
Sketch.rdf_source
def rdf_source(self, aformat="turtle"): """ Serialize graph using the format required """ if aformat and aformat not in self.SUPPORTED_FORMATS: return "Sorry. Allowed formats are %s" % str(self.SUPPORTED_FORMATS) if aformat == "dot": return self.__serializedDot() else: # use stardard rdf serializat...
python
def rdf_source(self, aformat="turtle"): """ Serialize graph using the format required """ if aformat and aformat not in self.SUPPORTED_FORMATS: return "Sorry. Allowed formats are %s" % str(self.SUPPORTED_FORMATS) if aformat == "dot": return self.__serializedDot() else: # use stardard rdf serializat...
[ "def", "rdf_source", "(", "self", ",", "aformat", "=", "\"turtle\"", ")", ":", "if", "aformat", "and", "aformat", "not", "in", "self", ".", "SUPPORTED_FORMATS", ":", "return", "\"Sorry. Allowed formats are %s\"", "%", "str", "(", "self", ".", "SUPPORTED_FORMATS"...
Serialize graph using the format required
[ "Serialize", "graph", "using", "the", "format", "required" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/hacks/sketch.py#L122-L132
train
lambdamusic/Ontospy
ontospy/extras/hacks/sketch.py
Sketch.omnigraffle
def omnigraffle(self): """ tries to open an export directly in omnigraffle """ temp = self.rdf_source("dot") try: # try to put in the user/tmp folder from os.path import expanduser home = expanduser("~") filename = home + "/tmp/turtle_sketch.dot" f = open(filename, "w") except: filename = "turt...
python
def omnigraffle(self): """ tries to open an export directly in omnigraffle """ temp = self.rdf_source("dot") try: # try to put in the user/tmp folder from os.path import expanduser home = expanduser("~") filename = home + "/tmp/turtle_sketch.dot" f = open(filename, "w") except: filename = "turt...
[ "def", "omnigraffle", "(", "self", ")", ":", "temp", "=", "self", ".", "rdf_source", "(", "\"dot\"", ")", "try", ":", "from", "os", ".", "path", "import", "expanduser", "home", "=", "expanduser", "(", "\"~\"", ")", "filename", "=", "home", "+", "\"/tmp...
tries to open an export directly in omnigraffle
[ "tries", "to", "open", "an", "export", "directly", "in", "omnigraffle" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/hacks/sketch.py#L149-L166
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
main
def main(): """ standalone line script """ print("Ontospy " + VERSION) Shell()._clear_screen() print(Style.BRIGHT + "** Ontospy Interactive Ontology Browser " + VERSION + " **" + Style.RESET_ALL) # manager.get_or_create_home_repo() Shell().cmdloop() raise SystemExit(1)
python
def main(): """ standalone line script """ print("Ontospy " + VERSION) Shell()._clear_screen() print(Style.BRIGHT + "** Ontospy Interactive Ontology Browser " + VERSION + " **" + Style.RESET_ALL) # manager.get_or_create_home_repo() Shell().cmdloop() raise SystemExit(1)
[ "def", "main", "(", ")", ":", "print", "(", "\"Ontospy \"", "+", "VERSION", ")", "Shell", "(", ")", ".", "_clear_screen", "(", ")", "print", "(", "Style", ".", "BRIGHT", "+", "\"** Ontospy Interactive Ontology Browser \"", "+", "VERSION", "+", "\" **\"", "+"...
standalone line script
[ "standalone", "line", "script" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L1319-L1328
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell._print
def _print(self, ms, style="TIP"): """ abstraction for managing color printing """ styles1 = {'IMPORTANT': Style.BRIGHT, 'TIP': Style.DIM, 'URI': Style.BRIGHT, 'TEXT': Fore.GREEN, 'MAGENTA': Fore.MAGENTA, 'BLU...
python
def _print(self, ms, style="TIP"): """ abstraction for managing color printing """ styles1 = {'IMPORTANT': Style.BRIGHT, 'TIP': Style.DIM, 'URI': Style.BRIGHT, 'TEXT': Fore.GREEN, 'MAGENTA': Fore.MAGENTA, 'BLU...
[ "def", "_print", "(", "self", ",", "ms", ",", "style", "=", "\"TIP\"", ")", ":", "styles1", "=", "{", "'IMPORTANT'", ":", "Style", ".", "BRIGHT", ",", "'TIP'", ":", "Style", ".", "DIM", ",", "'URI'", ":", "Style", ".", "BRIGHT", ",", "'TEXT'", ":",...
abstraction for managing color printing
[ "abstraction", "for", "managing", "color", "printing" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L157-L172
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell._printM
def _printM(self, messages): """print a list of strings - for the mom used only by stats printout""" if len(messages) == 2: print(Style.BRIGHT + messages[0] + Style.RESET_ALL + Fore.BLUE + messages[1] + Style.RESET_ALL) else: print("Not implemented")
python
def _printM(self, messages): """print a list of strings - for the mom used only by stats printout""" if len(messages) == 2: print(Style.BRIGHT + messages[0] + Style.RESET_ALL + Fore.BLUE + messages[1] + Style.RESET_ALL) else: print("Not implemented")
[ "def", "_printM", "(", "self", ",", "messages", ")", ":", "if", "len", "(", "messages", ")", "==", "2", ":", "print", "(", "Style", ".", "BRIGHT", "+", "messages", "[", "0", "]", "+", "Style", ".", "RESET_ALL", "+", "Fore", ".", "BLUE", "+", "mes...
print a list of strings - for the mom used only by stats printout
[ "print", "a", "list", "of", "strings", "-", "for", "the", "mom", "used", "only", "by", "stats", "printout" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L174-L180
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell._printDescription
def _printDescription(self, hrlinetop=True): """generic method to print out a description""" if hrlinetop: self._print("----------------") NOTFOUND = "[not found]" if self.currentEntity: obj = self.currentEntity['object'] label = obj.bestLabel() or NOT...
python
def _printDescription(self, hrlinetop=True): """generic method to print out a description""" if hrlinetop: self._print("----------------") NOTFOUND = "[not found]" if self.currentEntity: obj = self.currentEntity['object'] label = obj.bestLabel() or NOT...
[ "def", "_printDescription", "(", "self", ",", "hrlinetop", "=", "True", ")", ":", "if", "hrlinetop", ":", "self", ".", "_print", "(", "\"----------------\"", ")", "NOTFOUND", "=", "\"[not found]\"", "if", "self", ".", "currentEntity", ":", "obj", "=", "self"...
generic method to print out a description
[ "generic", "method", "to", "print", "out", "a", "description" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L240-L274
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell._next_ontology
def _next_ontology(self): """Dynamically retrieves the next ontology in the list""" currentfile = self.current['file'] try: idx = self.all_ontologies.index(currentfile) return self.all_ontologies[idx+1] except: return self.all_ontologies[0]
python
def _next_ontology(self): """Dynamically retrieves the next ontology in the list""" currentfile = self.current['file'] try: idx = self.all_ontologies.index(currentfile) return self.all_ontologies[idx+1] except: return self.all_ontologies[0]
[ "def", "_next_ontology", "(", "self", ")", ":", "currentfile", "=", "self", ".", "current", "[", "'file'", "]", "try", ":", "idx", "=", "self", ".", "all_ontologies", ".", "index", "(", "currentfile", ")", "return", "self", ".", "all_ontologies", "[", "i...
Dynamically retrieves the next ontology in the list
[ "Dynamically", "retrieves", "the", "next", "ontology", "in", "the", "list" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L519-L526
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell._load_ontology
def _load_ontology(self, filename, preview_mode=False): """ Loads an ontology Unless preview_mode=True, it is always loaded from the local repository note: if the ontology does not have a cached version, it is created preview_mode: used to pass a URI/path to be inspected withou...
python
def _load_ontology(self, filename, preview_mode=False): """ Loads an ontology Unless preview_mode=True, it is always loaded from the local repository note: if the ontology does not have a cached version, it is created preview_mode: used to pass a URI/path to be inspected withou...
[ "def", "_load_ontology", "(", "self", ",", "filename", ",", "preview_mode", "=", "False", ")", ":", "if", "not", "preview_mode", ":", "fullpath", "=", "self", ".", "LOCAL_MODELS", "+", "filename", "g", "=", "manager", ".", "get_pickled_ontology", "(", "filen...
Loads an ontology Unless preview_mode=True, it is always loaded from the local repository note: if the ontology does not have a cached version, it is created preview_mode: used to pass a URI/path to be inspected without saving it locally
[ "Loads", "an", "ontology" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L531-L551
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell._select_property
def _select_property(self, line): """try to match a property and load it""" g = self.current['graph'] if not line: out = g.all_properties using_pattern = False else: using_pattern = True if line.isdigit(): line = int(line) ...
python
def _select_property(self, line): """try to match a property and load it""" g = self.current['graph'] if not line: out = g.all_properties using_pattern = False else: using_pattern = True if line.isdigit(): line = int(line) ...
[ "def", "_select_property", "(", "self", ",", "line", ")", ":", "g", "=", "self", ".", "current", "[", "'graph'", "]", "if", "not", "line", ":", "out", "=", "g", ".", "all_properties", "using_pattern", "=", "False", "else", ":", "using_pattern", "=", "T...
try to match a property and load it
[ "try", "to", "match", "a", "property", "and", "load", "it" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L597-L623
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell._select_concept
def _select_concept(self, line): """try to match a class and load it""" g = self.current['graph'] if not line: out = g.all_skos_concepts using_pattern = False else: using_pattern = True if line.isdigit(): line = int(line) ...
python
def _select_concept(self, line): """try to match a class and load it""" g = self.current['graph'] if not line: out = g.all_skos_concepts using_pattern = False else: using_pattern = True if line.isdigit(): line = int(line) ...
[ "def", "_select_concept", "(", "self", ",", "line", ")", ":", "g", "=", "self", ".", "current", "[", "'graph'", "]", "if", "not", "line", ":", "out", "=", "g", ".", "all_skos_concepts", "using_pattern", "=", "False", "else", ":", "using_pattern", "=", ...
try to match a class and load it
[ "try", "to", "match", "a", "class", "and", "load", "it" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L625-L650
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell.do_visualize
def do_visualize(self, line): """Visualize an ontology - ie wrapper for export command""" if not self.current: self._help_noontology() return line = line.split() try: # from ..viz.builder import action_visualize from ..ontodocs.builder i...
python
def do_visualize(self, line): """Visualize an ontology - ie wrapper for export command""" if not self.current: self._help_noontology() return line = line.split() try: # from ..viz.builder import action_visualize from ..ontodocs.builder i...
[ "def", "do_visualize", "(", "self", ",", "line", ")", ":", "if", "not", "self", ".", "current", ":", "self", ".", "_help_noontology", "(", ")", "return", "line", "=", "line", ".", "split", "(", ")", "try", ":", "from", ".", ".", "ontodocs", ".", "b...
Visualize an ontology - ie wrapper for export command
[ "Visualize", "an", "ontology", "-", "ie", "wrapper", "for", "export", "command" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L964-L984
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell.do_import
def do_import(self, line): """Import an ontology""" line = line.split() if line and line[0] == "starter-pack": actions.action_bootstrap() elif line and line[0] == "uri": self._print( "------------------\nEnter a valid graph URI: (e.g. http://www...
python
def do_import(self, line): """Import an ontology""" line = line.split() if line and line[0] == "starter-pack": actions.action_bootstrap() elif line and line[0] == "uri": self._print( "------------------\nEnter a valid graph URI: (e.g. http://www...
[ "def", "do_import", "(", "self", ",", "line", ")", ":", "line", "=", "line", ".", "split", "(", ")", "if", "line", "and", "line", "[", "0", "]", "==", "\"starter-pack\"", ":", "actions", ".", "action_bootstrap", "(", ")", "elif", "line", "and", "line...
Import an ontology
[ "Import", "an", "ontology" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L986-L1026
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell.do_file
def do_file(self, line): """PErform some file operation""" opts = self.FILE_OPTS if not self.all_ontologies: self._help_nofiles() return line = line.split() if not line or line[0] not in opts: self.help_file() return if ...
python
def do_file(self, line): """PErform some file operation""" opts = self.FILE_OPTS if not self.all_ontologies: self._help_nofiles() return line = line.split() if not line or line[0] not in opts: self.help_file() return if ...
[ "def", "do_file", "(", "self", ",", "line", ")", ":", "opts", "=", "self", ".", "FILE_OPTS", "if", "not", "self", ".", "all_ontologies", ":", "self", ".", "_help_nofiles", "(", ")", "return", "line", "=", "line", ".", "split", "(", ")", "if", "not", ...
PErform some file operation
[ "PErform", "some", "file", "operation" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L1028-L1047
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell.do_serialize
def do_serialize(self, line): """Serialize an entity into an RDF flavour""" opts = self.SERIALIZE_OPTS if not self.current: self._help_noontology() return line = line.split() g = self.current['graph'] if not line: line = ['turtle'] ...
python
def do_serialize(self, line): """Serialize an entity into an RDF flavour""" opts = self.SERIALIZE_OPTS if not self.current: self._help_noontology() return line = line.split() g = self.current['graph'] if not line: line = ['turtle'] ...
[ "def", "do_serialize", "(", "self", ",", "line", ")", ":", "opts", "=", "self", ".", "SERIALIZE_OPTS", "if", "not", "self", ".", "current", ":", "self", ".", "_help_noontology", "(", ")", "return", "line", "=", "line", ".", "split", "(", ")", "g", "=...
Serialize an entity into an RDF flavour
[ "Serialize", "an", "entity", "into", "an", "RDF", "flavour" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L1049-L1071
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell.do_back
def do_back(self, line): "Go back one step. From entity => ontology; from ontology => ontospy top level." if self.currentEntity: self.currentEntity = None self.prompt = _get_prompt(self.current['file']) else: self.current = None self.prompt = _get_...
python
def do_back(self, line): "Go back one step. From entity => ontology; from ontology => ontospy top level." if self.currentEntity: self.currentEntity = None self.prompt = _get_prompt(self.current['file']) else: self.current = None self.prompt = _get_...
[ "def", "do_back", "(", "self", ",", "line", ")", ":", "\"Go back one step. From entity => ontology; from ontology => ontospy top level.\"", "if", "self", ".", "currentEntity", ":", "self", ".", "currentEntity", "=", "None", "self", ".", "prompt", "=", "_get_prompt", "...
Go back one step. From entity => ontology; from ontology => ontospy top level.
[ "Go", "back", "one", "step", ".", "From", "entity", "=", ">", "ontology", ";", "from", "ontology", "=", ">", "ontospy", "top", "level", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L1100-L1107
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell.do_zen
def do_zen(self, line): """Inspiring quotes for the working ontologist""" _quote = random.choice(QUOTES) # print(_quote['source']) print(Style.DIM + unicode(_quote['text'])) print(Style.BRIGHT + unicode(_quote['source']) + Style.RESET_ALL)
python
def do_zen(self, line): """Inspiring quotes for the working ontologist""" _quote = random.choice(QUOTES) # print(_quote['source']) print(Style.DIM + unicode(_quote['text'])) print(Style.BRIGHT + unicode(_quote['source']) + Style.RESET_ALL)
[ "def", "do_zen", "(", "self", ",", "line", ")", ":", "_quote", "=", "random", ".", "choice", "(", "QUOTES", ")", "print", "(", "Style", ".", "DIM", "+", "unicode", "(", "_quote", "[", "'text'", "]", ")", ")", "print", "(", "Style", ".", "BRIGHT", ...
Inspiring quotes for the working ontologist
[ "Inspiring", "quotes", "for", "the", "working", "ontologist" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L1114-L1119
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell.complete_get
def complete_get(self, text, line, begidx, endidx): """completion for find command""" options = self.GET_OPTS if not text: completions = options else: completions = [f for f in options if f.startswith(text) ...
python
def complete_get(self, text, line, begidx, endidx): """completion for find command""" options = self.GET_OPTS if not text: completions = options else: completions = [f for f in options if f.startswith(text) ...
[ "def", "complete_get", "(", "self", ",", "text", ",", "line", ",", "begidx", ",", "endidx", ")", ":", "options", "=", "self", ".", "GET_OPTS", "if", "not", "text", ":", "completions", "=", "options", "else", ":", "completions", "=", "[", "f", "for", ...
completion for find command
[ "completion", "for", "find", "command" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L1234-L1246
train
lambdamusic/Ontospy
ontospy/extras/shell_lib.py
Shell.complete_info
def complete_info(self, text, line, begidx, endidx): """completion for info command""" opts = self.INFO_OPTS if not text: completions = opts else: completions = [f for f in opts if f.startswith(text) ...
python
def complete_info(self, text, line, begidx, endidx): """completion for info command""" opts = self.INFO_OPTS if not text: completions = opts else: completions = [f for f in opts if f.startswith(text) ...
[ "def", "complete_info", "(", "self", ",", "text", ",", "line", ",", "begidx", ",", "endidx", ")", ":", "opts", "=", "self", ".", "INFO_OPTS", "if", "not", "text", ":", "completions", "=", "opts", "else", ":", "completions", "=", "[", "f", "for", "f",...
completion for info command
[ "completion", "for", "info", "command" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/shell_lib.py#L1248-L1260
train
lambdamusic/Ontospy
ontospy/ontodocs/utils.py
build_D3treeStandard
def build_D3treeStandard(old, MAX_DEPTH, level=1, toplayer=None): """ For d3s examples all we need is a json with name, children and size .. eg { "name": "flare", "children": [ { "name": "analytics", "children": [ { "name": "cluster", "children": [ {"name": "AgglomerativeCluster", ...
python
def build_D3treeStandard(old, MAX_DEPTH, level=1, toplayer=None): """ For d3s examples all we need is a json with name, children and size .. eg { "name": "flare", "children": [ { "name": "analytics", "children": [ { "name": "cluster", "children": [ {"name": "AgglomerativeCluster", ...
[ "def", "build_D3treeStandard", "(", "old", ",", "MAX_DEPTH", ",", "level", "=", "1", ",", "toplayer", "=", "None", ")", ":", "out", "=", "[", "]", "if", "not", "old", ":", "old", "=", "toplayer", "for", "x", "in", "old", ":", "d", "=", "{", "}", ...
For d3s examples all we need is a json with name, children and size .. eg { "name": "flare", "children": [ { "name": "analytics", "children": [ { "name": "cluster", "children": [ {"name": "AgglomerativeCluster", "size": 3938}, {"name": "CommunityStructure", "size": 3812}, {"name":...
[ "For", "d3s", "examples", "all", "we", "need", "is", "a", "json", "with", "name", "children", "and", "size", "..", "eg" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/utils.py#L11-L51
train
lambdamusic/Ontospy
ontospy/ontodocs/utils.py
build_D3bubbleChart
def build_D3bubbleChart(old, MAX_DEPTH, level=1, toplayer=None): """ Similar to standar d3, but nodes with children need to be duplicated otherwise they are not depicted explicitly but just color coded "name": "all", "children": [ {"name": "Biological Science", "size": 9000}, {"name": "Biological Sci...
python
def build_D3bubbleChart(old, MAX_DEPTH, level=1, toplayer=None): """ Similar to standar d3, but nodes with children need to be duplicated otherwise they are not depicted explicitly but just color coded "name": "all", "children": [ {"name": "Biological Science", "size": 9000}, {"name": "Biological Sci...
[ "def", "build_D3bubbleChart", "(", "old", ",", "MAX_DEPTH", ",", "level", "=", "1", ",", "toplayer", "=", "None", ")", ":", "out", "=", "[", "]", "if", "not", "old", ":", "old", "=", "toplayer", "for", "x", "in", "old", ":", "d", "=", "{", "}", ...
Similar to standar d3, but nodes with children need to be duplicated otherwise they are not depicted explicitly but just color coded "name": "all", "children": [ {"name": "Biological Science", "size": 9000}, {"name": "Biological Science", "children": [ {"name": "Biological techniques", "size": 6939}, ...
[ "Similar", "to", "standar", "d3", "but", "nodes", "with", "children", "need", "to", "be", "duplicated", "otherwise", "they", "are", "not", "depicted", "explicitly", "but", "just", "color", "coded" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/utils.py#L63-L113
train
lambdamusic/Ontospy
ontospy/ontodocs/viz_factory.py
VizFactory.infer_best_title
def infer_best_title(self): """Selects something usable as a title for an ontospy graph""" if self.ontospy_graph.all_ontologies: return self.ontospy_graph.all_ontologies[0].uri elif self.ontospy_graph.sources: return self.ontospy_graph.sources[0] else: ...
python
def infer_best_title(self): """Selects something usable as a title for an ontospy graph""" if self.ontospy_graph.all_ontologies: return self.ontospy_graph.all_ontologies[0].uri elif self.ontospy_graph.sources: return self.ontospy_graph.sources[0] else: ...
[ "def", "infer_best_title", "(", "self", ")", ":", "if", "self", ".", "ontospy_graph", ".", "all_ontologies", ":", "return", "self", ".", "ontospy_graph", ".", "all_ontologies", "[", "0", "]", ".", "uri", "elif", "self", ".", "ontospy_graph", ".", "sources", ...
Selects something usable as a title for an ontospy graph
[ "Selects", "something", "usable", "as", "a", "title", "for", "an", "ontospy", "graph" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/viz_factory.py#L73-L80
train
lambdamusic/Ontospy
ontospy/ontodocs/viz_factory.py
VizFactory.build
def build(self, output_path=""): """method that should be inherited by all vis classes""" self.output_path = self.checkOutputPath(output_path) self._buildStaticFiles() self.final_url = self._buildTemplates() printDebug("Done.", "comment") printDebug("=> %s" % (self.final...
python
def build(self, output_path=""): """method that should be inherited by all vis classes""" self.output_path = self.checkOutputPath(output_path) self._buildStaticFiles() self.final_url = self._buildTemplates() printDebug("Done.", "comment") printDebug("=> %s" % (self.final...
[ "def", "build", "(", "self", ",", "output_path", "=", "\"\"", ")", ":", "self", ".", "output_path", "=", "self", ".", "checkOutputPath", "(", "output_path", ")", "self", ".", "_buildStaticFiles", "(", ")", "self", ".", "final_url", "=", "self", ".", "_bu...
method that should be inherited by all vis classes
[ "method", "that", "should", "be", "inherited", "by", "all", "vis", "classes" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/viz_factory.py#L82-L90
train
lambdamusic/Ontospy
ontospy/ontodocs/viz_factory.py
VizFactory._buildTemplates
def _buildTemplates(self): """ do all the things necessary to build the viz should be adapted to work for single-file viz, or multi-files etc. :param output_path: :return: """ # in this case we only have one contents = self._renderTemplate(self.template_...
python
def _buildTemplates(self): """ do all the things necessary to build the viz should be adapted to work for single-file viz, or multi-files etc. :param output_path: :return: """ # in this case we only have one contents = self._renderTemplate(self.template_...
[ "def", "_buildTemplates", "(", "self", ")", ":", "contents", "=", "self", ".", "_renderTemplate", "(", "self", ".", "template_name", ",", "extraContext", "=", "None", ")", "f", "=", "self", ".", "main_file_name", "main_url", "=", "self", ".", "_save2File", ...
do all the things necessary to build the viz should be adapted to work for single-file viz, or multi-files etc. :param output_path: :return:
[ "do", "all", "the", "things", "necessary", "to", "build", "the", "viz", "should", "be", "adapted", "to", "work", "for", "single", "-", "file", "viz", "or", "multi", "-", "files", "etc", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/viz_factory.py#L92-L105
train
lambdamusic/Ontospy
ontospy/ontodocs/viz_factory.py
VizFactory._build_basic_context
def _build_basic_context(self): """ Return a standard dict used in django as a template context """ # printDebug(str(self.ontospy_graph.toplayer_classes)) topclasses = self.ontospy_graph.toplayer_classes[:] if len(topclasses) < 3: # massage the toplayer! for ...
python
def _build_basic_context(self): """ Return a standard dict used in django as a template context """ # printDebug(str(self.ontospy_graph.toplayer_classes)) topclasses = self.ontospy_graph.toplayer_classes[:] if len(topclasses) < 3: # massage the toplayer! for ...
[ "def", "_build_basic_context", "(", "self", ")", ":", "topclasses", "=", "self", ".", "ontospy_graph", ".", "toplayer_classes", "[", ":", "]", "if", "len", "(", "topclasses", ")", "<", "3", ":", "for", "topclass", "in", "self", ".", "ontospy_graph", ".", ...
Return a standard dict used in django as a template context
[ "Return", "a", "standard", "dict", "used", "in", "django", "as", "a", "template", "context" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/viz_factory.py#L161-L195
train
lambdamusic/Ontospy
ontospy/ontodocs/viz_factory.py
VizFactory.checkOutputPath
def checkOutputPath(self, output_path): """ Create or clean up output path """ if not output_path: # output_path = self.output_path_DEFAULT output_path = os.path.join(self.output_path_DEFAULT, slugify(unicode(self.title))) ...
python
def checkOutputPath(self, output_path): """ Create or clean up output path """ if not output_path: # output_path = self.output_path_DEFAULT output_path = os.path.join(self.output_path_DEFAULT, slugify(unicode(self.title))) ...
[ "def", "checkOutputPath", "(", "self", ",", "output_path", ")", ":", "if", "not", "output_path", ":", "output_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "output_path_DEFAULT", ",", "slugify", "(", "unicode", "(", "self", ".", "title", ...
Create or clean up output path
[ "Create", "or", "clean", "up", "output", "path" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/viz_factory.py#L205-L216
train
lambdamusic/Ontospy
ontospy/ontodocs/viz_factory.py
VizFactory.highlight_code
def highlight_code(self, ontospy_entity): """ produce an html version of Turtle code with syntax highlighted using Pygments CSS """ try: pygments_code = highlight(ontospy_entity.rdf_source(), TurtleLexer(), HtmlFormatter()) ...
python
def highlight_code(self, ontospy_entity): """ produce an html version of Turtle code with syntax highlighted using Pygments CSS """ try: pygments_code = highlight(ontospy_entity.rdf_source(), TurtleLexer(), HtmlFormatter()) ...
[ "def", "highlight_code", "(", "self", ",", "ontospy_entity", ")", ":", "try", ":", "pygments_code", "=", "highlight", "(", "ontospy_entity", ".", "rdf_source", "(", ")", ",", "TurtleLexer", "(", ")", ",", "HtmlFormatter", "(", ")", ")", "pygments_code_css", ...
produce an html version of Turtle code with syntax highlighted using Pygments CSS
[ "produce", "an", "html", "version", "of", "Turtle", "code", "with", "syntax", "highlighted", "using", "Pygments", "CSS" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/viz_factory.py#L218-L233
train
lambdamusic/Ontospy
ontospy/extras/sparqlpy.py
SparqlEndpoint.query
def query(self, q, format="", convert=True): """ Generic SELECT query structure. 'q' is the main body of the query. The results passed out are not converted yet: see the 'format' method Results could be iterated using the idiom: for l in obj : do_something_with_line(l) If convert is False, we return the col...
python
def query(self, q, format="", convert=True): """ Generic SELECT query structure. 'q' is the main body of the query. The results passed out are not converted yet: see the 'format' method Results could be iterated using the idiom: for l in obj : do_something_with_line(l) If convert is False, we return the col...
[ "def", "query", "(", "self", ",", "q", ",", "format", "=", "\"\"", ",", "convert", "=", "True", ")", ":", "lines", "=", "[", "\"PREFIX %s: <%s>\"", "%", "(", "k", ",", "r", ")", "for", "k", ",", "r", "in", "self", ".", "prefixes", ".", "iteritems...
Generic SELECT query structure. 'q' is the main body of the query. The results passed out are not converted yet: see the 'format' method Results could be iterated using the idiom: for l in obj : do_something_with_line(l) If convert is False, we return the collection of rdflib instances
[ "Generic", "SELECT", "query", "structure", ".", "q", "is", "the", "main", "body", "of", "the", "query", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/sparqlpy.py#L103-L121
train
lambdamusic/Ontospy
ontospy/extras/sparqlpy.py
SparqlEndpoint.describe
def describe(self, uri, format="", convert=True): """ A simple DESCRIBE query with no 'where' arguments. 'uri' is the resource you want to describe. TODO: there are some errors with describe queries, due to the results being sent back For the moment we're not using them much.. needs to be tested more. """ ...
python
def describe(self, uri, format="", convert=True): """ A simple DESCRIBE query with no 'where' arguments. 'uri' is the resource you want to describe. TODO: there are some errors with describe queries, due to the results being sent back For the moment we're not using them much.. needs to be tested more. """ ...
[ "def", "describe", "(", "self", ",", "uri", ",", "format", "=", "\"\"", ",", "convert", "=", "True", ")", ":", "lines", "=", "[", "\"PREFIX %s: <%s>\"", "%", "(", "k", ",", "r", ")", "for", "k", ",", "r", "in", "self", ".", "prefixes", ".", "iter...
A simple DESCRIBE query with no 'where' arguments. 'uri' is the resource you want to describe. TODO: there are some errors with describe queries, due to the results being sent back For the moment we're not using them much.. needs to be tested more.
[ "A", "simple", "DESCRIBE", "query", "with", "no", "where", "arguments", ".", "uri", "is", "the", "resource", "you", "want", "to", "describe", "." ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/sparqlpy.py#L125-L144
train
lambdamusic/Ontospy
ontospy/extras/sparqlpy.py
SparqlEndpoint.__doQuery
def __doQuery(self, query, format, convert): """ Inner method that does the actual query """ self.__getFormat(format) self.sparql.setQuery(query) if convert: results = self.sparql.query().convert() else: results = self.sparql.query() return results
python
def __doQuery(self, query, format, convert): """ Inner method that does the actual query """ self.__getFormat(format) self.sparql.setQuery(query) if convert: results = self.sparql.query().convert() else: results = self.sparql.query() return results
[ "def", "__doQuery", "(", "self", ",", "query", ",", "format", ",", "convert", ")", ":", "self", ".", "__getFormat", "(", "format", ")", "self", ".", "sparql", ".", "setQuery", "(", "query", ")", "if", "convert", ":", "results", "=", "self", ".", "spa...
Inner method that does the actual query
[ "Inner", "method", "that", "does", "the", "actual", "query" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/sparqlpy.py#L212-L223
train
lambdamusic/Ontospy
ontospy/extras/hacks/turtle-cli.py
get_default_preds
def get_default_preds(): """dynamically build autocomplete options based on an external file""" g = ontospy.Ontospy(rdfsschema, text=True, verbose=False, hide_base_schemas=False) classes = [(x.qname, x.bestDescription()) for x in g.all_classes] properties = [(x.qname, x.bestDescription()) for x in g.all...
python
def get_default_preds(): """dynamically build autocomplete options based on an external file""" g = ontospy.Ontospy(rdfsschema, text=True, verbose=False, hide_base_schemas=False) classes = [(x.qname, x.bestDescription()) for x in g.all_classes] properties = [(x.qname, x.bestDescription()) for x in g.all...
[ "def", "get_default_preds", "(", ")", ":", "g", "=", "ontospy", ".", "Ontospy", "(", "rdfsschema", ",", "text", "=", "True", ",", "verbose", "=", "False", ",", "hide_base_schemas", "=", "False", ")", "classes", "=", "[", "(", "x", ".", "qname", ",", ...
dynamically build autocomplete options based on an external file
[ "dynamically", "build", "autocomplete", "options", "based", "on", "an", "external", "file" ]
eb46cb13792b2b87f21babdf976996318eec7571
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/hacks/turtle-cli.py#L42-L48
train