repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
google/dotty
efilter/parsers/dottysql/grammar.py
application
def application(tokens): """Matches function call (application).""" tokens = iter(tokens) func = next(tokens) paren = next(tokens) if func and func.name == "symbol" and paren.name == "lparen": # We would be able to unambiguously parse function application with # whitespace between t...
python
def application(tokens): """Matches function call (application).""" tokens = iter(tokens) func = next(tokens) paren = next(tokens) if func and func.name == "symbol" and paren.name == "lparen": # We would be able to unambiguously parse function application with # whitespace between t...
[ "def", "application", "(", "tokens", ")", ":", "tokens", "=", "iter", "(", "tokens", ")", "func", "=", "next", "(", "tokens", ")", "paren", "=", "next", "(", "tokens", ")", "if", "func", "and", "func", ".", "name", "==", "\"symbol\"", "and", "paren",...
Matches function call (application).
[ "Matches", "function", "call", "(", "application", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/grammar.py#L208-L223
train
google/dotty
setup.py
BdistRPMCommand._make_spec_file
def _make_spec_file(self): """Generates the text of an RPM spec file. Returns: A list of strings containing the lines of text. """ # Note that bdist_rpm can be an old style class. if issubclass(BdistRPMCommand, object): spec_file = super(BdistRPMCommand, se...
python
def _make_spec_file(self): """Generates the text of an RPM spec file. Returns: A list of strings containing the lines of text. """ # Note that bdist_rpm can be an old style class. if issubclass(BdistRPMCommand, object): spec_file = super(BdistRPMCommand, se...
[ "def", "_make_spec_file", "(", "self", ")", ":", "# Note that bdist_rpm can be an old style class.", "if", "issubclass", "(", "BdistRPMCommand", ",", "object", ")", ":", "spec_file", "=", "super", "(", "BdistRPMCommand", ",", "self", ")", ".", "_make_spec_file", "("...
Generates the text of an RPM spec file. Returns: A list of strings containing the lines of text.
[ "Generates", "the", "text", "of", "an", "RPM", "spec", "file", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/setup.py#L45-L105
train
google/dotty
efilter/scope.py
ScopeStack.resolve
def resolve(self, name): """Call IStructured.resolve across all scopes and return first hit.""" for scope in reversed(self.scopes): try: return structured.resolve(scope, name) except (KeyError, AttributeError): continue raise AttributeErro...
python
def resolve(self, name): """Call IStructured.resolve across all scopes and return first hit.""" for scope in reversed(self.scopes): try: return structured.resolve(scope, name) except (KeyError, AttributeError): continue raise AttributeErro...
[ "def", "resolve", "(", "self", ",", "name", ")", ":", "for", "scope", "in", "reversed", "(", "self", ".", "scopes", ")", ":", "try", ":", "return", "structured", ".", "resolve", "(", "scope", ",", "name", ")", "except", "(", "KeyError", ",", "Attribu...
Call IStructured.resolve across all scopes and return first hit.
[ "Call", "IStructured", ".", "resolve", "across", "all", "scopes", "and", "return", "first", "hit", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/scope.py#L73-L81
train
google/dotty
efilter/scope.py
ScopeStack.getmembers
def getmembers(self): """Gets members (vars) from all scopes, using both runtime and static. This method will attempt both static and runtime getmembers. This is the recommended way of getting available members. Returns: Set of available vars. Raises: N...
python
def getmembers(self): """Gets members (vars) from all scopes, using both runtime and static. This method will attempt both static and runtime getmembers. This is the recommended way of getting available members. Returns: Set of available vars. Raises: N...
[ "def", "getmembers", "(", "self", ")", ":", "names", "=", "set", "(", ")", "for", "scope", "in", "self", ".", "scopes", ":", "if", "isinstance", "(", "scope", ",", "type", ")", ":", "names", ".", "update", "(", "structured", ".", "getmembers_static", ...
Gets members (vars) from all scopes, using both runtime and static. This method will attempt both static and runtime getmembers. This is the recommended way of getting available members. Returns: Set of available vars. Raises: NotImplementedError if any scope f...
[ "Gets", "members", "(", "vars", ")", "from", "all", "scopes", "using", "both", "runtime", "and", "static", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/scope.py#L83-L102
train
google/dotty
efilter/scope.py
ScopeStack.getmembers_runtime
def getmembers_runtime(self): """Gets members (vars) from all scopes using ONLY runtime information. You most likely want to use ScopeStack.getmembers instead. Returns: Set of available vars. Raises: NotImplementedError if any scope fails to implement 'getmembe...
python
def getmembers_runtime(self): """Gets members (vars) from all scopes using ONLY runtime information. You most likely want to use ScopeStack.getmembers instead. Returns: Set of available vars. Raises: NotImplementedError if any scope fails to implement 'getmembe...
[ "def", "getmembers_runtime", "(", "self", ")", ":", "names", "=", "set", "(", ")", "for", "scope", "in", "self", ".", "scopes", ":", "names", ".", "update", "(", "structured", ".", "getmembers_runtime", "(", "scope", ")", ")", "return", "names" ]
Gets members (vars) from all scopes using ONLY runtime information. You most likely want to use ScopeStack.getmembers instead. Returns: Set of available vars. Raises: NotImplementedError if any scope fails to implement 'getmembers'.
[ "Gets", "members", "(", "vars", ")", "from", "all", "scopes", "using", "ONLY", "runtime", "information", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/scope.py#L104-L119
train
google/dotty
efilter/scope.py
ScopeStack.getmembers_static
def getmembers_static(cls): """Gets members (vars) from all scopes using ONLY static information. You most likely want to use ScopeStack.getmembers instead. Returns: Set of available vars. Raises: NotImplementedError if any scope fails to implement 'getmembers'...
python
def getmembers_static(cls): """Gets members (vars) from all scopes using ONLY static information. You most likely want to use ScopeStack.getmembers instead. Returns: Set of available vars. Raises: NotImplementedError if any scope fails to implement 'getmembers'...
[ "def", "getmembers_static", "(", "cls", ")", ":", "names", "=", "set", "(", ")", "for", "scope", "in", "cls", ".", "scopes", ":", "names", ".", "update", "(", "structured", ".", "getmembers_static", "(", "scope", ")", ")", "return", "names" ]
Gets members (vars) from all scopes using ONLY static information. You most likely want to use ScopeStack.getmembers instead. Returns: Set of available vars. Raises: NotImplementedError if any scope fails to implement 'getmembers'.
[ "Gets", "members", "(", "vars", ")", "from", "all", "scopes", "using", "ONLY", "static", "information", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/scope.py#L122-L137
train
google/dotty
efilter/scope.py
ScopeStack.reflect
def reflect(self, name): """Reflect 'name' starting with local scope all the way up to global. This method will attempt both static and runtime reflection. This is the recommended way of using reflection. Returns: Type of 'name', or protocol.AnyType. Caveat: ...
python
def reflect(self, name): """Reflect 'name' starting with local scope all the way up to global. This method will attempt both static and runtime reflection. This is the recommended way of using reflection. Returns: Type of 'name', or protocol.AnyType. Caveat: ...
[ "def", "reflect", "(", "self", ",", "name", ")", ":", "# Return whatever the most local scope defines this as, or bubble all", "# the way to the top.", "result", "=", "None", "for", "scope", "in", "reversed", "(", "self", ".", "scopes", ")", ":", "try", ":", "if", ...
Reflect 'name' starting with local scope all the way up to global. This method will attempt both static and runtime reflection. This is the recommended way of using reflection. Returns: Type of 'name', or protocol.AnyType. Caveat: The type of 'name' does not ne...
[ "Reflect", "name", "starting", "with", "local", "scope", "all", "the", "way", "up", "to", "global", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/scope.py#L139-L170
train
google/dotty
efilter/scope.py
ScopeStack.reflect_runtime_member
def reflect_runtime_member(self, name): """Reflect 'name' using ONLY runtime reflection. You most likely want to use ScopeStack.reflect instead. Returns: Type of 'name', or protocol.AnyType. """ for scope in reversed(self.scopes): try: re...
python
def reflect_runtime_member(self, name): """Reflect 'name' using ONLY runtime reflection. You most likely want to use ScopeStack.reflect instead. Returns: Type of 'name', or protocol.AnyType. """ for scope in reversed(self.scopes): try: re...
[ "def", "reflect_runtime_member", "(", "self", ",", "name", ")", ":", "for", "scope", "in", "reversed", "(", "self", ".", "scopes", ")", ":", "try", ":", "return", "structured", ".", "reflect_runtime_member", "(", "scope", ",", "name", ")", "except", "(", ...
Reflect 'name' using ONLY runtime reflection. You most likely want to use ScopeStack.reflect instead. Returns: Type of 'name', or protocol.AnyType.
[ "Reflect", "name", "using", "ONLY", "runtime", "reflection", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/scope.py#L172-L186
train
google/dotty
efilter/scope.py
ScopeStack.reflect_static_member
def reflect_static_member(cls, name): """Reflect 'name' using ONLY static reflection. You most likely want to use ScopeStack.reflect instead. Returns: Type of 'name', or protocol.AnyType. """ for scope in reversed(cls.scopes): try: return...
python
def reflect_static_member(cls, name): """Reflect 'name' using ONLY static reflection. You most likely want to use ScopeStack.reflect instead. Returns: Type of 'name', or protocol.AnyType. """ for scope in reversed(cls.scopes): try: return...
[ "def", "reflect_static_member", "(", "cls", ",", "name", ")", ":", "for", "scope", "in", "reversed", "(", "cls", ".", "scopes", ")", ":", "try", ":", "return", "structured", ".", "reflect_static_member", "(", "scope", ",", "name", ")", "except", "(", "No...
Reflect 'name' using ONLY static reflection. You most likely want to use ScopeStack.reflect instead. Returns: Type of 'name', or protocol.AnyType.
[ "Reflect", "name", "using", "ONLY", "static", "reflection", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/scope.py#L189-L203
train
radical-cybertools/radical.entk
src/radical/entk/utils/prof_utils.py
get_hostmap
def get_hostmap(profile): ''' We abuse the profile combination to also derive a pilot-host map, which will tell us on what exact host each pilot has been running. To do so, we check for the PMGR_ACTIVE advance event in agent_0.prof, and use the NTP sync info to associate a hostname. ''' # F...
python
def get_hostmap(profile): ''' We abuse the profile combination to also derive a pilot-host map, which will tell us on what exact host each pilot has been running. To do so, we check for the PMGR_ACTIVE advance event in agent_0.prof, and use the NTP sync info to associate a hostname. ''' # F...
[ "def", "get_hostmap", "(", "profile", ")", ":", "# FIXME: This should be replaced by proper hostname logging", "# in `pilot.resource_details`.", "hostmap", "=", "dict", "(", ")", "# map pilot IDs to host names", "for", "entry", "in", "profile", ":", "if", "entry", "[...
We abuse the profile combination to also derive a pilot-host map, which will tell us on what exact host each pilot has been running. To do so, we check for the PMGR_ACTIVE advance event in agent_0.prof, and use the NTP sync info to associate a hostname.
[ "We", "abuse", "the", "profile", "combination", "to", "also", "derive", "a", "pilot", "-", "host", "map", "which", "will", "tell", "us", "on", "what", "exact", "host", "each", "pilot", "has", "been", "running", ".", "To", "do", "so", "we", "check", "fo...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/utils/prof_utils.py#L16-L31
train
radical-cybertools/radical.entk
src/radical/entk/utils/prof_utils.py
get_hostmap_deprecated
def get_hostmap_deprecated(profiles): ''' This method mangles combine_profiles and get_hostmap, and is deprecated. At this point it only returns the hostmap ''' hostmap = dict() # map pilot IDs to host names for pname, prof in profiles.iteritems(): if not len(prof): conti...
python
def get_hostmap_deprecated(profiles): ''' This method mangles combine_profiles and get_hostmap, and is deprecated. At this point it only returns the hostmap ''' hostmap = dict() # map pilot IDs to host names for pname, prof in profiles.iteritems(): if not len(prof): conti...
[ "def", "get_hostmap_deprecated", "(", "profiles", ")", ":", "hostmap", "=", "dict", "(", ")", "# map pilot IDs to host names", "for", "pname", ",", "prof", "in", "profiles", ".", "iteritems", "(", ")", ":", "if", "not", "len", "(", "prof", ")", ":", "conti...
This method mangles combine_profiles and get_hostmap, and is deprecated. At this point it only returns the hostmap
[ "This", "method", "mangles", "combine_profiles", "and", "get_hostmap", "and", "is", "deprecated", ".", "At", "this", "point", "it", "only", "returns", "the", "hostmap" ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/utils/prof_utils.py#L34-L60
train
radical-cybertools/radical.entk
src/radical/entk/appman/appmanager.py
AppManager.run
def run(self): """ **Purpose**: Run the application manager. Once the workflow and resource manager have been assigned. Invoking this method will start the setting up the communication infrastructure, submitting a resource request and then submission of all the tasks. """ ...
python
def run(self): """ **Purpose**: Run the application manager. Once the workflow and resource manager have been assigned. Invoking this method will start the setting up the communication infrastructure, submitting a resource request and then submission of all the tasks. """ ...
[ "def", "run", "(", "self", ")", ":", "try", ":", "# Set None objects local to each run", "self", ".", "_wfp", "=", "None", "self", ".", "_sync_thread", "=", "None", "self", ".", "_terminate_sync", "=", "Event", "(", ")", "self", ".", "_resubmit_failed", "=",...
**Purpose**: Run the application manager. Once the workflow and resource manager have been assigned. Invoking this method will start the setting up the communication infrastructure, submitting a resource request and then submission of all the tasks.
[ "**", "Purpose", "**", ":", "Run", "the", "application", "manager", ".", "Once", "the", "workflow", "and", "resource", "manager", "have", "been", "assigned", ".", "Invoking", "this", "method", "will", "start", "the", "setting", "up", "the", "communication", ...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/appman/appmanager.py#L247-L503
train
radical-cybertools/radical.entk
src/radical/entk/appman/appmanager.py
AppManager._setup_mqs
def _setup_mqs(self): """ **Purpose**: Setup RabbitMQ system on the client side. We instantiate queue(s) 'pendingq-*' for communication between the enqueuer thread and the task manager process. We instantiate queue(s) 'completedq-*' for communication between the task manager and dequeuer...
python
def _setup_mqs(self): """ **Purpose**: Setup RabbitMQ system on the client side. We instantiate queue(s) 'pendingq-*' for communication between the enqueuer thread and the task manager process. We instantiate queue(s) 'completedq-*' for communication between the task manager and dequeuer...
[ "def", "_setup_mqs", "(", "self", ")", ":", "try", ":", "self", ".", "_prof", ".", "prof", "(", "'init mqs setup'", ",", "uid", "=", "self", ".", "_uid", ")", "self", ".", "_logger", ".", "debug", "(", "'Setting up mq connection and channel'", ")", "mq_con...
**Purpose**: Setup RabbitMQ system on the client side. We instantiate queue(s) 'pendingq-*' for communication between the enqueuer thread and the task manager process. We instantiate queue(s) 'completedq-*' for communication between the task manager and dequeuer thread. We instantiate queue 'sync-to-mas...
[ "**", "Purpose", "**", ":", "Setup", "RabbitMQ", "system", "on", "the", "client", "side", ".", "We", "instantiate", "queue", "(", "s", ")", "pendingq", "-", "*", "for", "communication", "between", "the", "enqueuer", "thread", "and", "the", "task", "manager...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/appman/appmanager.py#L527-L589
train
radical-cybertools/radical.entk
src/radical/entk/appman/appmanager.py
AppManager._synchronizer
def _synchronizer(self): """ **Purpose**: Thread in the master process to keep the workflow data structure in appmanager up to date. We receive pipelines, stages and tasks objects directly. The respective object is updated in this master process. Details: Important to no...
python
def _synchronizer(self): """ **Purpose**: Thread in the master process to keep the workflow data structure in appmanager up to date. We receive pipelines, stages and tasks objects directly. The respective object is updated in this master process. Details: Important to no...
[ "def", "_synchronizer", "(", "self", ")", ":", "try", ":", "self", ".", "_prof", ".", "prof", "(", "'synchronizer started'", ",", "uid", "=", "self", ".", "_uid", ")", "self", ".", "_logger", ".", "info", "(", "'synchronizer thread started'", ")", "def", ...
**Purpose**: Thread in the master process to keep the workflow data structure in appmanager up to date. We receive pipelines, stages and tasks objects directly. The respective object is updated in this master process. Details: Important to note that acknowledgements of the type ...
[ "**", "Purpose", "**", ":", "Thread", "in", "the", "master", "process", "to", "keep", "the", "workflow", "data", "structure", "in", "appmanager", "up", "to", "date", ".", "We", "receive", "pipelines", "stages", "and", "tasks", "objects", "directly", ".", "...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/appman/appmanager.py#L619-L958
train
bradmontgomery/django-redis-metrics
redis_metrics/forms.py
MetricCategoryForm.categorize_metrics
def categorize_metrics(self): """Called only on a valid form, this method will place the chosen metrics in the given catgory.""" category = self.cleaned_data['category_name'] metrics = self.cleaned_data['metrics'] self.r.reset_category(category, metrics)
python
def categorize_metrics(self): """Called only on a valid form, this method will place the chosen metrics in the given catgory.""" category = self.cleaned_data['category_name'] metrics = self.cleaned_data['metrics'] self.r.reset_category(category, metrics)
[ "def", "categorize_metrics", "(", "self", ")", ":", "category", "=", "self", ".", "cleaned_data", "[", "'category_name'", "]", "metrics", "=", "self", ".", "cleaned_data", "[", "'metrics'", "]", "self", ".", "r", ".", "reset_category", "(", "category", ",", ...
Called only on a valid form, this method will place the chosen metrics in the given catgory.
[ "Called", "only", "on", "a", "valid", "form", "this", "method", "will", "place", "the", "chosen", "metrics", "in", "the", "given", "catgory", "." ]
2c92332920113d28c39234b949aa496b39a091d1
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/forms.py#L50-L55
train
radical-cybertools/radical.entk
src/radical/entk/execman/rp/resource_manager.py
ResourceManager._submit_resource_request
def _submit_resource_request(self): """ **Purpose**: Create and submits a RADICAL Pilot Job as per the user provided resource description """ try: self._prof.prof('creating rreq', uid=self._uid) def _pilot_state_cb(pilot, state): ...
python
def _submit_resource_request(self): """ **Purpose**: Create and submits a RADICAL Pilot Job as per the user provided resource description """ try: self._prof.prof('creating rreq', uid=self._uid) def _pilot_state_cb(pilot, state): ...
[ "def", "_submit_resource_request", "(", "self", ")", ":", "try", ":", "self", ".", "_prof", ".", "prof", "(", "'creating rreq'", ",", "uid", "=", "self", ".", "_uid", ")", "def", "_pilot_state_cb", "(", "pilot", ",", "state", ")", ":", "self", ".", "_l...
**Purpose**: Create and submits a RADICAL Pilot Job as per the user provided resource description
[ "**", "Purpose", "**", ":", "Create", "and", "submits", "a", "RADICAL", "Pilot", "Job", "as", "per", "the", "user", "provided", "resource", "description" ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/rp/resource_manager.py#L106-L188
train
radical-cybertools/radical.entk
src/radical/entk/execman/rp/resource_manager.py
ResourceManager._terminate_resource_request
def _terminate_resource_request(self): """ **Purpose**: Cancel the RADICAL Pilot Job """ try: if self._pilot: self._prof.prof('canceling resource allocation', uid=self._uid) self._pilot.cancel() download_rp_profile = os.envir...
python
def _terminate_resource_request(self): """ **Purpose**: Cancel the RADICAL Pilot Job """ try: if self._pilot: self._prof.prof('canceling resource allocation', uid=self._uid) self._pilot.cancel() download_rp_profile = os.envir...
[ "def", "_terminate_resource_request", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_pilot", ":", "self", ".", "_prof", ".", "prof", "(", "'canceling resource allocation'", ",", "uid", "=", "self", ".", "_uid", ")", "self", ".", "_pilot", ".", "...
**Purpose**: Cancel the RADICAL Pilot Job
[ "**", "Purpose", "**", ":", "Cancel", "the", "RADICAL", "Pilot", "Job" ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/rp/resource_manager.py#L190-L214
train
bertouttier/solaredge
solaredge/solaredge.py
Solaredge.get_list
def get_list(self, size=100, startIndex=0, searchText="", sortProperty="", sortOrder='ASC', status='Active,Pending'): """ Request service locations Returns ------- dict """ url = urljoin(BASEURL, "sites", "list") params = { 'api_key': self.t...
python
def get_list(self, size=100, startIndex=0, searchText="", sortProperty="", sortOrder='ASC', status='Active,Pending'): """ Request service locations Returns ------- dict """ url = urljoin(BASEURL, "sites", "list") params = { 'api_key': self.t...
[ "def", "get_list", "(", "self", ",", "size", "=", "100", ",", "startIndex", "=", "0", ",", "searchText", "=", "\"\"", ",", "sortProperty", "=", "\"\"", ",", "sortOrder", "=", "'ASC'", ",", "status", "=", "'Active,Pending'", ")", ":", "url", "=", "urljo...
Request service locations Returns ------- dict
[ "Request", "service", "locations" ]
2c94b38527374b0abd088e2819455b332bc5153a
https://github.com/bertouttier/solaredge/blob/2c94b38527374b0abd088e2819455b332bc5153a/solaredge/solaredge.py#L30-L57
train
google/dotty
efilter/parsers/common/token_stream.py
TokenStream.match
def match(self, f, *args): """Match grammar function 'f' against next token and set 'self.matched'. Arguments: f: A grammar function - see efilter.parsers.common.grammar. Must return TokenMatch or None. args: Passed to 'f', if any. Returns: I...
python
def match(self, f, *args): """Match grammar function 'f' against next token and set 'self.matched'. Arguments: f: A grammar function - see efilter.parsers.common.grammar. Must return TokenMatch or None. args: Passed to 'f', if any. Returns: I...
[ "def", "match", "(", "self", ",", "f", ",", "*", "args", ")", ":", "try", ":", "match", "=", "f", "(", "self", ".", "tokenizer", ",", "*", "args", ")", "except", "StopIteration", ":", "# The grammar function might have tried to access more tokens than", "# are...
Match grammar function 'f' against next token and set 'self.matched'. Arguments: f: A grammar function - see efilter.parsers.common.grammar. Must return TokenMatch or None. args: Passed to 'f', if any. Returns: Instance of efilter.parsers.common.gram...
[ "Match", "grammar", "function", "f", "against", "next", "token", "and", "set", "self", ".", "matched", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/token_stream.py#L46-L76
train
google/dotty
efilter/parsers/common/token_stream.py
TokenStream.accept
def accept(self, f, *args): """Like 'match', but consume the token (tokenizer advances.)""" match = self.match(f, *args) if match is None: return self.tokenizer.skip(len(match.tokens)) return match
python
def accept(self, f, *args): """Like 'match', but consume the token (tokenizer advances.)""" match = self.match(f, *args) if match is None: return self.tokenizer.skip(len(match.tokens)) return match
[ "def", "accept", "(", "self", ",", "f", ",", "*", "args", ")", ":", "match", "=", "self", ".", "match", "(", "f", ",", "*", "args", ")", "if", "match", "is", "None", ":", "return", "self", ".", "tokenizer", ".", "skip", "(", "len", "(", "match"...
Like 'match', but consume the token (tokenizer advances.)
[ "Like", "match", "but", "consume", "the", "token", "(", "tokenizer", "advances", ".", ")" ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/token_stream.py#L78-L85
train
google/dotty
efilter/parsers/common/token_stream.py
TokenStream.reject
def reject(self, f, *args): """Like 'match', but throw a parse error if 'f' matches. This is useful when a parser wants to be strict about specific things being prohibited. For example, DottySQL bans the use of SQL keywords as variable names. """ match = self.match(f, *a...
python
def reject(self, f, *args): """Like 'match', but throw a parse error if 'f' matches. This is useful when a parser wants to be strict about specific things being prohibited. For example, DottySQL bans the use of SQL keywords as variable names. """ match = self.match(f, *a...
[ "def", "reject", "(", "self", ",", "f", ",", "*", "args", ")", ":", "match", "=", "self", ".", "match", "(", "f", ",", "*", "args", ")", "if", "match", ":", "token", "=", "self", ".", "peek", "(", "0", ")", "raise", "errors", ".", "EfilterParse...
Like 'match', but throw a parse error if 'f' matches. This is useful when a parser wants to be strict about specific things being prohibited. For example, DottySQL bans the use of SQL keywords as variable names.
[ "Like", "match", "but", "throw", "a", "parse", "error", "if", "f", "matches", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/token_stream.py#L87-L99
train
google/dotty
efilter/parsers/common/token_stream.py
TokenStream.expect
def expect(self, f, *args): """Like 'accept' but throws a parse error if 'f' doesn't match.""" match = self.accept(f, *args) if match: return match try: func_name = f.func_name except AttributeError: func_name = "<unnamed grammar function>" ...
python
def expect(self, f, *args): """Like 'accept' but throws a parse error if 'f' doesn't match.""" match = self.accept(f, *args) if match: return match try: func_name = f.func_name except AttributeError: func_name = "<unnamed grammar function>" ...
[ "def", "expect", "(", "self", ",", "f", ",", "*", "args", ")", ":", "match", "=", "self", ".", "accept", "(", "f", ",", "*", "args", ")", "if", "match", ":", "return", "match", "try", ":", "func_name", "=", "f", ".", "func_name", "except", "Attri...
Like 'accept' but throws a parse error if 'f' doesn't match.
[ "Like", "accept", "but", "throws", "a", "parse", "error", "if", "f", "doesn", "t", "match", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/token_stream.py#L101-L115
train
google/dotty
efilter/parsers/common/token_stream.py
TokenStream.current_position
def current_position(self): """Return a tuple of (start, end).""" token = self.tokenizer.peek(0) if token: return token.start, token.end return self.tokenizer.position, self.tokenizer.position + 1
python
def current_position(self): """Return a tuple of (start, end).""" token = self.tokenizer.peek(0) if token: return token.start, token.end return self.tokenizer.position, self.tokenizer.position + 1
[ "def", "current_position", "(", "self", ")", ":", "token", "=", "self", ".", "tokenizer", ".", "peek", "(", "0", ")", "if", "token", ":", "return", "token", ".", "start", ",", "token", ".", "end", "return", "self", ".", "tokenizer", ".", "position", ...
Return a tuple of (start, end).
[ "Return", "a", "tuple", "of", "(", "start", "end", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/token_stream.py#L117-L123
train
google/dotty
efilter/parsers/common/ast_transforms.py
ComplementEquivalence
def ComplementEquivalence(*args, **kwargs): """Change x != y to not(x == y).""" return ast.Complement( ast.Equivalence(*args, **kwargs), **kwargs)
python
def ComplementEquivalence(*args, **kwargs): """Change x != y to not(x == y).""" return ast.Complement( ast.Equivalence(*args, **kwargs), **kwargs)
[ "def", "ComplementEquivalence", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "ast", ".", "Complement", "(", "ast", ".", "Equivalence", "(", "*", "args", ",", "*", "*", "kwargs", ")", ",", "*", "*", "kwargs", ")" ]
Change x != y to not(x == y).
[ "Change", "x", "!", "=", "y", "to", "not", "(", "x", "==", "y", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/ast_transforms.py#L43-L46
train
google/dotty
efilter/parsers/common/ast_transforms.py
ComplementMembership
def ComplementMembership(*args, **kwargs): """Change (x not in y) to not(x in y).""" return ast.Complement( ast.Membership(*args, **kwargs), **kwargs)
python
def ComplementMembership(*args, **kwargs): """Change (x not in y) to not(x in y).""" return ast.Complement( ast.Membership(*args, **kwargs), **kwargs)
[ "def", "ComplementMembership", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "ast", ".", "Complement", "(", "ast", ".", "Membership", "(", "*", "args", ",", "*", "*", "kwargs", ")", ",", "*", "*", "kwargs", ")" ]
Change (x not in y) to not(x in y).
[ "Change", "(", "x", "not", "in", "y", ")", "to", "not", "(", "x", "in", "y", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/ast_transforms.py#L49-L52
train
google/dotty
efilter/parsers/common/ast_transforms.py
ReverseComplementMembership
def ReverseComplementMembership(x, y, **kwargs): """Change (x doesn't contain y) to not(y in x).""" return ast.Complement( ast.Membership(y, x, **kwargs), **kwargs)
python
def ReverseComplementMembership(x, y, **kwargs): """Change (x doesn't contain y) to not(y in x).""" return ast.Complement( ast.Membership(y, x, **kwargs), **kwargs)
[ "def", "ReverseComplementMembership", "(", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "return", "ast", ".", "Complement", "(", "ast", ".", "Membership", "(", "y", ",", "x", ",", "*", "*", "kwargs", ")", ",", "*", "*", "kwargs", ")" ]
Change (x doesn't contain y) to not(y in x).
[ "Change", "(", "x", "doesn", "t", "contain", "y", ")", "to", "not", "(", "y", "in", "x", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/ast_transforms.py#L60-L63
train
google/dotty
efilter/transforms/solve.py
__solve_for_repeated
def __solve_for_repeated(expr, vars): """Helper: solve 'expr' always returning an IRepeated. If the result of solving 'expr' is a list or a tuple of IStructured objects then treat is as a repeated value of IStructured objects because that's what the called meant to do. This is a convenience helper so u...
python
def __solve_for_repeated(expr, vars): """Helper: solve 'expr' always returning an IRepeated. If the result of solving 'expr' is a list or a tuple of IStructured objects then treat is as a repeated value of IStructured objects because that's what the called meant to do. This is a convenience helper so u...
[ "def", "__solve_for_repeated", "(", "expr", ",", "vars", ")", ":", "var", "=", "solve", "(", "expr", ",", "vars", ")", ".", "value", "if", "(", "var", "and", "isinstance", "(", "var", ",", "(", "tuple", ",", "list", ")", ")", "and", "protocol", "."...
Helper: solve 'expr' always returning an IRepeated. If the result of solving 'expr' is a list or a tuple of IStructured objects then treat is as a repeated value of IStructured objects because that's what the called meant to do. This is a convenience helper so users of the API don't have to create IRep...
[ "Helper", ":", "solve", "expr", "always", "returning", "an", "IRepeated", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L84-L108
train
google/dotty
efilter/transforms/solve.py
__solve_for_scalar
def __solve_for_scalar(expr, vars): """Helper: solve 'expr' always returning a scalar (not IRepeated). If the output of 'expr' is a single value or a single RowTuple with a single column then return the value in that column. Otherwise raise. Arguments: expr: Expression to solve. vars: ...
python
def __solve_for_scalar(expr, vars): """Helper: solve 'expr' always returning a scalar (not IRepeated). If the output of 'expr' is a single value or a single RowTuple with a single column then return the value in that column. Otherwise raise. Arguments: expr: Expression to solve. vars: ...
[ "def", "__solve_for_scalar", "(", "expr", ",", "vars", ")", ":", "var", "=", "solve", "(", "expr", ",", "vars", ")", ".", "value", "try", ":", "scalar", "=", "repeated", ".", "getvalue", "(", "var", ")", "except", "TypeError", ":", "raise", "errors", ...
Helper: solve 'expr' always returning a scalar (not IRepeated). If the output of 'expr' is a single value or a single RowTuple with a single column then return the value in that column. Otherwise raise. Arguments: expr: Expression to solve. vars: The scope. Returns: A scalar v...
[ "Helper", ":", "solve", "expr", "always", "returning", "a", "scalar", "(", "not", "IRepeated", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L111-L145
train
google/dotty
efilter/transforms/solve.py
__solve_and_destructure_repeated
def __solve_and_destructure_repeated(expr, vars): """Helper: solve 'expr' always returning a list of scalars. If the output of 'expr' is one or more row tuples with only a single column then return a repeated value of values in that column. If there are more than one column per row then raise. Thi...
python
def __solve_and_destructure_repeated(expr, vars): """Helper: solve 'expr' always returning a list of scalars. If the output of 'expr' is one or more row tuples with only a single column then return a repeated value of values in that column. If there are more than one column per row then raise. Thi...
[ "def", "__solve_and_destructure_repeated", "(", "expr", ",", "vars", ")", ":", "iterable", ",", "isrepeating", "=", "__solve_for_repeated", "(", "expr", ",", "vars", ")", "if", "iterable", "is", "None", ":", "return", "(", ")", ",", "isrepeating", "if", "not...
Helper: solve 'expr' always returning a list of scalars. If the output of 'expr' is one or more row tuples with only a single column then return a repeated value of values in that column. If there are more than one column per row then raise. This returns a list because there's no point in wrapping the...
[ "Helper", ":", "solve", "expr", "always", "returning", "a", "list", "of", "scalars", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L148-L195
train
google/dotty
efilter/transforms/solve.py
solve_var
def solve_var(expr, vars): """Returns the value of the var named in the expression.""" try: return Result(structured.resolve(vars, expr.value), ()) except (KeyError, AttributeError) as e: # Raise a better exception for accessing a non-existent member. raise errors.EfilterKeyError(roo...
python
def solve_var(expr, vars): """Returns the value of the var named in the expression.""" try: return Result(structured.resolve(vars, expr.value), ()) except (KeyError, AttributeError) as e: # Raise a better exception for accessing a non-existent member. raise errors.EfilterKeyError(roo...
[ "def", "solve_var", "(", "expr", ",", "vars", ")", ":", "try", ":", "return", "Result", "(", "structured", ".", "resolve", "(", "vars", ",", "expr", ".", "value", ")", ",", "(", ")", ")", "except", "(", "KeyError", ",", "AttributeError", ")", "as", ...
Returns the value of the var named in the expression.
[ "Returns", "the", "value", "of", "the", "var", "named", "in", "the", "expression", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L234-L256
train
google/dotty
efilter/transforms/solve.py
solve_select
def solve_select(expr, vars): """Use IAssociative.select to get key (rhs) from the data (lhs). This operation supports both scalars and repeated values on the LHS - selecting from a repeated value implies a map-like operation and returns a new repeated value. """ data, _ = __solve_for_repeated(...
python
def solve_select(expr, vars): """Use IAssociative.select to get key (rhs) from the data (lhs). This operation supports both scalars and repeated values on the LHS - selecting from a repeated value implies a map-like operation and returns a new repeated value. """ data, _ = __solve_for_repeated(...
[ "def", "solve_select", "(", "expr", ",", "vars", ")", ":", "data", ",", "_", "=", "__solve_for_repeated", "(", "expr", ".", "lhs", ",", "vars", ")", "key", "=", "solve", "(", "expr", ".", "rhs", ",", "vars", ")", ".", "value", "try", ":", "results"...
Use IAssociative.select to get key (rhs) from the data (lhs). This operation supports both scalars and repeated values on the LHS - selecting from a repeated value implies a map-like operation and returns a new repeated value.
[ "Use", "IAssociative", ".", "select", "to", "get", "key", "(", "rhs", ")", "from", "the", "data", "(", "lhs", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L260-L288
train
google/dotty
efilter/transforms/solve.py
solve_resolve
def solve_resolve(expr, vars): """Use IStructured.resolve to get member (rhs) from the object (lhs). This operation supports both scalars and repeated values on the LHS - resolving from a repeated value implies a map-like operation and returns a new repeated values. """ objs, _ = __solve_for_re...
python
def solve_resolve(expr, vars): """Use IStructured.resolve to get member (rhs) from the object (lhs). This operation supports both scalars and repeated values on the LHS - resolving from a repeated value implies a map-like operation and returns a new repeated values. """ objs, _ = __solve_for_re...
[ "def", "solve_resolve", "(", "expr", ",", "vars", ")", ":", "objs", ",", "_", "=", "__solve_for_repeated", "(", "expr", ".", "lhs", ",", "vars", ")", "member", "=", "solve", "(", "expr", ".", "rhs", ",", "vars", ")", ".", "value", "try", ":", "resu...
Use IStructured.resolve to get member (rhs) from the object (lhs). This operation supports both scalars and repeated values on the LHS - resolving from a repeated value implies a map-like operation and returns a new repeated values.
[ "Use", "IStructured", ".", "resolve", "to", "get", "member", "(", "rhs", ")", "from", "the", "object", "(", "lhs", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L292-L322
train
google/dotty
efilter/transforms/solve.py
solve_apply
def solve_apply(expr, vars): """Returns the result of applying function (lhs) to its arguments (rest). We use IApplicative to apply the function, because that gives the host application an opportunity to compare the function being called against a whitelist. EFILTER will never directly call a function ...
python
def solve_apply(expr, vars): """Returns the result of applying function (lhs) to its arguments (rest). We use IApplicative to apply the function, because that gives the host application an opportunity to compare the function being called against a whitelist. EFILTER will never directly call a function ...
[ "def", "solve_apply", "(", "expr", ",", "vars", ")", ":", "func", "=", "__solve_for_scalar", "(", "expr", ".", "func", ",", "vars", ")", "args", "=", "[", "]", "kwargs", "=", "{", "}", "for", "arg", "in", "expr", ".", "args", ":", "if", "isinstance...
Returns the result of applying function (lhs) to its arguments (rest). We use IApplicative to apply the function, because that gives the host application an opportunity to compare the function being called against a whitelist. EFILTER will never directly call a function that wasn't provided through a p...
[ "Returns", "the", "result", "of", "applying", "function", "(", "lhs", ")", "to", "its", "arguments", "(", "rest", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L326-L350
train
google/dotty
efilter/transforms/solve.py
solve_bind
def solve_bind(expr, vars): """Build a RowTuple from key/value pairs under the bind. The Bind subtree is arranged as follows: Bind | First KV Pair | | First Key Expression | | First Value Expression | Second KV Pair | | Second Key Expression | | Second Value Expression Etc... ...
python
def solve_bind(expr, vars): """Build a RowTuple from key/value pairs under the bind. The Bind subtree is arranged as follows: Bind | First KV Pair | | First Key Expression | | First Value Expression | Second KV Pair | | Second Key Expression | | Second Value Expression Etc... ...
[ "def", "solve_bind", "(", "expr", ",", "vars", ")", ":", "value_expressions", "=", "[", "]", "keys", "=", "[", "]", "for", "pair", "in", "expr", ".", "children", ":", "keys", ".", "append", "(", "solve", "(", "pair", ".", "key", ",", "vars", ")", ...
Build a RowTuple from key/value pairs under the bind. The Bind subtree is arranged as follows: Bind | First KV Pair | | First Key Expression | | First Value Expression | Second KV Pair | | Second Key Expression | | Second Value Expression Etc... As we evaluate the subtree, eac...
[ "Build", "a", "RowTuple", "from", "key", "/", "value", "pairs", "under", "the", "bind", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L354-L388
train
google/dotty
efilter/transforms/solve.py
solve_repeat
def solve_repeat(expr, vars): """Build a repeated value from subexpressions.""" try: result = repeated.meld(*[solve(x, vars).value for x in expr.children]) return Result(result, ()) except TypeError: raise errors.EfilterTypeError( root=expr, query=expr.source, ...
python
def solve_repeat(expr, vars): """Build a repeated value from subexpressions.""" try: result = repeated.meld(*[solve(x, vars).value for x in expr.children]) return Result(result, ()) except TypeError: raise errors.EfilterTypeError( root=expr, query=expr.source, ...
[ "def", "solve_repeat", "(", "expr", ",", "vars", ")", ":", "try", ":", "result", "=", "repeated", ".", "meld", "(", "*", "[", "solve", "(", "x", ",", "vars", ")", ".", "value", "for", "x", "in", "expr", ".", "children", "]", ")", "return", "Resul...
Build a repeated value from subexpressions.
[ "Build", "a", "repeated", "value", "from", "subexpressions", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L392-L400
train
google/dotty
efilter/transforms/solve.py
solve_tuple
def solve_tuple(expr, vars): """Build a tuple from subexpressions.""" result = tuple(solve(x, vars).value for x in expr.children) return Result(result, ())
python
def solve_tuple(expr, vars): """Build a tuple from subexpressions.""" result = tuple(solve(x, vars).value for x in expr.children) return Result(result, ())
[ "def", "solve_tuple", "(", "expr", ",", "vars", ")", ":", "result", "=", "tuple", "(", "solve", "(", "x", ",", "vars", ")", ".", "value", "for", "x", "in", "expr", ".", "children", ")", "return", "Result", "(", "result", ",", "(", ")", ")" ]
Build a tuple from subexpressions.
[ "Build", "a", "tuple", "from", "subexpressions", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L404-L407
train
google/dotty
efilter/transforms/solve.py
solve_ifelse
def solve_ifelse(expr, vars): """Evaluate conditions and return the one that matches.""" for condition, result in expr.conditions(): if boolean.asbool(solve(condition, vars).value): return solve(result, vars) return solve(expr.default(), vars)
python
def solve_ifelse(expr, vars): """Evaluate conditions and return the one that matches.""" for condition, result in expr.conditions(): if boolean.asbool(solve(condition, vars).value): return solve(result, vars) return solve(expr.default(), vars)
[ "def", "solve_ifelse", "(", "expr", ",", "vars", ")", ":", "for", "condition", ",", "result", "in", "expr", ".", "conditions", "(", ")", ":", "if", "boolean", ".", "asbool", "(", "solve", "(", "condition", ",", "vars", ")", ".", "value", ")", ":", ...
Evaluate conditions and return the one that matches.
[ "Evaluate", "conditions", "and", "return", "the", "one", "that", "matches", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L411-L417
train
google/dotty
efilter/transforms/solve.py
solve_map
def solve_map(expr, vars): """Solves the map-form, by recursively calling its RHS with new vars. let-forms are binary expressions. The LHS should evaluate to an IAssociative that can be used as new vars with which to solve a new query, of which the RHS is the root. In most cases, the LHS will be a Var ...
python
def solve_map(expr, vars): """Solves the map-form, by recursively calling its RHS with new vars. let-forms are binary expressions. The LHS should evaluate to an IAssociative that can be used as new vars with which to solve a new query, of which the RHS is the root. In most cases, the LHS will be a Var ...
[ "def", "solve_map", "(", "expr", ",", "vars", ")", ":", "lhs_values", ",", "_", "=", "__solve_for_repeated", "(", "expr", ".", "lhs", ",", "vars", ")", "def", "lazy_map", "(", ")", ":", "try", ":", "for", "lhs_value", "in", "repeated", ".", "getvalues"...
Solves the map-form, by recursively calling its RHS with new vars. let-forms are binary expressions. The LHS should evaluate to an IAssociative that can be used as new vars with which to solve a new query, of which the RHS is the root. In most cases, the LHS will be a Var (var). Typically, map-forms r...
[ "Solves", "the", "map", "-", "form", "by", "recursively", "calling", "its", "RHS", "with", "new", "vars", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L421-L446
train
google/dotty
efilter/transforms/solve.py
solve_let
def solve_let(expr, vars): """Solves a let-form by calling RHS with nested scope.""" lhs_value = solve(expr.lhs, vars).value if not isinstance(lhs_value, structured.IStructured): raise errors.EfilterTypeError( root=expr.lhs, query=expr.original, message="The LHS of 'let' must...
python
def solve_let(expr, vars): """Solves a let-form by calling RHS with nested scope.""" lhs_value = solve(expr.lhs, vars).value if not isinstance(lhs_value, structured.IStructured): raise errors.EfilterTypeError( root=expr.lhs, query=expr.original, message="The LHS of 'let' must...
[ "def", "solve_let", "(", "expr", ",", "vars", ")", ":", "lhs_value", "=", "solve", "(", "expr", ".", "lhs", ",", "vars", ")", ".", "value", "if", "not", "isinstance", "(", "lhs_value", ",", "structured", ".", "IStructured", ")", ":", "raise", "errors",...
Solves a let-form by calling RHS with nested scope.
[ "Solves", "a", "let", "-", "form", "by", "calling", "RHS", "with", "nested", "scope", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L450-L459
train
google/dotty
efilter/transforms/solve.py
solve_filter
def solve_filter(expr, vars): """Filter values on the LHS by evaluating RHS with each value. Returns any LHS values for which RHS evaluates to a true value. """ lhs_values, _ = __solve_for_repeated(expr.lhs, vars) def lazy_filter(): for lhs_value in repeated.getvalues(lhs_values): ...
python
def solve_filter(expr, vars): """Filter values on the LHS by evaluating RHS with each value. Returns any LHS values for which RHS evaluates to a true value. """ lhs_values, _ = __solve_for_repeated(expr.lhs, vars) def lazy_filter(): for lhs_value in repeated.getvalues(lhs_values): ...
[ "def", "solve_filter", "(", "expr", ",", "vars", ")", ":", "lhs_values", ",", "_", "=", "__solve_for_repeated", "(", "expr", ".", "lhs", ",", "vars", ")", "def", "lazy_filter", "(", ")", ":", "for", "lhs_value", "in", "repeated", ".", "getvalues", "(", ...
Filter values on the LHS by evaluating RHS with each value. Returns any LHS values for which RHS evaluates to a true value.
[ "Filter", "values", "on", "the", "LHS", "by", "evaluating", "RHS", "with", "each", "value", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L463-L475
train
google/dotty
efilter/transforms/solve.py
solve_sort
def solve_sort(expr, vars): """Sort values on the LHS by the value they yield when passed to RHS.""" lhs_values = repeated.getvalues(__solve_for_repeated(expr.lhs, vars)[0]) sort_expression = expr.rhs def _key_func(x): return solve(sort_expression, __nest_scope(expr.lhs, vars, x)).value r...
python
def solve_sort(expr, vars): """Sort values on the LHS by the value they yield when passed to RHS.""" lhs_values = repeated.getvalues(__solve_for_repeated(expr.lhs, vars)[0]) sort_expression = expr.rhs def _key_func(x): return solve(sort_expression, __nest_scope(expr.lhs, vars, x)).value r...
[ "def", "solve_sort", "(", "expr", ",", "vars", ")", ":", "lhs_values", "=", "repeated", ".", "getvalues", "(", "__solve_for_repeated", "(", "expr", ".", "lhs", ",", "vars", ")", "[", "0", "]", ")", "sort_expression", "=", "expr", ".", "rhs", "def", "_k...
Sort values on the LHS by the value they yield when passed to RHS.
[ "Sort", "values", "on", "the", "LHS", "by", "the", "value", "they", "yield", "when", "passed", "to", "RHS", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L528-L539
train
google/dotty
efilter/transforms/solve.py
solve_each
def solve_each(expr, vars): """Return True if RHS evaluates to a true value with each state of LHS. If LHS evaluates to a normal IAssociative object then this is the same as a regular let-form, except the return value is always a boolean. If LHS evaluates to a repeared var (see efilter.protocols.repeat...
python
def solve_each(expr, vars): """Return True if RHS evaluates to a true value with each state of LHS. If LHS evaluates to a normal IAssociative object then this is the same as a regular let-form, except the return value is always a boolean. If LHS evaluates to a repeared var (see efilter.protocols.repeat...
[ "def", "solve_each", "(", "expr", ",", "vars", ")", ":", "lhs_values", ",", "_", "=", "__solve_for_repeated", "(", "expr", ".", "lhs", ",", "vars", ")", "for", "lhs_value", "in", "repeated", ".", "getvalues", "(", "lhs_values", ")", ":", "result", "=", ...
Return True if RHS evaluates to a true value with each state of LHS. If LHS evaluates to a normal IAssociative object then this is the same as a regular let-form, except the return value is always a boolean. If LHS evaluates to a repeared var (see efilter.protocols.repeated) of IAssociative objects the...
[ "Return", "True", "if", "RHS", "evaluates", "to", "a", "true", "value", "with", "each", "state", "of", "LHS", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L543-L560
train
google/dotty
efilter/transforms/solve.py
solve_cast
def solve_cast(expr, vars): """Get cast LHS to RHS.""" lhs = solve(expr.lhs, vars).value t = solve(expr.rhs, vars).value if t is None: raise errors.EfilterTypeError( root=expr, query=expr.source, message="Cannot find type named %r." % expr.rhs.value) if not isinstan...
python
def solve_cast(expr, vars): """Get cast LHS to RHS.""" lhs = solve(expr.lhs, vars).value t = solve(expr.rhs, vars).value if t is None: raise errors.EfilterTypeError( root=expr, query=expr.source, message="Cannot find type named %r." % expr.rhs.value) if not isinstan...
[ "def", "solve_cast", "(", "expr", ",", "vars", ")", ":", "lhs", "=", "solve", "(", "expr", ".", "lhs", ",", "vars", ")", ".", "value", "t", "=", "solve", "(", "expr", ".", "rhs", ",", "vars", ")", ".", "value", "if", "t", "is", "None", ":", "...
Get cast LHS to RHS.
[ "Get", "cast", "LHS", "to", "RHS", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L586-L608
train
google/dotty
efilter/transforms/solve.py
solve_isinstance
def solve_isinstance(expr, vars): """Typecheck whether LHS is type on the RHS.""" lhs = solve(expr.lhs, vars) try: t = solve(expr.rhs, vars).value except errors.EfilterKeyError: t = None if t is None: raise errors.EfilterTypeError( root=expr.rhs, query=expr.sour...
python
def solve_isinstance(expr, vars): """Typecheck whether LHS is type on the RHS.""" lhs = solve(expr.lhs, vars) try: t = solve(expr.rhs, vars).value except errors.EfilterKeyError: t = None if t is None: raise errors.EfilterTypeError( root=expr.rhs, query=expr.sour...
[ "def", "solve_isinstance", "(", "expr", ",", "vars", ")", ":", "lhs", "=", "solve", "(", "expr", ".", "lhs", ",", "vars", ")", "try", ":", "t", "=", "solve", "(", "expr", ".", "rhs", ",", "vars", ")", ".", "value", "except", "errors", ".", "Efilt...
Typecheck whether LHS is type on the RHS.
[ "Typecheck", "whether", "LHS", "is", "type", "on", "the", "RHS", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/solve.py#L612-L631
train
radical-cybertools/radical.entk
setup.py
set_version
def set_version(mod_root): """ mod_root a VERSION file containes the version strings is created in mod_root, during installation. That file is used at runtime to get the version information. """ try: version_base = None version_detail = None # ge...
python
def set_version(mod_root): """ mod_root a VERSION file containes the version strings is created in mod_root, during installation. That file is used at runtime to get the version information. """ try: version_base = None version_detail = None # ge...
[ "def", "set_version", "(", "mod_root", ")", ":", "try", ":", "version_base", "=", "None", "version_detail", "=", "None", "# get version from './VERSION'", "src_root", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "if", "not", "src_root", ":", ...
mod_root a VERSION file containes the version strings is created in mod_root, during installation. That file is used at runtime to get the version information.
[ "mod_root", "a", "VERSION", "file", "containes", "the", "version", "strings", "is", "created", "in", "mod_root", "during", "installation", ".", "That", "file", "is", "used", "at", "runtime", "to", "get", "the", "version", "information", "." ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/setup.py#L26-L111
train
radical-cybertools/radical.entk
setup.py
makeDataFiles
def makeDataFiles(prefix, dir): """ Create distutils data_files structure from dir distutil will copy all file rooted under dir into prefix, excluding dir itself, just like 'ditto src dst' works, and unlike 'cp -r src dst, which copy src into dst'. Typical usage: # install the contents of 'w...
python
def makeDataFiles(prefix, dir): """ Create distutils data_files structure from dir distutil will copy all file rooted under dir into prefix, excluding dir itself, just like 'ditto src dst' works, and unlike 'cp -r src dst, which copy src into dst'. Typical usage: # install the contents of 'w...
[ "def", "makeDataFiles", "(", "prefix", ",", "dir", ")", ":", "# Strip 'dir/' from of path before joining with prefix", "dir", "=", "dir", ".", "rstrip", "(", "'/'", ")", "strip", "=", "len", "(", "dir", ")", "+", "1", "found", "=", "[", "]", "os", ".", "...
Create distutils data_files structure from dir distutil will copy all file rooted under dir into prefix, excluding dir itself, just like 'ditto src dst' works, and unlike 'cp -r src dst, which copy src into dst'. Typical usage: # install the contents of 'wiki' under sys.prefix+'share/moin' ...
[ "Create", "distutils", "data_files", "structure", "from", "dir", "distutil", "will", "copy", "all", "file", "rooted", "under", "dir", "into", "prefix", "excluding", "dir", "itself", "just", "like", "ditto", "src", "dst", "works", "and", "unlike", "cp", "-", ...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/setup.py#L126-L153
train
radical-cybertools/radical.entk
setup.py
visit
def visit((prefix, strip, found), dirname, names): """ Visit directory, create distutil tuple Add distutil tuple for each directory using this format: (destination, [dirname/file1, dirname/file2, ...]) distutil will copy later file1, file2, ... info destination. """ files = [] # Iterate ...
python
def visit((prefix, strip, found), dirname, names): """ Visit directory, create distutil tuple Add distutil tuple for each directory using this format: (destination, [dirname/file1, dirname/file2, ...]) distutil will copy later file1, file2, ... info destination. """ files = [] # Iterate ...
[ "def", "visit", "(", "(", "prefix", ",", "strip", ",", "found", ")", ",", "dirname", ",", "names", ")", ":", "files", "=", "[", "]", "# Iterate over a copy of names, modify names", "for", "name", "in", "names", "[", ":", "]", ":", "path", "=", "os", "....
Visit directory, create distutil tuple Add distutil tuple for each directory using this format: (destination, [dirname/file1, dirname/file2, ...]) distutil will copy later file1, file2, ... info destination.
[ "Visit", "directory", "create", "distutil", "tuple", "Add", "distutil", "tuple", "for", "each", "directory", "using", "this", "format", ":", "(", "destination", "[", "dirname", "/", "file1", "dirname", "/", "file2", "...", "]", ")", "distutil", "will", "copy...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/setup.py#L155-L174
train
radical-cybertools/radical.entk
setup.py
isgood
def isgood(name): """ Whether name should be installed """ if not isbad(name): if name.endswith('.py') or name.endswith('.json') or name.endswith('.tar'): return True return False
python
def isgood(name): """ Whether name should be installed """ if not isbad(name): if name.endswith('.py') or name.endswith('.json') or name.endswith('.tar'): return True return False
[ "def", "isgood", "(", "name", ")", ":", "if", "not", "isbad", "(", "name", ")", ":", "if", "name", ".", "endswith", "(", "'.py'", ")", "or", "name", ".", "endswith", "(", "'.json'", ")", "or", "name", ".", "endswith", "(", "'.tar'", ")", ":", "re...
Whether name should be installed
[ "Whether", "name", "should", "be", "installed" ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/setup.py#L183-L188
train
radical-cybertools/radical.entk
src/radical/entk/appman/wfprocessor.py
WFprocessor._initialize_workflow
def _initialize_workflow(self): """ **Purpose**: Initialize the PST of the workflow with a uid and type checks """ try: self._prof.prof('initializing workflow', uid=self._uid) for p in self._workflow: p._assign_uid(self._sid) self._...
python
def _initialize_workflow(self): """ **Purpose**: Initialize the PST of the workflow with a uid and type checks """ try: self._prof.prof('initializing workflow', uid=self._uid) for p in self._workflow: p._assign_uid(self._sid) self._...
[ "def", "_initialize_workflow", "(", "self", ")", ":", "try", ":", "self", ".", "_prof", ".", "prof", "(", "'initializing workflow'", ",", "uid", "=", "self", ".", "_uid", ")", "for", "p", "in", "self", ".", "_workflow", ":", "p", ".", "_assign_uid", "(...
**Purpose**: Initialize the PST of the workflow with a uid and type checks
[ "**", "Purpose", "**", ":", "Initialize", "the", "PST", "of", "the", "workflow", "with", "a", "uid", "and", "type", "checks" ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/appman/wfprocessor.py#L87-L104
train
radical-cybertools/radical.entk
src/radical/entk/appman/wfprocessor.py
WFprocessor._enqueue
def _enqueue(self, local_prof): """ **Purpose**: This is the function that is run in the enqueue thread. This function extracts Tasks from the copy of workflow that exists in the WFprocessor object and pushes them to the queues in the pending_q list. Since this thread works on the copy o...
python
def _enqueue(self, local_prof): """ **Purpose**: This is the function that is run in the enqueue thread. This function extracts Tasks from the copy of workflow that exists in the WFprocessor object and pushes them to the queues in the pending_q list. Since this thread works on the copy o...
[ "def", "_enqueue", "(", "self", ",", "local_prof", ")", ":", "try", ":", "local_prof", ".", "prof", "(", "'enqueue-thread started'", ",", "uid", "=", "self", ".", "_uid", ")", "self", ".", "_logger", ".", "info", "(", "'enqueue-thread started'", ")", "# Ac...
**Purpose**: This is the function that is run in the enqueue thread. This function extracts Tasks from the copy of workflow that exists in the WFprocessor object and pushes them to the queues in the pending_q list. Since this thread works on the copy of the workflow, every state update to the Task, Stag...
[ "**", "Purpose", "**", ":", "This", "is", "the", "function", "that", "is", "run", "in", "the", "enqueue", "thread", ".", "This", "function", "extracts", "Tasks", "from", "the", "copy", "of", "workflow", "that", "exists", "in", "the", "WFprocessor", "object...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/appman/wfprocessor.py#L106-L271
train
radical-cybertools/radical.entk
src/radical/entk/appman/wfprocessor.py
WFprocessor._dequeue
def _dequeue(self, local_prof): """ **Purpose**: This is the function that is run in the dequeue thread. This function extracts Tasks from the completed queus and updates the copy of workflow that exists in the WFprocessor object. Since this thread works on the copy of the workflow, ever...
python
def _dequeue(self, local_prof): """ **Purpose**: This is the function that is run in the dequeue thread. This function extracts Tasks from the completed queus and updates the copy of workflow that exists in the WFprocessor object. Since this thread works on the copy of the workflow, ever...
[ "def", "_dequeue", "(", "self", ",", "local_prof", ")", ":", "try", ":", "local_prof", ".", "prof", "(", "'dequeue-thread started'", ",", "uid", "=", "self", ".", "_uid", ")", "self", ".", "_logger", ".", "info", "(", "'Dequeue thread started'", ")", "mq_c...
**Purpose**: This is the function that is run in the dequeue thread. This function extracts Tasks from the completed queus and updates the copy of workflow that exists in the WFprocessor object. Since this thread works on the copy of the workflow, every state update to the Task, Stage and Pipeline is ...
[ "**", "Purpose", "**", ":", "This", "is", "the", "function", "that", "is", "run", "in", "the", "dequeue", "thread", ".", "This", "function", "extracts", "Tasks", "from", "the", "completed", "queus", "and", "updates", "the", "copy", "of", "workflow", "that"...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/appman/wfprocessor.py#L273-L456
train
radical-cybertools/radical.entk
src/radical/entk/appman/wfprocessor.py
WFprocessor._wfp
def _wfp(self): """ **Purpose**: This is the function executed in the wfp process. The function is used to simply create and spawn two threads: enqueue, dequeue. The enqueue thread pushes ready tasks to the queues in the pending_q slow list whereas the dequeue thread pulls completed task...
python
def _wfp(self): """ **Purpose**: This is the function executed in the wfp process. The function is used to simply create and spawn two threads: enqueue, dequeue. The enqueue thread pushes ready tasks to the queues in the pending_q slow list whereas the dequeue thread pulls completed task...
[ "def", "_wfp", "(", "self", ")", ":", "try", ":", "local_prof", "=", "ru", ".", "Profiler", "(", "name", "=", "'radical.entk.%s'", "%", "self", ".", "_uid", "+", "'-proc'", ",", "path", "=", "self", ".", "_path", ")", "local_prof", ".", "prof", "(", ...
**Purpose**: This is the function executed in the wfp process. The function is used to simply create and spawn two threads: enqueue, dequeue. The enqueue thread pushes ready tasks to the queues in the pending_q slow list whereas the dequeue thread pulls completed tasks from the queues in the completed_q...
[ "**", "Purpose", "**", ":", "This", "is", "the", "function", "executed", "in", "the", "wfp", "process", ".", "The", "function", "is", "used", "to", "simply", "create", "and", "spawn", "two", "threads", ":", "enqueue", "dequeue", ".", "The", "enqueue", "t...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/appman/wfprocessor.py#L458-L569
train
radical-cybertools/radical.entk
src/radical/entk/appman/wfprocessor.py
WFprocessor.start_processor
def start_processor(self): """ **Purpose**: Method to start the wfp process. The wfp function is not to be accessed directly. The function is started in a separate process using this method. """ if not self._wfp_process: try: self._prof.prof...
python
def start_processor(self): """ **Purpose**: Method to start the wfp process. The wfp function is not to be accessed directly. The function is started in a separate process using this method. """ if not self._wfp_process: try: self._prof.prof...
[ "def", "start_processor", "(", "self", ")", ":", "if", "not", "self", ".", "_wfp_process", ":", "try", ":", "self", ".", "_prof", ".", "prof", "(", "'creating wfp process'", ",", "uid", "=", "self", ".", "_uid", ")", "self", ".", "_wfp_process", "=", "...
**Purpose**: Method to start the wfp process. The wfp function is not to be accessed directly. The function is started in a separate process using this method.
[ "**", "Purpose", "**", ":", "Method", "to", "start", "the", "wfp", "process", ".", "The", "wfp", "function", "is", "not", "to", "be", "accessed", "directly", ".", "The", "function", "is", "started", "in", "a", "separate", "process", "using", "this", "met...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/appman/wfprocessor.py#L575-L610
train
radical-cybertools/radical.entk
src/radical/entk/appman/wfprocessor.py
WFprocessor.terminate_processor
def terminate_processor(self): """ **Purpose**: Method to terminate the wfp process. This method is blocking as it waits for the wfp process to terminate (aka join). """ try: if self.check_processor(): self._logger.debug( 'Attempt...
python
def terminate_processor(self): """ **Purpose**: Method to terminate the wfp process. This method is blocking as it waits for the wfp process to terminate (aka join). """ try: if self.check_processor(): self._logger.debug( 'Attempt...
[ "def", "terminate_processor", "(", "self", ")", ":", "try", ":", "if", "self", ".", "check_processor", "(", ")", ":", "self", ".", "_logger", ".", "debug", "(", "'Attempting to end WFprocessor... event: %s'", "%", "self", ".", "_wfp_terminate", ".", "is_set", ...
**Purpose**: Method to terminate the wfp process. This method is blocking as it waits for the wfp process to terminate (aka join).
[ "**", "Purpose", "**", ":", "Method", "to", "terminate", "the", "wfp", "process", ".", "This", "method", "is", "blocking", "as", "it", "waits", "for", "the", "wfp", "process", "to", "terminate", "(", "aka", "join", ")", "." ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/appman/wfprocessor.py#L612-L636
train
radical-cybertools/radical.entk
src/radical/entk/appman/wfprocessor.py
WFprocessor.workflow_incomplete
def workflow_incomplete(self): """ **Purpose**: Method to check if the workflow execution is incomplete. """ try: for pipe in self._workflow: with pipe.lock: if pipe.completed: pass else: ...
python
def workflow_incomplete(self): """ **Purpose**: Method to check if the workflow execution is incomplete. """ try: for pipe in self._workflow: with pipe.lock: if pipe.completed: pass else: ...
[ "def", "workflow_incomplete", "(", "self", ")", ":", "try", ":", "for", "pipe", "in", "self", ".", "_workflow", ":", "with", "pipe", ".", "lock", ":", "if", "pipe", ".", "completed", ":", "pass", "else", ":", "return", "True", "return", "False", "excep...
**Purpose**: Method to check if the workflow execution is incomplete.
[ "**", "Purpose", "**", ":", "Method", "to", "check", "if", "the", "workflow", "execution", "is", "incomplete", "." ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/appman/wfprocessor.py#L638-L655
train
google/dotty
efilter/protocols/repeated.py
meld
def meld(*values): """Return the repeated value, or the first value if there's only one. This is a convenience function, equivalent to calling getvalue(repeated(x)) to get x. This function skips over instances of None in values (None is not allowed in repeated variables). Examples: me...
python
def meld(*values): """Return the repeated value, or the first value if there's only one. This is a convenience function, equivalent to calling getvalue(repeated(x)) to get x. This function skips over instances of None in values (None is not allowed in repeated variables). Examples: me...
[ "def", "meld", "(", "*", "values", ")", ":", "values", "=", "[", "x", "for", "x", "in", "values", "if", "x", "is", "not", "None", "]", "if", "not", "values", ":", "return", "None", "result", "=", "repeated", "(", "*", "values", ")", "if", "isrepe...
Return the repeated value, or the first value if there's only one. This is a convenience function, equivalent to calling getvalue(repeated(x)) to get x. This function skips over instances of None in values (None is not allowed in repeated variables). Examples: meld("foo", "bar") # => List...
[ "Return", "the", "repeated", "value", "or", "the", "first", "value", "if", "there", "s", "only", "one", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocols/repeated.py#L55-L78
train
google/dotty
efilter/protocols/repeated.py
getvalue
def getvalue(x): """Return the single value of x or raise TypError if more than one value.""" if isrepeating(x): raise TypeError( "Ambiguous call to getvalue for %r which has more than one value." % x) for value in getvalues(x): return value
python
def getvalue(x): """Return the single value of x or raise TypError if more than one value.""" if isrepeating(x): raise TypeError( "Ambiguous call to getvalue for %r which has more than one value." % x) for value in getvalues(x): return value
[ "def", "getvalue", "(", "x", ")", ":", "if", "isrepeating", "(", "x", ")", ":", "raise", "TypeError", "(", "\"Ambiguous call to getvalue for %r which has more than one value.\"", "%", "x", ")", "for", "value", "in", "getvalues", "(", "x", ")", ":", "return", "...
Return the single value of x or raise TypError if more than one value.
[ "Return", "the", "single", "value", "of", "x", "or", "raise", "TypError", "if", "more", "than", "one", "value", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocols/repeated.py#L120-L128
train
radical-cybertools/radical.entk
src/radical/entk/task/task.py
Task.luid
def luid(self): """ Unique ID of the current task (fully qualified). example: >>> task.luid pipe.0001.stage.0004.task.0234 :getter: Returns the fully qualified uid of the current task :type: String """ p_elem = self.parent_pipeline.get('n...
python
def luid(self): """ Unique ID of the current task (fully qualified). example: >>> task.luid pipe.0001.stage.0004.task.0234 :getter: Returns the fully qualified uid of the current task :type: String """ p_elem = self.parent_pipeline.get('n...
[ "def", "luid", "(", "self", ")", ":", "p_elem", "=", "self", ".", "parent_pipeline", ".", "get", "(", "'name'", ")", "if", "not", "p_elem", ":", "p_elem", "=", "self", ".", "parent_pipeline", "[", "'uid'", "]", "s_elem", "=", "self", ".", "parent_stage...
Unique ID of the current task (fully qualified). example: >>> task.luid pipe.0001.stage.0004.task.0234 :getter: Returns the fully qualified uid of the current task :type: String
[ "Unique", "ID", "of", "the", "current", "task", "(", "fully", "qualified", ")", "." ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/task/task.py#L88-L111
train
radical-cybertools/radical.entk
src/radical/entk/task/task.py
Task.to_dict
def to_dict(self): """ Convert current Task into a dictionary :return: python dictionary """ task_desc_as_dict = { 'uid': self._uid, 'name': self._name, 'state': self._state, 'state_history': self._state_history, 'pre...
python
def to_dict(self): """ Convert current Task into a dictionary :return: python dictionary """ task_desc_as_dict = { 'uid': self._uid, 'name': self._name, 'state': self._state, 'state_history': self._state_history, 'pre...
[ "def", "to_dict", "(", "self", ")", ":", "task_desc_as_dict", "=", "{", "'uid'", ":", "self", ".", "_uid", ",", "'name'", ":", "self", ".", "_name", ",", "'state'", ":", "self", ".", "_state", ",", "'state_history'", ":", "self", ".", "_state_history", ...
Convert current Task into a dictionary :return: python dictionary
[ "Convert", "current", "Task", "into", "a", "dictionary" ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/task/task.py#L724-L764
train
radical-cybertools/radical.entk
src/radical/entk/task/task.py
Task.from_dict
def from_dict(self, d): """ Create a Task from a dictionary. The change is in inplace. :argument: python dictionary :return: None """ if 'uid' in d: if d['uid']: self._uid = d['uid'] if 'name' in d: if d['name']: ...
python
def from_dict(self, d): """ Create a Task from a dictionary. The change is in inplace. :argument: python dictionary :return: None """ if 'uid' in d: if d['uid']: self._uid = d['uid'] if 'name' in d: if d['name']: ...
[ "def", "from_dict", "(", "self", ",", "d", ")", ":", "if", "'uid'", "in", "d", ":", "if", "d", "[", "'uid'", "]", ":", "self", ".", "_uid", "=", "d", "[", "'uid'", "]", "if", "'name'", "in", "d", ":", "if", "d", "[", "'name'", "]", ":", "se...
Create a Task from a dictionary. The change is in inplace. :argument: python dictionary :return: None
[ "Create", "a", "Task", "from", "a", "dictionary", ".", "The", "change", "is", "in", "inplace", "." ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/task/task.py#L766-L948
train
radical-cybertools/radical.entk
src/radical/entk/task/task.py
Task._assign_uid
def _assign_uid(self, sid): """ Purpose: Assign a uid to the current object based on the sid passed """ self._uid = ru.generate_id( 'task.%(item_counter)04d', ru.ID_CUSTOM, namespace=sid)
python
def _assign_uid(self, sid): """ Purpose: Assign a uid to the current object based on the sid passed """ self._uid = ru.generate_id( 'task.%(item_counter)04d', ru.ID_CUSTOM, namespace=sid)
[ "def", "_assign_uid", "(", "self", ",", "sid", ")", ":", "self", ".", "_uid", "=", "ru", ".", "generate_id", "(", "'task.%(item_counter)04d'", ",", "ru", ".", "ID_CUSTOM", ",", "namespace", "=", "sid", ")" ]
Purpose: Assign a uid to the current object based on the sid passed
[ "Purpose", ":", "Assign", "a", "uid", "to", "the", "current", "object", "based", "on", "the", "sid", "passed" ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/task/task.py#L954-L959
train
radical-cybertools/radical.entk
src/radical/entk/task/task.py
Task._validate
def _validate(self): """ Purpose: Validate that the state of the task is 'DESCRIBED' and that an executable has been specified for the task. """ if self._state is not states.INITIAL: raise ValueError(obj=self._uid, attribute='state', ...
python
def _validate(self): """ Purpose: Validate that the state of the task is 'DESCRIBED' and that an executable has been specified for the task. """ if self._state is not states.INITIAL: raise ValueError(obj=self._uid, attribute='state', ...
[ "def", "_validate", "(", "self", ")", ":", "if", "self", ".", "_state", "is", "not", "states", ".", "INITIAL", ":", "raise", "ValueError", "(", "obj", "=", "self", ".", "_uid", ",", "attribute", "=", "'state'", ",", "expected_value", "=", "states", "."...
Purpose: Validate that the state of the task is 'DESCRIBED' and that an executable has been specified for the task.
[ "Purpose", ":", "Validate", "that", "the", "state", "of", "the", "task", "is", "DESCRIBED", "and", "that", "an", "executable", "has", "been", "specified", "for", "the", "task", "." ]
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/task/task.py#L961-L975
train
radical-cybertools/radical.entk
src/radical/entk/execman/rp/task_manager.py
TaskManager._process_tasks
def _process_tasks(self, task_queue, rmgr, logger, mq_hostname, port, local_prof, sid): ''' **Purpose**: The new thread that gets spawned by the main tmgr process invokes this function. This function receives tasks from 'task_queue' and submits them to the RADICAL Pilot RTS. ''' ...
python
def _process_tasks(self, task_queue, rmgr, logger, mq_hostname, port, local_prof, sid): ''' **Purpose**: The new thread that gets spawned by the main tmgr process invokes this function. This function receives tasks from 'task_queue' and submits them to the RADICAL Pilot RTS. ''' ...
[ "def", "_process_tasks", "(", "self", ",", "task_queue", ",", "rmgr", ",", "logger", ",", "mq_hostname", ",", "port", ",", "local_prof", ",", "sid", ")", ":", "placeholder_dict", "=", "dict", "(", ")", "def", "load_placeholder", "(", "task", ",", "rts_uid"...
**Purpose**: The new thread that gets spawned by the main tmgr process invokes this function. This function receives tasks from 'task_queue' and submits them to the RADICAL Pilot RTS.
[ "**", "Purpose", "**", ":", "The", "new", "thread", "that", "gets", "spawned", "by", "the", "main", "tmgr", "process", "invokes", "this", "function", ".", "This", "function", "receives", "tasks", "from", "task_queue", "and", "submits", "them", "to", "the", ...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/rp/task_manager.py#L187-L330
train
google/dotty
efilter/transforms/infer_type.py
infer_type
def infer_type(expr, scope): """Try to infer the type of x[y] if y is a known value (literal).""" # Do we know what the key even is? if isinstance(expr.key, ast.Literal): key = expr.key.value else: return protocol.AnyType container_type = infer_type(expr.value, scope) try: ...
python
def infer_type(expr, scope): """Try to infer the type of x[y] if y is a known value (literal).""" # Do we know what the key even is? if isinstance(expr.key, ast.Literal): key = expr.key.value else: return protocol.AnyType container_type = infer_type(expr.value, scope) try: ...
[ "def", "infer_type", "(", "expr", ",", "scope", ")", ":", "# Do we know what the key even is?", "if", "isinstance", "(", "expr", ".", "key", ",", "ast", ".", "Literal", ")", ":", "key", "=", "expr", ".", "key", ".", "value", "else", ":", "return", "proto...
Try to infer the type of x[y] if y is a known value (literal).
[ "Try", "to", "infer", "the", "type", "of", "x", "[", "y", "]", "if", "y", "is", "a", "known", "value", "(", "literal", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/infer_type.py#L108-L123
train
google/dotty
efilter/transforms/infer_type.py
infer_type
def infer_type(expr, scope): """Try to infer the type of x.y if y is a known value (literal).""" # Do we know what the member is? if isinstance(expr.member, ast.Literal): member = expr.member.value else: return protocol.AnyType container_type = infer_type(expr.obj, scope) try: ...
python
def infer_type(expr, scope): """Try to infer the type of x.y if y is a known value (literal).""" # Do we know what the member is? if isinstance(expr.member, ast.Literal): member = expr.member.value else: return protocol.AnyType container_type = infer_type(expr.obj, scope) try: ...
[ "def", "infer_type", "(", "expr", ",", "scope", ")", ":", "# Do we know what the member is?", "if", "isinstance", "(", "expr", ".", "member", ",", "ast", ".", "Literal", ")", ":", "member", "=", "expr", ".", "member", ".", "value", "else", ":", "return", ...
Try to infer the type of x.y if y is a known value (literal).
[ "Try", "to", "infer", "the", "type", "of", "x", ".", "y", "if", "y", "is", "a", "known", "value", "(", "literal", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/transforms/infer_type.py#L127-L142
train
radical-cybertools/radical.entk
src/radical/entk/execman/mock/task_manager.py
TaskManager._tmgr
def _tmgr(self, uid, rmgr, logger, mq_hostname, port, pending_queue, completed_queue): """ **Purpose**: Method to be run by the tmgr process. This method receives a Task from the pending_queue and submits it to the RTS. Currently, it also converts Tasks into CUDs and CUs into (partially describe...
python
def _tmgr(self, uid, rmgr, logger, mq_hostname, port, pending_queue, completed_queue): """ **Purpose**: Method to be run by the tmgr process. This method receives a Task from the pending_queue and submits it to the RTS. Currently, it also converts Tasks into CUDs and CUs into (partially describe...
[ "def", "_tmgr", "(", "self", ",", "uid", ",", "rmgr", ",", "logger", ",", "mq_hostname", ",", "port", ",", "pending_queue", ",", "completed_queue", ")", ":", "try", ":", "def", "heartbeat_response", "(", "mq_channel", ")", ":", "try", ":", "# Get request f...
**Purpose**: Method to be run by the tmgr process. This method receives a Task from the pending_queue and submits it to the RTS. Currently, it also converts Tasks into CUDs and CUs into (partially described) Tasks. This conversion is necessary since the current RTS is RADICAL Pilot. Once Tasks are recov...
[ "**", "Purpose", "**", ":", "Method", "to", "be", "run", "by", "the", "tmgr", "process", ".", "This", "method", "receives", "a", "Task", "from", "the", "pending_queue", "and", "submits", "it", "to", "the", "RTS", ".", "Currently", "it", "also", "converts...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/mock/task_manager.py#L59-L171
train
radical-cybertools/radical.entk
src/radical/entk/execman/mock/task_manager.py
TaskManager.start_manager
def start_manager(self): """ **Purpose**: Method to start the tmgr process. The tmgr function is not to be accessed directly. The function is started in a separate thread using this method. """ if not self._tmgr_process: try: self._prof.prof...
python
def start_manager(self): """ **Purpose**: Method to start the tmgr process. The tmgr function is not to be accessed directly. The function is started in a separate thread using this method. """ if not self._tmgr_process: try: self._prof.prof...
[ "def", "start_manager", "(", "self", ")", ":", "if", "not", "self", ".", "_tmgr_process", ":", "try", ":", "self", ".", "_prof", ".", "prof", "(", "'creating tmgr process'", ",", "uid", "=", "self", ".", "_uid", ")", "self", ".", "_tmgr_terminate", "=", ...
**Purpose**: Method to start the tmgr process. The tmgr function is not to be accessed directly. The function is started in a separate thread using this method.
[ "**", "Purpose", "**", ":", "Method", "to", "start", "the", "tmgr", "process", ".", "The", "tmgr", "function", "is", "not", "to", "be", "accessed", "directly", ".", "The", "function", "is", "started", "in", "a", "separate", "thread", "using", "this", "me...
945f6c93c9a62db90ad191b306418d5c1cdd9d24
https://github.com/radical-cybertools/radical.entk/blob/945f6c93c9a62db90ad191b306418d5c1cdd9d24/src/radical/entk/execman/mock/task_manager.py#L277-L317
train
google/dotty
efilter/parsers/common/grammar.py
keyword
def keyword(tokens, expected): """Case-insensitive keyword match.""" try: token = next(iter(tokens)) except StopIteration: return if token and token.name == "symbol" and token.value.lower() == expected: return TokenMatch(None, token.value, (token,))
python
def keyword(tokens, expected): """Case-insensitive keyword match.""" try: token = next(iter(tokens)) except StopIteration: return if token and token.name == "symbol" and token.value.lower() == expected: return TokenMatch(None, token.value, (token,))
[ "def", "keyword", "(", "tokens", ",", "expected", ")", ":", "try", ":", "token", "=", "next", "(", "iter", "(", "tokens", ")", ")", "except", "StopIteration", ":", "return", "if", "token", "and", "token", ".", "name", "==", "\"symbol\"", "and", "token"...
Case-insensitive keyword match.
[ "Case", "-", "insensitive", "keyword", "match", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/grammar.py#L234-L242
train
google/dotty
efilter/parsers/common/grammar.py
multi_keyword
def multi_keyword(tokens, keyword_parts): """Match a case-insensitive keyword consisting of multiple tokens.""" tokens = iter(tokens) matched_tokens = [] limit = len(keyword_parts) for idx in six.moves.range(limit): try: token = next(tokens) except StopIteration: ...
python
def multi_keyword(tokens, keyword_parts): """Match a case-insensitive keyword consisting of multiple tokens.""" tokens = iter(tokens) matched_tokens = [] limit = len(keyword_parts) for idx in six.moves.range(limit): try: token = next(tokens) except StopIteration: ...
[ "def", "multi_keyword", "(", "tokens", ",", "keyword_parts", ")", ":", "tokens", "=", "iter", "(", "tokens", ")", "matched_tokens", "=", "[", "]", "limit", "=", "len", "(", "keyword_parts", ")", "for", "idx", "in", "six", ".", "moves", ".", "range", "(...
Match a case-insensitive keyword consisting of multiple tokens.
[ "Match", "a", "case", "-", "insensitive", "keyword", "consisting", "of", "multiple", "tokens", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/grammar.py#L245-L263
train
google/dotty
efilter/parsers/common/grammar.py
prefix
def prefix(tokens, operator_table): """Match a prefix of an operator.""" operator, matched_tokens = operator_table.prefix.match(tokens) if operator: return TokenMatch(operator, None, matched_tokens)
python
def prefix(tokens, operator_table): """Match a prefix of an operator.""" operator, matched_tokens = operator_table.prefix.match(tokens) if operator: return TokenMatch(operator, None, matched_tokens)
[ "def", "prefix", "(", "tokens", ",", "operator_table", ")", ":", "operator", ",", "matched_tokens", "=", "operator_table", ".", "prefix", ".", "match", "(", "tokens", ")", "if", "operator", ":", "return", "TokenMatch", "(", "operator", ",", "None", ",", "m...
Match a prefix of an operator.
[ "Match", "a", "prefix", "of", "an", "operator", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/grammar.py#L281-L285
train
google/dotty
efilter/parsers/common/grammar.py
infix
def infix(tokens, operator_table): """Match an infix of an operator.""" operator, matched_tokens = operator_table.infix.match(tokens) if operator: return TokenMatch(operator, None, matched_tokens)
python
def infix(tokens, operator_table): """Match an infix of an operator.""" operator, matched_tokens = operator_table.infix.match(tokens) if operator: return TokenMatch(operator, None, matched_tokens)
[ "def", "infix", "(", "tokens", ",", "operator_table", ")", ":", "operator", ",", "matched_tokens", "=", "operator_table", ".", "infix", ".", "match", "(", "tokens", ")", "if", "operator", ":", "return", "TokenMatch", "(", "operator", ",", "None", ",", "mat...
Match an infix of an operator.
[ "Match", "an", "infix", "of", "an", "operator", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/grammar.py#L288-L292
train
google/dotty
efilter/parsers/common/grammar.py
suffix
def suffix(tokens, operator_table): """Match a suffix of an operator.""" operator, matched_tokens = operator_table.suffix.match(tokens) if operator: return TokenMatch(operator, None, matched_tokens)
python
def suffix(tokens, operator_table): """Match a suffix of an operator.""" operator, matched_tokens = operator_table.suffix.match(tokens) if operator: return TokenMatch(operator, None, matched_tokens)
[ "def", "suffix", "(", "tokens", ",", "operator_table", ")", ":", "operator", ",", "matched_tokens", "=", "operator_table", ".", "suffix", ".", "match", "(", "tokens", ")", "if", "operator", ":", "return", "TokenMatch", "(", "operator", ",", "None", ",", "m...
Match a suffix of an operator.
[ "Match", "a", "suffix", "of", "an", "operator", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/grammar.py#L295-L299
train
google/dotty
efilter/parsers/common/grammar.py
token_name
def token_name(tokens, expected): """Match a token name (type).""" try: token = next(iter(tokens)) except StopIteration: return if token and token.name == expected: return TokenMatch(None, token.value, (token,))
python
def token_name(tokens, expected): """Match a token name (type).""" try: token = next(iter(tokens)) except StopIteration: return if token and token.name == expected: return TokenMatch(None, token.value, (token,))
[ "def", "token_name", "(", "tokens", ",", "expected", ")", ":", "try", ":", "token", "=", "next", "(", "iter", "(", "tokens", ")", ")", "except", "StopIteration", ":", "return", "if", "token", "and", "token", ".", "name", "==", "expected", ":", "return"...
Match a token name (type).
[ "Match", "a", "token", "name", "(", "type", ")", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/grammar.py#L302-L310
train
google/dotty
efilter/parsers/common/grammar.py
match_tokens
def match_tokens(expected_tokens): """Generate a grammar function that will match 'expected_tokens' only.""" if isinstance(expected_tokens, Token): # Match a single token. def _grammar_func(tokens): try: next_token = next(iter(tokens)) except StopIteration...
python
def match_tokens(expected_tokens): """Generate a grammar function that will match 'expected_tokens' only.""" if isinstance(expected_tokens, Token): # Match a single token. def _grammar_func(tokens): try: next_token = next(iter(tokens)) except StopIteration...
[ "def", "match_tokens", "(", "expected_tokens", ")", ":", "if", "isinstance", "(", "expected_tokens", ",", "Token", ")", ":", "# Match a single token.", "def", "_grammar_func", "(", "tokens", ")", ":", "try", ":", "next_token", "=", "next", "(", "iter", "(", ...
Generate a grammar function that will match 'expected_tokens' only.
[ "Generate", "a", "grammar", "function", "that", "will", "match", "expected_tokens", "only", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/grammar.py#L313-L338
train
bradmontgomery/django-redis-metrics
redis_metrics/utils.py
set_metric
def set_metric(slug, value, category=None, expire=None, date=None): """Create/Increment a metric.""" get_r().set_metric(slug, value, category=category, expire=expire, date=date)
python
def set_metric(slug, value, category=None, expire=None, date=None): """Create/Increment a metric.""" get_r().set_metric(slug, value, category=category, expire=expire, date=date)
[ "def", "set_metric", "(", "slug", ",", "value", ",", "category", "=", "None", ",", "expire", "=", "None", ",", "date", "=", "None", ")", ":", "get_r", "(", ")", ".", "set_metric", "(", "slug", ",", "value", ",", "category", "=", "category", ",", "e...
Create/Increment a metric.
[ "Create", "/", "Increment", "a", "metric", "." ]
2c92332920113d28c39234b949aa496b39a091d1
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/utils.py#L18-L20
train
bradmontgomery/django-redis-metrics
redis_metrics/utils.py
metric
def metric(slug, num=1, category=None, expire=None, date=None): """Create/Increment a metric.""" get_r().metric(slug, num=num, category=category, expire=expire, date=date)
python
def metric(slug, num=1, category=None, expire=None, date=None): """Create/Increment a metric.""" get_r().metric(slug, num=num, category=category, expire=expire, date=date)
[ "def", "metric", "(", "slug", ",", "num", "=", "1", ",", "category", "=", "None", ",", "expire", "=", "None", ",", "date", "=", "None", ")", ":", "get_r", "(", ")", ".", "metric", "(", "slug", ",", "num", "=", "num", ",", "category", "=", "cate...
Create/Increment a metric.
[ "Create", "/", "Increment", "a", "metric", "." ]
2c92332920113d28c39234b949aa496b39a091d1
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/utils.py#L23-L25
train
google/dotty
efilter/parsers/dottysql/parser.py
Parser.expression
def expression(self, previous_precedence=0): """An expression is an atom or an infix expression. Grammar (sort of, actually a precedence-climbing parser): expression = atom [ binary_operator expression ] . Args: previous_precedence: What operator precedence should we st...
python
def expression(self, previous_precedence=0): """An expression is an atom or an infix expression. Grammar (sort of, actually a precedence-climbing parser): expression = atom [ binary_operator expression ] . Args: previous_precedence: What operator precedence should we st...
[ "def", "expression", "(", "self", ",", "previous_precedence", "=", "0", ")", ":", "lhs", "=", "self", ".", "atom", "(", ")", "return", "self", ".", "operator", "(", "lhs", ",", "previous_precedence", ")" ]
An expression is an atom or an infix expression. Grammar (sort of, actually a precedence-climbing parser): expression = atom [ binary_operator expression ] . Args: previous_precedence: What operator precedence should we start with?
[ "An", "expression", "is", "an", "atom", "or", "an", "infix", "expression", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L143-L154
train
google/dotty
efilter/parsers/dottysql/parser.py
Parser.atom
def atom(self): """Parse an atom, which is most things. Grammar: atom = [ prefix ] ( select_expression | any_expression | func_application | let_expr | var | literal ...
python
def atom(self): """Parse an atom, which is most things. Grammar: atom = [ prefix ] ( select_expression | any_expression | func_application | let_expr | var | literal ...
[ "def", "atom", "(", "self", ")", ":", "# Parameter replacement with literals.", "if", "self", ".", "tokens", ".", "accept", "(", "grammar", ".", "param", ")", ":", "return", "self", ".", "param", "(", ")", "# Let expressions (let(x = 5, y = 10) x + y)", "if", "s...
Parse an atom, which is most things. Grammar: atom = [ prefix ] ( select_expression | any_expression | func_application | let_expr | var | literal | list |...
[ "Parse", "an", "atom", "which", "is", "most", "things", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L156-L259
train
google/dotty
efilter/parsers/dottysql/parser.py
Parser.accept_operator
def accept_operator(self, precedence): """Accept the next binary operator only if it's of higher precedence.""" match = grammar.infix(self.tokens) if not match: return if match.operator.precedence < precedence: return # The next thing is an operator that...
python
def accept_operator(self, precedence): """Accept the next binary operator only if it's of higher precedence.""" match = grammar.infix(self.tokens) if not match: return if match.operator.precedence < precedence: return # The next thing is an operator that...
[ "def", "accept_operator", "(", "self", ",", "precedence", ")", ":", "match", "=", "grammar", ".", "infix", "(", "self", ".", "tokens", ")", "if", "not", "match", ":", "return", "if", "match", ".", "operator", ".", "precedence", "<", "precedence", ":", ...
Accept the next binary operator only if it's of higher precedence.
[ "Accept", "the", "next", "binary", "operator", "only", "if", "it", "s", "of", "higher", "precedence", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L315-L325
train
google/dotty
efilter/parsers/dottysql/parser.py
Parser.operator
def operator(self, lhs, min_precedence): """Climb operator precedence as long as there are operators. This function implements a basic precedence climbing parser to deal with binary operators in a sane fashion. The outer loop will keep spinning as long as the next token is an operator w...
python
def operator(self, lhs, min_precedence): """Climb operator precedence as long as there are operators. This function implements a basic precedence climbing parser to deal with binary operators in a sane fashion. The outer loop will keep spinning as long as the next token is an operator w...
[ "def", "operator", "(", "self", ",", "lhs", ",", "min_precedence", ")", ":", "# Spin as long as the next token is an operator of higher", "# precedence. (This may not do anything, which is fine.)", "while", "self", ".", "accept_operator", "(", "precedence", "=", "min_precedence...
Climb operator precedence as long as there are operators. This function implements a basic precedence climbing parser to deal with binary operators in a sane fashion. The outer loop will keep spinning as long as the next token is an operator with a precedence of at least 'min_precedence...
[ "Climb", "operator", "precedence", "as", "long", "as", "there", "are", "operators", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L327-L377
train
google/dotty
efilter/parsers/dottysql/parser.py
Parser.dot_rhs
def dot_rhs(self): """Match the right-hand side of a dot (.) operator. The RHS must be a symbol token, but it is interpreted as a literal string (because that's what goes in the AST of Resolve.) """ self.tokens.expect(common_grammar.symbol) return ast.Literal(self.tokens...
python
def dot_rhs(self): """Match the right-hand side of a dot (.) operator. The RHS must be a symbol token, but it is interpreted as a literal string (because that's what goes in the AST of Resolve.) """ self.tokens.expect(common_grammar.symbol) return ast.Literal(self.tokens...
[ "def", "dot_rhs", "(", "self", ")", ":", "self", ".", "tokens", ".", "expect", "(", "common_grammar", ".", "symbol", ")", "return", "ast", ".", "Literal", "(", "self", ".", "tokens", ".", "matched", ".", "value", ",", "start", "=", "self", ".", "toke...
Match the right-hand side of a dot (.) operator. The RHS must be a symbol token, but it is interpreted as a literal string (because that's what goes in the AST of Resolve.)
[ "Match", "the", "right", "-", "hand", "side", "of", "a", "dot", "(", ".", ")", "operator", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L379-L388
train
google/dotty
efilter/parsers/dottysql/parser.py
Parser.select
def select(self): """First part of an SQL query.""" # Try to match the asterisk, any or list of vars. if self.tokens.accept(grammar.select_any): return self.select_any() if self.tokens.accept(grammar.select_all): # The FROM after SELECT * is required. ...
python
def select(self): """First part of an SQL query.""" # Try to match the asterisk, any or list of vars. if self.tokens.accept(grammar.select_any): return self.select_any() if self.tokens.accept(grammar.select_all): # The FROM after SELECT * is required. ...
[ "def", "select", "(", "self", ")", ":", "# Try to match the asterisk, any or list of vars.", "if", "self", ".", "tokens", ".", "accept", "(", "grammar", ".", "select_any", ")", ":", "return", "self", ".", "select_any", "(", ")", "if", "self", ".", "tokens", ...
First part of an SQL query.
[ "First", "part", "of", "an", "SQL", "query", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L392-L403
train
google/dotty
efilter/parsers/dottysql/parser.py
Parser._guess_name_of
def _guess_name_of(self, expr): """Tries to guess what variable name 'expr' ends in. This is a heuristic that roughly emulates what most SQL databases name columns, based on selected variable names or applied functions. """ if isinstance(expr, ast.Var): return expr.v...
python
def _guess_name_of(self, expr): """Tries to guess what variable name 'expr' ends in. This is a heuristic that roughly emulates what most SQL databases name columns, based on selected variable names or applied functions. """ if isinstance(expr, ast.Var): return expr.v...
[ "def", "_guess_name_of", "(", "self", ",", "expr", ")", ":", "if", "isinstance", "(", "expr", ",", "ast", ".", "Var", ")", ":", "return", "expr", ".", "value", "if", "isinstance", "(", "expr", ",", "ast", ".", "Resolve", ")", ":", "# We know the RHS of...
Tries to guess what variable name 'expr' ends in. This is a heuristic that roughly emulates what most SQL databases name columns, based on selected variable names or applied functions.
[ "Tries", "to", "guess", "what", "variable", "name", "expr", "ends", "in", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L439-L459
train
google/dotty
efilter/parsers/dottysql/parser.py
Parser.select_limit
def select_limit(self, source_expression): """Match LIMIT take [OFFSET drop].""" start = self.tokens.matched.start # The expression right after LIMIT is the count to take. limit_count_expression = self.expression() # Optional OFFSET follows. if self.tokens.accept(gramma...
python
def select_limit(self, source_expression): """Match LIMIT take [OFFSET drop].""" start = self.tokens.matched.start # The expression right after LIMIT is the count to take. limit_count_expression = self.expression() # Optional OFFSET follows. if self.tokens.accept(gramma...
[ "def", "select_limit", "(", "self", ",", "source_expression", ")", ":", "start", "=", "self", ".", "tokens", ".", "matched", ".", "start", "# The expression right after LIMIT is the count to take.", "limit_count_expression", "=", "self", ".", "expression", "(", ")", ...
Match LIMIT take [OFFSET drop].
[ "Match", "LIMIT", "take", "[", "OFFSET", "drop", "]", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L573-L607
train
google/dotty
efilter/parsers/dottysql/parser.py
Parser.builtin
def builtin(self, keyword): """Parse the pseudo-function application subgrammar.""" # The match includes the lparen token, so the keyword is just the first # token in the match, not the whole thing. keyword_start = self.tokens.matched.first.start keyword_end = self.tokens.matched...
python
def builtin(self, keyword): """Parse the pseudo-function application subgrammar.""" # The match includes the lparen token, so the keyword is just the first # token in the match, not the whole thing. keyword_start = self.tokens.matched.first.start keyword_end = self.tokens.matched...
[ "def", "builtin", "(", "self", ",", "keyword", ")", ":", "# The match includes the lparen token, so the keyword is just the first", "# token in the match, not the whole thing.", "keyword_start", "=", "self", ".", "tokens", ".", "matched", ".", "first", ".", "start", "keywor...
Parse the pseudo-function application subgrammar.
[ "Parse", "the", "pseudo", "-", "function", "application", "subgrammar", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L611-L638
train
google/dotty
efilter/parsers/dottysql/parser.py
Parser.application
def application(self, func): """Parse the function application subgrammar. Function application can, conceptually, be thought of as a mixfix operator, similar to the way array subscripting works. However, it is not clear at this point whether we want to allow it to work as such, ...
python
def application(self, func): """Parse the function application subgrammar. Function application can, conceptually, be thought of as a mixfix operator, similar to the way array subscripting works. However, it is not clear at this point whether we want to allow it to work as such, ...
[ "def", "application", "(", "self", ",", "func", ")", ":", "start", "=", "self", ".", "tokens", ".", "matched", ".", "start", "if", "self", ".", "tokens", ".", "accept", "(", "common_grammar", ".", "rparen", ")", ":", "# That was easy.", "return", "ast", ...
Parse the function application subgrammar. Function application can, conceptually, be thought of as a mixfix operator, similar to the way array subscripting works. However, it is not clear at this point whether we want to allow it to work as such, because doing so would permit queries t...
[ "Parse", "the", "function", "application", "subgrammar", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L666-L695
train
google/dotty
efilter/parsers/dottysql/parser.py
Parser.list
def list(self): """Parse a list (tuple) which can contain any combination of types.""" start = self.tokens.matched.start if self.tokens.accept(common_grammar.rbracket): return ast.Tuple(start=start, end=self.tokens.matched.end, source=self.original) ...
python
def list(self): """Parse a list (tuple) which can contain any combination of types.""" start = self.tokens.matched.start if self.tokens.accept(common_grammar.rbracket): return ast.Tuple(start=start, end=self.tokens.matched.end, source=self.original) ...
[ "def", "list", "(", "self", ")", ":", "start", "=", "self", ".", "tokens", ".", "matched", ".", "start", "if", "self", ".", "tokens", ".", "accept", "(", "common_grammar", ".", "rbracket", ")", ":", "return", "ast", ".", "Tuple", "(", "start", "=", ...
Parse a list (tuple) which can contain any combination of types.
[ "Parse", "a", "list", "(", "tuple", ")", "which", "can", "contain", "any", "combination", "of", "types", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L699-L714
train
google/dotty
efilter/ext/row_tuple.py
RowTuple.get_singleton
def get_singleton(self): """If the row only has one column, return that value; otherwise raise. Raises: ValueError, if count of columns is not 1. """ only_value = None for value in six.itervalues(self.ordered_dict): # This loop will raise if it runs more ...
python
def get_singleton(self): """If the row only has one column, return that value; otherwise raise. Raises: ValueError, if count of columns is not 1. """ only_value = None for value in six.itervalues(self.ordered_dict): # This loop will raise if it runs more ...
[ "def", "get_singleton", "(", "self", ")", ":", "only_value", "=", "None", "for", "value", "in", "six", ".", "itervalues", "(", "self", ".", "ordered_dict", ")", ":", "# This loop will raise if it runs more than once.", "if", "only_value", "is", "not", "None", ":...
If the row only has one column, return that value; otherwise raise. Raises: ValueError, if count of columns is not 1.
[ "If", "the", "row", "only", "has", "one", "column", "return", "that", "value", ";", "otherwise", "raise", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/ext/row_tuple.py#L93-L110
train
bradmontgomery/django-redis-metrics
redis_metrics/management/commands/system_metric.py
Command._cpu
def _cpu(self): """Record CPU usage.""" value = int(psutil.cpu_percent()) set_metric("cpu", value, category=self.category) gauge("cpu", value)
python
def _cpu(self): """Record CPU usage.""" value = int(psutil.cpu_percent()) set_metric("cpu", value, category=self.category) gauge("cpu", value)
[ "def", "_cpu", "(", "self", ")", ":", "value", "=", "int", "(", "psutil", ".", "cpu_percent", "(", ")", ")", "set_metric", "(", "\"cpu\"", ",", "value", ",", "category", "=", "self", ".", "category", ")", "gauge", "(", "\"cpu\"", ",", "value", ")" ]
Record CPU usage.
[ "Record", "CPU", "usage", "." ]
2c92332920113d28c39234b949aa496b39a091d1
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/management/commands/system_metric.py#L83-L87
train
bradmontgomery/django-redis-metrics
redis_metrics/management/commands/system_metric.py
Command._mem
def _mem(self): """Record Memory usage.""" value = int(psutil.virtual_memory().percent) set_metric("memory", value, category=self.category) gauge("memory", value)
python
def _mem(self): """Record Memory usage.""" value = int(psutil.virtual_memory().percent) set_metric("memory", value, category=self.category) gauge("memory", value)
[ "def", "_mem", "(", "self", ")", ":", "value", "=", "int", "(", "psutil", ".", "virtual_memory", "(", ")", ".", "percent", ")", "set_metric", "(", "\"memory\"", ",", "value", ",", "category", "=", "self", ".", "category", ")", "gauge", "(", "\"memory\"...
Record Memory usage.
[ "Record", "Memory", "usage", "." ]
2c92332920113d28c39234b949aa496b39a091d1
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/management/commands/system_metric.py#L89-L93
train
bradmontgomery/django-redis-metrics
redis_metrics/management/commands/system_metric.py
Command._disk
def _disk(self): """Record Disk usage.""" mountpoints = [ p.mountpoint for p in psutil.disk_partitions() if p.device.endswith(self.device) ] if len(mountpoints) != 1: raise CommandError("Unknown device: {0}".format(self.device)) value = int(ps...
python
def _disk(self): """Record Disk usage.""" mountpoints = [ p.mountpoint for p in psutil.disk_partitions() if p.device.endswith(self.device) ] if len(mountpoints) != 1: raise CommandError("Unknown device: {0}".format(self.device)) value = int(ps...
[ "def", "_disk", "(", "self", ")", ":", "mountpoints", "=", "[", "p", ".", "mountpoint", "for", "p", "in", "psutil", ".", "disk_partitions", "(", ")", "if", "p", ".", "device", ".", "endswith", "(", "self", ".", "device", ")", "]", "if", "len", "(",...
Record Disk usage.
[ "Record", "Disk", "usage", "." ]
2c92332920113d28c39234b949aa496b39a091d1
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/management/commands/system_metric.py#L95-L106
train
bradmontgomery/django-redis-metrics
redis_metrics/management/commands/system_metric.py
Command._net
def _net(self): """Record Network usage.""" data = psutil.network_io_counters(pernic=True) if self.device not in data: raise CommandError("Unknown device: {0}".format(self.device)) # Network bytes sent value = data[self.device].bytes_sent metric("net-{0}-sent...
python
def _net(self): """Record Network usage.""" data = psutil.network_io_counters(pernic=True) if self.device not in data: raise CommandError("Unknown device: {0}".format(self.device)) # Network bytes sent value = data[self.device].bytes_sent metric("net-{0}-sent...
[ "def", "_net", "(", "self", ")", ":", "data", "=", "psutil", ".", "network_io_counters", "(", "pernic", "=", "True", ")", "if", "self", ".", "device", "not", "in", "data", ":", "raise", "CommandError", "(", "\"Unknown device: {0}\"", ".", "format", "(", ...
Record Network usage.
[ "Record", "Network", "usage", "." ]
2c92332920113d28c39234b949aa496b39a091d1
https://github.com/bradmontgomery/django-redis-metrics/blob/2c92332920113d28c39234b949aa496b39a091d1/redis_metrics/management/commands/system_metric.py#L108-L121
train
google/dotty
efilter/protocol.py
implements
def implements(obj, protocol): """Does the object 'obj' implement the 'prococol'?""" if isinstance(obj, type): raise TypeError("First argument to implements must be an instance. " "Got %r." % obj) return isinstance(obj, protocol) or issubclass(AnyType, protocol)
python
def implements(obj, protocol): """Does the object 'obj' implement the 'prococol'?""" if isinstance(obj, type): raise TypeError("First argument to implements must be an instance. " "Got %r." % obj) return isinstance(obj, protocol) or issubclass(AnyType, protocol)
[ "def", "implements", "(", "obj", ",", "protocol", ")", ":", "if", "isinstance", "(", "obj", ",", "type", ")", ":", "raise", "TypeError", "(", "\"First argument to implements must be an instance. \"", "\"Got %r.\"", "%", "obj", ")", "return", "isinstance", "(", "...
Does the object 'obj' implement the 'prococol'?
[ "Does", "the", "object", "obj", "implement", "the", "prococol", "?" ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L73-L78
train
google/dotty
efilter/protocol.py
isa
def isa(cls, protocol): """Does the type 'cls' participate in the 'protocol'?""" if not isinstance(cls, type): raise TypeError("First argument to isa must be a type. Got %s." % repr(cls)) if not isinstance(protocol, type): raise TypeError(("Second argument to isa mus...
python
def isa(cls, protocol): """Does the type 'cls' participate in the 'protocol'?""" if not isinstance(cls, type): raise TypeError("First argument to isa must be a type. Got %s." % repr(cls)) if not isinstance(protocol, type): raise TypeError(("Second argument to isa mus...
[ "def", "isa", "(", "cls", ",", "protocol", ")", ":", "if", "not", "isinstance", "(", "cls", ",", "type", ")", ":", "raise", "TypeError", "(", "\"First argument to isa must be a type. Got %s.\"", "%", "repr", "(", "cls", ")", ")", "if", "not", "isinstance", ...
Does the type 'cls' participate in the 'protocol'?
[ "Does", "the", "type", "cls", "participate", "in", "the", "protocol", "?" ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L81-L90
train
google/dotty
efilter/protocol.py
Protocol.implemented
def implemented(cls, for_type): """Assert that protocol 'cls' is implemented for type 'for_type'. This will cause 'for_type' to be registered with the protocol 'cls'. Subsequently, protocol.isa(for_type, cls) will return True, as will isinstance, issubclass and others. Raises: ...
python
def implemented(cls, for_type): """Assert that protocol 'cls' is implemented for type 'for_type'. This will cause 'for_type' to be registered with the protocol 'cls'. Subsequently, protocol.isa(for_type, cls) will return True, as will isinstance, issubclass and others. Raises: ...
[ "def", "implemented", "(", "cls", ",", "for_type", ")", ":", "for", "function", "in", "cls", ".", "required", "(", ")", ":", "if", "not", "function", ".", "implemented_for_type", "(", "for_type", ")", ":", "raise", "TypeError", "(", "\"%r doesn't implement %...
Assert that protocol 'cls' is implemented for type 'for_type'. This will cause 'for_type' to be registered with the protocol 'cls'. Subsequently, protocol.isa(for_type, cls) will return True, as will isinstance, issubclass and others. Raises: TypeError if 'for_type' doesn't...
[ "Assert", "that", "protocol", "cls", "is", "implemented", "for", "type", "for_type", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L126-L144
train
google/dotty
efilter/protocol.py
Protocol.__get_type_args
def __get_type_args(for_type=None, for_types=None): """Parse the arguments and return a tuple of types to implement for. Raises: ValueError or TypeError as appropriate. """ if for_type: if for_types: raise ValueError("Cannot pass both for_type and...
python
def __get_type_args(for_type=None, for_types=None): """Parse the arguments and return a tuple of types to implement for. Raises: ValueError or TypeError as appropriate. """ if for_type: if for_types: raise ValueError("Cannot pass both for_type and...
[ "def", "__get_type_args", "(", "for_type", "=", "None", ",", "for_types", "=", "None", ")", ":", "if", "for_type", ":", "if", "for_types", ":", "raise", "ValueError", "(", "\"Cannot pass both for_type and for_types.\"", ")", "for_types", "=", "(", "for_type", ",...
Parse the arguments and return a tuple of types to implement for. Raises: ValueError or TypeError as appropriate.
[ "Parse", "the", "arguments", "and", "return", "a", "tuple", "of", "types", "to", "implement", "for", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L147-L164
train
google/dotty
efilter/protocol.py
Protocol.implicit_static
def implicit_static(cls, for_type=None, for_types=None): """Automatically generate implementations for a type. Implement the protocol for the 'for_type' type by dispatching each member function of the protocol to an instance method of the same name declared on the type 'for_type'. ...
python
def implicit_static(cls, for_type=None, for_types=None): """Automatically generate implementations for a type. Implement the protocol for the 'for_type' type by dispatching each member function of the protocol to an instance method of the same name declared on the type 'for_type'. ...
[ "def", "implicit_static", "(", "cls", ",", "for_type", "=", "None", ",", "for_types", "=", "None", ")", ":", "for", "type_", "in", "cls", ".", "__get_type_args", "(", "for_type", ",", "for_types", ")", ":", "implementations", "=", "{", "}", "for", "funct...
Automatically generate implementations for a type. Implement the protocol for the 'for_type' type by dispatching each member function of the protocol to an instance method of the same name declared on the type 'for_type'. Arguments: for_type: The type to implictly implement...
[ "Automatically", "generate", "implementations", "for", "a", "type", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L187-L219
train
google/dotty
efilter/protocol.py
Protocol._build_late_dispatcher
def _build_late_dispatcher(func_name): """Return a function that calls method 'func_name' on objects. This is useful for building late-bound dynamic dispatch. Arguments: func_name: The name of the instance method that should be called. Returns: A function that ...
python
def _build_late_dispatcher(func_name): """Return a function that calls method 'func_name' on objects. This is useful for building late-bound dynamic dispatch. Arguments: func_name: The name of the instance method that should be called. Returns: A function that ...
[ "def", "_build_late_dispatcher", "(", "func_name", ")", ":", "def", "_late_dynamic_dispatcher", "(", "obj", ",", "*", "args", ")", ":", "method", "=", "getattr", "(", "obj", ",", "func_name", ",", "None", ")", "if", "not", "callable", "(", "method", ")", ...
Return a function that calls method 'func_name' on objects. This is useful for building late-bound dynamic dispatch. Arguments: func_name: The name of the instance method that should be called. Returns: A function that takes an 'obj' parameter, followed by *args and ...
[ "Return", "a", "function", "that", "calls", "method", "func_name", "on", "objects", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L222-L245
train
google/dotty
efilter/protocol.py
Protocol.implicit_dynamic
def implicit_dynamic(cls, for_type=None, for_types=None): """Automatically generate late dynamic dispatchers to type. This is similar to 'implicit_static', except instead of binding the instance methods, it generates a dispatcher that will call whatever instance method of the same name ...
python
def implicit_dynamic(cls, for_type=None, for_types=None): """Automatically generate late dynamic dispatchers to type. This is similar to 'implicit_static', except instead of binding the instance methods, it generates a dispatcher that will call whatever instance method of the same name ...
[ "def", "implicit_dynamic", "(", "cls", ",", "for_type", "=", "None", ",", "for_types", "=", "None", ")", ":", "for", "type_", "in", "cls", ".", "__get_type_args", "(", "for_type", ",", "for_types", ")", ":", "implementations", "=", "{", "}", "for", "func...
Automatically generate late dynamic dispatchers to type. This is similar to 'implicit_static', except instead of binding the instance methods, it generates a dispatcher that will call whatever instance method of the same name happens to be available at time of dispatch. This ha...
[ "Automatically", "generate", "late", "dynamic", "dispatchers", "to", "type", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L248-L268
train
google/dotty
efilter/protocol.py
Protocol.implement
def implement(cls, implementations, for_type=None, for_types=None): """Provide protocol implementation for a type. Register all implementations of multimethod functions in this protocol and add the type into the abstract base class of the protocol. Arguments: implem...
python
def implement(cls, implementations, for_type=None, for_types=None): """Provide protocol implementation for a type. Register all implementations of multimethod functions in this protocol and add the type into the abstract base class of the protocol. Arguments: implem...
[ "def", "implement", "(", "cls", ",", "implementations", ",", "for_type", "=", "None", ",", "for_types", "=", "None", ")", ":", "for", "type_", "in", "cls", ".", "__get_type_args", "(", "for_type", ",", "for_types", ")", ":", "cls", ".", "_implement_for_typ...
Provide protocol implementation for a type. Register all implementations of multimethod functions in this protocol and add the type into the abstract base class of the protocol. Arguments: implementations: A dict of (function, implementation), where each fun...
[ "Provide", "protocol", "implementation", "for", "a", "type", "." ]
b145131499be0c4b755fc2e2ac19be11a50bce6a
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L271-L294
train