partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
CloudInventoryCache.get_all_data_from_cache
Reads the JSON inventory from the cache file. Returns Python dictionary.
client/loomengine/playbooks/gce.py
def get_all_data_from_cache(self, filename=''): ''' Reads the JSON inventory from the cache file. Returns Python dictionary. ''' data = '' if not filename: filename = self.cache_path_cache with open(filename, 'r') as cache: data = cache.read() return json...
def get_all_data_from_cache(self, filename=''): ''' Reads the JSON inventory from the cache file. Returns Python dictionary. ''' data = '' if not filename: filename = self.cache_path_cache with open(filename, 'r') as cache: data = cache.read() return json...
[ "Reads", "the", "JSON", "inventory", "from", "the", "cache", "file", ".", "Returns", "Python", "dictionary", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L137-L145
[ "def", "get_all_data_from_cache", "(", "self", ",", "filename", "=", "''", ")", ":", "data", "=", "''", "if", "not", "filename", ":", "filename", "=", "self", ".", "cache_path_cache", "with", "open", "(", "filename", ",", "'r'", ")", "as", "cache", ":", ...
db2031a1a87124fee1aeb7414a668c03d774a698
train
CloudInventoryCache.write_to_cache
Writes data to file as JSON. Returns True.
client/loomengine/playbooks/gce.py
def write_to_cache(self, data, filename=''): ''' Writes data to file as JSON. Returns True. ''' if not filename: filename = self.cache_path_cache json_data = json.dumps(data) with open(filename, 'w') as cache: cache.write(json_data) return True
def write_to_cache(self, data, filename=''): ''' Writes data to file as JSON. Returns True. ''' if not filename: filename = self.cache_path_cache json_data = json.dumps(data) with open(filename, 'w') as cache: cache.write(json_data) return True
[ "Writes", "data", "to", "file", "as", "JSON", ".", "Returns", "True", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L147-L154
[ "def", "write_to_cache", "(", "self", ",", "data", ",", "filename", "=", "''", ")", ":", "if", "not", "filename", ":", "filename", "=", "self", ".", "cache_path_cache", "json_data", "=", "json", ".", "dumps", "(", "data", ")", "with", "open", "(", "fil...
db2031a1a87124fee1aeb7414a668c03d774a698
train
GceInventory.get_config
Reads the settings from the gce.ini file. Populates a SafeConfigParser object with defaults and attempts to read an .ini-style configuration from the filename specified in GCE_INI_PATH. If the environment variable is not present, the filename defaults to gce.ini in the current w...
client/loomengine/playbooks/gce.py
def get_config(self): """ Reads the settings from the gce.ini file. Populates a SafeConfigParser object with defaults and attempts to read an .ini-style configuration from the filename specified in GCE_INI_PATH. If the environment variable is not present, the filename de...
def get_config(self): """ Reads the settings from the gce.ini file. Populates a SafeConfigParser object with defaults and attempts to read an .ini-style configuration from the filename specified in GCE_INI_PATH. If the environment variable is not present, the filename de...
[ "Reads", "the", "settings", "from", "the", "gce", ".", "ini", "file", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L198-L254
[ "def", "get_config", "(", "self", ")", ":", "gce_ini_default_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "__file__", ")", ")", ",", "\"gce.ini\"", ")", "gce_ini_path"...
db2031a1a87124fee1aeb7414a668c03d774a698
train
GceInventory.get_inventory_options
Determine inventory options. Environment variables always take precedence over configuration files.
client/loomengine/playbooks/gce.py
def get_inventory_options(self): """Determine inventory options. Environment variables always take precedence over configuration files.""" ip_type = self.config.get('inventory', 'inventory_ip_type') # If the appropriate environment variables are set, they override # other configu...
def get_inventory_options(self): """Determine inventory options. Environment variables always take precedence over configuration files.""" ip_type = self.config.get('inventory', 'inventory_ip_type') # If the appropriate environment variables are set, they override # other configu...
[ "Determine", "inventory", "options", ".", "Environment", "variables", "always", "take", "precedence", "over", "configuration", "files", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L256-L263
[ "def", "get_inventory_options", "(", "self", ")", ":", "ip_type", "=", "self", ".", "config", ".", "get", "(", "'inventory'", ",", "'inventory_ip_type'", ")", "# If the appropriate environment variables are set, they override", "# other configuration", "ip_type", "=", "os...
db2031a1a87124fee1aeb7414a668c03d774a698
train
GceInventory.get_gce_driver
Determine the GCE authorization settings and return a libcloud driver.
client/loomengine/playbooks/gce.py
def get_gce_driver(self): """Determine the GCE authorization settings and return a libcloud driver. """ # Attempt to get GCE params from a configuration file, if one # exists. secrets_path = self.config.get('gce', 'libcloud_secrets') secrets_found = False ...
def get_gce_driver(self): """Determine the GCE authorization settings and return a libcloud driver. """ # Attempt to get GCE params from a configuration file, if one # exists. secrets_path = self.config.get('gce', 'libcloud_secrets') secrets_found = False ...
[ "Determine", "the", "GCE", "authorization", "settings", "and", "return", "a", "libcloud", "driver", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L265-L312
[ "def", "get_gce_driver", "(", "self", ")", ":", "# Attempt to get GCE params from a configuration file, if one", "# exists.", "secrets_path", "=", "self", ".", "config", ".", "get", "(", "'gce'", ",", "'libcloud_secrets'", ")", "secrets_found", "=", "False", "try", ":...
db2031a1a87124fee1aeb7414a668c03d774a698
train
GceInventory.parse_env_zones
returns a list of comma separated zones parsed from the GCE_ZONE environment variable. If provided, this will be used to filter the results of the grouped_instances call
client/loomengine/playbooks/gce.py
def parse_env_zones(self): '''returns a list of comma separated zones parsed from the GCE_ZONE environment variable. If provided, this will be used to filter the results of the grouped_instances call''' import csv reader = csv.reader([os.environ.get('GCE_ZONE',"")], skipinitialspace=True...
def parse_env_zones(self): '''returns a list of comma separated zones parsed from the GCE_ZONE environment variable. If provided, this will be used to filter the results of the grouped_instances call''' import csv reader = csv.reader([os.environ.get('GCE_ZONE',"")], skipinitialspace=True...
[ "returns", "a", "list", "of", "comma", "separated", "zones", "parsed", "from", "the", "GCE_ZONE", "environment", "variable", ".", "If", "provided", "this", "will", "be", "used", "to", "filter", "the", "results", "of", "the", "grouped_instances", "call" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L314-L320
[ "def", "parse_env_zones", "(", "self", ")", ":", "import", "csv", "reader", "=", "csv", ".", "reader", "(", "[", "os", ".", "environ", ".", "get", "(", "'GCE_ZONE'", ",", "\"\"", ")", "]", ",", "skipinitialspace", "=", "True", ")", "zones", "=", "[",...
db2031a1a87124fee1aeb7414a668c03d774a698
train
GceInventory.parse_cli_args
Command line argument processing
client/loomengine/playbooks/gce.py
def parse_cli_args(self): ''' Command line argument processing ''' parser = argparse.ArgumentParser( description='Produce an Ansible Inventory file based on GCE') parser.add_argument('--list', action='store_true', default=True, help='List instances (de...
def parse_cli_args(self): ''' Command line argument processing ''' parser = argparse.ArgumentParser( description='Produce an Ansible Inventory file based on GCE') parser.add_argument('--list', action='store_true', default=True, help='List instances (de...
[ "Command", "line", "argument", "processing" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L322-L336
[ "def", "parse_cli_args", "(", "self", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Produce an Ansible Inventory file based on GCE'", ")", "parser", ".", "add_argument", "(", "'--list'", ",", "action", "=", "'store_true'", ",...
db2031a1a87124fee1aeb7414a668c03d774a698
train
GceInventory.load_inventory_from_cache
Loads inventory from JSON on disk.
client/loomengine/playbooks/gce.py
def load_inventory_from_cache(self): ''' Loads inventory from JSON on disk. ''' try: self.inventory = self.cache.get_all_data_from_cache() hosts = self.inventory['_meta']['hostvars'] except Exception as e: print( "Invalid inventory file %s. P...
def load_inventory_from_cache(self): ''' Loads inventory from JSON on disk. ''' try: self.inventory = self.cache.get_all_data_from_cache() hosts = self.inventory['_meta']['hostvars'] except Exception as e: print( "Invalid inventory file %s. P...
[ "Loads", "inventory", "from", "JSON", "on", "disk", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L374-L384
[ "def", "load_inventory_from_cache", "(", "self", ")", ":", "try", ":", "self", ".", "inventory", "=", "self", ".", "cache", ".", "get_all_data_from_cache", "(", ")", "hosts", "=", "self", ".", "inventory", "[", "'_meta'", "]", "[", "'hostvars'", "]", "exce...
db2031a1a87124fee1aeb7414a668c03d774a698
train
GceInventory.do_api_calls_update_cache
Do API calls and save data in cache.
client/loomengine/playbooks/gce.py
def do_api_calls_update_cache(self): ''' Do API calls and save data in cache. ''' zones = self.parse_env_zones() data = self.group_instances(zones) self.cache.write_to_cache(data) self.inventory = data
def do_api_calls_update_cache(self): ''' Do API calls and save data in cache. ''' zones = self.parse_env_zones() data = self.group_instances(zones) self.cache.write_to_cache(data) self.inventory = data
[ "Do", "API", "calls", "and", "save", "data", "in", "cache", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L386-L391
[ "def", "do_api_calls_update_cache", "(", "self", ")", ":", "zones", "=", "self", ".", "parse_env_zones", "(", ")", "data", "=", "self", ".", "group_instances", "(", "zones", ")", "self", ".", "cache", ".", "write_to_cache", "(", "data", ")", "self", ".", ...
db2031a1a87124fee1aeb7414a668c03d774a698
train
GceInventory.group_instances
Group all instances
client/loomengine/playbooks/gce.py
def group_instances(self, zones=None): '''Group all instances''' groups = {} meta = {} meta["hostvars"] = {} for node in self.list_nodes(): # This check filters on the desired instance states defined in the # config file with the instance_states config o...
def group_instances(self, zones=None): '''Group all instances''' groups = {} meta = {} meta["hostvars"] = {} for node in self.list_nodes(): # This check filters on the desired instance states defined in the # config file with the instance_states config o...
[ "Group", "all", "instances" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L402-L463
[ "def", "group_instances", "(", "self", ",", "zones", "=", "None", ")", ":", "groups", "=", "{", "}", "meta", "=", "{", "}", "meta", "[", "\"hostvars\"", "]", "=", "{", "}", "for", "node", "in", "self", ".", "list_nodes", "(", ")", ":", "# This chec...
db2031a1a87124fee1aeb7414a668c03d774a698
train
GceInventory.json_format_dict
Converts a dict to a JSON object and dumps it as a formatted string
client/loomengine/playbooks/gce.py
def json_format_dict(self, data, pretty=False): ''' Converts a dict to a JSON object and dumps it as a formatted string ''' if pretty: return json.dumps(data, sort_keys=True, indent=2) else: return json.dumps(data)
def json_format_dict(self, data, pretty=False): ''' Converts a dict to a JSON object and dumps it as a formatted string ''' if pretty: return json.dumps(data, sort_keys=True, indent=2) else: return json.dumps(data)
[ "Converts", "a", "dict", "to", "a", "JSON", "object", "and", "dumps", "it", "as", "a", "formatted", "string" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/client/loomengine/playbooks/gce.py#L465-L472
[ "def", "json_format_dict", "(", "self", ",", "data", ",", "pretty", "=", "False", ")", ":", "if", "pretty", ":", "return", "json", ".", "dumps", "(", "data", ",", "sort_keys", "=", "True", ",", "indent", "=", "2", ")", "else", ":", "return", "json", ...
db2031a1a87124fee1aeb7414a668c03d774a698
train
TaskMonitor._stream_docker_logs
Stream stdout and stderr from the task container to this process's stdout and stderr, respectively.
worker/loomengine_worker/task_monitor.py
def _stream_docker_logs(self): """Stream stdout and stderr from the task container to this process's stdout and stderr, respectively. """ thread = threading.Thread(target=self._stderr_stream_worker) thread.start() for line in self.docker_client.logs(self.container, stdout...
def _stream_docker_logs(self): """Stream stdout and stderr from the task container to this process's stdout and stderr, respectively. """ thread = threading.Thread(target=self._stderr_stream_worker) thread.start() for line in self.docker_client.logs(self.container, stdout...
[ "Stream", "stdout", "and", "stderr", "from", "the", "task", "container", "to", "this", "process", "s", "stdout", "and", "stderr", "respectively", "." ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/worker/loomengine_worker/task_monitor.py#L286-L295
[ "def", "_stream_docker_logs", "(", "self", ")", ":", "thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_stderr_stream_worker", ")", "thread", ".", "start", "(", ")", "for", "line", "in", "self", ".", "docker_client", ".", "logs",...
db2031a1a87124fee1aeb7414a668c03d774a698
train
TemplateSerializer.to_internal_value
Because we allow template ID string values, where serializers normally expect a dict
server/loomengine_server/api/serializers/templates.py
def to_internal_value(self, data): """Because we allow template ID string values, where serializers normally expect a dict """ converted_data = _convert_template_id_to_dict(data) return super(TemplateSerializer, self)\ .to_internal_value(converted_data)
def to_internal_value(self, data): """Because we allow template ID string values, where serializers normally expect a dict """ converted_data = _convert_template_id_to_dict(data) return super(TemplateSerializer, self)\ .to_internal_value(converted_data)
[ "Because", "we", "allow", "template", "ID", "string", "values", "where", "serializers", "normally", "expect", "a", "dict" ]
StanfordBioinformatics/loom
python
https://github.com/StanfordBioinformatics/loom/blob/db2031a1a87124fee1aeb7414a668c03d774a698/server/loomengine_server/api/serializers/templates.py#L105-L111
[ "def", "to_internal_value", "(", "self", ",", "data", ")", ":", "converted_data", "=", "_convert_template_id_to_dict", "(", "data", ")", "return", "super", "(", "TemplateSerializer", ",", "self", ")", ".", "to_internal_value", "(", "converted_data", ")" ]
db2031a1a87124fee1aeb7414a668c03d774a698
train
identifier_cmp
Compare two identifier (for pre-release/build components).
semantic_version/base.py
def identifier_cmp(a, b): """Compare two identifier (for pre-release/build components).""" a_cmp, a_is_int = _to_int(a) b_cmp, b_is_int = _to_int(b) if a_is_int and b_is_int: # Numeric identifiers are compared as integers return base_cmp(a_cmp, b_cmp) elif a_is_int: # Numer...
def identifier_cmp(a, b): """Compare two identifier (for pre-release/build components).""" a_cmp, a_is_int = _to_int(a) b_cmp, b_is_int = _to_int(b) if a_is_int and b_is_int: # Numeric identifiers are compared as integers return base_cmp(a_cmp, b_cmp) elif a_is_int: # Numer...
[ "Compare", "two", "identifier", "(", "for", "pre", "-", "release", "/", "build", "components", ")", "." ]
rbarrois/python-semanticversion
python
https://github.com/rbarrois/python-semanticversion/blob/fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074/semantic_version/base.py#L28-L44
[ "def", "identifier_cmp", "(", "a", ",", "b", ")", ":", "a_cmp", ",", "a_is_int", "=", "_to_int", "(", "a", ")", "b_cmp", ",", "b_is_int", "=", "_to_int", "(", "b", ")", "if", "a_is_int", "and", "b_is_int", ":", "# Numeric identifiers are compared as integers...
fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074
train
identifier_list_cmp
Compare two identifier list (pre-release/build components). The rule is: - Identifiers are paired between lists - They are compared from left to right - If all first identifiers match, the longest list is greater. >>> identifier_list_cmp(['1', '2'], ['1', '2']) 0 >>> identifier...
semantic_version/base.py
def identifier_list_cmp(a, b): """Compare two identifier list (pre-release/build components). The rule is: - Identifiers are paired between lists - They are compared from left to right - If all first identifiers match, the longest list is greater. >>> identifier_list_cmp(['1', '2']...
def identifier_list_cmp(a, b): """Compare two identifier list (pre-release/build components). The rule is: - Identifiers are paired between lists - They are compared from left to right - If all first identifiers match, the longest list is greater. >>> identifier_list_cmp(['1', '2']...
[ "Compare", "two", "identifier", "list", "(", "pre", "-", "release", "/", "build", "components", ")", "." ]
rbarrois/python-semanticversion
python
https://github.com/rbarrois/python-semanticversion/blob/fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074/semantic_version/base.py#L47-L68
[ "def", "identifier_list_cmp", "(", "a", ",", "b", ")", ":", "identifier_pairs", "=", "zip", "(", "a", ",", "b", ")", "for", "id_a", ",", "id_b", "in", "identifier_pairs", ":", "cmp_res", "=", "identifier_cmp", "(", "id_a", ",", "id_b", ")", "if", "cmp_...
fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074
train
Version.coerce
Coerce an arbitrary version string into a semver-compatible one. The rule is: - If not enough components, fill minor/patch with zeroes; unless partial=True - If more than 3 dot-separated components, extra components are "build" data. If some "build" data already appeared, ap...
semantic_version/base.py
def coerce(cls, version_string, partial=False): """Coerce an arbitrary version string into a semver-compatible one. The rule is: - If not enough components, fill minor/patch with zeroes; unless partial=True - If more than 3 dot-separated components, extra components are "build...
def coerce(cls, version_string, partial=False): """Coerce an arbitrary version string into a semver-compatible one. The rule is: - If not enough components, fill minor/patch with zeroes; unless partial=True - If more than 3 dot-separated components, extra components are "build...
[ "Coerce", "an", "arbitrary", "version", "string", "into", "a", "semver", "-", "compatible", "one", "." ]
rbarrois/python-semanticversion
python
https://github.com/rbarrois/python-semanticversion/blob/fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074/semantic_version/base.py#L114-L183
[ "def", "coerce", "(", "cls", ",", "version_string", ",", "partial", "=", "False", ")", ":", "base_re", "=", "re", ".", "compile", "(", "r'^\\d+(?:\\.\\d+(?:\\.\\d+)?)?'", ")", "match", "=", "base_re", ".", "match", "(", "version_string", ")", "if", "not", ...
fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074
train
Version.parse
Parse a version string into a Version() object. Args: version_string (str), the version string to parse partial (bool), whether to accept incomplete input coerce (bool), whether to try to map the passed in string into a valid Version.
semantic_version/base.py
def parse(cls, version_string, partial=False, coerce=False): """Parse a version string into a Version() object. Args: version_string (str), the version string to parse partial (bool), whether to accept incomplete input coerce (bool), whether to try to map the passed ...
def parse(cls, version_string, partial=False, coerce=False): """Parse a version string into a Version() object. Args: version_string (str), the version string to parse partial (bool), whether to accept incomplete input coerce (bool), whether to try to map the passed ...
[ "Parse", "a", "version", "string", "into", "a", "Version", "()", "object", "." ]
rbarrois/python-semanticversion
python
https://github.com/rbarrois/python-semanticversion/blob/fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074/semantic_version/base.py#L186-L243
[ "def", "parse", "(", "cls", ",", "version_string", ",", "partial", "=", "False", ",", "coerce", "=", "False", ")", ":", "if", "not", "version_string", ":", "raise", "ValueError", "(", "'Invalid empty version string: %r'", "%", "version_string", ")", "if", "par...
fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074
train
Version._comparison_functions
Retrieve comparison methods to apply on version components. This is a private API. Args: partial (bool): whether to provide 'partial' or 'strict' matching. Returns: 5-tuple of cmp-like functions.
semantic_version/base.py
def _comparison_functions(cls, partial=False): """Retrieve comparison methods to apply on version components. This is a private API. Args: partial (bool): whether to provide 'partial' or 'strict' matching. Returns: 5-tuple of cmp-like functions. """ ...
def _comparison_functions(cls, partial=False): """Retrieve comparison methods to apply on version components. This is a private API. Args: partial (bool): whether to provide 'partial' or 'strict' matching. Returns: 5-tuple of cmp-like functions. """ ...
[ "Retrieve", "comparison", "methods", "to", "apply", "on", "version", "components", "." ]
rbarrois/python-semanticversion
python
https://github.com/rbarrois/python-semanticversion/blob/fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074/semantic_version/base.py#L281-L344
[ "def", "_comparison_functions", "(", "cls", ",", "partial", "=", "False", ")", ":", "def", "prerelease_cmp", "(", "a", ",", "b", ")", ":", "\"\"\"Compare prerelease components.\n\n Special rule: a version without prerelease component has higher\n precedence ...
fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074
train
Version.__compare_helper
Helper for comparison. Allows the caller to provide: - The condition - The return value if the comparison is meaningless (ie versions with build metadata).
semantic_version/base.py
def __compare_helper(self, other, condition, notimpl_target): """Helper for comparison. Allows the caller to provide: - The condition - The return value if the comparison is meaningless (ie versions with build metadata). """ if not isinstance(other, self.__cl...
def __compare_helper(self, other, condition, notimpl_target): """Helper for comparison. Allows the caller to provide: - The condition - The return value if the comparison is meaningless (ie versions with build metadata). """ if not isinstance(other, self.__cl...
[ "Helper", "for", "comparison", "." ]
rbarrois/python-semanticversion
python
https://github.com/rbarrois/python-semanticversion/blob/fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074/semantic_version/base.py#L365-L380
[ "def", "__compare_helper", "(", "self", ",", "other", ",", "condition", ",", "notimpl_target", ")", ":", "if", "not", "isinstance", "(", "other", ",", "self", ".", "__class__", ")", ":", "return", "NotImplemented", "cmp_res", "=", "self", ".", "__cmp__", "...
fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074
train
Spec.match
Check whether a Version satisfies the Spec.
semantic_version/base.py
def match(self, version): """Check whether a Version satisfies the Spec.""" return all(spec.match(version) for spec in self.specs)
def match(self, version): """Check whether a Version satisfies the Spec.""" return all(spec.match(version) for spec in self.specs)
[ "Check", "whether", "a", "Version", "satisfies", "the", "Spec", "." ]
rbarrois/python-semanticversion
python
https://github.com/rbarrois/python-semanticversion/blob/fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074/semantic_version/base.py#L514-L516
[ "def", "match", "(", "self", ",", "version", ")", ":", "return", "all", "(", "spec", ".", "match", "(", "version", ")", "for", "spec", "in", "self", ".", "specs", ")" ]
fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074
train
Spec.select
Select the best compatible version among an iterable of options.
semantic_version/base.py
def select(self, versions): """Select the best compatible version among an iterable of options.""" options = list(self.filter(versions)) if options: return max(options) return None
def select(self, versions): """Select the best compatible version among an iterable of options.""" options = list(self.filter(versions)) if options: return max(options) return None
[ "Select", "the", "best", "compatible", "version", "among", "an", "iterable", "of", "options", "." ]
rbarrois/python-semanticversion
python
https://github.com/rbarrois/python-semanticversion/blob/fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074/semantic_version/base.py#L524-L529
[ "def", "select", "(", "self", ",", "versions", ")", ":", "options", "=", "list", "(", "self", ".", "filter", "(", "versions", ")", ")", "if", "options", ":", "return", "max", "(", "options", ")", "return", "None" ]
fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074
train
VersionField.deconstruct
Handle django.db.migrations.
semantic_version/django_fields.py
def deconstruct(self): """Handle django.db.migrations.""" name, path, args, kwargs = super(VersionField, self).deconstruct() kwargs['partial'] = self.partial kwargs['coerce'] = self.coerce return name, path, args, kwargs
def deconstruct(self): """Handle django.db.migrations.""" name, path, args, kwargs = super(VersionField, self).deconstruct() kwargs['partial'] = self.partial kwargs['coerce'] = self.coerce return name, path, args, kwargs
[ "Handle", "django", ".", "db", ".", "migrations", "." ]
rbarrois/python-semanticversion
python
https://github.com/rbarrois/python-semanticversion/blob/fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074/semantic_version/django_fields.py#L53-L58
[ "def", "deconstruct", "(", "self", ")", ":", "name", ",", "path", ",", "args", ",", "kwargs", "=", "super", "(", "VersionField", ",", "self", ")", ".", "deconstruct", "(", ")", "kwargs", "[", "'partial'", "]", "=", "self", ".", "partial", "kwargs", "...
fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074
train
VersionField.to_python
Converts any value to a base.Version field.
semantic_version/django_fields.py
def to_python(self, value): """Converts any value to a base.Version field.""" if value is None or value == '': return value if isinstance(value, base.Version): return value if self.coerce: return base.Version.coerce(value, partial=self.partial) ...
def to_python(self, value): """Converts any value to a base.Version field.""" if value is None or value == '': return value if isinstance(value, base.Version): return value if self.coerce: return base.Version.coerce(value, partial=self.partial) ...
[ "Converts", "any", "value", "to", "a", "base", ".", "Version", "field", "." ]
rbarrois/python-semanticversion
python
https://github.com/rbarrois/python-semanticversion/blob/fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074/semantic_version/django_fields.py#L60-L69
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", "or", "value", "==", "''", ":", "return", "value", "if", "isinstance", "(", "value", ",", "base", ".", "Version", ")", ":", "return", "value", "if", "self", ".", ...
fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074
train
SpecField.to_python
Converts any value to a base.Spec field.
semantic_version/django_fields.py
def to_python(self, value): """Converts any value to a base.Spec field.""" if value is None or value == '': return value if isinstance(value, base.Spec): return value return base.Spec(value)
def to_python(self, value): """Converts any value to a base.Spec field.""" if value is None or value == '': return value if isinstance(value, base.Spec): return value return base.Spec(value)
[ "Converts", "any", "value", "to", "a", "base", ".", "Spec", "field", "." ]
rbarrois/python-semanticversion
python
https://github.com/rbarrois/python-semanticversion/blob/fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074/semantic_version/django_fields.py#L78-L84
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", "or", "value", "==", "''", ":", "return", "value", "if", "isinstance", "(", "value", ",", "base", ".", "Spec", ")", ":", "return", "value", "return", "base", ".", ...
fdef1e9cdae901d095d8e8c9cd6fa6adcfe02074
train
ARDrone.move_left
Make the drone move left.
ardrone/drone.py
def move_left(self): """Make the drone move left.""" self.at(ardrone.at.pcmd, True, -self.speed, 0, 0, 0)
def move_left(self): """Make the drone move left.""" self.at(ardrone.at.pcmd, True, -self.speed, 0, 0, 0)
[ "Make", "the", "drone", "move", "left", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L55-L57
[ "def", "move_left", "(", "self", ")", ":", "self", ".", "at", "(", "ardrone", ".", "at", ".", "pcmd", ",", "True", ",", "-", "self", ".", "speed", ",", "0", ",", "0", ",", "0", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
ARDrone.move_right
Make the drone move right.
ardrone/drone.py
def move_right(self): """Make the drone move right.""" self.at(ardrone.at.pcmd, True, self.speed, 0, 0, 0)
def move_right(self): """Make the drone move right.""" self.at(ardrone.at.pcmd, True, self.speed, 0, 0, 0)
[ "Make", "the", "drone", "move", "right", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L59-L61
[ "def", "move_right", "(", "self", ")", ":", "self", ".", "at", "(", "ardrone", ".", "at", ".", "pcmd", ",", "True", ",", "self", ".", "speed", ",", "0", ",", "0", ",", "0", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
ARDrone.move_up
Make the drone rise upwards.
ardrone/drone.py
def move_up(self): """Make the drone rise upwards.""" self.at(ardrone.at.pcmd, True, 0, 0, self.speed, 0)
def move_up(self): """Make the drone rise upwards.""" self.at(ardrone.at.pcmd, True, 0, 0, self.speed, 0)
[ "Make", "the", "drone", "rise", "upwards", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L63-L65
[ "def", "move_up", "(", "self", ")", ":", "self", ".", "at", "(", "ardrone", ".", "at", ".", "pcmd", ",", "True", ",", "0", ",", "0", ",", "self", ".", "speed", ",", "0", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
ARDrone.move_down
Make the drone decent downwards.
ardrone/drone.py
def move_down(self): """Make the drone decent downwards.""" self.at(ardrone.at.pcmd, True, 0, 0, -self.speed, 0)
def move_down(self): """Make the drone decent downwards.""" self.at(ardrone.at.pcmd, True, 0, 0, -self.speed, 0)
[ "Make", "the", "drone", "decent", "downwards", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L67-L69
[ "def", "move_down", "(", "self", ")", ":", "self", ".", "at", "(", "ardrone", ".", "at", ".", "pcmd", ",", "True", ",", "0", ",", "0", ",", "-", "self", ".", "speed", ",", "0", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
ARDrone.move_forward
Make the drone move forward.
ardrone/drone.py
def move_forward(self): """Make the drone move forward.""" self.at(ardrone.at.pcmd, True, 0, -self.speed, 0, 0)
def move_forward(self): """Make the drone move forward.""" self.at(ardrone.at.pcmd, True, 0, -self.speed, 0, 0)
[ "Make", "the", "drone", "move", "forward", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L71-L73
[ "def", "move_forward", "(", "self", ")", ":", "self", ".", "at", "(", "ardrone", ".", "at", ".", "pcmd", ",", "True", ",", "0", ",", "-", "self", ".", "speed", ",", "0", ",", "0", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
ARDrone.move_backward
Make the drone move backwards.
ardrone/drone.py
def move_backward(self): """Make the drone move backwards.""" self.at(ardrone.at.pcmd, True, 0, self.speed, 0, 0)
def move_backward(self): """Make the drone move backwards.""" self.at(ardrone.at.pcmd, True, 0, self.speed, 0, 0)
[ "Make", "the", "drone", "move", "backwards", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L75-L77
[ "def", "move_backward", "(", "self", ")", ":", "self", ".", "at", "(", "ardrone", ".", "at", ".", "pcmd", ",", "True", ",", "0", ",", "self", ".", "speed", ",", "0", ",", "0", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
ARDrone.turn_left
Make the drone rotate left.
ardrone/drone.py
def turn_left(self): """Make the drone rotate left.""" self.at(ardrone.at.pcmd, True, 0, 0, 0, -self.speed)
def turn_left(self): """Make the drone rotate left.""" self.at(ardrone.at.pcmd, True, 0, 0, 0, -self.speed)
[ "Make", "the", "drone", "rotate", "left", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L79-L81
[ "def", "turn_left", "(", "self", ")", ":", "self", ".", "at", "(", "ardrone", ".", "at", ".", "pcmd", ",", "True", ",", "0", ",", "0", ",", "0", ",", "-", "self", ".", "speed", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
ARDrone.turn_right
Make the drone rotate right.
ardrone/drone.py
def turn_right(self): """Make the drone rotate right.""" self.at(ardrone.at.pcmd, True, 0, 0, 0, self.speed)
def turn_right(self): """Make the drone rotate right.""" self.at(ardrone.at.pcmd, True, 0, 0, 0, self.speed)
[ "Make", "the", "drone", "rotate", "right", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L83-L85
[ "def", "turn_right", "(", "self", ")", ":", "self", ".", "at", "(", "ardrone", ".", "at", ".", "pcmd", ",", "True", ",", "0", ",", "0", ",", "0", ",", "self", ".", "speed", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
ARDrone.reset
Toggle the drone's emergency state.
ardrone/drone.py
def reset(self): """Toggle the drone's emergency state.""" self.at(ardrone.at.ref, False, True) time.sleep(0.1) self.at(ardrone.at.ref, False, False)
def reset(self): """Toggle the drone's emergency state.""" self.at(ardrone.at.ref, False, True) time.sleep(0.1) self.at(ardrone.at.ref, False, False)
[ "Toggle", "the", "drone", "s", "emergency", "state", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L87-L91
[ "def", "reset", "(", "self", ")", ":", "self", ".", "at", "(", "ardrone", ".", "at", ".", "ref", ",", "False", ",", "True", ")", "time", ".", "sleep", "(", "0.1", ")", "self", ".", "at", "(", "ardrone", ".", "at", ".", "ref", ",", "False", ",...
def437148a114f66d1ca30bf2398a017002b2cd6
train
ARDrone.at
Wrapper for the low level at commands. This method takes care that the sequence number is increased after each at command and the watchdog timer is started to make sure the drone receives a command at least every second.
ardrone/drone.py
def at(self, cmd, *args, **kwargs): """Wrapper for the low level at commands. This method takes care that the sequence number is increased after each at command and the watchdog timer is started to make sure the drone receives a command at least every second. """ with se...
def at(self, cmd, *args, **kwargs): """Wrapper for the low level at commands. This method takes care that the sequence number is increased after each at command and the watchdog timer is started to make sure the drone receives a command at least every second. """ with se...
[ "Wrapper", "for", "the", "low", "level", "at", "commands", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L111-L123
[ "def", "at", "(", "self", ",", "cmd", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "com_watchdog_timer", ".", "cancel", "(", ")", "cmd", "(", "self", ".", "host", ",", "self", ".", "sequence"...
def437148a114f66d1ca30bf2398a017002b2cd6
train
ARDrone.halt
Shutdown the drone. This method does not land or halt the actual drone, but the communication with the drone. You should call it at the end of your application to close all sockets, pipes, processes and threads related with this object.
ardrone/drone.py
def halt(self): """Shutdown the drone. This method does not land or halt the actual drone, but the communication with the drone. You should call it at the end of your application to close all sockets, pipes, processes and threads related with this object. """ wit...
def halt(self): """Shutdown the drone. This method does not land or halt the actual drone, but the communication with the drone. You should call it at the end of your application to close all sockets, pipes, processes and threads related with this object. """ wit...
[ "Shutdown", "the", "drone", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L133-L146
[ "def", "halt", "(", "self", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "com_watchdog_timer", ".", "cancel", "(", ")", "self", ".", "ipc_thread", ".", "stop", "(", ")", "self", ".", "ipc_thread", ".", "join", "(", ")", "self", ".", "ne...
def437148a114f66d1ca30bf2398a017002b2cd6
train
ARDrone.move
Makes the drone move (translate/rotate). Parameters: lr -- left-right tilt: float [-1..1] negative: left, positive: right fb -- front-back tilt: float [-1..1] negative: forwards, positive: backwards vv -- vertical speed: float [-1..1] negative: go down, positive: rise ...
ardrone/drone.py
def move(self, lr, fb, vv, va): """Makes the drone move (translate/rotate). Parameters: lr -- left-right tilt: float [-1..1] negative: left, positive: right fb -- front-back tilt: float [-1..1] negative: forwards, positive: backwards vv -- vertical speed: float [-1.....
def move(self, lr, fb, vv, va): """Makes the drone move (translate/rotate). Parameters: lr -- left-right tilt: float [-1..1] negative: left, positive: right fb -- front-back tilt: float [-1..1] negative: forwards, positive: backwards vv -- vertical speed: float [-1.....
[ "Makes", "the", "drone", "move", "(", "translate", "/", "rotate", ")", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/drone.py#L148-L158
[ "def", "move", "(", "self", ",", "lr", ",", "fb", ",", "vv", ",", "va", ")", ":", "self", ".", "at", "(", "ardrone", ".", "at", ".", "pcmd", ",", "True", ",", "lr", ",", "fb", ",", "vv", ",", "va", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
ref
Basic behaviour of the drone: take-off/landing, emergency stop/reset) Parameters: seq -- sequence number takeoff -- True: Takeoff / False: Land emergency -- True: Turn off the engines
ardrone/at.py
def ref(host, seq, takeoff, emergency=False): """ Basic behaviour of the drone: take-off/landing, emergency stop/reset) Parameters: seq -- sequence number takeoff -- True: Takeoff / False: Land emergency -- True: Turn off the engines """ p = 0b10001010101000000000000000000 if takeof...
def ref(host, seq, takeoff, emergency=False): """ Basic behaviour of the drone: take-off/landing, emergency stop/reset) Parameters: seq -- sequence number takeoff -- True: Takeoff / False: Land emergency -- True: Turn off the engines """ p = 0b10001010101000000000000000000 if takeof...
[ "Basic", "behaviour", "of", "the", "drone", ":", "take", "-", "off", "/", "landing", "emergency", "stop", "/", "reset", ")" ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/at.py#L16-L30
[ "def", "ref", "(", "host", ",", "seq", ",", "takeoff", ",", "emergency", "=", "False", ")", ":", "p", "=", "0b10001010101000000000000000000", "if", "takeoff", ":", "p", "|=", "0b1000000000", "if", "emergency", ":", "p", "|=", "0b100000000", "at", "(", "h...
def437148a114f66d1ca30bf2398a017002b2cd6
train
pcmd
Makes the drone move (translate/rotate). Parameters: seq -- sequence number progressive -- True: enable progressive commands, False: disable (i.e. enable hovering mode) lr -- left-right tilt: float [-1..1] negative: left, positive: right rb -- front-back tilt: float [-1..1] negative: forwar...
ardrone/at.py
def pcmd(host, seq, progressive, lr, fb, vv, va): """ Makes the drone move (translate/rotate). Parameters: seq -- sequence number progressive -- True: enable progressive commands, False: disable (i.e. enable hovering mode) lr -- left-right tilt: float [-1..1] negative: left, positive: r...
def pcmd(host, seq, progressive, lr, fb, vv, va): """ Makes the drone move (translate/rotate). Parameters: seq -- sequence number progressive -- True: enable progressive commands, False: disable (i.e. enable hovering mode) lr -- left-right tilt: float [-1..1] negative: left, positive: r...
[ "Makes", "the", "drone", "move", "(", "translate", "/", "rotate", ")", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/at.py#L33-L51
[ "def", "pcmd", "(", "host", ",", "seq", ",", "progressive", ",", "lr", ",", "fb", ",", "vv", ",", "va", ")", ":", "p", "=", "1", "if", "progressive", "else", "0", "at", "(", "host", ",", "'PCMD'", ",", "seq", ",", "[", "p", ",", "float", "(",...
def437148a114f66d1ca30bf2398a017002b2cd6
train
config
Set configuration parameters of the drone.
ardrone/at.py
def config(host, seq, option, value): """Set configuration parameters of the drone.""" at(host, 'CONFIG', seq, [str(option), str(value)])
def config(host, seq, option, value): """Set configuration parameters of the drone.""" at(host, 'CONFIG', seq, [str(option), str(value)])
[ "Set", "configuration", "parameters", "of", "the", "drone", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/at.py#L76-L78
[ "def", "config", "(", "host", ",", "seq", ",", "option", ",", "value", ")", ":", "at", "(", "host", ",", "'CONFIG'", ",", "seq", ",", "[", "str", "(", "option", ")", ",", "str", "(", "value", ")", "]", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
pwm
Sends control values directly to the engines, overriding control loops. Parameters: seq -- sequence number m1 -- Integer: front left command m2 -- Integer: front right command m3 -- Integer: back right command m4 -- Integer: back left command
ardrone/at.py
def pwm(host, seq, m1, m2, m3, m4): """ Sends control values directly to the engines, overriding control loops. Parameters: seq -- sequence number m1 -- Integer: front left command m2 -- Integer: front right command m3 -- Integer: back right command m4 -- Integer: back left command ...
def pwm(host, seq, m1, m2, m3, m4): """ Sends control values directly to the engines, overriding control loops. Parameters: seq -- sequence number m1 -- Integer: front left command m2 -- Integer: front right command m3 -- Integer: back right command m4 -- Integer: back left command ...
[ "Sends", "control", "values", "directly", "to", "the", "engines", "overriding", "control", "loops", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/at.py#L100-L111
[ "def", "pwm", "(", "host", ",", "seq", ",", "m1", ",", "m2", ",", "m3", ",", "m4", ")", ":", "at", "(", "host", ",", "'PWM'", ",", "seq", ",", "[", "m1", ",", "m2", ",", "m3", ",", "m4", "]", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
led
Control the drones LED. Parameters: seq -- sequence number anim -- Integer: animation to play f -- Float: frequency in HZ of the animation d -- Integer: total duration in seconds of the animation
ardrone/at.py
def led(host, seq, anim, f, d): """ Control the drones LED. Parameters: seq -- sequence number anim -- Integer: animation to play f -- Float: frequency in HZ of the animation d -- Integer: total duration in seconds of the animation """ at(host, 'LED', seq, [anim, float(f), d])
def led(host, seq, anim, f, d): """ Control the drones LED. Parameters: seq -- sequence number anim -- Integer: animation to play f -- Float: frequency in HZ of the animation d -- Integer: total duration in seconds of the animation """ at(host, 'LED', seq, [anim, float(f), d])
[ "Control", "the", "drones", "LED", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/at.py#L114-L124
[ "def", "led", "(", "host", ",", "seq", ",", "anim", ",", "f", ",", "d", ")", ":", "at", "(", "host", ",", "'LED'", ",", "seq", ",", "[", "anim", ",", "float", "(", "f", ")", ",", "d", "]", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
anim
Makes the drone execute a predefined movement (animation). Parameters: seq -- sequcence number anim -- Integer: animation to play d -- Integer: total duration in seconds of the animation
ardrone/at.py
def anim(host, seq, anim, d): """ Makes the drone execute a predefined movement (animation). Parameters: seq -- sequcence number anim -- Integer: animation to play d -- Integer: total duration in seconds of the animation """ at(host, 'ANIM', seq, [anim, d])
def anim(host, seq, anim, d): """ Makes the drone execute a predefined movement (animation). Parameters: seq -- sequcence number anim -- Integer: animation to play d -- Integer: total duration in seconds of the animation """ at(host, 'ANIM', seq, [anim, d])
[ "Makes", "the", "drone", "execute", "a", "predefined", "movement", "(", "animation", ")", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/at.py#L127-L136
[ "def", "anim", "(", "host", ",", "seq", ",", "anim", ",", "d", ")", ":", "at", "(", "host", ",", "'ANIM'", ",", "seq", ",", "[", "anim", ",", "d", "]", ")" ]
def437148a114f66d1ca30bf2398a017002b2cd6
train
at
Parameters: command -- the command seq -- the sequence number params -- a list of elements which can be either int, float or string
ardrone/at.py
def at(host, command, seq, params): """ Parameters: command -- the command seq -- the sequence number params -- a list of elements which can be either int, float or string """ params_str = [] for p in params: if type(p) == int: params_str.append('{:d}'.format(p)) ...
def at(host, command, seq, params): """ Parameters: command -- the command seq -- the sequence number params -- a list of elements which can be either int, float or string """ params_str = [] for p in params: if type(p) == int: params_str.append('{:d}'.format(p)) ...
[ "Parameters", ":", "command", "--", "the", "command", "seq", "--", "the", "sequence", "number", "params", "--", "a", "list", "of", "elements", "which", "can", "be", "either", "int", "float", "or", "string" ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/at.py#L138-L155
[ "def", "at", "(", "host", ",", "command", ",", "seq", ",", "params", ")", ":", "params_str", "=", "[", "]", "for", "p", "in", "params", ":", "if", "type", "(", "p", ")", "==", "int", ":", "params_str", ".", "append", "(", "'{:d}'", ".", "format",...
def437148a114f66d1ca30bf2398a017002b2cd6
train
decode
Decode a navdata packet.
ardrone/navdata.py
def decode(packet): """Decode a navdata packet.""" offset = 0 _ = struct.unpack_from('IIII', packet, offset) s = _[1] state = dict() state['fly'] = s & 1 # FLY MASK : (0) ardrone is landed, (1) ardrone is flying state['video'] = s >> 1 & 1 # VIDEO MASK :...
def decode(packet): """Decode a navdata packet.""" offset = 0 _ = struct.unpack_from('IIII', packet, offset) s = _[1] state = dict() state['fly'] = s & 1 # FLY MASK : (0) ardrone is landed, (1) ardrone is flying state['video'] = s >> 1 & 1 # VIDEO MASK :...
[ "Decode", "a", "navdata", "packet", "." ]
fkmclane/python-ardrone
python
https://github.com/fkmclane/python-ardrone/blob/def437148a114f66d1ca30bf2398a017002b2cd6/ardrone/navdata.py#L4-L82
[ "def", "decode", "(", "packet", ")", ":", "offset", "=", "0", "_", "=", "struct", ".", "unpack_from", "(", "'IIII'", ",", "packet", ",", "offset", ")", "s", "=", "_", "[", "1", "]", "state", "=", "dict", "(", ")", "state", "[", "'fly'", "]", "=...
def437148a114f66d1ca30bf2398a017002b2cd6
train
VtkData.tofile
Save VTK data to file.
pyvtk/__init__.py
def tofile(self, filename, format = 'ascii'): """Save VTK data to file. """ if not common.is_string(filename): raise TypeError('argument filename must be string but got %s'%(type(filename))) if format not in ['ascii','binary']: raise TypeError('argument format mus...
def tofile(self, filename, format = 'ascii'): """Save VTK data to file. """ if not common.is_string(filename): raise TypeError('argument filename must be string but got %s'%(type(filename))) if format not in ['ascii','binary']: raise TypeError('argument format mus...
[ "Save", "VTK", "data", "to", "file", "." ]
pearu/pyvtk
python
https://github.com/pearu/pyvtk/blob/b004ec3c03299a2d75338a4be93dd29f076b70ab/pyvtk/__init__.py#L190-L204
[ "def", "tofile", "(", "self", ",", "filename", ",", "format", "=", "'ascii'", ")", ":", "if", "not", "common", ".", "is_string", "(", "filename", ")", ":", "raise", "TypeError", "(", "'argument filename must be string but got %s'", "%", "(", "type", "(", "fi...
b004ec3c03299a2d75338a4be93dd29f076b70ab
train
_get_attr_value
Simple helper to get the value of an instance's attribute if it exists. If the instance attribute is callable it will be called and the result will be returned. Optionally accepts a default value to return if the attribute is missing. Defaults to `None` >>> class Foo(object): ... bar = 'b...
zebra/mixins.py
def _get_attr_value(instance, attr, default=None): """ Simple helper to get the value of an instance's attribute if it exists. If the instance attribute is callable it will be called and the result will be returned. Optionally accepts a default value to return if the attribute is missing. Defa...
def _get_attr_value(instance, attr, default=None): """ Simple helper to get the value of an instance's attribute if it exists. If the instance attribute is callable it will be called and the result will be returned. Optionally accepts a default value to return if the attribute is missing. Defa...
[ "Simple", "helper", "to", "get", "the", "value", "of", "an", "instance", "s", "attribute", "if", "it", "exists", "." ]
GoodCloud/django-zebra
python
https://github.com/GoodCloud/django-zebra/blob/fdb2f2eb9eddb83eebb339359e629c88f4f6ba17/zebra/mixins.py#L6-L35
[ "def", "_get_attr_value", "(", "instance", ",", "attr", ",", "default", "=", "None", ")", ":", "value", "=", "default", "if", "hasattr", "(", "instance", ",", "attr", ")", ":", "value", "=", "getattr", "(", "instance", ",", "attr", ")", "if", "callable...
fdb2f2eb9eddb83eebb339359e629c88f4f6ba17
train
audit_customer_subscription
Audits the provided customer's subscription against stripe and returns a pair that contains a boolean and a result type. Default result types can be found in zebra.conf.defaults and can be overridden in your project's settings.
zebra/utils.py
def audit_customer_subscription(customer, unknown=True): """ Audits the provided customer's subscription against stripe and returns a pair that contains a boolean and a result type. Default result types can be found in zebra.conf.defaults and can be overridden in your project's settings. """ ...
def audit_customer_subscription(customer, unknown=True): """ Audits the provided customer's subscription against stripe and returns a pair that contains a boolean and a result type. Default result types can be found in zebra.conf.defaults and can be overridden in your project's settings. """ ...
[ "Audits", "the", "provided", "customer", "s", "subscription", "against", "stripe", "and", "returns", "a", "pair", "that", "contains", "a", "boolean", "and", "a", "result", "type", "." ]
GoodCloud/django-zebra
python
https://github.com/GoodCloud/django-zebra/blob/fdb2f2eb9eddb83eebb339359e629c88f4f6ba17/zebra/utils.py#L6-L26
[ "def", "audit_customer_subscription", "(", "customer", ",", "unknown", "=", "True", ")", ":", "if", "(", "hasattr", "(", "customer", ",", "'suspended'", ")", "and", "customer", ".", "suspended", ")", ":", "result", "=", "AUDIT_RESULTS", "[", "'suspended'", "...
fdb2f2eb9eddb83eebb339359e629c88f4f6ba17
train
polydata_fromfile
Use VtkData(<filename>).
pyvtk/PolyData.py
def polydata_fromfile(f, self): """Use VtkData(<filename>).""" points = [] data = dict(vertices=[], lines=[], polygons=[], triangle_strips=[]) l = common._getline(f).decode('ascii') k,n,datatype = [s.strip().lower() for s in l.split(' ')] if k!='points': raise ValueError('expected points...
def polydata_fromfile(f, self): """Use VtkData(<filename>).""" points = [] data = dict(vertices=[], lines=[], polygons=[], triangle_strips=[]) l = common._getline(f).decode('ascii') k,n,datatype = [s.strip().lower() for s in l.split(' ')] if k!='points': raise ValueError('expected points...
[ "Use", "VtkData", "(", "<filename", ">", ")", "." ]
pearu/pyvtk
python
https://github.com/pearu/pyvtk/blob/b004ec3c03299a2d75338a4be93dd29f076b70ab/pyvtk/PolyData.py#L73-L113
[ "def", "polydata_fromfile", "(", "f", ",", "self", ")", ":", "points", "=", "[", "]", "data", "=", "dict", "(", "vertices", "=", "[", "]", ",", "lines", "=", "[", "]", ",", "polygons", "=", "[", "]", ",", "triangle_strips", "=", "[", "]", ")", ...
b004ec3c03299a2d75338a4be93dd29f076b70ab
train
webhooks
Handles all known webhooks from stripe, and calls signals. Plug in as you need.
zebra/views.py
def webhooks(request): """ Handles all known webhooks from stripe, and calls signals. Plug in as you need. """ if request.method != "POST": return HttpResponse("Invalid Request.", status=400) json = simplejson.loads(request.POST["json"]) if json["event"] == "recurring_payment_fail...
def webhooks(request): """ Handles all known webhooks from stripe, and calls signals. Plug in as you need. """ if request.method != "POST": return HttpResponse("Invalid Request.", status=400) json = simplejson.loads(request.POST["json"]) if json["event"] == "recurring_payment_fail...
[ "Handles", "all", "known", "webhooks", "from", "stripe", "and", "calls", "signals", ".", "Plug", "in", "as", "you", "need", "." ]
GoodCloud/django-zebra
python
https://github.com/GoodCloud/django-zebra/blob/fdb2f2eb9eddb83eebb339359e629c88f4f6ba17/zebra/views.py#L28-L60
[ "def", "webhooks", "(", "request", ")", ":", "if", "request", ".", "method", "!=", "\"POST\"", ":", "return", "HttpResponse", "(", "\"Invalid Request.\"", ",", "status", "=", "400", ")", "json", "=", "simplejson", ".", "loads", "(", "request", ".", "POST",...
fdb2f2eb9eddb83eebb339359e629c88f4f6ba17
train
webhooks_v2
Handles all known webhooks from stripe, and calls signals. Plug in as you need.
zebra/views.py
def webhooks_v2(request): """ Handles all known webhooks from stripe, and calls signals. Plug in as you need. """ if request.method != "POST": return HttpResponse("Invalid Request.", status=400) try: event_json = simplejson.loads(request.body) except AttributeError: ...
def webhooks_v2(request): """ Handles all known webhooks from stripe, and calls signals. Plug in as you need. """ if request.method != "POST": return HttpResponse("Invalid Request.", status=400) try: event_json = simplejson.loads(request.body) except AttributeError: ...
[ "Handles", "all", "known", "webhooks", "from", "stripe", "and", "calls", "signals", ".", "Plug", "in", "as", "you", "need", "." ]
GoodCloud/django-zebra
python
https://github.com/GoodCloud/django-zebra/blob/fdb2f2eb9eddb83eebb339359e629c88f4f6ba17/zebra/views.py#L63-L82
[ "def", "webhooks_v2", "(", "request", ")", ":", "if", "request", ".", "method", "!=", "\"POST\"", ":", "return", "HttpResponse", "(", "\"Invalid Request.\"", ",", "status", "=", "400", ")", "try", ":", "event_json", "=", "simplejson", ".", "loads", "(", "r...
fdb2f2eb9eddb83eebb339359e629c88f4f6ba17
train
is_number
Check if obj is number.
pyvtk/common.py
def is_number(obj): """Check if obj is number.""" return isinstance(obj, (int, float, np.int_, np.float_))
def is_number(obj): """Check if obj is number.""" return isinstance(obj, (int, float, np.int_, np.float_))
[ "Check", "if", "obj", "is", "number", "." ]
pearu/pyvtk
python
https://github.com/pearu/pyvtk/blob/b004ec3c03299a2d75338a4be93dd29f076b70ab/pyvtk/common.py#L34-L36
[ "def", "is_number", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "(", "int", ",", "float", ",", "np", ".", "int_", ",", "np", ".", "float_", ")", ")" ]
b004ec3c03299a2d75338a4be93dd29f076b70ab
train
Common.get_seq
Return sequence.
pyvtk/common.py
def get_seq(self,obj,default=None): """Return sequence.""" if is_sequence(obj): return obj if is_number(obj): return [obj] if obj is None and default is not None: log.warning('using default value (%s)'%(default)) return self.get_seq(default) ra...
def get_seq(self,obj,default=None): """Return sequence.""" if is_sequence(obj): return obj if is_number(obj): return [obj] if obj is None and default is not None: log.warning('using default value (%s)'%(default)) return self.get_seq(default) ra...
[ "Return", "sequence", "." ]
pearu/pyvtk
python
https://github.com/pearu/pyvtk/blob/b004ec3c03299a2d75338a4be93dd29f076b70ab/pyvtk/common.py#L130-L138
[ "def", "get_seq", "(", "self", ",", "obj", ",", "default", "=", "None", ")", ":", "if", "is_sequence", "(", "obj", ")", ":", "return", "obj", "if", "is_number", "(", "obj", ")", ":", "return", "[", "obj", "]", "if", "obj", "is", "None", "and", "d...
b004ec3c03299a2d75338a4be93dd29f076b70ab
train
Common.get_seq_seq
Return sequence of sequences.
pyvtk/common.py
def get_seq_seq(self,obj,default=None): """Return sequence of sequences.""" if is_sequence2(obj): return [self.get_seq(o,default) for o in obj] else: return [self.get_seq(obj,default)]
def get_seq_seq(self,obj,default=None): """Return sequence of sequences.""" if is_sequence2(obj): return [self.get_seq(o,default) for o in obj] else: return [self.get_seq(obj,default)]
[ "Return", "sequence", "of", "sequences", "." ]
pearu/pyvtk
python
https://github.com/pearu/pyvtk/blob/b004ec3c03299a2d75338a4be93dd29f076b70ab/pyvtk/common.py#L139-L144
[ "def", "get_seq_seq", "(", "self", ",", "obj", ",", "default", "=", "None", ")", ":", "if", "is_sequence2", "(", "obj", ")", ":", "return", "[", "self", ".", "get_seq", "(", "o", ",", "default", ")", "for", "o", "in", "obj", "]", "else", ":", "re...
b004ec3c03299a2d75338a4be93dd29f076b70ab
train
Common.get_3_tuple
Return 3-tuple from number -> (obj,default[1],default[2]) 0-sequence|None -> default 1-sequence -> (obj[0],default[1],default[2]) 2-sequence -> (obj[0],obj[1],default[2]) (3 or more)-sequence -> (obj[0],obj[1],obj[2])
pyvtk/common.py
def get_3_tuple(self,obj,default=None): """Return 3-tuple from number -> (obj,default[1],default[2]) 0-sequence|None -> default 1-sequence -> (obj[0],default[1],default[2]) 2-sequence -> (obj[0],obj[1],default[2]) (3 or more)-sequence -> (obj[0],obj[1],obj[2]) """...
def get_3_tuple(self,obj,default=None): """Return 3-tuple from number -> (obj,default[1],default[2]) 0-sequence|None -> default 1-sequence -> (obj[0],default[1],default[2]) 2-sequence -> (obj[0],obj[1],default[2]) (3 or more)-sequence -> (obj[0],obj[1],obj[2]) """...
[ "Return", "3", "-", "tuple", "from", "number", "-", ">", "(", "obj", "default", "[", "1", "]", "default", "[", "2", "]", ")", "0", "-", "sequence|None", "-", ">", "default", "1", "-", "sequence", "-", ">", "(", "obj", "[", "0", "]", "default", ...
pearu/pyvtk
python
https://github.com/pearu/pyvtk/blob/b004ec3c03299a2d75338a4be93dd29f076b70ab/pyvtk/common.py#L163-L195
[ "def", "get_3_tuple", "(", "self", ",", "obj", ",", "default", "=", "None", ")", ":", "if", "not", "(", "default", "is", "not", "None", "and", "type", "(", "default", ")", "is", "tuple", "and", "len", "(", "default", ")", "==", "3", ")", ":", "ra...
b004ec3c03299a2d75338a4be93dd29f076b70ab
train
Common.get_3_tuple_list
Return list of 3-tuples from sequence of a sequence, sequence - it is mapped to sequence of 3-sequences if possible number
pyvtk/common.py
def get_3_tuple_list(self,obj,default=None): """Return list of 3-tuples from sequence of a sequence, sequence - it is mapped to sequence of 3-sequences if possible number """ if is_sequence2(obj): return [self.get_3_tuple(o,default) for o in obj] elif ...
def get_3_tuple_list(self,obj,default=None): """Return list of 3-tuples from sequence of a sequence, sequence - it is mapped to sequence of 3-sequences if possible number """ if is_sequence2(obj): return [self.get_3_tuple(o,default) for o in obj] elif ...
[ "Return", "list", "of", "3", "-", "tuples", "from", "sequence", "of", "a", "sequence", "sequence", "-", "it", "is", "mapped", "to", "sequence", "of", "3", "-", "sequences", "if", "possible", "number" ]
pearu/pyvtk
python
https://github.com/pearu/pyvtk/blob/b004ec3c03299a2d75338a4be93dd29f076b70ab/pyvtk/common.py#L196-L207
[ "def", "get_3_tuple_list", "(", "self", ",", "obj", ",", "default", "=", "None", ")", ":", "if", "is_sequence2", "(", "obj", ")", ":", "return", "[", "self", ".", "get_3_tuple", "(", "o", ",", "default", ")", "for", "o", "in", "obj", "]", "elif", "...
b004ec3c03299a2d75338a4be93dd29f076b70ab
train
Common.get_3_3_tuple
Return tuple of 3-tuples
pyvtk/common.py
def get_3_3_tuple(self,obj,default=None): """Return tuple of 3-tuples """ if is_sequence2(obj): ret = [] for i in range(3): if i<len(obj): ret.append(self.get_3_tuple(obj[i],default)) else: ret.append...
def get_3_3_tuple(self,obj,default=None): """Return tuple of 3-tuples """ if is_sequence2(obj): ret = [] for i in range(3): if i<len(obj): ret.append(self.get_3_tuple(obj[i],default)) else: ret.append...
[ "Return", "tuple", "of", "3", "-", "tuples" ]
pearu/pyvtk
python
https://github.com/pearu/pyvtk/blob/b004ec3c03299a2d75338a4be93dd29f076b70ab/pyvtk/common.py#L208-L233
[ "def", "get_3_3_tuple", "(", "self", ",", "obj", ",", "default", "=", "None", ")", ":", "if", "is_sequence2", "(", "obj", ")", ":", "ret", "=", "[", "]", "for", "i", "in", "range", "(", "3", ")", ":", "if", "i", "<", "len", "(", "obj", ")", "...
b004ec3c03299a2d75338a4be93dd29f076b70ab
train
Common.get_3_3_tuple_list
Return list of 3x3-tuples.
pyvtk/common.py
def get_3_3_tuple_list(self,obj,default=None): """Return list of 3x3-tuples. """ if is_sequence3(obj): return [self.get_3_3_tuple(o,default) for o in obj] return [self.get_3_3_tuple(obj,default)]
def get_3_3_tuple_list(self,obj,default=None): """Return list of 3x3-tuples. """ if is_sequence3(obj): return [self.get_3_3_tuple(o,default) for o in obj] return [self.get_3_3_tuple(obj,default)]
[ "Return", "list", "of", "3x3", "-", "tuples", "." ]
pearu/pyvtk
python
https://github.com/pearu/pyvtk/blob/b004ec3c03299a2d75338a4be93dd29f076b70ab/pyvtk/common.py#L234-L239
[ "def", "get_3_3_tuple_list", "(", "self", ",", "obj", ",", "default", "=", "None", ")", ":", "if", "is_sequence3", "(", "obj", ")", ":", "return", "[", "self", ".", "get_3_3_tuple", "(", "o", ",", "default", ")", "for", "o", "in", "obj", "]", "return...
b004ec3c03299a2d75338a4be93dd29f076b70ab
train
Boto3.connect
Iterate through the application configuration and instantiate the services.
flask_boto3/__init__.py
def connect(self): """Iterate through the application configuration and instantiate the services. """ requested_services = set( svc.lower() for svc in current_app.config.get('BOTO3_SERVICES', []) ) region = current_app.config.get('BOTO3_REGION') sess_...
def connect(self): """Iterate through the application configuration and instantiate the services. """ requested_services = set( svc.lower() for svc in current_app.config.get('BOTO3_SERVICES', []) ) region = current_app.config.get('BOTO3_REGION') sess_...
[ "Iterate", "through", "the", "application", "configuration", "and", "instantiate", "the", "services", "." ]
Ketouem/flask-boto3
python
https://github.com/Ketouem/flask-boto3/blob/3958edc9539421c0fd4923115a1d53ab0db91ac9/flask_boto3/__init__.py#L23-L69
[ "def", "connect", "(", "self", ")", ":", "requested_services", "=", "set", "(", "svc", ".", "lower", "(", ")", "for", "svc", "in", "current_app", ".", "config", ".", "get", "(", "'BOTO3_SERVICES'", ",", "[", "]", ")", ")", "region", "=", "current_app",...
3958edc9539421c0fd4923115a1d53ab0db91ac9
train
Boto3.clients
Get all clients (with and without associated resources)
flask_boto3/__init__.py
def clients(self): """ Get all clients (with and without associated resources) """ clients = {} for k, v in self.connections.items(): if hasattr(v.meta, 'client'): # has boto3 resource clients[k] = v.meta.client else: ...
def clients(self): """ Get all clients (with and without associated resources) """ clients = {} for k, v in self.connections.items(): if hasattr(v.meta, 'client'): # has boto3 resource clients[k] = v.meta.client else: ...
[ "Get", "all", "clients", "(", "with", "and", "without", "associated", "resources", ")" ]
Ketouem/flask-boto3
python
https://github.com/Ketouem/flask-boto3/blob/3958edc9539421c0fd4923115a1d53ab0db91ac9/flask_boto3/__init__.py#L85-L95
[ "def", "clients", "(", "self", ")", ":", "clients", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "connections", ".", "items", "(", ")", ":", "if", "hasattr", "(", "v", ".", "meta", ",", "'client'", ")", ":", "# has boto3 resource", "clie...
3958edc9539421c0fd4923115a1d53ab0db91ac9
train
init_kerberos
Configure the GSSAPI service name, and validate the presence of the appropriate principal in the kerberos keytab. :param app: a flask application :type app: flask.Flask :param service: GSSAPI service name :type service: str :param hostname: hostname the service runs under :type hostname: st...
flask_kerberos.py
def init_kerberos(app, service='HTTP', hostname=gethostname()): ''' Configure the GSSAPI service name, and validate the presence of the appropriate principal in the kerberos keytab. :param app: a flask application :type app: flask.Flask :param service: GSSAPI service name :type service: str...
def init_kerberos(app, service='HTTP', hostname=gethostname()): ''' Configure the GSSAPI service name, and validate the presence of the appropriate principal in the kerberos keytab. :param app: a flask application :type app: flask.Flask :param service: GSSAPI service name :type service: str...
[ "Configure", "the", "GSSAPI", "service", "name", "and", "validate", "the", "presence", "of", "the", "appropriate", "principal", "in", "the", "kerberos", "keytab", "." ]
mkomitee/flask-kerberos
python
https://github.com/mkomitee/flask-kerberos/blob/f8f811d1fa3c44cb71b6ca1bef9b7b2b72dd22b0/flask_kerberos.py#L14-L37
[ "def", "init_kerberos", "(", "app", ",", "service", "=", "'HTTP'", ",", "hostname", "=", "gethostname", "(", ")", ")", ":", "global", "_SERVICE_NAME", "_SERVICE_NAME", "=", "\"%s@%s\"", "%", "(", "service", ",", "hostname", ")", "if", "'KRB5_KTNAME'", "not",...
f8f811d1fa3c44cb71b6ca1bef9b7b2b72dd22b0
train
date_to_timestamp
date to unix timestamp in milliseconds
djutils/date_utils.py
def date_to_timestamp(date): """ date to unix timestamp in milliseconds """ date_tuple = date.timetuple() timestamp = calendar.timegm(date_tuple) * 1000 return timestamp
def date_to_timestamp(date): """ date to unix timestamp in milliseconds """ date_tuple = date.timetuple() timestamp = calendar.timegm(date_tuple) * 1000 return timestamp
[ "date", "to", "unix", "timestamp", "in", "milliseconds" ]
telminov/sw-django-utils
python
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/date_utils.py#L39-L45
[ "def", "date_to_timestamp", "(", "date", ")", ":", "date_tuple", "=", "date", ".", "timetuple", "(", ")", "timestamp", "=", "calendar", ".", "timegm", "(", "date_tuple", ")", "*", "1000", "return", "timestamp" ]
43b8491c87a5dd8fce145834c00198f4de14ceb9
train
random_date
This function will return a random datetime between two datetime objects. :param start: :param end:
djutils/date_utils.py
def random_date(dt_from, dt_to): """ This function will return a random datetime between two datetime objects. :param start: :param end: """ delta = dt_to - dt_from int_delta = (delta.days * 24 * 60 * 60) + delta.seconds random_second = randrange(int_delta) return dt_from + datetime....
def random_date(dt_from, dt_to): """ This function will return a random datetime between two datetime objects. :param start: :param end: """ delta = dt_to - dt_from int_delta = (delta.days * 24 * 60 * 60) + delta.seconds random_second = randrange(int_delta) return dt_from + datetime....
[ "This", "function", "will", "return", "a", "random", "datetime", "between", "two", "datetime", "objects", ".", ":", "param", "start", ":", ":", "param", "end", ":" ]
telminov/sw-django-utils
python
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/date_utils.py#L48-L57
[ "def", "random_date", "(", "dt_from", ",", "dt_to", ")", ":", "delta", "=", "dt_to", "-", "dt_from", "int_delta", "=", "(", "delta", ".", "days", "*", "24", "*", "60", "*", "60", ")", "+", "delta", ".", "seconds", "random_second", "=", "randrange", "...
43b8491c87a5dd8fce145834c00198f4de14ceb9
train
object_to_json
transform object to json
djutils/json_utils.py
def object_to_json(obj, indent=2): """ transform object to json """ instance_json = json.dumps(obj, indent=indent, ensure_ascii=False, cls=DjangoJSONEncoder) return instance_json
def object_to_json(obj, indent=2): """ transform object to json """ instance_json = json.dumps(obj, indent=indent, ensure_ascii=False, cls=DjangoJSONEncoder) return instance_json
[ "transform", "object", "to", "json" ]
telminov/sw-django-utils
python
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/json_utils.py#L9-L14
[ "def", "object_to_json", "(", "obj", ",", "indent", "=", "2", ")", ":", "instance_json", "=", "json", ".", "dumps", "(", "obj", ",", "indent", "=", "indent", ",", "ensure_ascii", "=", "False", ",", "cls", "=", "DjangoJSONEncoder", ")", "return", "instanc...
43b8491c87a5dd8fce145834c00198f4de14ceb9
train
qs_to_json
transform QuerySet to json
djutils/json_utils.py
def qs_to_json(qs, fields=None): """ transform QuerySet to json """ if not fields : fields = [f.name for f in qs.model._meta.fields] # сформируем список для сериализации objects = [] for value_dict in qs.values(*fields): # сохраним порядок полей, как определено в моделе ...
def qs_to_json(qs, fields=None): """ transform QuerySet to json """ if not fields : fields = [f.name for f in qs.model._meta.fields] # сформируем список для сериализации objects = [] for value_dict in qs.values(*fields): # сохраним порядок полей, как определено в моделе ...
[ "transform", "QuerySet", "to", "json" ]
telminov/sw-django-utils
python
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/json_utils.py#L25-L44
[ "def", "qs_to_json", "(", "qs", ",", "fields", "=", "None", ")", ":", "if", "not", "fields", ":", "fields", "=", "[", "f", ".", "name", "for", "f", "in", "qs", ".", "model", ".", "_meta", ".", "fields", "]", "# сформируем список для сериализации", "obj...
43b8491c87a5dd8fce145834c00198f4de14ceb9
train
mongoqs_to_json
transform mongoengine.QuerySet to json
djutils/json_utils.py
def mongoqs_to_json(qs, fields=None): """ transform mongoengine.QuerySet to json """ l = list(qs.as_pymongo()) for element in l: element.pop('_cls') # use DjangoJSONEncoder for transform date data type to datetime json_qs = json.dumps(l, indent=2, ensure_ascii=False, cls=DjangoJSO...
def mongoqs_to_json(qs, fields=None): """ transform mongoengine.QuerySet to json """ l = list(qs.as_pymongo()) for element in l: element.pop('_cls') # use DjangoJSONEncoder for transform date data type to datetime json_qs = json.dumps(l, indent=2, ensure_ascii=False, cls=DjangoJSO...
[ "transform", "mongoengine", ".", "QuerySet", "to", "json" ]
telminov/sw-django-utils
python
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/json_utils.py#L47-L59
[ "def", "mongoqs_to_json", "(", "qs", ",", "fields", "=", "None", ")", ":", "l", "=", "list", "(", "qs", ".", "as_pymongo", "(", ")", ")", "for", "element", "in", "l", ":", "element", ".", "pop", "(", "'_cls'", ")", "# use DjangoJSONEncoder for transform ...
43b8491c87a5dd8fce145834c00198f4de14ceb9
train
url_path
join base_url and some GET-parameters to one; it could be absolute url optionally usage example: c['current_url'] = url_path(request, use_urllib=True, is_full=False) ... <a href="{{ current_url }}">Лабораторный номер</a>
djutils/views/helpers.py
def url_path(request, base_url=None, is_full=False, *args, **kwargs): """ join base_url and some GET-parameters to one; it could be absolute url optionally usage example: c['current_url'] = url_path(request, use_urllib=True, is_full=False) ... <a href="{{ current_url }}">Лабораторн...
def url_path(request, base_url=None, is_full=False, *args, **kwargs): """ join base_url and some GET-parameters to one; it could be absolute url optionally usage example: c['current_url'] = url_path(request, use_urllib=True, is_full=False) ... <a href="{{ current_url }}">Лабораторн...
[ "join", "base_url", "and", "some", "GET", "-", "parameters", "to", "one", ";", "it", "could", "be", "absolute", "url", "optionally" ]
telminov/sw-django-utils
python
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/views/helpers.py#L7-L26
[ "def", "url_path", "(", "request", ",", "base_url", "=", "None", ",", "is_full", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "base_url", ":", "base_url", "=", "request", ".", "path", "if", "is_full", ":", "protocol...
43b8491c87a5dd8fce145834c00198f4de14ceb9
train
url_params
create string with GET-params of request usage example: c['sort_url'] = url_params(request, except_params=('sort',)) ... <a href="{{ sort_url }}&sort=lab_number">Лабораторный номер</a>
djutils/views/helpers.py
def url_params(request, except_params=None, as_is=False): """ create string with GET-params of request usage example: c['sort_url'] = url_params(request, except_params=('sort',)) ... <a href="{{ sort_url }}&sort=lab_number">Лабораторный номер</a> """ if not request.GET: ...
def url_params(request, except_params=None, as_is=False): """ create string with GET-params of request usage example: c['sort_url'] = url_params(request, except_params=('sort',)) ... <a href="{{ sort_url }}&sort=lab_number">Лабораторный номер</a> """ if not request.GET: ...
[ "create", "string", "with", "GET", "-", "params", "of", "request" ]
telminov/sw-django-utils
python
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/views/helpers.py#L28-L50
[ "def", "url_params", "(", "request", ",", "except_params", "=", "None", ",", "as_is", "=", "False", ")", ":", "if", "not", "request", ".", "GET", ":", "return", "''", "params", "=", "[", "]", "for", "key", ",", "value", "in", "request", ".", "GET", ...
43b8491c87a5dd8fce145834c00198f4de14ceb9
train
prepare_sort_params
Prepare sort params. Add revers '-' if need. Params: params - list of sort parameters request sort_key revers_sort - list or set with keys that need reverse default sort direction except_params - GET-params that will be ignored Example: ...
djutils/views/helpers.py
def prepare_sort_params(params, request, sort_key='sort', revers_sort=None, except_params=None): """ Prepare sort params. Add revers '-' if need. Params: params - list of sort parameters request sort_key revers_sort - list or set with keys that need re...
def prepare_sort_params(params, request, sort_key='sort', revers_sort=None, except_params=None): """ Prepare sort params. Add revers '-' if need. Params: params - list of sort parameters request sort_key revers_sort - list or set with keys that need re...
[ "Prepare", "sort", "params", ".", "Add", "revers", "-", "if", "need", ".", "Params", ":", "params", "-", "list", "of", "sort", "parameters", "request", "sort_key", "revers_sort", "-", "list", "or", "set", "with", "keys", "that", "need", "reverse", "default...
telminov/sw-django-utils
python
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/views/helpers.py#L53-L100
[ "def", "prepare_sort_params", "(", "params", ",", "request", ",", "sort_key", "=", "'sort'", ",", "revers_sort", "=", "None", ",", "except_params", "=", "None", ")", ":", "current_param", ",", "current_reversed", "=", "sort_key_process", "(", "request", ",", "...
43b8491c87a5dd8fce145834c00198f4de14ceb9
train
sort_key_process
process sort-parameter value (for example, "-name") return: current_param - field for sorting ("name) current_reversed - revers flag (True)
djutils/views/helpers.py
def sort_key_process(request, sort_key='sort'): """ process sort-parameter value (for example, "-name") return: current_param - field for sorting ("name) current_reversed - revers flag (True) """ current = request.GET.get(sort_key) current_reversed = False cur...
def sort_key_process(request, sort_key='sort'): """ process sort-parameter value (for example, "-name") return: current_param - field for sorting ("name) current_reversed - revers flag (True) """ current = request.GET.get(sort_key) current_reversed = False cur...
[ "process", "sort", "-", "parameter", "value", "(", "for", "example", "-", "name", ")", "return", ":", "current_param", "-", "field", "for", "sorting", "(", "name", ")", "current_reversed", "-", "revers", "flag", "(", "True", ")" ]
telminov/sw-django-utils
python
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/views/helpers.py#L103-L119
[ "def", "sort_key_process", "(", "request", ",", "sort_key", "=", "'sort'", ")", ":", "current", "=", "request", ".", "GET", ".", "get", "(", "sort_key", ")", "current_reversed", "=", "False", "current_param", "=", "None", "if", "current", ":", "mo", "=", ...
43b8491c87a5dd8fce145834c00198f4de14ceb9
train
transform_form_error
transform form errors to list like ["field1: error1", "field2: error2"]
djutils/forms.py
def transform_form_error(form, verbose=True): """ transform form errors to list like ["field1: error1", "field2: error2"] """ errors = [] for field, err_msg in form.errors.items(): if field == '__all__': # general errors errors.append(', '.join(err_msg)) else...
def transform_form_error(form, verbose=True): """ transform form errors to list like ["field1: error1", "field2: error2"] """ errors = [] for field, err_msg in form.errors.items(): if field == '__all__': # general errors errors.append(', '.join(err_msg)) else...
[ "transform", "form", "errors", "to", "list", "like", "[", "field1", ":", "error1", "field2", ":", "error2", "]" ]
telminov/sw-django-utils
python
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/forms.py#L3-L17
[ "def", "transform_form_error", "(", "form", ",", "verbose", "=", "True", ")", ":", "errors", "=", "[", "]", "for", "field", ",", "err_msg", "in", "form", ".", "errors", ".", "items", "(", ")", ":", "if", "field", "==", "'__all__'", ":", "# general erro...
43b8491c87a5dd8fce145834c00198f4de14ceb9
train
process_date_from_to_options
to_datetime - приводить ли date к datetime default_dt_to - устанавливать заведомо будущее дефолтное значение для dt_to
djutils/management/commands/__init__.py
def process_date_from_to_options(options, to_datetime=False, default_dt_to=False): """ to_datetime - приводить ли date к datetime default_dt_to - устанавливать заведомо будущее дефолтное значение для dt_to """ start_time = datetime.datetime.now() if options.get('last_week'): dt_...
def process_date_from_to_options(options, to_datetime=False, default_dt_to=False): """ to_datetime - приводить ли date к datetime default_dt_to - устанавливать заведомо будущее дефолтное значение для dt_to """ start_time = datetime.datetime.now() if options.get('last_week'): dt_...
[ "to_datetime", "-", "приводить", "ли", "date", "к", "datetime", "default_dt_to", "-", "устанавливать", "заведомо", "будущее", "дефолтное", "значение", "для", "dt_to" ]
telminov/sw-django-utils
python
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/management/commands/__init__.py#L30-L77
[ "def", "process_date_from_to_options", "(", "options", ",", "to_datetime", "=", "False", ",", "default_dt_to", "=", "False", ")", ":", "start_time", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "if", "options", ".", "get", "(", "'last_week'", ")",...
43b8491c87a5dd8fce145834c00198f4de14ceb9
train
_chunked
Collect data into chunks of up to length n. :type iterable: Iterable[T] :type n: int :rtype: Iterator[list[T]]
genderize/__init__.py
def _chunked(iterable, n): """ Collect data into chunks of up to length n. :type iterable: Iterable[T] :type n: int :rtype: Iterator[list[T]] """ it = iter(iterable) while True: chunk = list(islice(it, n)) if chunk: yield chunk else: return
def _chunked(iterable, n): """ Collect data into chunks of up to length n. :type iterable: Iterable[T] :type n: int :rtype: Iterator[list[T]] """ it = iter(iterable) while True: chunk = list(islice(it, n)) if chunk: yield chunk else: return
[ "Collect", "data", "into", "chunks", "of", "up", "to", "length", "n", ".", ":", "type", "iterable", ":", "Iterable", "[", "T", "]", ":", "type", "n", ":", "int", ":", "rtype", ":", "Iterator", "[", "list", "[", "T", "]]" ]
SteelPangolin/genderize
python
https://github.com/SteelPangolin/genderize/blob/53ca94012702f3589ab528b628b28df52397232f/genderize/__init__.py#L166-L179
[ "def", "_chunked", "(", "iterable", ",", "n", ")", ":", "it", "=", "iter", "(", "iterable", ")", "while", "True", ":", "chunk", "=", "list", "(", "islice", "(", "it", ",", "n", ")", ")", "if", "chunk", ":", "yield", "chunk", "else", ":", "return"...
53ca94012702f3589ab528b628b28df52397232f
train
Genderize.get
Look up gender for a list of names. Can optionally refine search with locale info. May make multiple requests if there are more names than can be retrieved in one call. :param names: List of names. :type names: Iterable[str] :param country_id: Optional ISO 3166-1 alpha-2...
genderize/__init__.py
def get(self, names, country_id=None, language_id=None, retheader=False): """ Look up gender for a list of names. Can optionally refine search with locale info. May make multiple requests if there are more names than can be retrieved in one call. :param names: List of na...
def get(self, names, country_id=None, language_id=None, retheader=False): """ Look up gender for a list of names. Can optionally refine search with locale info. May make multiple requests if there are more names than can be retrieved in one call. :param names: List of na...
[ "Look", "up", "gender", "for", "a", "list", "of", "names", ".", "Can", "optionally", "refine", "search", "with", "locale", "info", ".", "May", "make", "multiple", "requests", "if", "there", "are", "more", "names", "than", "can", "be", "retrieved", "in", ...
SteelPangolin/genderize
python
https://github.com/SteelPangolin/genderize/blob/53ca94012702f3589ab528b628b28df52397232f/genderize/__init__.py#L66-L110
[ "def", "get", "(", "self", ",", "names", ",", "country_id", "=", "None", ",", "language_id", "=", "None", ",", "retheader", "=", "False", ")", ":", "responses", "=", "[", "self", ".", "_get_chunk", "(", "name_chunk", ",", "country_id", ",", "language_id"...
53ca94012702f3589ab528b628b28df52397232f
train
Genderize.get1
Look up gender for a single name. See :py:meth:`get`. Doesn't support retheader option.
genderize/__init__.py
def get1(self, name, **kwargs): """ Look up gender for a single name. See :py:meth:`get`. Doesn't support retheader option. """ if 'retheader' in kwargs: raise GenderizeException( "get1() doesn't support the retheader option.") return s...
def get1(self, name, **kwargs): """ Look up gender for a single name. See :py:meth:`get`. Doesn't support retheader option. """ if 'retheader' in kwargs: raise GenderizeException( "get1() doesn't support the retheader option.") return s...
[ "Look", "up", "gender", "for", "a", "single", "name", ".", "See", ":", "py", ":", "meth", ":", "get", ".", "Doesn", "t", "support", "retheader", "option", "." ]
SteelPangolin/genderize
python
https://github.com/SteelPangolin/genderize/blob/53ca94012702f3589ab528b628b28df52397232f/genderize/__init__.py#L154-L163
[ "def", "get1", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "if", "'retheader'", "in", "kwargs", ":", "raise", "GenderizeException", "(", "\"get1() doesn't support the retheader option.\"", ")", "return", "self", ".", "get", "(", "[", "name", ...
53ca94012702f3589ab528b628b28df52397232f
train
saveVarsInMat
Hacky convinience function to dump a couple of python variables in a .mat file. See `awmstools.saveVars`.
src/mlab/mlabwrap.py
def saveVarsInMat(filename, varNamesStr, outOf=None, **opts): """Hacky convinience function to dump a couple of python variables in a .mat file. See `awmstools.saveVars`. """ from mlabwrap import mlab filename, varnames, outOf = __saveVarsHelper( filename, varNamesStr, outOf, '.mat', **op...
def saveVarsInMat(filename, varNamesStr, outOf=None, **opts): """Hacky convinience function to dump a couple of python variables in a .mat file. See `awmstools.saveVars`. """ from mlabwrap import mlab filename, varnames, outOf = __saveVarsHelper( filename, varNamesStr, outOf, '.mat', **op...
[ "Hacky", "convinience", "function", "to", "dump", "a", "couple", "of", "python", "variables", "in", "a", ".", "mat", "file", ".", "See", "awmstools", ".", "saveVars", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/mlabwrap.py#L651-L664
[ "def", "saveVarsInMat", "(", "filename", ",", "varNamesStr", ",", "outOf", "=", "None", ",", "*", "*", "opts", ")", ":", "from", "mlabwrap", "import", "mlab", "filename", ",", "varnames", ",", "outOf", "=", "__saveVarsHelper", "(", "filename", ",", "varNam...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MlabWrap._make_proxy
Creates a proxy for a variable. XXX create and cache nested proxies also here.
src/mlab/mlabwrap.py
def _make_proxy(self, varname, parent=None, constructor=MlabObjectProxy): """Creates a proxy for a variable. XXX create and cache nested proxies also here. """ # FIXME why not just use gensym here? proxy_val_name = "PROXY_VAL%d__" % self._proxy_count self._proxy_count +=...
def _make_proxy(self, varname, parent=None, constructor=MlabObjectProxy): """Creates a proxy for a variable. XXX create and cache nested proxies also here. """ # FIXME why not just use gensym here? proxy_val_name = "PROXY_VAL%d__" % self._proxy_count self._proxy_count +=...
[ "Creates", "a", "proxy", "for", "a", "variable", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/mlabwrap.py#L440-L451
[ "def", "_make_proxy", "(", "self", ",", "varname", ",", "parent", "=", "None", ",", "constructor", "=", "MlabObjectProxy", ")", ":", "# FIXME why not just use gensym here?", "proxy_val_name", "=", "\"PROXY_VAL%d__\"", "%", "self", ".", "_proxy_count", "self", ".", ...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MlabWrap._do
Semi-raw execution of a matlab command. Smartly handle calls to matlab, figure out what to do with `args`, and when to use function call syntax and not. If no `args` are specified, the ``cmd`` not ``result = cmd()`` form is used in Matlab -- this also makes literal Matlab commands lega...
src/mlab/mlabwrap.py
def _do(self, cmd, *args, **kwargs): """Semi-raw execution of a matlab command. Smartly handle calls to matlab, figure out what to do with `args`, and when to use function call syntax and not. If no `args` are specified, the ``cmd`` not ``result = cmd()`` form is used in Matlab...
def _do(self, cmd, *args, **kwargs): """Semi-raw execution of a matlab command. Smartly handle calls to matlab, figure out what to do with `args`, and when to use function call syntax and not. If no `args` are specified, the ``cmd`` not ``result = cmd()`` form is used in Matlab...
[ "Semi", "-", "raw", "execution", "of", "a", "matlab", "command", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/mlabwrap.py#L487-L559
[ "def", "_do", "(", "self", ",", "cmd", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "handle_out", "=", "kwargs", ".", "get", "(", "'handle_out'", ",", "_flush_write_stdout", ")", "#self._session = self._session or mlabraw.open()", "# HACK", "if", "self...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MlabWrap._get
r"""Directly access a variable in matlab space. This should normally not be used by user code.
src/mlab/mlabwrap.py
def _get(self, name, remove=False): r"""Directly access a variable in matlab space. This should normally not be used by user code.""" # FIXME should this really be needed in normal operation? if name in self._proxies: return self._proxies[name] varname = name vartype = s...
def _get(self, name, remove=False): r"""Directly access a variable in matlab space. This should normally not be used by user code.""" # FIXME should this really be needed in normal operation? if name in self._proxies: return self._proxies[name] varname = name vartype = s...
[ "r", "Directly", "access", "a", "variable", "in", "matlab", "space", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/mlabwrap.py#L561-L593
[ "def", "_get", "(", "self", ",", "name", ",", "remove", "=", "False", ")", ":", "# FIXME should this really be needed in normal operation?", "if", "name", "in", "self", ".", "_proxies", ":", "return", "self", ".", "_proxies", "[", "name", "]", "varname", "=", ...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MlabWrap._set
r"""Directly set a variable `name` in matlab space to `value`. This should normally not be used in user code.
src/mlab/mlabwrap.py
def _set(self, name, value): r"""Directly set a variable `name` in matlab space to `value`. This should normally not be used in user code.""" if isinstance(value, MlabObjectProxy): mlabraw.eval(self._session, "%s = %s;" % (name, value._name)) else: ## mlabraw.put...
def _set(self, name, value): r"""Directly set a variable `name` in matlab space to `value`. This should normally not be used in user code.""" if isinstance(value, MlabObjectProxy): mlabraw.eval(self._session, "%s = %s;" % (name, value._name)) else: ## mlabraw.put...
[ "r", "Directly", "set", "a", "variable", "name", "in", "matlab", "space", "to", "value", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/mlabwrap.py#L595-L603
[ "def", "_set", "(", "self", ",", "name", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "MlabObjectProxy", ")", ":", "mlabraw", ".", "eval", "(", "self", ".", "_session", ",", "\"%s = %s;\"", "%", "(", "name", ",", "value", ".", "_nam...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MatlabCom.open
Dispatches the matlab COM client. Note: If this method fails, try running matlab with the -regserver flag.
src/mlab/matlabcom.py
def open(self, visible=False): """ Dispatches the matlab COM client. Note: If this method fails, try running matlab with the -regserver flag. """ if self.client: raise MatlabConnectionError('Matlab(TM) COM client is still active. Use close to ' 'close it') self.client = ...
def open(self, visible=False): """ Dispatches the matlab COM client. Note: If this method fails, try running matlab with the -regserver flag. """ if self.client: raise MatlabConnectionError('Matlab(TM) COM client is still active. Use close to ' 'close it') self.client = ...
[ "Dispatches", "the", "matlab", "COM", "client", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/matlabcom.py#L54-L63
[ "def", "open", "(", "self", ",", "visible", "=", "False", ")", ":", "if", "self", ".", "client", ":", "raise", "MatlabConnectionError", "(", "'Matlab(TM) COM client is still active. Use close to '", "'close it'", ")", "self", ".", "client", "=", "win32com", ".", ...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MatlabCom.eval
Evaluates a matlab expression synchronously. If identify_erros is true, and the last output line after evaluating the expressions begins with '???' an excpetion is thrown with the matlab error following the '???'. The return value of the function is the matlab output following the call.
src/mlab/matlabcom.py
def eval(self, expression, identify_erros=True): """ Evaluates a matlab expression synchronously. If identify_erros is true, and the last output line after evaluating the expressions begins with '???' an excpetion is thrown with the matlab error following the '???'. The return value of the function...
def eval(self, expression, identify_erros=True): """ Evaluates a matlab expression synchronously. If identify_erros is true, and the last output line after evaluating the expressions begins with '???' an excpetion is thrown with the matlab error following the '???'. The return value of the function...
[ "Evaluates", "a", "matlab", "expression", "synchronously", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/matlabcom.py#L75-L90
[ "def", "eval", "(", "self", ",", "expression", ",", "identify_erros", "=", "True", ")", ":", "#print expression", "self", ".", "_check_open", "(", ")", "ret", "=", "self", ".", "client", ".", "Execute", "(", "expression", ")", "#print ret", "if", "identify...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MatlabCom.get
Loads the requested variables from the matlab com client. names_to_get can be either a variable name or a list of variable names. If it is a variable name, the values is returned. If it is a list, a dictionary of variable_name -> value is returned. If convert_to_numpy is true, the method will all arra...
src/mlab/matlabcom.py
def get(self, names_to_get, convert_to_numpy=True): """ Loads the requested variables from the matlab com client. names_to_get can be either a variable name or a list of variable names. If it is a variable name, the values is returned. If it is a list, a dictionary of variable_name -> value is returned...
def get(self, names_to_get, convert_to_numpy=True): """ Loads the requested variables from the matlab com client. names_to_get can be either a variable name or a list of variable names. If it is a variable name, the values is returned. If it is a list, a dictionary of variable_name -> value is returned...
[ "Loads", "the", "requested", "variables", "from", "the", "matlab", "com", "client", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/matlabcom.py#L92-L117
[ "def", "get", "(", "self", ",", "names_to_get", ",", "convert_to_numpy", "=", "True", ")", ":", "self", ".", "_check_open", "(", ")", "single_itme", "=", "isinstance", "(", "names_to_get", ",", "(", "unicode", ",", "str", ")", ")", "if", "single_itme", "...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MatlabCom.put
Loads a dictionary of variable names into the matlab com client.
src/mlab/matlabcom.py
def put(self, name_to_val): """ Loads a dictionary of variable names into the matlab com client. """ self._check_open() for name, val in name_to_val.iteritems(): # First try to put data as a matrix: try: self.client.PutFullMatrix(name, 'base', val, None) except: self.cl...
def put(self, name_to_val): """ Loads a dictionary of variable names into the matlab com client. """ self._check_open() for name, val in name_to_val.iteritems(): # First try to put data as a matrix: try: self.client.PutFullMatrix(name, 'base', val, None) except: self.cl...
[ "Loads", "a", "dictionary", "of", "variable", "names", "into", "the", "matlab", "com", "client", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/matlabcom.py#L119-L128
[ "def", "put", "(", "self", ",", "name_to_val", ")", ":", "self", ".", "_check_open", "(", ")", "for", "name", ",", "val", "in", "name_to_val", ".", "iteritems", "(", ")", ":", "# First try to put data as a matrix:", "try", ":", "self", ".", "client", ".", ...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
open
Opens MATLAB using specified connection (or DCOM+ protocol on Windows)where matlab_location
src/mlab/mlabraw.py
def open(): global _MATLAB_RELEASE '''Opens MATLAB using specified connection (or DCOM+ protocol on Windows)where matlab_location ''' if is_win: ret = MatlabConnection() ret.open() return ret else: if settings.MATLAB_PATH != 'guess': matlab_path = settings.MA...
def open(): global _MATLAB_RELEASE '''Opens MATLAB using specified connection (or DCOM+ protocol on Windows)where matlab_location ''' if is_win: ret = MatlabConnection() ret.open() return ret else: if settings.MATLAB_PATH != 'guess': matlab_path = settings.MA...
[ "Opens", "MATLAB", "using", "specified", "connection", "(", "or", "DCOM", "+", "protocol", "on", "Windows", ")", "where", "matlab_location" ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/mlabraw.py#L39-L60
[ "def", "open", "(", ")", ":", "global", "_MATLAB_RELEASE", "if", "is_win", ":", "ret", "=", "MatlabConnection", "(", ")", "ret", ".", "open", "(", ")", "return", "ret", "else", ":", "if", "settings", ".", "MATLAB_PATH", "!=", "'guess'", ":", "matlab_path...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
_list_releases
Tries to guess matlab process release version and location path on osx machines. The paths we will search are in the format: /Applications/MATLAB_R[YEAR][VERSION].app/bin/matlab We will try the latest version first. If no path is found, None is reutrned.
src/mlab/matlabpipe.py
def _list_releases(): ''' Tries to guess matlab process release version and location path on osx machines. The paths we will search are in the format: /Applications/MATLAB_R[YEAR][VERSION].app/bin/matlab We will try the latest version first. If no path is found, None is reutrned. ''' if...
def _list_releases(): ''' Tries to guess matlab process release version and location path on osx machines. The paths we will search are in the format: /Applications/MATLAB_R[YEAR][VERSION].app/bin/matlab We will try the latest version first. If no path is found, None is reutrned. ''' if...
[ "Tries", "to", "guess", "matlab", "process", "release", "version", "and", "location", "path", "on", "osx", "machines", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/matlabpipe.py#L41-L62
[ "def", "_list_releases", "(", ")", ":", "if", "is_linux", "(", ")", ":", "base_path", "=", "'/usr/local/MATLAB/R%d%s/bin/matlab'", "else", ":", "# assume mac", "base_path", "=", "'/Applications/MATLAB_R%d%s.app/bin/matlab'", "years", "=", "range", "(", "2050", ",", ...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
is_valid_release_version
Checks that the given version code is valid.
src/mlab/matlabpipe.py
def is_valid_release_version(version): '''Checks that the given version code is valid.''' return version is not None and len(version) == 6 and version[0] == 'R' \ and int(version[1:5]) in range(1990, 2050) \ and version[5] in ('h', 'g', 'f', 'e', 'd', 'c', 'b', 'a')
def is_valid_release_version(version): '''Checks that the given version code is valid.''' return version is not None and len(version) == 6 and version[0] == 'R' \ and int(version[1:5]) in range(1990, 2050) \ and version[5] in ('h', 'g', 'f', 'e', 'd', 'c', 'b', 'a')
[ "Checks", "that", "the", "given", "version", "code", "is", "valid", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/matlabpipe.py#L72-L76
[ "def", "is_valid_release_version", "(", "version", ")", ":", "return", "version", "is", "not", "None", "and", "len", "(", "version", ")", "==", "6", "and", "version", "[", "0", "]", "==", "'R'", "and", "int", "(", "version", "[", "1", ":", "5", "]", ...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
find_matlab_version
Tries to guess matlab's version according to its process path. If we couldn't gues the version, None is returned.
src/mlab/matlabpipe.py
def find_matlab_version(process_path): """ Tries to guess matlab's version according to its process path. If we couldn't gues the version, None is returned. """ bin_path = os.path.dirname(process_path) matlab_path = os.path.dirname(bin_path) matlab_dir_name = os.path.basename(matlab_path) v...
def find_matlab_version(process_path): """ Tries to guess matlab's version according to its process path. If we couldn't gues the version, None is returned. """ bin_path = os.path.dirname(process_path) matlab_path = os.path.dirname(bin_path) matlab_dir_name = os.path.basename(matlab_path) v...
[ "Tries", "to", "guess", "matlab", "s", "version", "according", "to", "its", "process", "path", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/matlabpipe.py#L91-L104
[ "def", "find_matlab_version", "(", "process_path", ")", ":", "bin_path", "=", "os", ".", "path", ".", "dirname", "(", "process_path", ")", "matlab_path", "=", "os", ".", "path", ".", "dirname", "(", "bin_path", ")", "matlab_dir_name", "=", "os", ".", "path...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MatlabPipe.open
Opens the matlab process.
src/mlab/matlabpipe.py
def open(self, print_matlab_welcome=False): '''Opens the matlab process.''' if self.process and not self.process.returncode: raise MatlabConnectionError('Matlab(TM) process is still active. Use close to ' 'close it') self.process = subproce...
def open(self, print_matlab_welcome=False): '''Opens the matlab process.''' if self.process and not self.process.returncode: raise MatlabConnectionError('Matlab(TM) process is still active. Use close to ' 'close it') self.process = subproce...
[ "Opens", "the", "matlab", "process", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/matlabpipe.py#L148-L162
[ "def", "open", "(", "self", ",", "print_matlab_welcome", "=", "False", ")", ":", "if", "self", ".", "process", "and", "not", "self", ".", "process", ".", "returncode", ":", "raise", "MatlabConnectionError", "(", "'Matlab(TM) process is still active. Use close to '",...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MatlabPipe.eval
Evaluates a matlab expression synchronously. If identify_erros is true, and the last output line after evaluating the expressions begins with '???' and excpetion is thrown with the matlab error following the '???'. If on_new_output is not None, it will be called whenever a new output is...
src/mlab/matlabpipe.py
def eval(self, expression, identify_errors=True, print_expression=True, on_new_output=sys.stdout.write): """ Evaluates a matlab expression synchronously. If identify_erros is true, and the last output line after evaluat...
def eval(self, expression, identify_errors=True, print_expression=True, on_new_output=sys.stdout.write): """ Evaluates a matlab expression synchronously. If identify_erros is true, and the last output line after evaluat...
[ "Evaluates", "a", "matlab", "expression", "synchronously", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/matlabpipe.py#L170-L195
[ "def", "eval", "(", "self", ",", "expression", ",", "identify_errors", "=", "True", ",", "print_expression", "=", "True", ",", "on_new_output", "=", "sys", ".", "stdout", ".", "write", ")", ":", "self", ".", "_check_open", "(", ")", "if", "print_expression...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MatlabPipe.put
Loads a dictionary of variable names into the matlab shell. oned_as is the same as in scipy.io.matlab.savemat function: oned_as : {'column', 'row'}, optional If 'column', write 1-D numpy arrays as column vectors. If 'row', write 1D numpy arrays as row vectors.
src/mlab/matlabpipe.py
def put(self, name_to_val, oned_as='row', on_new_output=None): """ Loads a dictionary of variable names into the matlab shell. oned_as is the same as in scipy.io.matlab.savemat function: oned_as : {'column', 'row'}, optional If 'column', write 1-D numpy arrays as column vectors. ...
def put(self, name_to_val, oned_as='row', on_new_output=None): """ Loads a dictionary of variable names into the matlab shell. oned_as is the same as in scipy.io.matlab.savemat function: oned_as : {'column', 'row'}, optional If 'column', write 1-D numpy arrays as column vectors. ...
[ "Loads", "a", "dictionary", "of", "variable", "names", "into", "the", "matlab", "shell", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/matlabpipe.py#L198-L218
[ "def", "put", "(", "self", ",", "name_to_val", ",", "oned_as", "=", "'row'", ",", "on_new_output", "=", "None", ")", ":", "self", ".", "_check_open", "(", ")", "# We can't give stdin to mlabio.savemat because it needs random access :(", "temp", "=", "StringIO", "(",...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
MatlabPipe.get
Loads the requested variables from the matlab shell. names_to_get can be either a variable name, a list of variable names, or None. If it is a variable name, the values is returned. If it is a list, a dictionary of variable_name -> value is returned. If it is None, a dictionary ...
src/mlab/matlabpipe.py
def get(self, names_to_get, extract_numpy_scalars=True, on_new_output=None): """ Loads the requested variables from the matlab shell. names_to_get can be either a variable name, a list of variable names, or None. If it is a var...
def get(self, names_to_get, extract_numpy_scalars=True, on_new_output=None): """ Loads the requested variables from the matlab shell. names_to_get can be either a variable name, a list of variable names, or None. If it is a var...
[ "Loads", "the", "requested", "variables", "from", "the", "matlab", "shell", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/matlabpipe.py#L220-L279
[ "def", "get", "(", "self", ",", "names_to_get", ",", "extract_numpy_scalars", "=", "True", ",", "on_new_output", "=", "None", ")", ":", "self", ".", "_check_open", "(", ")", "single_item", "=", "isinstance", "(", "names_to_get", ",", "(", "unicode", ",", "...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
rexGroups
Return the named groups in a regular expression (compiled or as string) in occuring order. >>> rexGroups(r'(?P<name>\w+) +(?P<surname>\w+)') ('name', 'surname')
src/mlab/awmstools.py
def rexGroups(rex): """Return the named groups in a regular expression (compiled or as string) in occuring order. >>> rexGroups(r'(?P<name>\w+) +(?P<surname>\w+)') ('name', 'surname') """ if isinstance(rex,basestring): rex = re.compile(rex) return zip(*sorted([(n,g) for (g,n) in rex.groupi...
def rexGroups(rex): """Return the named groups in a regular expression (compiled or as string) in occuring order. >>> rexGroups(r'(?P<name>\w+) +(?P<surname>\w+)') ('name', 'surname') """ if isinstance(rex,basestring): rex = re.compile(rex) return zip(*sorted([(n,g) for (g,n) in rex.groupi...
[ "Return", "the", "named", "groups", "in", "a", "regular", "expression", "(", "compiled", "or", "as", "string", ")", "in", "occuring", "order", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L140-L149
[ "def", "rexGroups", "(", "rex", ")", ":", "if", "isinstance", "(", "rex", ",", "basestring", ")", ":", "rex", "=", "re", ".", "compile", "(", "rex", ")", "return", "zip", "(", "*", "sorted", "(", "[", "(", "n", ",", "g", ")", "for", "(", "g", ...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
div
``div(a,b)`` is like ``a // b`` if ``b`` devides ``a``, otherwise an `ValueError` is raised. >>> div(10,2) 5 >>> div(10,3) Traceback (most recent call last): ... ValueError: 3 does not divide 10
src/mlab/awmstools.py
def div(a,b): """``div(a,b)`` is like ``a // b`` if ``b`` devides ``a``, otherwise an `ValueError` is raised. >>> div(10,2) 5 >>> div(10,3) Traceback (most recent call last): ... ValueError: 3 does not divide 10 """ res, fail = divmod(a,b) if fail: raise ValueError("...
def div(a,b): """``div(a,b)`` is like ``a // b`` if ``b`` devides ``a``, otherwise an `ValueError` is raised. >>> div(10,2) 5 >>> div(10,3) Traceback (most recent call last): ... ValueError: 3 does not divide 10 """ res, fail = divmod(a,b) if fail: raise ValueError("...
[ "div", "(", "a", "b", ")", "is", "like", "a", "//", "b", "if", "b", "devides", "a", "otherwise", "an", "ValueError", "is", "raised", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L243-L258
[ "def", "div", "(", "a", ",", "b", ")", ":", "res", ",", "fail", "=", "divmod", "(", "a", ",", "b", ")", "if", "fail", ":", "raise", "ValueError", "(", "\"%r does not divide %r\"", "%", "(", "b", ",", "a", ")", ")", "else", ":", "return", "res" ]
72a98adf6499f548848ad44c604f74d68f07fe4f
train
ipshuffle
r"""Shuffle list `l` inplace and return it.
src/mlab/awmstools.py
def ipshuffle(l, random=None): r"""Shuffle list `l` inplace and return it.""" import random as _random _random.shuffle(l, random) return l
def ipshuffle(l, random=None): r"""Shuffle list `l` inplace and return it.""" import random as _random _random.shuffle(l, random) return l
[ "r", "Shuffle", "list", "l", "inplace", "and", "return", "it", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L261-L265
[ "def", "ipshuffle", "(", "l", ",", "random", "=", "None", ")", ":", "import", "random", "as", "_random", "_random", ".", "shuffle", "(", "l", ",", "random", ")", "return", "l" ]
72a98adf6499f548848ad44c604f74d68f07fe4f
train
shuffle
r"""Return shuffled *copy* of `seq`.
src/mlab/awmstools.py
def shuffle(seq, random=None): r"""Return shuffled *copy* of `seq`.""" if isinstance(seq, list): return ipshuffle(seq[:], random) elif isString(seq): # seq[0:0] == "" or u"" return seq[0:0].join(ipshuffle(list(seq)),random) else: return type(seq)(ipshuffle(list(seq),rand...
def shuffle(seq, random=None): r"""Return shuffled *copy* of `seq`.""" if isinstance(seq, list): return ipshuffle(seq[:], random) elif isString(seq): # seq[0:0] == "" or u"" return seq[0:0].join(ipshuffle(list(seq)),random) else: return type(seq)(ipshuffle(list(seq),rand...
[ "r", "Return", "shuffled", "*", "copy", "*", "of", "seq", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L281-L289
[ "def", "shuffle", "(", "seq", ",", "random", "=", "None", ")", ":", "if", "isinstance", "(", "seq", ",", "list", ")", ":", "return", "ipshuffle", "(", "seq", "[", ":", "]", ",", "random", ")", "elif", "isString", "(", "seq", ")", ":", "# seq[0:0] =...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
slurp
r"""Read in a complete file `file` as a string Parameters: - `file`: a file handle or a string (`str` or `unicode`). - `binary`: whether to read in the file in binary mode (default: False).
src/mlab/awmstools.py
def slurp(file, binary=False, expand=False): r"""Read in a complete file `file` as a string Parameters: - `file`: a file handle or a string (`str` or `unicode`). - `binary`: whether to read in the file in binary mode (default: False). """ mode = "r" + ["b",""][not binary] file = _normaliz...
def slurp(file, binary=False, expand=False): r"""Read in a complete file `file` as a string Parameters: - `file`: a file handle or a string (`str` or `unicode`). - `binary`: whether to read in the file in binary mode (default: False). """ mode = "r" + ["b",""][not binary] file = _normaliz...
[ "r", "Read", "in", "a", "complete", "file", "file", "as", "a", "string", "Parameters", ":" ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L322-L332
[ "def", "slurp", "(", "file", ",", "binary", "=", "False", ",", "expand", "=", "False", ")", ":", "mode", "=", "\"r\"", "+", "[", "\"b\"", ",", "\"\"", "]", "[", "not", "binary", "]", "file", "=", "_normalizeToFile", "(", "file", ",", "mode", "=", ...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
withFile
Pass `file` to `func` and ensure the file is closed afterwards. If `file` is a string, open according to `mode`; if `expand` is true also expand user and vars.
src/mlab/awmstools.py
def withFile(file, func, mode='r', expand=False): """Pass `file` to `func` and ensure the file is closed afterwards. If `file` is a string, open according to `mode`; if `expand` is true also expand user and vars. """ file = _normalizeToFile(file, mode=mode, expand=expand) try: return ...
def withFile(file, func, mode='r', expand=False): """Pass `file` to `func` and ensure the file is closed afterwards. If `file` is a string, open according to `mode`; if `expand` is true also expand user and vars. """ file = _normalizeToFile(file, mode=mode, expand=expand) try: return ...
[ "Pass", "file", "to", "func", "and", "ensure", "the", "file", "is", "closed", "afterwards", ".", "If", "file", "is", "a", "string", "open", "according", "to", "mode", ";", "if", "expand", "is", "true", "also", "expand", "user", "and", "vars", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L335-L342
[ "def", "withFile", "(", "file", ",", "func", ",", "mode", "=", "'r'", ",", "expand", "=", "False", ")", ":", "file", "=", "_normalizeToFile", "(", "file", ",", "mode", "=", "mode", ",", "expand", "=", "expand", ")", "try", ":", "return", "func", "(...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
slurpLines
r"""Read in a complete file (specified by a file handler or a filename string/unicode string) as list of lines
src/mlab/awmstools.py
def slurpLines(file, expand=False): r"""Read in a complete file (specified by a file handler or a filename string/unicode string) as list of lines""" file = _normalizeToFile(file, "r", expand) try: return file.readlines() finally: file.close()
def slurpLines(file, expand=False): r"""Read in a complete file (specified by a file handler or a filename string/unicode string) as list of lines""" file = _normalizeToFile(file, "r", expand) try: return file.readlines() finally: file.close()
[ "r", "Read", "in", "a", "complete", "file", "(", "specified", "by", "a", "file", "handler", "or", "a", "filename", "string", "/", "unicode", "string", ")", "as", "list", "of", "lines" ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L345-L350
[ "def", "slurpLines", "(", "file", ",", "expand", "=", "False", ")", ":", "file", "=", "_normalizeToFile", "(", "file", ",", "\"r\"", ",", "expand", ")", "try", ":", "return", "file", ".", "readlines", "(", ")", "finally", ":", "file", ".", "close", "...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
slurpChompedLines
r"""Return ``file`` a list of chomped lines. See `slurpLines`.
src/mlab/awmstools.py
def slurpChompedLines(file, expand=False): r"""Return ``file`` a list of chomped lines. See `slurpLines`.""" f=_normalizeToFile(file, "r", expand) try: return list(chompLines(f)) finally: f.close()
def slurpChompedLines(file, expand=False): r"""Return ``file`` a list of chomped lines. See `slurpLines`.""" f=_normalizeToFile(file, "r", expand) try: return list(chompLines(f)) finally: f.close()
[ "r", "Return", "file", "a", "list", "of", "chomped", "lines", ".", "See", "slurpLines", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L352-L356
[ "def", "slurpChompedLines", "(", "file", ",", "expand", "=", "False", ")", ":", "f", "=", "_normalizeToFile", "(", "file", ",", "\"r\"", ",", "expand", ")", "try", ":", "return", "list", "(", "chompLines", "(", "f", ")", ")", "finally", ":", "f", "."...
72a98adf6499f548848ad44c604f74d68f07fe4f
train
strToTempfile
Create a new tempfile, write ``s`` to it and return the filename. `suffix`, `prefix` and `dir` are like in `tempfile.mkstemp`.
src/mlab/awmstools.py
def strToTempfile(s, suffix=None, prefix=None, dir=None, binary=False): """Create a new tempfile, write ``s`` to it and return the filename. `suffix`, `prefix` and `dir` are like in `tempfile.mkstemp`. """ fd, filename = tempfile.mkstemp(**dict((k,v) for (k,v) in ...
def strToTempfile(s, suffix=None, prefix=None, dir=None, binary=False): """Create a new tempfile, write ``s`` to it and return the filename. `suffix`, `prefix` and `dir` are like in `tempfile.mkstemp`. """ fd, filename = tempfile.mkstemp(**dict((k,v) for (k,v) in ...
[ "Create", "a", "new", "tempfile", "write", "s", "to", "it", "and", "return", "the", "filename", ".", "suffix", "prefix", "and", "dir", "are", "like", "in", "tempfile", ".", "mkstemp", "." ]
ewiger/mlab
python
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L358-L366
[ "def", "strToTempfile", "(", "s", ",", "suffix", "=", "None", ",", "prefix", "=", "None", ",", "dir", "=", "None", ",", "binary", "=", "False", ")", ":", "fd", ",", "filename", "=", "tempfile", ".", "mkstemp", "(", "*", "*", "dict", "(", "(", "k"...
72a98adf6499f548848ad44c604f74d68f07fe4f