repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
cocaine/cocaine-tools
cocaine/tools/dispatch.py
access_storage_create
def access_storage_create(name, **kwargs): """ Creates new ACL for the specified collection. Does nothing if ACL already exists. """ ctx = Context(**kwargs) ctx.execute_action('access:storage:create', **{ 'storage': ctx.repo.create_secure_service('storage'), 'name': name, })
python
def access_storage_create(name, **kwargs): """ Creates new ACL for the specified collection. Does nothing if ACL already exists. """ ctx = Context(**kwargs) ctx.execute_action('access:storage:create', **{ 'storage': ctx.repo.create_secure_service('storage'), 'name': name, })
[ "def", "access_storage_create", "(", "name", ",", "*", "*", "kwargs", ")", ":", "ctx", "=", "Context", "(", "*", "*", "kwargs", ")", "ctx", ".", "execute_action", "(", "'access:storage:create'", ",", "*", "*", "{", "'storage'", ":", "ctx", ".", "repo", ...
Creates new ACL for the specified collection. Does nothing if ACL already exists.
[ "Creates", "new", "ACL", "for", "the", "specified", "collection", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1843-L1853
train
Creates new ACL for the specified collection.
cocaine/cocaine-tools
cocaine/tools/dispatch.py
access_storage_edit
def access_storage_edit(name, cid, uid, perm, **kwargs): """ Edits ACL for the specified collection. Creates if necessary. """ ctx = Context(**kwargs) ctx.execute_action('access:storage:edit', **{ 'storage': ctx.repo.create_secure_service('storage'), 'name': name, 'cids'...
python
def access_storage_edit(name, cid, uid, perm, **kwargs): """ Edits ACL for the specified collection. Creates if necessary. """ ctx = Context(**kwargs) ctx.execute_action('access:storage:edit', **{ 'storage': ctx.repo.create_secure_service('storage'), 'name': name, 'cids'...
[ "def", "access_storage_edit", "(", "name", ",", "cid", ",", "uid", ",", "perm", ",", "*", "*", "kwargs", ")", ":", "ctx", "=", "Context", "(", "*", "*", "kwargs", ")", "ctx", ".", "execute_action", "(", "'access:storage:edit'", ",", "*", "*", "{", "'...
Edits ACL for the specified collection. Creates if necessary.
[ "Edits", "ACL", "for", "the", "specified", "collection", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1863-L1876
train
Edits ACL for the specified collection.
cocaine/cocaine-tools
cocaine/tools/dispatch.py
access_storage_rm
def access_storage_rm(name, yes, **kwargs): """ Remove ACL for the specified collection. If none is specified - removes ACL for all collections. """ if name is None: if not yes: click.confirm('Are you sure you want to remove all ACL?', abort=True) ctx = Context(**kwargs) ...
python
def access_storage_rm(name, yes, **kwargs): """ Remove ACL for the specified collection. If none is specified - removes ACL for all collections. """ if name is None: if not yes: click.confirm('Are you sure you want to remove all ACL?', abort=True) ctx = Context(**kwargs) ...
[ "def", "access_storage_rm", "(", "name", ",", "yes", ",", "*", "*", "kwargs", ")", ":", "if", "name", "is", "None", ":", "if", "not", "yes", ":", "click", ".", "confirm", "(", "'Are you sure you want to remove all ACL?'", ",", "abort", "=", "True", ")", ...
Remove ACL for the specified collection. If none is specified - removes ACL for all collections.
[ "Remove", "ACL", "for", "the", "specified", "collection", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1883-L1897
train
Removes ACL for the specified collection.
cocaine/cocaine-tools
cocaine/tools/dispatch.py
access_list
def access_list(**kwargs): """ Shows services for which there are ACL specified. """ ctx = Context(**kwargs) ctx.execute_action('access:list', **{ 'unicorn': ctx.repo.create_secure_service('unicorn'), })
python
def access_list(**kwargs): """ Shows services for which there are ACL specified. """ ctx = Context(**kwargs) ctx.execute_action('access:list', **{ 'unicorn': ctx.repo.create_secure_service('unicorn'), })
[ "def", "access_list", "(", "*", "*", "kwargs", ")", ":", "ctx", "=", "Context", "(", "*", "*", "kwargs", ")", "ctx", ".", "execute_action", "(", "'access:list'", ",", "*", "*", "{", "'unicorn'", ":", "ctx", ".", "repo", ".", "create_secure_service", "(...
Shows services for which there are ACL specified.
[ "Shows", "services", "for", "which", "there", "are", "ACL", "specified", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1902-L1909
train
Shows services for which there are ACL specified.
cocaine/cocaine-tools
cocaine/tools/dispatch.py
access_view
def access_view(name, **kwargs): """ Shows ACL for the specified service. """ ctx = Context(**kwargs) ctx.execute_action('access:view', **{ 'unicorn': ctx.repo.create_secure_service('unicorn'), 'service': name, })
python
def access_view(name, **kwargs): """ Shows ACL for the specified service. """ ctx = Context(**kwargs) ctx.execute_action('access:view', **{ 'unicorn': ctx.repo.create_secure_service('unicorn'), 'service': name, })
[ "def", "access_view", "(", "name", ",", "*", "*", "kwargs", ")", ":", "ctx", "=", "Context", "(", "*", "*", "kwargs", ")", "ctx", ".", "execute_action", "(", "'access:view'", ",", "*", "*", "{", "'unicorn'", ":", "ctx", ".", "repo", ".", "create_secu...
Shows ACL for the specified service.
[ "Shows", "ACL", "for", "the", "specified", "service", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1915-L1923
train
Shows ACL for the specified service.
cocaine/cocaine-tools
cocaine/tools/dispatch.py
access_add
def access_add(name, event, cid, uid, **kwargs): """ Creates a new record with specified cid/uid in the event authorization. Requests with token that contains such cid/uid will have access to the specified event of a service. """ ctx = Context(**kwargs) ctx.execute_action('access:add', **{ ...
python
def access_add(name, event, cid, uid, **kwargs): """ Creates a new record with specified cid/uid in the event authorization. Requests with token that contains such cid/uid will have access to the specified event of a service. """ ctx = Context(**kwargs) ctx.execute_action('access:add', **{ ...
[ "def", "access_add", "(", "name", ",", "event", ",", "cid", ",", "uid", ",", "*", "*", "kwargs", ")", ":", "ctx", "=", "Context", "(", "*", "*", "kwargs", ")", "ctx", ".", "execute_action", "(", "'access:add'", ",", "*", "*", "{", "'unicorn'", ":",...
Creates a new record with specified cid/uid in the event authorization. Requests with token that contains such cid/uid will have access to the specified event of a service.
[ "Creates", "a", "new", "record", "with", "specified", "cid", "/", "uid", "in", "the", "event", "authorization", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1932-L1946
train
Add a record to the specified event authorization.
cocaine/cocaine-tools
cocaine/tools/dispatch.py
keyring_view
def keyring_view(**kwargs): """ View saved public keys. """ ctx = Context(**kwargs) ctx.execute_action('keyring:view', **{ 'storage': ctx.repo.create_secure_service('storage'), })
python
def keyring_view(**kwargs): """ View saved public keys. """ ctx = Context(**kwargs) ctx.execute_action('keyring:view', **{ 'storage': ctx.repo.create_secure_service('storage'), })
[ "def", "keyring_view", "(", "*", "*", "kwargs", ")", ":", "ctx", "=", "Context", "(", "*", "*", "kwargs", ")", "ctx", ".", "execute_action", "(", "'keyring:view'", ",", "*", "*", "{", "'storage'", ":", "ctx", ".", "repo", ".", "create_secure_service", ...
View saved public keys.
[ "View", "saved", "public", "keys", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1966-L1973
train
View saved public keys.
cocaine/cocaine-tools
cocaine/tools/dispatch.py
keyring_update
def keyring_update(cid, **kwargs): """ Downloads and saves public key(s). Downloads public key(s) from the TVM service for a given client id and saves in the storage for further usage. Note, that the cocaine-runtime automatically refreshes its keyring after this call. """ ctx = Context(**kw...
python
def keyring_update(cid, **kwargs): """ Downloads and saves public key(s). Downloads public key(s) from the TVM service for a given client id and saves in the storage for further usage. Note, that the cocaine-runtime automatically refreshes its keyring after this call. """ ctx = Context(**kw...
[ "def", "keyring_update", "(", "cid", ",", "*", "*", "kwargs", ")", ":", "ctx", "=", "Context", "(", "*", "*", "kwargs", ")", "ctx", ".", "execute_action", "(", "'keyring:update'", ",", "*", "*", "{", "'tvm'", ":", "ctx", ".", "repo", ".", "create_sec...
Downloads and saves public key(s). Downloads public key(s) from the TVM service for a given client id and saves in the storage for further usage. Note, that the cocaine-runtime automatically refreshes its keyring after this call.
[ "Downloads", "and", "saves", "public", "key", "(", "s", ")", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1979-L1991
train
Updates the public key for a given client id.
cocaine/cocaine-tools
cocaine/tools/dispatch.py
keyring_remove
def keyring_remove(key, yes, **kwargs): """ Removes a public key from the keyring. Does nothing if a key is already not in the keyring. If none is specified - clears the keyring. To force the cocaine-runtime to refresh its keyring, call `refresh` method. """ if key is None: if not yes: ...
python
def keyring_remove(key, yes, **kwargs): """ Removes a public key from the keyring. Does nothing if a key is already not in the keyring. If none is specified - clears the keyring. To force the cocaine-runtime to refresh its keyring, call `refresh` method. """ if key is None: if not yes: ...
[ "def", "keyring_remove", "(", "key", ",", "yes", ",", "*", "*", "kwargs", ")", ":", "if", "key", "is", "None", ":", "if", "not", "yes", ":", "click", ".", "confirm", "(", "'Are you sure you want to remove all keys?'", ",", "abort", "=", "True", ")", "ctx...
Removes a public key from the keyring. Does nothing if a key is already not in the keyring. If none is specified - clears the keyring. To force the cocaine-runtime to refresh its keyring, call `refresh` method.
[ "Removes", "a", "public", "key", "from", "the", "keyring", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L1998-L2013
train
Removes a public key from the keyring.
cocaine/cocaine-tools
cocaine/tools/dispatch.py
keyring_edit
def keyring_edit(**kwargs): """ Edits interactively the keyring. """ ctx = Context(**kwargs) ctx.timeout = None ctx.execute_action('keyring:edit', **{ 'storage': ctx.repo.create_secure_service('storage'), })
python
def keyring_edit(**kwargs): """ Edits interactively the keyring. """ ctx = Context(**kwargs) ctx.timeout = None ctx.execute_action('keyring:edit', **{ 'storage': ctx.repo.create_secure_service('storage'), })
[ "def", "keyring_edit", "(", "*", "*", "kwargs", ")", ":", "ctx", "=", "Context", "(", "*", "*", "kwargs", ")", "ctx", ".", "timeout", "=", "None", "ctx", ".", "execute_action", "(", "'keyring:edit'", ",", "*", "*", "{", "'storage'", ":", "ctx", ".", ...
Edits interactively the keyring.
[ "Edits", "interactively", "the", "keyring", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L2018-L2026
train
Edits interactively the keyring.
cocaine/cocaine-tools
cocaine/tools/dispatch.py
keyring_refresh
def keyring_refresh(**kwargs): """ Refresh the keyring in the cocaine-runtime. """ ctx = Context(**kwargs) ctx.execute_action('keyring:refresh', **{ 'tvm': ctx.repo.create_secure_service('tvm'), })
python
def keyring_refresh(**kwargs): """ Refresh the keyring in the cocaine-runtime. """ ctx = Context(**kwargs) ctx.execute_action('keyring:refresh', **{ 'tvm': ctx.repo.create_secure_service('tvm'), })
[ "def", "keyring_refresh", "(", "*", "*", "kwargs", ")", ":", "ctx", "=", "Context", "(", "*", "*", "kwargs", ")", "ctx", ".", "execute_action", "(", "'keyring:refresh'", ",", "*", "*", "{", "'tvm'", ":", "ctx", ".", "repo", ".", "create_secure_service", ...
Refresh the keyring in the cocaine-runtime.
[ "Refresh", "the", "keyring", "in", "the", "cocaine", "-", "runtime", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/dispatch.py#L2031-L2038
train
Refresh the keyring in the cocaine - runtime.
cnschema/cdata
cdata/summary.py
summarize_entity_person
def summarize_entity_person(person): """ assume person entity using cnschma person vocabulary, http://cnschema.org/Person """ ret = [] value = person.get("name") if not value: return False ret.append(value) prop = "courtesyName" value = json_get_first_item(person, prop) ...
python
def summarize_entity_person(person): """ assume person entity using cnschma person vocabulary, http://cnschema.org/Person """ ret = [] value = person.get("name") if not value: return False ret.append(value) prop = "courtesyName" value = json_get_first_item(person, prop) ...
[ "def", "summarize_entity_person", "(", "person", ")", ":", "ret", "=", "[", "]", "value", "=", "person", ".", "get", "(", "\"name\"", ")", "if", "not", "value", ":", "return", "False", "ret", ".", "append", "(", "value", ")", "prop", "=", "\"courtesyNa...
assume person entity using cnschma person vocabulary, http://cnschema.org/Person
[ "assume", "person", "entity", "using", "cnschma", "person", "vocabulary", "http", ":", "//", "cnschema", ".", "org", "/", "Person" ]
893e2e1e27b61c8551c8b5f5f9bf05ec61490e23
https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/summary.py#L25-L117
train
Summarize a person entity into a list of strings.
pjamesjoyce/lcopt
lcopt/bw2_export.py
Bw2Exporter.evaluate_parameter_sets
def evaluate_parameter_sets(self): """ This takes the parameter sets of the model instance and evaluates any formulas using the parameter values to create a fixed, full set of parameters for each parameter set in the model """ #parameter_interpreter = ParameterInterpreter(self....
python
def evaluate_parameter_sets(self): """ This takes the parameter sets of the model instance and evaluates any formulas using the parameter values to create a fixed, full set of parameters for each parameter set in the model """ #parameter_interpreter = ParameterInterpreter(self....
[ "def", "evaluate_parameter_sets", "(", "self", ")", ":", "#parameter_interpreter = ParameterInterpreter(self.modelInstance)", "#parameter_interpreter.evaluate_parameter_sets()", "self", ".", "parameter_interpreter", "=", "LcoptParameterSet", "(", "self", ".", "modelInstance", ")", ...
This takes the parameter sets of the model instance and evaluates any formulas using the parameter values to create a fixed, full set of parameters for each parameter set in the model
[ "This", "takes", "the", "parameter", "sets", "of", "the", "model", "instance", "and", "evaluates", "any", "formulas", "using", "the", "parameter", "values", "to", "create", "a", "fixed", "full", "set", "of", "parameters", "for", "each", "parameter", "set", "...
3f1caca31fece4a3068a384900707e6d21d04597
https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/bw2_export.py#L18-L28
train
This function takes the parameter sets of the model instance and evaluates any formulas using the parameter values for each parameter set in the model instance.
pjamesjoyce/lcopt
lcopt/bw2_export.py
Bw2Exporter.create_parameter_map
def create_parameter_map(self): """ Creates a parameter map which takes a tuple of the exchange 'from' and exchange 'to' codes and returns the parameter name for that exchange """ names = self.modelInstance.names db = self.modelInstance.database['items'] paramete...
python
def create_parameter_map(self): """ Creates a parameter map which takes a tuple of the exchange 'from' and exchange 'to' codes and returns the parameter name for that exchange """ names = self.modelInstance.names db = self.modelInstance.database['items'] paramete...
[ "def", "create_parameter_map", "(", "self", ")", ":", "names", "=", "self", ".", "modelInstance", ".", "names", "db", "=", "self", ".", "modelInstance", ".", "database", "[", "'items'", "]", "parameter_map", "=", "{", "}", "def", "get_names_index", "(", "m...
Creates a parameter map which takes a tuple of the exchange 'from' and exchange 'to' codes and returns the parameter name for that exchange
[ "Creates", "a", "parameter", "map", "which", "takes", "a", "tuple", "of", "the", "exchange", "from", "and", "exchange", "to", "codes", "and", "returns", "the", "parameter", "name", "for", "that", "exchange" ]
3f1caca31fece4a3068a384900707e6d21d04597
https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/bw2_export.py#L30-L55
train
Creates a parameter map which takes a tuple of the from and to codes and returns the parameter name for that exchange
gabfl/dbschema
src/schema_change.py
get_config
def get_config(override=None): """ Get config file """ # Set location config_path = os.path.expanduser('~') + '/.dbschema.yml' if override: config_path = override # Check if the config file exists check_exists(config_path) # Load config with open(config_path) as f: # u...
python
def get_config(override=None): """ Get config file """ # Set location config_path = os.path.expanduser('~') + '/.dbschema.yml' if override: config_path = override # Check if the config file exists check_exists(config_path) # Load config with open(config_path) as f: # u...
[ "def", "get_config", "(", "override", "=", "None", ")", ":", "# Set location", "config_path", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "+", "'/.dbschema.yml'", "if", "override", ":", "config_path", "=", "override", "# Check if the config file ...
Get config file
[ "Get", "config", "file" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L15-L31
train
Get the config file
gabfl/dbschema
src/schema_change.py
check_exists
def check_exists(path, type='file'): """ Check if a file or a folder exists """ if type == 'file': if not os.path.isfile(path): raise RuntimeError('The file `%s` does not exist.' % path) else: if not os.path.isdir(path): raise RuntimeError('The folder `%s` does not e...
python
def check_exists(path, type='file'): """ Check if a file or a folder exists """ if type == 'file': if not os.path.isfile(path): raise RuntimeError('The file `%s` does not exist.' % path) else: if not os.path.isdir(path): raise RuntimeError('The folder `%s` does not e...
[ "def", "check_exists", "(", "path", ",", "type", "=", "'file'", ")", ":", "if", "type", "==", "'file'", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "raise", "RuntimeError", "(", "'The file `%s` does not exist.'", "%", "path...
Check if a file or a folder exists
[ "Check", "if", "a", "file", "or", "a", "folder", "exists" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L34-L44
train
Check if a file or a folder exists.
gabfl/dbschema
src/schema_change.py
get_connection
def get_connection(engine, host, user, port, password, database, ssl={}): """ Returns a PostgreSQL or MySQL connection """ if engine == 'mysql': # Connection return get_mysql_connection(host, user, port, password, database, ssl) elif engine == 'postgresql': # Connection retu...
python
def get_connection(engine, host, user, port, password, database, ssl={}): """ Returns a PostgreSQL or MySQL connection """ if engine == 'mysql': # Connection return get_mysql_connection(host, user, port, password, database, ssl) elif engine == 'postgresql': # Connection retu...
[ "def", "get_connection", "(", "engine", ",", "host", ",", "user", ",", "port", ",", "password", ",", "database", ",", "ssl", "=", "{", "}", ")", ":", "if", "engine", "==", "'mysql'", ":", "# Connection", "return", "get_mysql_connection", "(", "host", ","...
Returns a PostgreSQL or MySQL connection
[ "Returns", "a", "PostgreSQL", "or", "MySQL", "connection" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L81-L91
train
Returns a PostgreSQL or MySQL connection
gabfl/dbschema
src/schema_change.py
get_mysql_connection
def get_mysql_connection(host, user, port, password, database, ssl={}): """ MySQL connection """ return pymysql.connect(host=host, user=user, port=port, password=password, db=database, ...
python
def get_mysql_connection(host, user, port, password, database, ssl={}): """ MySQL connection """ return pymysql.connect(host=host, user=user, port=port, password=password, db=database, ...
[ "def", "get_mysql_connection", "(", "host", ",", "user", ",", "port", ",", "password", ",", "database", ",", "ssl", "=", "{", "}", ")", ":", "return", "pymysql", ".", "connect", "(", "host", "=", "host", ",", "user", "=", "user", ",", "port", "=", ...
MySQL connection
[ "MySQL", "connection" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L94-L106
train
Get a MySQL connection.
gabfl/dbschema
src/schema_change.py
get_pg_connection
def get_pg_connection(host, user, port, password, database, ssl={}): """ PostgreSQL connection """ return psycopg2.connect(host=host, user=user, port=port, password=password, dbname=database, ...
python
def get_pg_connection(host, user, port, password, database, ssl={}): """ PostgreSQL connection """ return psycopg2.connect(host=host, user=user, port=port, password=password, dbname=database, ...
[ "def", "get_pg_connection", "(", "host", ",", "user", ",", "port", ",", "password", ",", "database", ",", "ssl", "=", "{", "}", ")", ":", "return", "psycopg2", ".", "connect", "(", "host", "=", "host", ",", "user", "=", "user", ",", "port", "=", "p...
PostgreSQL connection
[ "PostgreSQL", "connection" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L109-L121
train
Get a PostgreSQL connection.
gabfl/dbschema
src/schema_change.py
parse_statements
def parse_statements(queries_input, engine): """ Parse input and return a list of SQL statements """ queries = [] query = '' sql_delimiter = ';' # Possible delimiters used in PostgreSQL functions postgres_func_delimiters = ['$$', '##'] # Split input by lines lines = queries_input.stri...
python
def parse_statements(queries_input, engine): """ Parse input and return a list of SQL statements """ queries = [] query = '' sql_delimiter = ';' # Possible delimiters used in PostgreSQL functions postgres_func_delimiters = ['$$', '##'] # Split input by lines lines = queries_input.stri...
[ "def", "parse_statements", "(", "queries_input", ",", "engine", ")", ":", "queries", "=", "[", "]", "query", "=", "''", "sql_delimiter", "=", "';'", "# Possible delimiters used in PostgreSQL functions", "postgres_func_delimiters", "=", "[", "'$$'", ",", "'##'", "]",...
Parse input and return a list of SQL statements
[ "Parse", "input", "and", "return", "a", "list", "of", "SQL", "statements" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L124-L169
train
Parse input and return a list of SQL statements.
gabfl/dbschema
src/schema_change.py
run_migration
def run_migration(connection, queries, engine): """ Apply a migration to the SQL server """ # Execute query with connection.cursor() as cursorMig: # Parse statements queries = parse_statements(queries, engine) for query in queries: cursorMig.execute(query) conne...
python
def run_migration(connection, queries, engine): """ Apply a migration to the SQL server """ # Execute query with connection.cursor() as cursorMig: # Parse statements queries = parse_statements(queries, engine) for query in queries: cursorMig.execute(query) conne...
[ "def", "run_migration", "(", "connection", ",", "queries", ",", "engine", ")", ":", "# Execute query", "with", "connection", ".", "cursor", "(", ")", "as", "cursorMig", ":", "# Parse statements", "queries", "=", "parse_statements", "(", "queries", ",", "engine",...
Apply a migration to the SQL server
[ "Apply", "a", "migration", "to", "the", "SQL", "server" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L172-L184
train
Apply a migration to the SQL server
gabfl/dbschema
src/schema_change.py
save_migration
def save_migration(connection, basename): """ Save a migration in `migrations_applied` table """ # Prepare query sql = "INSERT INTO migrations_applied (name, date) VALUES (%s, NOW())" # Run with connection.cursor() as cursor: cursor.execute(sql, (basename,)) connection.commit() ...
python
def save_migration(connection, basename): """ Save a migration in `migrations_applied` table """ # Prepare query sql = "INSERT INTO migrations_applied (name, date) VALUES (%s, NOW())" # Run with connection.cursor() as cursor: cursor.execute(sql, (basename,)) connection.commit() ...
[ "def", "save_migration", "(", "connection", ",", "basename", ")", ":", "# Prepare query", "sql", "=", "\"INSERT INTO migrations_applied (name, date) VALUES (%s, NOW())\"", "# Run", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "exe...
Save a migration in `migrations_applied` table
[ "Save", "a", "migration", "in", "migrations_applied", "table" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L187-L198
train
Save a migration in migrations_applied table
gabfl/dbschema
src/schema_change.py
delete_migration
def delete_migration(connection, basename): """ Delete a migration in `migrations_applied` table """ # Prepare query sql = "DELETE FROM migrations_applied WHERE name = %s" # Run with connection.cursor() as cursor: cursor.execute(sql, (basename,)) connection.commit() return Tru...
python
def delete_migration(connection, basename): """ Delete a migration in `migrations_applied` table """ # Prepare query sql = "DELETE FROM migrations_applied WHERE name = %s" # Run with connection.cursor() as cursor: cursor.execute(sql, (basename,)) connection.commit() return Tru...
[ "def", "delete_migration", "(", "connection", ",", "basename", ")", ":", "# Prepare query", "sql", "=", "\"DELETE FROM migrations_applied WHERE name = %s\"", "# Run", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", ...
Delete a migration in `migrations_applied` table
[ "Delete", "a", "migration", "in", "migrations_applied", "table" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L201-L212
train
Delete a migration in migrations_applied table
gabfl/dbschema
src/schema_change.py
get_migrations_applied
def get_migrations_applied(engine, connection): """ Get list of migrations already applied """ try: # Get cursor based on engine if engine == 'postgresql': cursor = connection.cursor( cursor_factory=psycopg2.extras.RealDictCursor) else: cursor = c...
python
def get_migrations_applied(engine, connection): """ Get list of migrations already applied """ try: # Get cursor based on engine if engine == 'postgresql': cursor = connection.cursor( cursor_factory=psycopg2.extras.RealDictCursor) else: cursor = c...
[ "def", "get_migrations_applied", "(", "engine", ",", "connection", ")", ":", "try", ":", "# Get cursor based on engine", "if", "engine", "==", "'postgresql'", ":", "cursor", "=", "connection", ".", "cursor", "(", "cursor_factory", "=", "psycopg2", ".", "extras", ...
Get list of migrations already applied
[ "Get", "list", "of", "migrations", "already", "applied" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L221-L242
train
Get list of migrations already applied
gabfl/dbschema
src/schema_change.py
apply_migrations
def apply_migrations(engine, connection, path): """ Apply all migrations in a chronological order """ # Get migrations applied migrations_applied = get_migrations_applied(engine, connection) # print(migrationsApplied) # Get migrations folder for file in get_migrations_files(path): # Se...
python
def apply_migrations(engine, connection, path): """ Apply all migrations in a chronological order """ # Get migrations applied migrations_applied = get_migrations_applied(engine, connection) # print(migrationsApplied) # Get migrations folder for file in get_migrations_files(path): # Se...
[ "def", "apply_migrations", "(", "engine", ",", "connection", ",", "path", ")", ":", "# Get migrations applied", "migrations_applied", "=", "get_migrations_applied", "(", "engine", ",", "connection", ")", "# print(migrationsApplied)", "# Get migrations folder", "for", "fil...
Apply all migrations in a chronological order
[ "Apply", "all", "migrations", "in", "a", "chronological", "order" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L245-L277
train
Apply all migrations in chronological order
gabfl/dbschema
src/schema_change.py
rollback_migration
def rollback_migration(engine, connection, path, migration_to_rollback): """ Rollback a migration """ # Get migrations applied migrations_applied = get_migrations_applied(engine, connection) # Ensure that the migration was previously applied if not is_applied(migrations_applied, migration_to_rollb...
python
def rollback_migration(engine, connection, path, migration_to_rollback): """ Rollback a migration """ # Get migrations applied migrations_applied = get_migrations_applied(engine, connection) # Ensure that the migration was previously applied if not is_applied(migrations_applied, migration_to_rollb...
[ "def", "rollback_migration", "(", "engine", ",", "connection", ",", "path", ",", "migration_to_rollback", ")", ":", "# Get migrations applied", "migrations_applied", "=", "get_migrations_applied", "(", "engine", ",", "connection", ")", "# Ensure that the migration was previ...
Rollback a migration
[ "Rollback", "a", "migration" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L280-L313
train
Rollback a migration
gabfl/dbschema
src/schema_change.py
get_ssl
def get_ssl(database): """ Returns SSL options for the selected engine """ # Set available keys per engine if database['engine'] == 'postgresql': keys = ['sslmode', 'sslcert', 'sslkey', 'sslrootcert', 'sslcrl', 'sslcompression'] else: keys = ['ssl_ca', 'ssl_capath', 'ssl...
python
def get_ssl(database): """ Returns SSL options for the selected engine """ # Set available keys per engine if database['engine'] == 'postgresql': keys = ['sslmode', 'sslcert', 'sslkey', 'sslrootcert', 'sslcrl', 'sslcompression'] else: keys = ['ssl_ca', 'ssl_capath', 'ssl...
[ "def", "get_ssl", "(", "database", ")", ":", "# Set available keys per engine", "if", "database", "[", "'engine'", "]", "==", "'postgresql'", ":", "keys", "=", "[", "'sslmode'", ",", "'sslcert'", ",", "'sslkey'", ",", "'sslrootcert'", ",", "'sslcrl'", ",", "'s...
Returns SSL options for the selected engine
[ "Returns", "SSL", "options", "for", "the", "selected", "engine" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L316-L334
train
Returns the SSL options for the selected engine
gabfl/dbschema
src/schema_change.py
apply
def apply(config_override=None, tag_override=None, rollback=None, skip_missing=None): """ Look thru migrations and apply them """ # Load config config = get_config(config_override) databases = config['databases'] # If we are rolling back, ensure that we have a database tag if rollback and not ...
python
def apply(config_override=None, tag_override=None, rollback=None, skip_missing=None): """ Look thru migrations and apply them """ # Load config config = get_config(config_override) databases = config['databases'] # If we are rolling back, ensure that we have a database tag if rollback and not ...
[ "def", "apply", "(", "config_override", "=", "None", ",", "tag_override", "=", "None", ",", "rollback", "=", "None", ",", "skip_missing", "=", "None", ")", ":", "# Load config", "config", "=", "get_config", "(", "config_override", ")", "databases", "=", "con...
Look thru migrations and apply them
[ "Look", "thru", "migrations", "and", "apply", "them" ]
37722e6654e9f0374fac5518ebdca22f4c39f92f
https://github.com/gabfl/dbschema/blob/37722e6654e9f0374fac5518ebdca22f4c39f92f/src/schema_change.py#L337-L396
train
Apply migrations to the current database.
lucianoratamero/django_apistar
django_apistar/authentication/components.py
DjangoBasicAuthentication.resolve
def resolve(self, authorization: http.Header): """ Determine the user associated with a request, using HTTP Basic Authentication. """ if authorization is None: return None scheme, token = authorization.split() if scheme.lower() != 'basic': return ...
python
def resolve(self, authorization: http.Header): """ Determine the user associated with a request, using HTTP Basic Authentication. """ if authorization is None: return None scheme, token = authorization.split() if scheme.lower() != 'basic': return ...
[ "def", "resolve", "(", "self", ",", "authorization", ":", "http", ".", "Header", ")", ":", "if", "authorization", "is", "None", ":", "return", "None", "scheme", ",", "token", "=", "authorization", ".", "split", "(", ")", "if", "scheme", ".", "lower", "...
Determine the user associated with a request, using HTTP Basic Authentication.
[ "Determine", "the", "user", "associated", "with", "a", "request", "using", "HTTP", "Basic", "Authentication", "." ]
615024680b8033aa346acd188cd542db3341064f
https://github.com/lucianoratamero/django_apistar/blob/615024680b8033aa346acd188cd542db3341064f/django_apistar/authentication/components.py#L9-L23
train
Resolves the user associated with a request using HTTP Basic Authentication.
lucianoratamero/django_apistar
django_apistar/authentication/components.py
DjangoTokenAuthentication.resolve
def resolve(self, authorization: http.Header): """ Determine the user associated with a request, using Token Authentication. """ from django_apistar.authentication.models import Token if authorization is None: return None scheme, token = authorization.split(...
python
def resolve(self, authorization: http.Header): """ Determine the user associated with a request, using Token Authentication. """ from django_apistar.authentication.models import Token if authorization is None: return None scheme, token = authorization.split(...
[ "def", "resolve", "(", "self", ",", "authorization", ":", "http", ".", "Header", ")", ":", "from", "django_apistar", ".", "authentication", ".", "models", "import", "Token", "if", "authorization", "is", "None", ":", "return", "None", "scheme", ",", "token", ...
Determine the user associated with a request, using Token Authentication.
[ "Determine", "the", "user", "associated", "with", "a", "request", "using", "Token", "Authentication", "." ]
615024680b8033aa346acd188cd542db3341064f
https://github.com/lucianoratamero/django_apistar/blob/615024680b8033aa346acd188cd542db3341064f/django_apistar/authentication/components.py#L27-L45
train
Resolves the user associated with a request using Token Authentication.
MoseleyBioinformaticsLab/mwtab
mwtab/converter.py
Converter.convert
def convert(self): """Convert file(s) from ``mwTab`` format to ``JSON`` format or from ``JSON`` format to ``mwTab`` format. :return: None :rtype: :py:obj:`None` """ if not os.path.exists(os.path.dirname(self.file_generator.to_path)): dirname = os.path.dirname(self.fil...
python
def convert(self): """Convert file(s) from ``mwTab`` format to ``JSON`` format or from ``JSON`` format to ``mwTab`` format. :return: None :rtype: :py:obj:`None` """ if not os.path.exists(os.path.dirname(self.file_generator.to_path)): dirname = os.path.dirname(self.fil...
[ "def", "convert", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "dirname", "(", "self", ".", "file_generator", ".", "to_path", ")", ")", ":", "dirname", "=", "os", ".", "path", ".", "dirname", ...
Convert file(s) from ``mwTab`` format to ``JSON`` format or from ``JSON`` format to ``mwTab`` format. :return: None :rtype: :py:obj:`None`
[ "Convert", "file", "(", "s", ")", "from", "mwTab", "format", "to", "JSON", "format", "or", "from", "JSON", "format", "to", "mwTab", "format", ".", ":", "return", ":", "None", ":", "rtype", ":", ":", "py", ":", "obj", ":", "None" ]
8c0ae8ab2aa621662f99589ed41e481cf8b7152b
https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/converter.py#L172-L194
train
Convert file from MWTab format to JSON format.
MoseleyBioinformaticsLab/mwtab
mwtab/converter.py
Converter._many_to_many
def _many_to_many(self): """Perform many-to-many files conversion. :return: None :rtype: :py:obj:`None` """ if not self.file_generator.to_path_compression: self._to_dir(self.file_generator) elif self.file_generator.to_path_compression == "zip": sel...
python
def _many_to_many(self): """Perform many-to-many files conversion. :return: None :rtype: :py:obj:`None` """ if not self.file_generator.to_path_compression: self._to_dir(self.file_generator) elif self.file_generator.to_path_compression == "zip": sel...
[ "def", "_many_to_many", "(", "self", ")", ":", "if", "not", "self", ".", "file_generator", ".", "to_path_compression", ":", "self", ".", "_to_dir", "(", "self", ".", "file_generator", ")", "elif", "self", ".", "file_generator", ".", "to_path_compression", "=="...
Perform many-to-many files conversion. :return: None :rtype: :py:obj:`None`
[ "Perform", "many", "-", "to", "-", "many", "files", "conversion", ".", ":", "return", ":", "None", ":", "rtype", ":", ":", "py", ":", "obj", ":", "None" ]
8c0ae8ab2aa621662f99589ed41e481cf8b7152b
https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/converter.py#L196-L211
train
Perform many - to - many files conversion.
MoseleyBioinformaticsLab/mwtab
mwtab/converter.py
Converter._one_to_one
def _one_to_one(self): """Perform one-to-one file conversion. :return: None :rtype: :py:obj:`None` """ if not self.file_generator.to_path_compression: self._to_textfile(self.file_generator) elif self.file_generator.to_path_compression == "gz": self...
python
def _one_to_one(self): """Perform one-to-one file conversion. :return: None :rtype: :py:obj:`None` """ if not self.file_generator.to_path_compression: self._to_textfile(self.file_generator) elif self.file_generator.to_path_compression == "gz": self...
[ "def", "_one_to_one", "(", "self", ")", ":", "if", "not", "self", ".", "file_generator", ".", "to_path_compression", ":", "self", ".", "_to_textfile", "(", "self", ".", "file_generator", ")", "elif", "self", ".", "file_generator", ".", "to_path_compression", "...
Perform one-to-one file conversion. :return: None :rtype: :py:obj:`None`
[ "Perform", "one", "-", "to", "-", "one", "file", "conversion", ".", ":", "return", ":", "None", ":", "rtype", ":", ":", "py", ":", "obj", ":", "None" ]
8c0ae8ab2aa621662f99589ed41e481cf8b7152b
https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/converter.py#L213-L228
train
Perform one - to - one file conversion.
MoseleyBioinformaticsLab/mwtab
mwtab/converter.py
Converter._to_dir
def _to_dir(self, file_generator): """Convert files to directory. :return: None :rtype: :py:obj:`None` """ for f in file_generator: outpath = self._output_path(f.source, file_generator.to_format) if not os.path.exists(os.path.dirname(outpath)): ...
python
def _to_dir(self, file_generator): """Convert files to directory. :return: None :rtype: :py:obj:`None` """ for f in file_generator: outpath = self._output_path(f.source, file_generator.to_format) if not os.path.exists(os.path.dirname(outpath)): ...
[ "def", "_to_dir", "(", "self", ",", "file_generator", ")", ":", "for", "f", "in", "file_generator", ":", "outpath", "=", "self", ".", "_output_path", "(", "f", ".", "source", ",", "file_generator", ".", "to_format", ")", "if", "not", "os", ".", "path", ...
Convert files to directory. :return: None :rtype: :py:obj:`None`
[ "Convert", "files", "to", "directory", ".", ":", "return", ":", "None", ":", "rtype", ":", ":", "py", ":", "obj", ":", "None" ]
8c0ae8ab2aa621662f99589ed41e481cf8b7152b
https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/converter.py#L230-L242
train
Convert files to directory.
MoseleyBioinformaticsLab/mwtab
mwtab/converter.py
Converter._to_zipfile
def _to_zipfile(self, file_generator): """Convert files to zip archive. :return: None :rtype: :py:obj:`None` """ with zipfile.ZipFile(file_generator.to_path, mode="w", compression=zipfile.ZIP_DEFLATED) as outfile: for f in file_generator: outpath = sel...
python
def _to_zipfile(self, file_generator): """Convert files to zip archive. :return: None :rtype: :py:obj:`None` """ with zipfile.ZipFile(file_generator.to_path, mode="w", compression=zipfile.ZIP_DEFLATED) as outfile: for f in file_generator: outpath = sel...
[ "def", "_to_zipfile", "(", "self", ",", "file_generator", ")", ":", "with", "zipfile", ".", "ZipFile", "(", "file_generator", ".", "to_path", ",", "mode", "=", "\"w\"", ",", "compression", "=", "zipfile", ".", "ZIP_DEFLATED", ")", "as", "outfile", ":", "fo...
Convert files to zip archive. :return: None :rtype: :py:obj:`None`
[ "Convert", "files", "to", "zip", "archive", ".", ":", "return", ":", "None", ":", "rtype", ":", ":", "py", ":", "obj", ":", "None" ]
8c0ae8ab2aa621662f99589ed41e481cf8b7152b
https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/converter.py#L244-L252
train
Convert files to zip archive.
MoseleyBioinformaticsLab/mwtab
mwtab/converter.py
Converter._to_tarfile
def _to_tarfile(self, file_generator): """Convert files to tar archive. :return: None :rtype: :py:obj:`None` """ if file_generator.to_path_compression == "tar": tar_mode = "w" elif file_generator.to_path_compression == "tar.gz": tar_mode = "w:gz" ...
python
def _to_tarfile(self, file_generator): """Convert files to tar archive. :return: None :rtype: :py:obj:`None` """ if file_generator.to_path_compression == "tar": tar_mode = "w" elif file_generator.to_path_compression == "tar.gz": tar_mode = "w:gz" ...
[ "def", "_to_tarfile", "(", "self", ",", "file_generator", ")", ":", "if", "file_generator", ".", "to_path_compression", "==", "\"tar\"", ":", "tar_mode", "=", "\"w\"", "elif", "file_generator", ".", "to_path_compression", "==", "\"tar.gz\"", ":", "tar_mode", "=", ...
Convert files to tar archive. :return: None :rtype: :py:obj:`None`
[ "Convert", "files", "to", "tar", "archive", ".", ":", "return", ":", "None", ":", "rtype", ":", ":", "py", ":", "obj", ":", "None" ]
8c0ae8ab2aa621662f99589ed41e481cf8b7152b
https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/converter.py#L254-L274
train
Convert files to tar archive.
MoseleyBioinformaticsLab/mwtab
mwtab/converter.py
Converter._to_bz2file
def _to_bz2file(self, file_generator): """Convert file to bz2-compressed file. :return: None :rtype: :py:obj:`None` """ with bz2.BZ2File(file_generator.to_path, mode="wb") as outfile: for f in file_generator: outfile.write(f.writestr(file_generator.to_...
python
def _to_bz2file(self, file_generator): """Convert file to bz2-compressed file. :return: None :rtype: :py:obj:`None` """ with bz2.BZ2File(file_generator.to_path, mode="wb") as outfile: for f in file_generator: outfile.write(f.writestr(file_generator.to_...
[ "def", "_to_bz2file", "(", "self", ",", "file_generator", ")", ":", "with", "bz2", ".", "BZ2File", "(", "file_generator", ".", "to_path", ",", "mode", "=", "\"wb\"", ")", "as", "outfile", ":", "for", "f", "in", "file_generator", ":", "outfile", ".", "wri...
Convert file to bz2-compressed file. :return: None :rtype: :py:obj:`None`
[ "Convert", "file", "to", "bz2", "-", "compressed", "file", ".", ":", "return", ":", "None", ":", "rtype", ":", ":", "py", ":", "obj", ":", "None" ]
8c0ae8ab2aa621662f99589ed41e481cf8b7152b
https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/converter.py#L276-L283
train
Convert file to bz2 - compressed file.
MoseleyBioinformaticsLab/mwtab
mwtab/converter.py
Converter._to_gzipfile
def _to_gzipfile(self, file_generator): """Convert file to gzip-compressed file. :return: None :rtype: :py:obj:`None` """ with gzip.GzipFile(file_generator.to_path, mode="wb") as outfile: for f in file_generator: outfile.write(f.writestr(file_generator...
python
def _to_gzipfile(self, file_generator): """Convert file to gzip-compressed file. :return: None :rtype: :py:obj:`None` """ with gzip.GzipFile(file_generator.to_path, mode="wb") as outfile: for f in file_generator: outfile.write(f.writestr(file_generator...
[ "def", "_to_gzipfile", "(", "self", ",", "file_generator", ")", ":", "with", "gzip", ".", "GzipFile", "(", "file_generator", ".", "to_path", ",", "mode", "=", "\"wb\"", ")", "as", "outfile", ":", "for", "f", "in", "file_generator", ":", "outfile", ".", "...
Convert file to gzip-compressed file. :return: None :rtype: :py:obj:`None`
[ "Convert", "file", "to", "gzip", "-", "compressed", "file", ".", ":", "return", ":", "None", ":", "rtype", ":", ":", "py", ":", "obj", ":", "None" ]
8c0ae8ab2aa621662f99589ed41e481cf8b7152b
https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/converter.py#L285-L292
train
Convert file to gzip - compressed file.
MoseleyBioinformaticsLab/mwtab
mwtab/converter.py
Converter._to_textfile
def _to_textfile(self, file_generator): """Convert file to regular text file. :return: None :rtype: :py:obj:`None` """ to_path = file_generator.to_path \ if file_generator.to_path.endswith(file_generator.file_extension[file_generator.to_format]) \ else fil...
python
def _to_textfile(self, file_generator): """Convert file to regular text file. :return: None :rtype: :py:obj:`None` """ to_path = file_generator.to_path \ if file_generator.to_path.endswith(file_generator.file_extension[file_generator.to_format]) \ else fil...
[ "def", "_to_textfile", "(", "self", ",", "file_generator", ")", ":", "to_path", "=", "file_generator", ".", "to_path", "if", "file_generator", ".", "to_path", ".", "endswith", "(", "file_generator", ".", "file_extension", "[", "file_generator", ".", "to_format", ...
Convert file to regular text file. :return: None :rtype: :py:obj:`None`
[ "Convert", "file", "to", "regular", "text", "file", ".", ":", "return", ":", "None", ":", "rtype", ":", ":", "py", ":", "obj", ":", "None" ]
8c0ae8ab2aa621662f99589ed41e481cf8b7152b
https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/converter.py#L294-L305
train
Convert file to regular text file.
MoseleyBioinformaticsLab/mwtab
mwtab/converter.py
Converter._output_path
def _output_path(self, input_path, to_format, archive=False): """Construct an output path string from an input path string. :param str input_path: Input path string. :return: Output path string. :rtype: :py:class:`str` """ indirpath, fname = os.path.split(os.path.abspath(...
python
def _output_path(self, input_path, to_format, archive=False): """Construct an output path string from an input path string. :param str input_path: Input path string. :return: Output path string. :rtype: :py:class:`str` """ indirpath, fname = os.path.split(os.path.abspath(...
[ "def", "_output_path", "(", "self", ",", "input_path", ",", "to_format", ",", "archive", "=", "False", ")", ":", "indirpath", ",", "fname", "=", "os", ".", "path", ".", "split", "(", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "...
Construct an output path string from an input path string. :param str input_path: Input path string. :return: Output path string. :rtype: :py:class:`str`
[ "Construct", "an", "output", "path", "string", "from", "an", "input", "path", "string", ".", ":", "param", "str", "input_path", ":", "Input", "path", "string", ".", ":", "return", ":", "Output", "path", "string", ".", ":", "rtype", ":", ":", "py", ":",...
8c0ae8ab2aa621662f99589ed41e481cf8b7152b
https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/converter.py#L307-L327
train
Construct an output path string from an input path string.
liluo/mime
mime/type.py
Type.priority_compare
def priority_compare(self, other): """ Compares the MIME::Type based on how reliable it is before doing a normal <=> comparison. Used by MIME::Types#[] to sort types. The comparisons involved are: 1. self.simplified <=> other.simplified (ensures that we don't try to co...
python
def priority_compare(self, other): """ Compares the MIME::Type based on how reliable it is before doing a normal <=> comparison. Used by MIME::Types#[] to sort types. The comparisons involved are: 1. self.simplified <=> other.simplified (ensures that we don't try to co...
[ "def", "priority_compare", "(", "self", ",", "other", ")", ":", "pc", "=", "cmp", "(", "self", ".", "simplified", ",", "other", ".", "simplified", ")", "if", "pc", "is", "0", ":", "if", "self", ".", "is_registered", "!=", "other", ".", "is_registered",...
Compares the MIME::Type based on how reliable it is before doing a normal <=> comparison. Used by MIME::Types#[] to sort types. The comparisons involved are: 1. self.simplified <=> other.simplified (ensures that we don't try to compare different types) 2. IANA-registered defin...
[ "Compares", "the", "MIME", "::", "Type", "based", "on", "how", "reliable", "it", "is", "before", "doing", "a", "normal", "<", "=", ">", "comparison", ".", "Used", "by", "MIME", "::", "Types#", "[]", "to", "sort", "types", ".", "The", "comparisons", "in...
86af73dba53f7c9f8df975c6a70aeef5977b21ef
https://github.com/liluo/mime/blob/86af73dba53f7c9f8df975c6a70aeef5977b21ef/mime/type.py#L166-L201
train
Compares two MIME::Type objects to determine the priority of the two MIME::Types.
liluo/mime
mime/type.py
Type.urls
def urls(self): """ The decoded URL list for this MIME::Type. The special URL value IANA will be translated into: http://www.iana.org/assignments/media-types/<mediatype>/<subtype> The special URL value RFC### will be translated into: http://www.rfc-editor.org/rfc/rfc#...
python
def urls(self): """ The decoded URL list for this MIME::Type. The special URL value IANA will be translated into: http://www.iana.org/assignments/media-types/<mediatype>/<subtype> The special URL value RFC### will be translated into: http://www.rfc-editor.org/rfc/rfc#...
[ "def", "urls", "(", "self", ")", ":", "def", "_url", "(", "el", ")", ":", "if", "el", "==", "'IANA'", ":", "return", "IANA_URL", "%", "(", "self", ".", "media_type", ",", "self", ".", "sub_type", ")", "elif", "el", "==", "'LTSW'", ":", "return", ...
The decoded URL list for this MIME::Type. The special URL value IANA will be translated into: http://www.iana.org/assignments/media-types/<mediatype>/<subtype> The special URL value RFC### will be translated into: http://www.rfc-editor.org/rfc/rfc###.txt The special URL value...
[ "The", "decoded", "URL", "list", "for", "this", "MIME", "::", "Type", ".", "The", "special", "URL", "value", "IANA", "will", "be", "translated", "into", ":", "http", ":", "//", "www", ".", "iana", ".", "org", "/", "assignments", "/", "media", "-", "t...
86af73dba53f7c9f8df975c6a70aeef5977b21ef
https://github.com/liluo/mime/blob/86af73dba53f7c9f8df975c6a70aeef5977b21ef/mime/type.py#L242-L281
train
Returns a list of decoded URL values for this MIME::Type.
liluo/mime
mime/type.py
Type.simplify
def simplify(cls, content_type): """ The MIME types main- and sub-label can both start with <tt>x-</tt>, which indicates that it is a non-registered name. Of course, after registration this flag can disappear, adds to the confusing proliferation of MIME types. The simplified stri...
python
def simplify(cls, content_type): """ The MIME types main- and sub-label can both start with <tt>x-</tt>, which indicates that it is a non-registered name. Of course, after registration this flag can disappear, adds to the confusing proliferation of MIME types. The simplified stri...
[ "def", "simplify", "(", "cls", ",", "content_type", ")", ":", "matchdata", "=", "MEDIA_TYPE_RE", ".", "match", "(", "content_type", ")", "if", "matchdata", "is", "None", ":", "return", "None", "wrap", "=", "lambda", "s", ":", "re", ".", "sub", "(", "UN...
The MIME types main- and sub-label can both start with <tt>x-</tt>, which indicates that it is a non-registered name. Of course, after registration this flag can disappear, adds to the confusing proliferation of MIME types. The simplified string has the <tt>x-</tt> removed and are transl...
[ "The", "MIME", "types", "main", "-", "and", "sub", "-", "label", "can", "both", "start", "with", "<tt", ">", "x", "-", "<", "/", "tt", ">", "which", "indicates", "that", "it", "is", "a", "non", "-", "registered", "name", ".", "Of", "course", "after...
86af73dba53f7c9f8df975c6a70aeef5977b21ef
https://github.com/liluo/mime/blob/86af73dba53f7c9f8df975c6a70aeef5977b21ef/mime/type.py#L383-L396
train
Simplifies the content - type into a single entry.
liluo/mime
mime/type.py
Type.from_array
def from_array(cls, content_type, extensions=[], encoding=None, system=None, is_obsolete=False, docs=None, url=None, is_registered=False): """ Creates a MIME::Type from an array in the form of: [type-name, [extensions], encoding, system] +extension...
python
def from_array(cls, content_type, extensions=[], encoding=None, system=None, is_obsolete=False, docs=None, url=None, is_registered=False): """ Creates a MIME::Type from an array in the form of: [type-name, [extensions], encoding, system] +extension...
[ "def", "from_array", "(", "cls", ",", "content_type", ",", "extensions", "=", "[", "]", ",", "encoding", "=", "None", ",", "system", "=", "None", ",", "is_obsolete", "=", "False", ",", "docs", "=", "None", ",", "url", "=", "None", ",", "is_registered",...
Creates a MIME::Type from an array in the form of: [type-name, [extensions], encoding, system] +extensions+, +encoding+, and +system+ are optional. Type.from_array("application/x-ruby", ['rb'], '8bit') # Type.from_array(["application/x-ruby", ['rb'], '8bit']) These are equi...
[ "Creates", "a", "MIME", "::", "Type", "from", "an", "array", "in", "the", "form", "of", ":", "[", "type", "-", "name", "[", "extensions", "]", "encoding", "system", "]", "+", "extensions", "+", "+", "encoding", "+", "and", "+", "system", "+", "are", ...
86af73dba53f7c9f8df975c6a70aeef5977b21ef
https://github.com/liluo/mime/blob/86af73dba53f7c9f8df975c6a70aeef5977b21ef/mime/type.py#L399-L421
train
Creates a new MIME :: Type instance from an array.
liluo/mime
mime/type.py
Type.from_hash
def from_hash(cls, hash): """ Creates a MIME::Type from a hash. Keys are case-insensitive, dashes may be replaced with underscores, and the internal Symbol of the lowercase-underscore version can be used as well. That is, Content-Type can be provided as content-type, Cont...
python
def from_hash(cls, hash): """ Creates a MIME::Type from a hash. Keys are case-insensitive, dashes may be replaced with underscores, and the internal Symbol of the lowercase-underscore version can be used as well. That is, Content-Type can be provided as content-type, Cont...
[ "def", "from_hash", "(", "cls", ",", "hash", ")", ":", "wrap_key", "=", "lambda", "k", ":", "k", ".", "lower", "(", ")", ".", "replace", "(", "'-'", ",", "'_'", ")", "type_hash", "=", "dict", "(", "[", "(", "wrap_key", "(", "k", ")", ",", "v", ...
Creates a MIME::Type from a hash. Keys are case-insensitive, dashes may be replaced with underscores, and the internal Symbol of the lowercase-underscore version can be used as well. That is, Content-Type can be provided as content-type, Content_Type, content_type, or :content_type. ...
[ "Creates", "a", "MIME", "::", "Type", "from", "a", "hash", ".", "Keys", "are", "case", "-", "insensitive", "dashes", "may", "be", "replaced", "with", "underscores", "and", "the", "internal", "Symbol", "of", "the", "lowercase", "-", "underscore", "version", ...
86af73dba53f7c9f8df975c6a70aeef5977b21ef
https://github.com/liluo/mime/blob/86af73dba53f7c9f8df975c6a70aeef5977b21ef/mime/type.py#L424-L454
train
Creates a new MIME::Type instance from a hash.
liluo/mime
mime/type.py
Type.from_mime_type
def from_mime_type(cls, mime_type): """ Essentially a copy constructor. Type.from_mime_type(plaintext) is equivalent to: t = Type.new(plaintext.content_type.dup) t.extensions = plaintext.extensions.dup t.system = plaintext.system.dup t.encod...
python
def from_mime_type(cls, mime_type): """ Essentially a copy constructor. Type.from_mime_type(plaintext) is equivalent to: t = Type.new(plaintext.content_type.dup) t.extensions = plaintext.extensions.dup t.system = plaintext.system.dup t.encod...
[ "def", "from_mime_type", "(", "cls", ",", "mime_type", ")", ":", "mt", "=", "cls", "(", "deepcopy", "(", "mime_type", ".", "content_type", ")", ")", "mt", ".", "extensions", "=", "map", "(", "deepcopy", ",", "mime_type", ".", "extensions", ")", "mt", "...
Essentially a copy constructor. Type.from_mime_type(plaintext) is equivalent to: t = Type.new(plaintext.content_type.dup) t.extensions = plaintext.extensions.dup t.system = plaintext.system.dup t.encoding = plaintext.encoding.dup
[ "Essentially", "a", "copy", "constructor", ".", "Type", ".", "from_mime_type", "(", "plaintext", ")", "is", "equivalent", "to", ":", "t", "=", "Type", ".", "new", "(", "plaintext", ".", "content_type", ".", "dup", ")", "t", ".", "extensions", "=", "plain...
86af73dba53f7c9f8df975c6a70aeef5977b21ef
https://github.com/liluo/mime/blob/86af73dba53f7c9f8df975c6a70aeef5977b21ef/mime/type.py#L457-L476
train
Creates a new object from a MIME type.
cocaine/cocaine-tools
cocaine/tools/cli.py
Executor.loop
def loop(self): """Lazy event loop initialization""" if not self._loop: self._loop = IOLoop.current() return self._loop return self._loop
python
def loop(self): """Lazy event loop initialization""" if not self._loop: self._loop = IOLoop.current() return self._loop return self._loop
[ "def", "loop", "(", "self", ")", ":", "if", "not", "self", ".", "_loop", ":", "self", ".", "_loop", "=", "IOLoop", ".", "current", "(", ")", "return", "self", ".", "_loop", "return", "self", ".", "_loop" ]
Lazy event loop initialization
[ "Lazy", "event", "loop", "initialization" ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/cli.py#L245-L250
train
Lazy event loop initialization
cocaine/cocaine-tools
cocaine/tools/cli.py
Executor.execute_action
def execute_action(self, action_name, **options): """Execute action with specified options. Tries to create action from its name and invokes it. :param action_name: action name. :param options: various action configuration. """ assert action_name in NG_ACTIONS, 'wrong a...
python
def execute_action(self, action_name, **options): """Execute action with specified options. Tries to create action from its name and invokes it. :param action_name: action name. :param options: various action configuration. """ assert action_name in NG_ACTIONS, 'wrong a...
[ "def", "execute_action", "(", "self", ",", "action_name", ",", "*", "*", "options", ")", ":", "assert", "action_name", "in", "NG_ACTIONS", ",", "'wrong action - {0}'", ".", "format", "(", "action_name", ")", "action", "=", "NG_ACTIONS", "[", "action_name", "]"...
Execute action with specified options. Tries to create action from its name and invokes it. :param action_name: action name. :param options: various action configuration.
[ "Execute", "action", "with", "specified", "options", "." ]
d8834f8e04ca42817d5f4e368d471484d4b3419f
https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/cli.py#L252-L263
train
Executes action with specified options.
cnschema/cdata
cdata/table.py
json2excel
def json2excel(items, keys, filename, page_size=60000): """ max_page_size is 65000 because we output old excel .xls format """ wb = xlwt.Workbook() rowindex = 0 sheetindex = 0 for item in items: if rowindex % page_size == 0: sheetname = "%02d" % sheetindex ws = wb...
python
def json2excel(items, keys, filename, page_size=60000): """ max_page_size is 65000 because we output old excel .xls format """ wb = xlwt.Workbook() rowindex = 0 sheetindex = 0 for item in items: if rowindex % page_size == 0: sheetname = "%02d" % sheetindex ws = wb...
[ "def", "json2excel", "(", "items", ",", "keys", ",", "filename", ",", "page_size", "=", "60000", ")", ":", "wb", "=", "xlwt", ".", "Workbook", "(", ")", "rowindex", "=", "0", "sheetindex", "=", "0", "for", "item", "in", "items", ":", "if", "rowindex"...
max_page_size is 65000 because we output old excel .xls format
[ "max_page_size", "is", "65000", "because", "we", "output", "old", "excel", ".", "xls", "format" ]
893e2e1e27b61c8551c8b5f5f9bf05ec61490e23
https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/table.py#L22-L53
train
Convert a list of dicts into an Excel file.
cnschema/cdata
cdata/table.py
excel2json
def excel2json(filename, non_empty_col=-1, file_contents=None): """ http://www.lexicon.net/sjmachin/xlrd.html non_empty_col is -1 to load all rows, when set to a none-empty value, this function will skip rows having empty cell on that col. """ if file_contents: workbook = xl...
python
def excel2json(filename, non_empty_col=-1, file_contents=None): """ http://www.lexicon.net/sjmachin/xlrd.html non_empty_col is -1 to load all rows, when set to a none-empty value, this function will skip rows having empty cell on that col. """ if file_contents: workbook = xl...
[ "def", "excel2json", "(", "filename", ",", "non_empty_col", "=", "-", "1", ",", "file_contents", "=", "None", ")", ":", "if", "file_contents", ":", "workbook", "=", "xlrd", ".", "open_workbook", "(", "file_contents", "=", "file_contents", ")", "else", ":", ...
http://www.lexicon.net/sjmachin/xlrd.html non_empty_col is -1 to load all rows, when set to a none-empty value, this function will skip rows having empty cell on that col.
[ "http", ":", "//", "www", ".", "lexicon", ".", "net", "/", "sjmachin", "/", "xlrd", ".", "html", "non_empty_col", "is", "-", "1", "to", "load", "all", "rows", "when", "set", "to", "a", "none", "-", "empty", "value", "this", "function", "will", "skip"...
893e2e1e27b61c8551c8b5f5f9bf05ec61490e23
https://github.com/cnschema/cdata/blob/893e2e1e27b61c8551c8b5f5f9bf05ec61490e23/cdata/table.py#L56-L106
train
Load a single file from an Excel file and return a dictionary of the objects.
pjamesjoyce/lcopt
lcopt/parameters.py
LcoptParameterSet.check_production_parameters_exist
def check_production_parameters_exist(self): """ old versions of models won't have produciton parameters, leading to ZeroDivision errors and breaking things""" for k, v in self.modelInstance.parameter_sets.items(): for p_id in self.modelInstance.production_params.keys(): if v...
python
def check_production_parameters_exist(self): """ old versions of models won't have produciton parameters, leading to ZeroDivision errors and breaking things""" for k, v in self.modelInstance.parameter_sets.items(): for p_id in self.modelInstance.production_params.keys(): if v...
[ "def", "check_production_parameters_exist", "(", "self", ")", ":", "for", "k", ",", "v", "in", "self", ".", "modelInstance", ".", "parameter_sets", ".", "items", "(", ")", ":", "for", "p_id", "in", "self", ".", "modelInstance", ".", "production_params", ".",...
old versions of models won't have produciton parameters, leading to ZeroDivision errors and breaking things
[ "old", "versions", "of", "models", "won", "t", "have", "produciton", "parameters", "leading", "to", "ZeroDivision", "errors", "and", "breaking", "things" ]
3f1caca31fece4a3068a384900707e6d21d04597
https://github.com/pjamesjoyce/lcopt/blob/3f1caca31fece4a3068a384900707e6d21d04597/lcopt/parameters.py#L100-L117
train
Check that the production parameters exist in the model instance.
camptocamp/Studio
studio/lib/mapserializer.py
Mapfile._create_symbol
def _create_symbol(self, id, symbolobj): """Creates the JSON representation of a symbol""" result = {'id': symbolobj.name, 'isPoint': False, 'isStroke': False, 'isFill': False} matcher = Mapfile._SYMBOL_NAME_REGEXP.match(symbolobj.name) if matcher: result['name'] = matcher.gr...
python
def _create_symbol(self, id, symbolobj): """Creates the JSON representation of a symbol""" result = {'id': symbolobj.name, 'isPoint': False, 'isStroke': False, 'isFill': False} matcher = Mapfile._SYMBOL_NAME_REGEXP.match(symbolobj.name) if matcher: result['name'] = matcher.gr...
[ "def", "_create_symbol", "(", "self", ",", "id", ",", "symbolobj", ")", ":", "result", "=", "{", "'id'", ":", "symbolobj", ".", "name", ",", "'isPoint'", ":", "False", ",", "'isStroke'", ":", "False", ",", "'isFill'", ":", "False", "}", "matcher", "=",...
Creates the JSON representation of a symbol
[ "Creates", "the", "JSON", "representation", "of", "a", "symbol" ]
43cb7298434fb606b15136801b79b03571a2f27e
https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/lib/mapserializer.py#L90-L102
train
Creates the JSON representation of a symbol
mete0r/hypua2jamo
src/hypua2jamo/__init__.py
translate
def translate(pua, composed=True): ''' Convert a unicode string with Hanyang-PUA codes to a Syllable-Initial-Peak-Final encoded unicode string. :param pua: a unicode string with Hanyang-PUA codes :param composed: the result should be composed as possible (default True) :return: Syllable-Initial-Pea...
python
def translate(pua, composed=True): ''' Convert a unicode string with Hanyang-PUA codes to a Syllable-Initial-Peak-Final encoded unicode string. :param pua: a unicode string with Hanyang-PUA codes :param composed: the result should be composed as possible (default True) :return: Syllable-Initial-Pea...
[ "def", "translate", "(", "pua", ",", "composed", "=", "True", ")", ":", "from", ".", "encoder", "import", "PUAComposedEncoder", "from", ".", "encoder", "import", "PUADecomposedEncoder", "if", "composed", ":", "JamoEncoder", "=", "PUAComposedEncoder", "else", ":"...
Convert a unicode string with Hanyang-PUA codes to a Syllable-Initial-Peak-Final encoded unicode string. :param pua: a unicode string with Hanyang-PUA codes :param composed: the result should be composed as possible (default True) :return: Syllable-Initial-Peak-Final encoded unicode string
[ "Convert", "a", "unicode", "string", "with", "Hanyang", "-", "PUA", "codes", "to", "a", "Syllable", "-", "Initial", "-", "Peak", "-", "Final", "encoded", "unicode", "string", "." ]
caceb33a26c27645703d659a82bb1152deef1469
https://github.com/mete0r/hypua2jamo/blob/caceb33a26c27645703d659a82bb1152deef1469/src/hypua2jamo/__init__.py#L32-L49
train
Translate a unicode string with Hanyang - PUA codes to a Syllable - Initial - Peak - Final encoded unicode string.
mete0r/hypua2jamo
src/hypua2jamo/__init__.py
codes2unicode
def codes2unicode(codes, composed=True): ''' Convert Hanyang-PUA code iterable to Syllable-Initial-Peak-Final encoded unicode string. :param codes: an iterable of Hanyang-PUA code :param composed: the result should be composed as much as possible (default True) :return: Syllable-Ini...
python
def codes2unicode(codes, composed=True): ''' Convert Hanyang-PUA code iterable to Syllable-Initial-Peak-Final encoded unicode string. :param codes: an iterable of Hanyang-PUA code :param composed: the result should be composed as much as possible (default True) :return: Syllable-Ini...
[ "def", "codes2unicode", "(", "codes", ",", "composed", "=", "True", ")", ":", "pua", "=", "u''", ".", "join", "(", "unichr", "(", "code", ")", "for", "code", "in", "codes", ")", "return", "translate", "(", "pua", ",", "composed", "=", "composed", ")"...
Convert Hanyang-PUA code iterable to Syllable-Initial-Peak-Final encoded unicode string. :param codes: an iterable of Hanyang-PUA code :param composed: the result should be composed as much as possible (default True) :return: Syllable-Initial-Peak-Final encoded unicode string
[ "Convert", "Hanyang", "-", "PUA", "code", "iterable", "to", "Syllable", "-", "Initial", "-", "Peak", "-", "Final", "encoded", "unicode", "string", "." ]
caceb33a26c27645703d659a82bb1152deef1469
https://github.com/mete0r/hypua2jamo/blob/caceb33a26c27645703d659a82bb1152deef1469/src/hypua2jamo/__init__.py#L52-L63
train
Convert a list of Hanyang - PUA codes to a Syllable - Initial - Peak - Final encoded unicode string.
teepark/greenhouse
greenhouse/io/ssl.py
SSLSocket.read
def read(self, len=1024): 'read up to len bytes and return them, or empty string on EOF' return self._with_retry( functools.partial(self._read_attempt, len), self.gettimeout())
python
def read(self, len=1024): 'read up to len bytes and return them, or empty string on EOF' return self._with_retry( functools.partial(self._read_attempt, len), self.gettimeout())
[ "def", "read", "(", "self", ",", "len", "=", "1024", ")", ":", "return", "self", ".", "_with_retry", "(", "functools", ".", "partial", "(", "self", ".", "_read_attempt", ",", "len", ")", ",", "self", ".", "gettimeout", "(", ")", ")" ]
read up to len bytes and return them, or empty string on EOF
[ "read", "up", "to", "len", "bytes", "and", "return", "them", "or", "empty", "string", "on", "EOF" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/io/ssl.py#L114-L118
train
read up to len bytes and return them or empty string on EOF
teepark/greenhouse
greenhouse/io/ssl.py
SSLSocket.write
def write(self, data): 'write data to the ssl channel and return the # of bytes transferred' return self._with_retry( functools.partial(self._sslobj.write, data), self.gettimeout())
python
def write(self, data): 'write data to the ssl channel and return the # of bytes transferred' return self._with_retry( functools.partial(self._sslobj.write, data), self.gettimeout())
[ "def", "write", "(", "self", ",", "data", ")", ":", "return", "self", ".", "_with_retry", "(", "functools", ".", "partial", "(", "self", ".", "_sslobj", ".", "write", ",", "data", ")", ",", "self", ".", "gettimeout", "(", ")", ")" ]
write data to the ssl channel and return the # of bytes transferred
[ "write", "data", "to", "the", "ssl", "channel", "and", "return", "the", "#", "of", "bytes", "transferred" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/io/ssl.py#L120-L124
train
write data to the ssl channel and return the # of bytes transferred
teepark/greenhouse
greenhouse/io/ssl.py
SSLSocket.do_handshake
def do_handshake(self, timeout): 'perform a SSL/TLS handshake' tout = _timeout(timeout) if not self._blocking: return self._sslobj.do_handshake() while 1: try: return self._sslobj.do_handshake() except ssl.SSLError, exc: ...
python
def do_handshake(self, timeout): 'perform a SSL/TLS handshake' tout = _timeout(timeout) if not self._blocking: return self._sslobj.do_handshake() while 1: try: return self._sslobj.do_handshake() except ssl.SSLError, exc: ...
[ "def", "do_handshake", "(", "self", ",", "timeout", ")", ":", "tout", "=", "_timeout", "(", "timeout", ")", "if", "not", "self", ".", "_blocking", ":", "return", "self", ".", "_sslobj", ".", "do_handshake", "(", ")", "while", "1", ":", "try", ":", "r...
perform a SSL/TLS handshake
[ "perform", "a", "SSL", "/", "TLS", "handshake" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/io/ssl.py#L242-L261
train
perform a SSL / TLS handshake
teepark/greenhouse
greenhouse/io/ssl.py
SSLSocket.connect
def connect(self, address): 'connects to the address and wraps the connection in an SSL context' tout = _timeout(self.gettimeout()) while 1: self._wait_event(tout.now, write=True) err = self._connect(address, tout.now) if err in (errno.EINPROGRESS, errno.EALRE...
python
def connect(self, address): 'connects to the address and wraps the connection in an SSL context' tout = _timeout(self.gettimeout()) while 1: self._wait_event(tout.now, write=True) err = self._connect(address, tout.now) if err in (errno.EINPROGRESS, errno.EALRE...
[ "def", "connect", "(", "self", ",", "address", ")", ":", "tout", "=", "_timeout", "(", "self", ".", "gettimeout", "(", ")", ")", "while", "1", ":", "self", ".", "_wait_event", "(", "tout", ".", "now", ",", "write", "=", "True", ")", "err", "=", "...
connects to the address and wraps the connection in an SSL context
[ "connects", "to", "the", "address", "and", "wraps", "the", "connection", "in", "an", "SSL", "context" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/io/ssl.py#L287-L297
train
connects to the address and wraps the connection in an SSL context
teepark/greenhouse
greenhouse/io/ssl.py
SSLSocket.makefile
def makefile(self, mode='r', bufsize=-1): 'return a file-like object that operates on the ssl connection' sockfile = gsock.SocketFile.__new__(gsock.SocketFile) gfiles.FileBase.__init__(sockfile) sockfile._sock = self sockfile.mode = mode if bufsize > 0: sockfi...
python
def makefile(self, mode='r', bufsize=-1): 'return a file-like object that operates on the ssl connection' sockfile = gsock.SocketFile.__new__(gsock.SocketFile) gfiles.FileBase.__init__(sockfile) sockfile._sock = self sockfile.mode = mode if bufsize > 0: sockfi...
[ "def", "makefile", "(", "self", ",", "mode", "=", "'r'", ",", "bufsize", "=", "-", "1", ")", ":", "sockfile", "=", "gsock", ".", "SocketFile", ".", "__new__", "(", "gsock", ".", "SocketFile", ")", "gfiles", ".", "FileBase", ".", "__init__", "(", "soc...
return a file-like object that operates on the ssl connection
[ "return", "a", "file", "-", "like", "object", "that", "operates", "on", "the", "ssl", "connection" ]
8fd1be4f5443ba090346b5ec82fdbeb0a060d956
https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/io/ssl.py#L324-L332
train
return a file - like object that operates on the ssl connection
polysquare/cmake-ast
container-setup.py
run
def run(cont, util, shell, argv=None): """Set up language runtimes and pass control to python project script.""" cont.fetch_and_import("setup/python/setup.py").run(cont, util, shell, ...
python
def run(cont, util, shell, argv=None): """Set up language runtimes and pass control to python project script.""" cont.fetch_and_import("setup/python/setup.py").run(cont, util, shell, ...
[ "def", "run", "(", "cont", ",", "util", ",", "shell", ",", "argv", "=", "None", ")", ":", "cont", ".", "fetch_and_import", "(", "\"setup/python/setup.py\"", ")", ".", "run", "(", "cont", ",", "util", ",", "shell", ",", "argv", ")", "cmake_cont", "=", ...
Set up language runtimes and pass control to python project script.
[ "Set", "up", "language", "runtimes", "and", "pass", "control", "to", "python", "project", "script", "." ]
431a32d595d76f1f8f993eb6ddcc79effbadff9d
https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/container-setup.py#L17-L64
train
Run cmake and return a list of cmake modules.
thombashi/DataProperty
dataproperty/_dataproperty.py
DataProperty.length
def length(self): """ :return: Length of the ``data``. :rtype: int """ if not self.__length: self.__length = self.__get_length() return self.__length
python
def length(self): """ :return: Length of the ``data``. :rtype: int """ if not self.__length: self.__length = self.__get_length() return self.__length
[ "def", "length", "(", "self", ")", ":", "if", "not", "self", ".", "__length", ":", "self", ".", "__length", "=", "self", ".", "__get_length", "(", ")", "return", "self", ".", "__length" ]
:return: Length of the ``data``. :rtype: int
[ ":", "return", ":", "Length", "of", "the", "data", ".", ":", "rtype", ":", "int" ]
1d1a4c6abee87264c2f870a932c0194895d80a18
https://github.com/thombashi/DataProperty/blob/1d1a4c6abee87264c2f870a932c0194895d80a18/dataproperty/_dataproperty.py#L113-L122
train
Returns the length of the data.
nickpandolfi/Cyther
cyther/extractor.py
get_content
def get_content(pattern, string, tag='content'): """ Finds the 'content' tag from a 'pattern' in the provided 'string' """ output = [] for match in re.finditer(pattern, string): output.append(match.group(tag)) return output
python
def get_content(pattern, string, tag='content'): """ Finds the 'content' tag from a 'pattern' in the provided 'string' """ output = [] for match in re.finditer(pattern, string): output.append(match.group(tag)) return output
[ "def", "get_content", "(", "pattern", ",", "string", ",", "tag", "=", "'content'", ")", ":", "output", "=", "[", "]", "for", "match", "in", "re", ".", "finditer", "(", "pattern", ",", "string", ")", ":", "output", ".", "append", "(", "match", ".", ...
Finds the 'content' tag from a 'pattern' in the provided 'string'
[ "Finds", "the", "content", "tag", "from", "a", "pattern", "in", "the", "provided", "string" ]
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/extractor.py#L13-L20
train
Finds the content tag from a pattern in a provided string
nickpandolfi/Cyther
cyther/extractor.py
extract
def extract(pattern, string, *, assert_equal=False, one=False, condense=False, default=None, default_if_multiple=True, default_if_none=True): """ Used to extract a given regex pattern from a string, given several options """ if isinstance(pattern, str): output = get_cont...
python
def extract(pattern, string, *, assert_equal=False, one=False, condense=False, default=None, default_if_multiple=True, default_if_none=True): """ Used to extract a given regex pattern from a string, given several options """ if isinstance(pattern, str): output = get_cont...
[ "def", "extract", "(", "pattern", ",", "string", ",", "*", ",", "assert_equal", "=", "False", ",", "one", "=", "False", ",", "condense", "=", "False", ",", "default", "=", "None", ",", "default_if_multiple", "=", "True", ",", "default_if_none", "=", "Tru...
Used to extract a given regex pattern from a string, given several options
[ "Used", "to", "extract", "a", "given", "regex", "pattern", "from", "a", "string", "given", "several", "options" ]
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/extractor.py#L23-L46
train
Extract a given regex pattern from a string
nickpandolfi/Cyther
cyther/extractor.py
extractRuntime
def extractRuntime(runtime_dirs): """ Used to find the correct static lib name to pass to gcc """ names = [str(item) for name in runtime_dirs for item in os.listdir(name)] string = '\n'.join(names) result = extract(RUNTIME_PATTERN, string, condense=True) return result
python
def extractRuntime(runtime_dirs): """ Used to find the correct static lib name to pass to gcc """ names = [str(item) for name in runtime_dirs for item in os.listdir(name)] string = '\n'.join(names) result = extract(RUNTIME_PATTERN, string, condense=True) return result
[ "def", "extractRuntime", "(", "runtime_dirs", ")", ":", "names", "=", "[", "str", "(", "item", ")", "for", "name", "in", "runtime_dirs", "for", "item", "in", "os", ".", "listdir", "(", "name", ")", "]", "string", "=", "'\\n'", ".", "join", "(", "name...
Used to find the correct static lib name to pass to gcc
[ "Used", "to", "find", "the", "correct", "static", "lib", "name", "to", "pass", "to", "gcc" ]
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/extractor.py#L52-L59
train
Used to find the correct static lib name to pass to gcc
nickpandolfi/Cyther
cyther/extractor.py
extractAtCyther
def extractAtCyther(string): """ Extracts the '@cyther' code to be run as a script after compilation """ if isinstance(string, str) and os.path.isfile(string): with open(string) as file: string = file.read() found_pound = extract(POUND_PATTERN, string) found_tripple = extrac...
python
def extractAtCyther(string): """ Extracts the '@cyther' code to be run as a script after compilation """ if isinstance(string, str) and os.path.isfile(string): with open(string) as file: string = file.read() found_pound = extract(POUND_PATTERN, string) found_tripple = extrac...
[ "def", "extractAtCyther", "(", "string", ")", ":", "if", "isinstance", "(", "string", ",", "str", ")", "and", "os", ".", "path", ".", "isfile", "(", "string", ")", ":", "with", "open", "(", "string", ")", "as", "file", ":", "string", "=", "file", "...
Extracts the '@cyther' code to be run as a script after compilation
[ "Extracts", "the" ]
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/extractor.py#L67-L80
train
Extracts the code to be run as a script after compilation
nickpandolfi/Cyther
cyther/extractor.py
extractVersion
def extractVersion(string, default='?'): """ Extracts a three digit standard format version number """ return extract(VERSION_PATTERN, string, condense=True, default=default, one=True)
python
def extractVersion(string, default='?'): """ Extracts a three digit standard format version number """ return extract(VERSION_PATTERN, string, condense=True, default=default, one=True)
[ "def", "extractVersion", "(", "string", ",", "default", "=", "'?'", ")", ":", "return", "extract", "(", "VERSION_PATTERN", ",", "string", ",", "condense", "=", "True", ",", "default", "=", "default", ",", "one", "=", "True", ")" ]
Extracts a three digit standard format version number
[ "Extracts", "a", "three", "digit", "standard", "format", "version", "number" ]
9fb0bd77af594008aa6ee8af460aa8c953abf5bc
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/extractor.py#L87-L92
train
Extracts a three digit standard format version number from a string.
EVEprosper/ProsperCommon
prosper/common/prosper_config.py
render_secrets
def render_secrets( config_path, secret_path, ): """combine a jinja template with a secret .ini file Args: config_path (str): path to .cfg file with jinja templating secret_path (str): path to .ini-like secrets file Returns: ProsperConfig: rendered configuration obj...
python
def render_secrets( config_path, secret_path, ): """combine a jinja template with a secret .ini file Args: config_path (str): path to .cfg file with jinja templating secret_path (str): path to .ini-like secrets file Returns: ProsperConfig: rendered configuration obj...
[ "def", "render_secrets", "(", "config_path", ",", "secret_path", ",", ")", ":", "with", "open", "(", "secret_path", ",", "'r'", ")", "as", "s_fh", ":", "secret_ini", "=", "anyconfig", ".", "load", "(", "s_fh", ",", "ac_parser", "=", "'ini'", ")", "with",...
combine a jinja template with a secret .ini file Args: config_path (str): path to .cfg file with jinja templating secret_path (str): path to .ini-like secrets file Returns: ProsperConfig: rendered configuration object
[ "combine", "a", "jinja", "template", "with", "a", "secret", ".", "ini", "file" ]
bcada3b25420099e1f204db8d55eb268e7b4dc27
https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L17-L46
train
Combine a jinja template with a secret. ini file
EVEprosper/ProsperCommon
prosper/common/prosper_config.py
check_value
def check_value( config, section, option, jinja_pattern=JINJA_PATTERN, ): """try to figure out if value is valid or jinja2 template value Args: config (:obj:`configparser.ConfigParser`): config object to read key from section (str): name of section in configparse...
python
def check_value( config, section, option, jinja_pattern=JINJA_PATTERN, ): """try to figure out if value is valid or jinja2 template value Args: config (:obj:`configparser.ConfigParser`): config object to read key from section (str): name of section in configparse...
[ "def", "check_value", "(", "config", ",", "section", ",", "option", ",", "jinja_pattern", "=", "JINJA_PATTERN", ",", ")", ":", "value", "=", "config", "[", "section", "]", "[", "option", "]", "if", "re", ".", "match", "(", "jinja_pattern", ",", "value", ...
try to figure out if value is valid or jinja2 template value Args: config (:obj:`configparser.ConfigParser`): config object to read key from section (str): name of section in configparser option (str): name of option in configparser jinja_pattern (:obj:`_sre.SRE_Pattern`): a `re.com...
[ "try", "to", "figure", "out", "if", "value", "is", "valid", "or", "jinja2", "template", "value" ]
bcada3b25420099e1f204db8d55eb268e7b4dc27
https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L48-L75
train
check if value is valid or jinja2 template value
EVEprosper/ProsperCommon
prosper/common/prosper_config.py
get_value_from_environment
def get_value_from_environment( section_name, key_name, envname_pad=ENVNAME_PAD, logger=logging.getLogger('ProsperCommon'), ): """check environment for key/value pair Args: section_name (str): section name key_name (str): key to look up envname_pad (str):...
python
def get_value_from_environment( section_name, key_name, envname_pad=ENVNAME_PAD, logger=logging.getLogger('ProsperCommon'), ): """check environment for key/value pair Args: section_name (str): section name key_name (str): key to look up envname_pad (str):...
[ "def", "get_value_from_environment", "(", "section_name", ",", "key_name", ",", "envname_pad", "=", "ENVNAME_PAD", ",", "logger", "=", "logging", ".", "getLogger", "(", "'ProsperCommon'", ")", ",", ")", ":", "var_name", "=", "'{pad}_{section}__{key}'", ".", "forma...
check environment for key/value pair Args: section_name (str): section name key_name (str): key to look up envname_pad (str): namespace padding logger (:obj:`logging.logger`): logging handle Returns: str: value in environment
[ "check", "environment", "for", "key", "/", "value", "pair" ]
bcada3b25420099e1f204db8d55eb268e7b4dc27
https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L211-L239
train
Get the value of a key in the environment
EVEprosper/ProsperCommon
prosper/common/prosper_config.py
get_configs
def get_configs( config_filepath, local_filepath_override='', ): """go and fetch the global/local configs from file and load them with configparser Args: config_filepath (str): path to config local_filepath_override (str): secondary place to locate config file Returns: ...
python
def get_configs( config_filepath, local_filepath_override='', ): """go and fetch the global/local configs from file and load them with configparser Args: config_filepath (str): path to config local_filepath_override (str): secondary place to locate config file Returns: ...
[ "def", "get_configs", "(", "config_filepath", ",", "local_filepath_override", "=", "''", ",", ")", ":", "global_config", "=", "read_config", "(", "config_filepath", ")", "local_filepath", "=", "get_local_config_filepath", "(", "config_filepath", ",", "True", ")", "i...
go and fetch the global/local configs from file and load them with configparser Args: config_filepath (str): path to config local_filepath_override (str): secondary place to locate config file Returns: ConfigParser: global_config ConfigParser: local_config
[ "go", "and", "fetch", "the", "global", "/", "local", "configs", "from", "file", "and", "load", "them", "with", "configparser" ]
bcada3b25420099e1f204db8d55eb268e7b4dc27
https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L241-L263
train
go and fetch the global and local configs from file and load them with configparser
EVEprosper/ProsperCommon
prosper/common/prosper_config.py
read_config
def read_config( config_filepath, logger=logging.getLogger('ProsperCommon'), ): """fetch and parse config file Args: config_filepath (str): path to config file. abspath > relpath logger (:obj:`logging.Logger`): logger to catch error msgs """ config_parser = configparse...
python
def read_config( config_filepath, logger=logging.getLogger('ProsperCommon'), ): """fetch and parse config file Args: config_filepath (str): path to config file. abspath > relpath logger (:obj:`logging.Logger`): logger to catch error msgs """ config_parser = configparse...
[ "def", "read_config", "(", "config_filepath", ",", "logger", "=", "logging", ".", "getLogger", "(", "'ProsperCommon'", ")", ",", ")", ":", "config_parser", "=", "configparser", ".", "ConfigParser", "(", "interpolation", "=", "ExtendedInterpolation", "(", ")", ",...
fetch and parse config file Args: config_filepath (str): path to config file. abspath > relpath logger (:obj:`logging.Logger`): logger to catch error msgs
[ "fetch", "and", "parse", "config", "file" ]
bcada3b25420099e1f204db8d55eb268e7b4dc27
https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L265-L287
train
fetch and parse config file
EVEprosper/ProsperCommon
prosper/common/prosper_config.py
get_local_config_filepath
def get_local_config_filepath( config_filepath, force_local=False, ): """helper for finding local filepath for config Args: config_filepath (str): path to local config abspath > relpath force_local (bool): force return of _local.cfg version Returns: str: Path to loc...
python
def get_local_config_filepath( config_filepath, force_local=False, ): """helper for finding local filepath for config Args: config_filepath (str): path to local config abspath > relpath force_local (bool): force return of _local.cfg version Returns: str: Path to loc...
[ "def", "get_local_config_filepath", "(", "config_filepath", ",", "force_local", "=", "False", ",", ")", ":", "local_config_name", "=", "path", ".", "basename", "(", "config_filepath", ")", ".", "split", "(", "'.'", ")", "[", "0", "]", "+", "'_local.cfg'", "l...
helper for finding local filepath for config Args: config_filepath (str): path to local config abspath > relpath force_local (bool): force return of _local.cfg version Returns: str: Path to local config, or global if path DNE
[ "helper", "for", "finding", "local", "filepath", "for", "config" ]
bcada3b25420099e1f204db8d55eb268e7b4dc27
https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L289-L314
train
helper function for finding local filepath for config
EVEprosper/ProsperCommon
prosper/common/prosper_config.py
ProsperConfig.get
def get( self, section_name, key_name, ): """Replicate configparser.get() functionality Args: section_name (str): section name in config key_name (str): key name in config.section_name Returns: str: do not check defaul...
python
def get( self, section_name, key_name, ): """Replicate configparser.get() functionality Args: section_name (str): section name in config key_name (str): key name in config.section_name Returns: str: do not check defaul...
[ "def", "get", "(", "self", ",", "section_name", ",", "key_name", ",", ")", ":", "value", "=", "None", "try", ":", "value", "=", "self", ".", "local_config", ".", "get", "(", "section_name", ",", "key_name", ")", "except", "Exception", "as", "error_msg", ...
Replicate configparser.get() functionality Args: section_name (str): section name in config key_name (str): key name in config.section_name Returns: str: do not check defaults, only return local value Raises: KeyError: unable to find option in e...
[ "Replicate", "configparser", ".", "get", "()", "functionality" ]
bcada3b25420099e1f204db8d55eb268e7b4dc27
https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L115-L148
train
Replicate configparser. get function
EVEprosper/ProsperCommon
prosper/common/prosper_config.py
ProsperConfig.get_option
def get_option( self, section_name, key_name, args_option=None, args_default=None, ): """evaluates the requested option and returns the correct value Notes: Priority order 1. args given at runtile 2. <co...
python
def get_option( self, section_name, key_name, args_option=None, args_default=None, ): """evaluates the requested option and returns the correct value Notes: Priority order 1. args given at runtile 2. <co...
[ "def", "get_option", "(", "self", ",", "section_name", ",", "key_name", ",", "args_option", "=", "None", ",", "args_default", "=", "None", ",", ")", ":", "if", "args_option", "!=", "args_default", "and", "args_option", "is", "not", "None", ":", "self", "."...
evaluates the requested option and returns the correct value Notes: Priority order 1. args given at runtile 2. <config_file>_local.cfg -- untracked config with #SECRETS 3. <config_file>.cfg -- tracked 'master' config without #SECRETS 4. environment va...
[ "evaluates", "the", "requested", "option", "and", "returns", "the", "correct", "value" ]
bcada3b25420099e1f204db8d55eb268e7b4dc27
https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/prosper/common/prosper_config.py#L150-L207
train
evaluates the requested option and returns the correct value
CenturyLinkCloud/clc-python-sdk
src/clc/APIv2/__init__.py
SetCredentials
def SetCredentials(api_username,api_passwd): """Establish API username and password associated with APIv2 commands.""" global V2_API_USERNAME global V2_API_PASSWD global _V2_ENABLED _V2_ENABLED = True V2_API_USERNAME = api_username V2_API_PASSWD = api_passwd
python
def SetCredentials(api_username,api_passwd): """Establish API username and password associated with APIv2 commands.""" global V2_API_USERNAME global V2_API_PASSWD global _V2_ENABLED _V2_ENABLED = True V2_API_USERNAME = api_username V2_API_PASSWD = api_passwd
[ "def", "SetCredentials", "(", "api_username", ",", "api_passwd", ")", ":", "global", "V2_API_USERNAME", "global", "V2_API_PASSWD", "global", "_V2_ENABLED", "_V2_ENABLED", "=", "True", "V2_API_USERNAME", "=", "api_username", "V2_API_PASSWD", "=", "api_passwd" ]
Establish API username and password associated with APIv2 commands.
[ "Establish", "API", "username", "and", "password", "associated", "with", "APIv2", "commands", "." ]
f4dba40c627cb08dd4b7d0d277e8d67578010b05
https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/__init__.py#L46-L53
train
Establish API username and password associated with APIv2 commands.
CenturyLinkCloud/clc-python-sdk
src/clc/APIv2/__init__.py
get_session
def get_session(username, password, default_endpoints=clc.defaults, cert=None): """Start a session with the given parameters Use instead of SetCredentials if you need a session object to avoid the use of global credentials. Returns a session object accepted by many v2 objects. """ if cert is None: cert = API._...
python
def get_session(username, password, default_endpoints=clc.defaults, cert=None): """Start a session with the given parameters Use instead of SetCredentials if you need a session object to avoid the use of global credentials. Returns a session object accepted by many v2 objects. """ if cert is None: cert = API._...
[ "def", "get_session", "(", "username", ",", "password", ",", "default_endpoints", "=", "clc", ".", "defaults", ",", "cert", "=", "None", ")", ":", "if", "cert", "is", "None", ":", "cert", "=", "API", ".", "_ResourcePath", "(", "'clc/cacert.pem'", ")", "s...
Start a session with the given parameters Use instead of SetCredentials if you need a session object to avoid the use of global credentials. Returns a session object accepted by many v2 objects.
[ "Start", "a", "session", "with", "the", "given", "parameters" ]
f4dba40c627cb08dd4b7d0d277e8d67578010b05
https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/__init__.py#L56-L91
train
Start a session with the given parameters Use instead of SetCredentials.
DIPSAS/SwarmManagement
SwarmManagement/__init__.py
main
def main(): """Entry point for the application script""" arguments = sys.argv[1:] print('Managing solution with arguments: ') print(arguments) SwarmManager.HandleManagement(arguments)
python
def main(): """Entry point for the application script""" arguments = sys.argv[1:] print('Managing solution with arguments: ') print(arguments) SwarmManager.HandleManagement(arguments)
[ "def", "main", "(", ")", ":", "arguments", "=", "sys", ".", "argv", "[", "1", ":", "]", "print", "(", "'Managing solution with arguments: '", ")", "print", "(", "arguments", ")", "SwarmManager", ".", "HandleManagement", "(", "arguments", ")" ]
Entry point for the application script
[ "Entry", "point", "for", "the", "application", "script" ]
c9ef1165b240c145d42e2d363925c8200fc19f43
https://github.com/DIPSAS/SwarmManagement/blob/c9ef1165b240c145d42e2d363925c8200fc19f43/SwarmManagement/__init__.py#L4-L9
train
Entry point for the application script
humangeo/preflyt
preflyt/utils.py
pformat_check
def pformat_check(success, checker, message): """Pretty print a check result :param success: `True` if the check was successful, `False` otherwise. :param checker: The checker dict that was executed :param message: The label for the check :returns: A string representation of the check """ ...
python
def pformat_check(success, checker, message): """Pretty print a check result :param success: `True` if the check was successful, `False` otherwise. :param checker: The checker dict that was executed :param message: The label for the check :returns: A string representation of the check """ ...
[ "def", "pformat_check", "(", "success", ",", "checker", ",", "message", ")", ":", "# TODO: Make this prettier.", "return", "\"[{}] {}: {}\"", ".", "format", "(", "\"✓\" i", " s", "ccess e", "se \"", "\", ch", "e", "ker[\"ch", "e", "cker\"], m", "e", "s", "age)",...
Pretty print a check result :param success: `True` if the check was successful, `False` otherwise. :param checker: The checker dict that was executed :param message: The label for the check :returns: A string representation of the check
[ "Pretty", "print", "a", "check", "result" ]
3174e6b8fc851ba5bd6c7fcf9becf36a6f6f6d93
https://github.com/humangeo/preflyt/blob/3174e6b8fc851ba5bd6c7fcf9becf36a6f6f6d93/preflyt/utils.py#L3-L13
train
Pretty print a check result in a NCBI - style format.
mjirik/imtools
imtools/tools.py
get_superpxl_intensities
def get_superpxl_intensities(im, suppxls): """Calculates mean intensities of pixels in superpixels inputs: im ... grayscale image, ndarray [MxN] suppxls ... image with suppxls labels, ndarray -same shape as im outputs: suppxl_intens ... vector with suppxls mean intensities """ ...
python
def get_superpxl_intensities(im, suppxls): """Calculates mean intensities of pixels in superpixels inputs: im ... grayscale image, ndarray [MxN] suppxls ... image with suppxls labels, ndarray -same shape as im outputs: suppxl_intens ... vector with suppxls mean intensities """ ...
[ "def", "get_superpxl_intensities", "(", "im", ",", "suppxls", ")", ":", "n_suppxl", "=", "np", ".", "int", "(", "suppxls", ".", "max", "(", ")", "+", "1", ")", "suppxl_intens", "=", "np", ".", "zeros", "(", "n_suppxl", ")", "for", "i", "in", "range",...
Calculates mean intensities of pixels in superpixels inputs: im ... grayscale image, ndarray [MxN] suppxls ... image with suppxls labels, ndarray -same shape as im outputs: suppxl_intens ... vector with suppxls mean intensities
[ "Calculates", "mean", "intensities", "of", "pixels", "in", "superpixels", "inputs", ":", "im", "...", "grayscale", "image", "ndarray", "[", "MxN", "]", "suppxls", "...", "image", "with", "suppxls", "labels", "ndarray", "-", "same", "shape", "as", "im", "outp...
eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/tools.py#L778-L797
train
Calculates mean intensities of pixels in superpixels in the specified image.
mjirik/imtools
imtools/tools.py
suppxl_ints2im
def suppxl_ints2im(suppxls, suppxl_ints=None, im=None): """Replaces superpixel labels with their mean value. inputs: suppxls ... image with suppxls labels, ndarray suppxl_intens ... vector with suppxls mean intensities im ... input image outputs: suppxl_ints_im ... image with...
python
def suppxl_ints2im(suppxls, suppxl_ints=None, im=None): """Replaces superpixel labels with their mean value. inputs: suppxls ... image with suppxls labels, ndarray suppxl_intens ... vector with suppxls mean intensities im ... input image outputs: suppxl_ints_im ... image with...
[ "def", "suppxl_ints2im", "(", "suppxls", ",", "suppxl_ints", "=", "None", ",", "im", "=", "None", ")", ":", "suppxl_ints_im", "=", "np", ".", "zeros", "(", "suppxls", ".", "shape", ")", "if", "suppxl_ints", "is", "None", "and", "im", "is", "not", "None...
Replaces superpixel labels with their mean value. inputs: suppxls ... image with suppxls labels, ndarray suppxl_intens ... vector with suppxls mean intensities im ... input image outputs: suppxl_ints_im ... image with suppxls mean intensities, ndarray same shape as suppxls
[ "Replaces", "superpixel", "labels", "with", "their", "mean", "value", ".", "inputs", ":", "suppxls", "...", "image", "with", "suppxls", "labels", "ndarray", "suppxl_intens", "...", "vector", "with", "suppxls", "mean", "intensities", "im", "...", "input", "image"...
eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/tools.py#L800-L820
train
Replaces superpixel labels with their mean value.
mjirik/imtools
imtools/tools.py
remove_empty_suppxls
def remove_empty_suppxls(suppxls): """Remove empty superpixels. Sometimes there are superpixels(labels), which are empty. To overcome subsequent problems, these empty superpixels should be removed. inputs: suppxls ... image with suppxls labels, ndarray [MxN]-same size as im outputs: new_...
python
def remove_empty_suppxls(suppxls): """Remove empty superpixels. Sometimes there are superpixels(labels), which are empty. To overcome subsequent problems, these empty superpixels should be removed. inputs: suppxls ... image with suppxls labels, ndarray [MxN]-same size as im outputs: new_...
[ "def", "remove_empty_suppxls", "(", "suppxls", ")", ":", "n_suppxls", "=", "np", ".", "int", "(", "suppxls", ".", "max", "(", ")", "+", "1", ")", "new_supps", "=", "np", ".", "zeros", "(", "suppxls", ".", "shape", ",", "dtype", "=", "np", ".", "int...
Remove empty superpixels. Sometimes there are superpixels(labels), which are empty. To overcome subsequent problems, these empty superpixels should be removed. inputs: suppxls ... image with suppxls labels, ndarray [MxN]-same size as im outputs: new_supps ... image with suppxls labels, ndarr...
[ "Remove", "empty", "superpixels", ".", "Sometimes", "there", "are", "superpixels", "(", "labels", ")", "which", "are", "empty", ".", "To", "overcome", "subsequent", "problems", "these", "empty", "superpixels", "should", "be", "removed", ".", "inputs", ":", "su...
eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/tools.py#L823-L839
train
Remove empty superpixels from the image with suppxls labels.
mjirik/imtools
imtools/tools.py
get_bbox
def get_bbox(im): ''' Returns bounding box in slicing-friendly format (i-min, i-xmax, j-min, j-max, k-min, k-max). The fourth and fifth items are returned only if input image is 3D. Parameters ---------- im - input binary image Returns ------- indices - (i-min, i-xmax, j-min, j-max,...
python
def get_bbox(im): ''' Returns bounding box in slicing-friendly format (i-min, i-xmax, j-min, j-max, k-min, k-max). The fourth and fifth items are returned only if input image is 3D. Parameters ---------- im - input binary image Returns ------- indices - (i-min, i-xmax, j-min, j-max,...
[ "def", "get_bbox", "(", "im", ")", ":", "coords", "=", "np", ".", "nonzero", "(", "im", ")", "inds", "=", "[", "]", "for", "i", "in", "coords", ":", "i_min", "=", "i", ".", "min", "(", ")", "i_max", "=", "i", ".", "max", "(", ")", "inds", "...
Returns bounding box in slicing-friendly format (i-min, i-xmax, j-min, j-max, k-min, k-max). The fourth and fifth items are returned only if input image is 3D. Parameters ---------- im - input binary image Returns ------- indices - (i-min, i-xmax, j-min, j-max, k-min, k-max) in 3D case, (i-...
[ "Returns", "bounding", "box", "in", "slicing", "-", "friendly", "format", "(", "i", "-", "min", "i", "-", "xmax", "j", "-", "min", "j", "-", "max", "k", "-", "min", "k", "-", "max", ")", ".", "The", "fourth", "and", "fifth", "items", "are", "retu...
eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/tools.py#L1000-L1019
train
Returns bounding box of the image in slicing - friendly format.
mjirik/imtools
imtools/tools.py
pyramid
def pyramid(image, scale=2, min_size=(30, 30), inter=None): """ Creates generator of image pyramid. :param image: input image :param scale: factor that controls by how much the image is resized at each layer :param min_size: minimum required width and height of the layer :return: generator of th...
python
def pyramid(image, scale=2, min_size=(30, 30), inter=None): """ Creates generator of image pyramid. :param image: input image :param scale: factor that controls by how much the image is resized at each layer :param min_size: minimum required width and height of the layer :return: generator of th...
[ "def", "pyramid", "(", "image", ",", "scale", "=", "2", ",", "min_size", "=", "(", "30", ",", "30", ")", ",", "inter", "=", "None", ")", ":", "yield", "image", "import", "cv2", "if", "inter", "is", "None", ":", "inter", "=", "cv2", ".", "INTER_AR...
Creates generator of image pyramid. :param image: input image :param scale: factor that controls by how much the image is resized at each layer :param min_size: minimum required width and height of the layer :return: generator of the image pyramid
[ "Creates", "generator", "of", "image", "pyramid", ".", ":", "param", "image", ":", "input", "image", ":", "param", "scale", ":", "factor", "that", "controls", "by", "how", "much", "the", "image", "is", "resized", "at", "each", "layer", ":", "param", "min...
eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/tools.py#L1249-L1275
train
Generates a generator of image pyramid.
mjirik/imtools
imtools/tools.py
sliding_window
def sliding_window(image, step_size, window_size, mask=None, only_whole=True): """ Creates generator of sliding windows. :param image: input image :param step_size: number of pixels we are going to skip in both the (x, y) direction :param window_size: the width and height of the window we are going ...
python
def sliding_window(image, step_size, window_size, mask=None, only_whole=True): """ Creates generator of sliding windows. :param image: input image :param step_size: number of pixels we are going to skip in both the (x, y) direction :param window_size: the width and height of the window we are going ...
[ "def", "sliding_window", "(", "image", ",", "step_size", ",", "window_size", ",", "mask", "=", "None", ",", "only_whole", "=", "True", ")", ":", "if", "mask", "is", "None", ":", "mask", "=", "np", ".", "ones", "(", "image", ".", "shape", ",", "dtype"...
Creates generator of sliding windows. :param image: input image :param step_size: number of pixels we are going to skip in both the (x, y) direction :param window_size: the width and height of the window we are going to extract :param mask: region of interest, if None it will slide through the whole ima...
[ "Creates", "generator", "of", "sliding", "windows", ".", ":", "param", "image", ":", "input", "image", ":", "param", "step_size", ":", "number", "of", "pixels", "we", "are", "going", "to", "skip", "in", "both", "the", "(", "x", "y", ")", "direction", "...
eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/tools.py#L1296-L1322
train
Generates a generator that produces a sliding window of the given size.
mjirik/imtools
imtools/tools.py
sliding_window_3d
def sliding_window_3d(image, step_size, window_size, mask=None, only_whole=True, include_last=False): """ Creates generator of sliding windows. :param image: input image :param step_size: number of pixels we are going to skip in both the (x, y) direction :param window_size: the width and height of t...
python
def sliding_window_3d(image, step_size, window_size, mask=None, only_whole=True, include_last=False): """ Creates generator of sliding windows. :param image: input image :param step_size: number of pixels we are going to skip in both the (x, y) direction :param window_size: the width and height of t...
[ "def", "sliding_window_3d", "(", "image", ",", "step_size", ",", "window_size", ",", "mask", "=", "None", ",", "only_whole", "=", "True", ",", "include_last", "=", "False", ")", ":", "if", "not", "isinstance", "(", "step_size", ",", "tuple", ")", ":", "s...
Creates generator of sliding windows. :param image: input image :param step_size: number of pixels we are going to skip in both the (x, y) direction :param window_size: the width and height of the window we are going to extract :param mask: region of interest, if None it will slide through the whole ima...
[ "Creates", "generator", "of", "sliding", "windows", ".", ":", "param", "image", ":", "input", "image", ":", "param", "step_size", ":", "number", "of", "pixels", "we", "are", "going", "to", "skip", "in", "both", "the", "(", "x", "y", ")", "direction", "...
eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/tools.py#L1325-L1373
train
Generates a generator that produces a sliding window of the given size.
mjirik/imtools
imtools/tools.py
split_to_tiles
def split_to_tiles(img, columns, rows): """ Split an image into a specified number of tiles. Args: img (ndarray): The image to split. number_tiles (int): The number of tiles required. Returns: Tuple of tiles """ # validate_image(img, number_tiles) im_w, im_h = img.sh...
python
def split_to_tiles(img, columns, rows): """ Split an image into a specified number of tiles. Args: img (ndarray): The image to split. number_tiles (int): The number of tiles required. Returns: Tuple of tiles """ # validate_image(img, number_tiles) im_w, im_h = img.sh...
[ "def", "split_to_tiles", "(", "img", ",", "columns", ",", "rows", ")", ":", "# validate_image(img, number_tiles)", "im_w", ",", "im_h", "=", "img", ".", "shape", "# columns, rows = calc_columns_rows(number_tiles)", "# extras = (columns * rows) - number_tiles", "tile_w", ","...
Split an image into a specified number of tiles. Args: img (ndarray): The image to split. number_tiles (int): The number of tiles required. Returns: Tuple of tiles
[ "Split", "an", "image", "into", "a", "specified", "number", "of", "tiles", ".", "Args", ":", "img", "(", "ndarray", ")", ":", "The", "image", "to", "split", ".", "number_tiles", "(", "int", ")", ":", "The", "number", "of", "tiles", "required", ".", "...
eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/tools.py#L1421-L1451
train
Splits an image into a specified number of tiles.
cltl/KafNafParserPy
KafNafParserPy/features_data.py
Cproperty.set_id
def set_id(self,pid): """ Set the property identifier @type pid: string @param pid: property identifier """ if self.type == 'KAF': return self.node.set('pid',pid) elif self.type == 'NAF': return self.node.set('id',pid)
python
def set_id(self,pid): """ Set the property identifier @type pid: string @param pid: property identifier """ if self.type == 'KAF': return self.node.set('pid',pid) elif self.type == 'NAF': return self.node.set('id',pid)
[ "def", "set_id", "(", "self", ",", "pid", ")", ":", "if", "self", ".", "type", "==", "'KAF'", ":", "return", "self", ".", "node", ".", "set", "(", "'pid'", ",", "pid", ")", "elif", "self", ".", "type", "==", "'NAF'", ":", "return", "self", ".", ...
Set the property identifier @type pid: string @param pid: property identifier
[ "Set", "the", "property", "identifier" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L47-L56
train
Set the property identifier associated with the object.
cltl/KafNafParserPy
KafNafParserPy/features_data.py
Cproperties.add_property
def add_property(self,pid, label,term_span): """ Adds a new property to the property layer @type pid: string @param pid: property identifier @type label: string @param label: the label of the property @type term_span: list @param term_span: list of term id...
python
def add_property(self,pid, label,term_span): """ Adds a new property to the property layer @type pid: string @param pid: property identifier @type label: string @param label: the label of the property @type term_span: list @param term_span: list of term id...
[ "def", "add_property", "(", "self", ",", "pid", ",", "label", ",", "term_span", ")", ":", "new_property", "=", "Cproperty", "(", "type", "=", "self", ".", "type", ")", "self", ".", "node", ".", "append", "(", "new_property", ".", "get_node", "(", ")", ...
Adds a new property to the property layer @type pid: string @param pid: property identifier @type label: string @param label: the label of the property @type term_span: list @param term_span: list of term identifiers
[ "Adds", "a", "new", "property", "to", "the", "property", "layer" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L128-L157
train
Adds a new property to the property layer.
cltl/KafNafParserPy
KafNafParserPy/features_data.py
Cfeatures.to_kaf
def to_kaf(self): """ Converts the element to NAF """ if self.type == 'NAF': ##convert all the properties for node in self.node.findall('properties/property'): node.set('pid',node.get('id')) del node.attrib['id']
python
def to_kaf(self): """ Converts the element to NAF """ if self.type == 'NAF': ##convert all the properties for node in self.node.findall('properties/property'): node.set('pid',node.get('id')) del node.attrib['id']
[ "def", "to_kaf", "(", "self", ")", ":", "if", "self", ".", "type", "==", "'NAF'", ":", "##convert all the properties", "for", "node", "in", "self", ".", "node", ".", "findall", "(", "'properties/property'", ")", ":", "node", ".", "set", "(", "'pid'", ","...
Converts the element to NAF
[ "Converts", "the", "element", "to", "NAF" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L187-L195
train
Converts the element to NAF
cltl/KafNafParserPy
KafNafParserPy/features_data.py
Cfeatures.to_naf
def to_naf(self): """ Converts the element to KAF """ if self.type == 'KAF': ##convert all the properties for node in self.node.findall('properties/property'): node.set('id',node.get('pid')) del node.attrib['pid']
python
def to_naf(self): """ Converts the element to KAF """ if self.type == 'KAF': ##convert all the properties for node in self.node.findall('properties/property'): node.set('id',node.get('pid')) del node.attrib['pid']
[ "def", "to_naf", "(", "self", ")", ":", "if", "self", ".", "type", "==", "'KAF'", ":", "##convert all the properties", "for", "node", "in", "self", ".", "node", ".", "findall", "(", "'properties/property'", ")", ":", "node", ".", "set", "(", "'id'", ",",...
Converts the element to KAF
[ "Converts", "the", "element", "to", "KAF" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L197-L205
train
Converts the element to NAF
cltl/KafNafParserPy
KafNafParserPy/features_data.py
Cfeatures.add_property
def add_property(self,pid, label,term_span): """ Adds a new property to the property layer @type pid: string @param pid: property identifier @type label: string @param label: the label of the property @type term_span: list @param term_span: list of term id...
python
def add_property(self,pid, label,term_span): """ Adds a new property to the property layer @type pid: string @param pid: property identifier @type label: string @param label: the label of the property @type term_span: list @param term_span: list of term id...
[ "def", "add_property", "(", "self", ",", "pid", ",", "label", ",", "term_span", ")", ":", "node_prop", "=", "self", ".", "node", ".", "find", "(", "'properties'", ")", "if", "node_prop", "is", "None", ":", "properties", "=", "Cproperties", "(", "type", ...
Adds a new property to the property layer @type pid: string @param pid: property identifier @type label: string @param label: the label of the property @type term_span: list @param term_span: list of term identifiers
[ "Adds", "a", "new", "property", "to", "the", "property", "layer" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L207-L224
train
Adds a new property to the property layer
cltl/KafNafParserPy
KafNafParserPy/features_data.py
Cfeatures.get_properties
def get_properties(self): """ Iterator that returns all the properties of the layuer @rtype: L{Cproperty} @return: list of property objects (iterator) """ node_prop = self.node.find('properties') if node_prop is not None: obj_properties = Cproperties(n...
python
def get_properties(self): """ Iterator that returns all the properties of the layuer @rtype: L{Cproperty} @return: list of property objects (iterator) """ node_prop = self.node.find('properties') if node_prop is not None: obj_properties = Cproperties(n...
[ "def", "get_properties", "(", "self", ")", ":", "node_prop", "=", "self", ".", "node", ".", "find", "(", "'properties'", ")", "if", "node_prop", "is", "not", "None", ":", "obj_properties", "=", "Cproperties", "(", "node_prop", ",", "self", ".", "type", "...
Iterator that returns all the properties of the layuer @rtype: L{Cproperty} @return: list of property objects (iterator)
[ "Iterator", "that", "returns", "all", "the", "properties", "of", "the", "layuer" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L227-L237
train
Iterator that returns all the properties of the layuer
cltl/KafNafParserPy
KafNafParserPy/features_data.py
Cfeatures.remove_properties
def remove_properties(self): """ Removes the property layer, if exists """ node_prop = self.node.find('properties') if node_prop is not None: self.node.remove(node_prop)
python
def remove_properties(self): """ Removes the property layer, if exists """ node_prop = self.node.find('properties') if node_prop is not None: self.node.remove(node_prop)
[ "def", "remove_properties", "(", "self", ")", ":", "node_prop", "=", "self", ".", "node", ".", "find", "(", "'properties'", ")", "if", "node_prop", "is", "not", "None", ":", "self", ".", "node", ".", "remove", "(", "node_prop", ")" ]
Removes the property layer, if exists
[ "Removes", "the", "property", "layer", "if", "exists" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/features_data.py#L240-L246
train
Removes the property layer if exists.
blag/django-secure-mail
secure_mail/forms.py
KeyForm.clean_key
def clean_key(self): """ Validate the key contains an email address. """ key = self.cleaned_data["key"] gpg = get_gpg() result = gpg.import_keys(key) if result.count == 0: raise forms.ValidationError(_("Invalid Key")) return key
python
def clean_key(self): """ Validate the key contains an email address. """ key = self.cleaned_data["key"] gpg = get_gpg() result = gpg.import_keys(key) if result.count == 0: raise forms.ValidationError(_("Invalid Key")) return key
[ "def", "clean_key", "(", "self", ")", ":", "key", "=", "self", ".", "cleaned_data", "[", "\"key\"", "]", "gpg", "=", "get_gpg", "(", ")", "result", "=", "gpg", ".", "import_keys", "(", "key", ")", "if", "result", ".", "count", "==", "0", ":", "rais...
Validate the key contains an email address.
[ "Validate", "the", "key", "contains", "an", "email", "address", "." ]
52987b6ce829e6de2dc8ab38ed3190bc2752b341
https://github.com/blag/django-secure-mail/blob/52987b6ce829e6de2dc8ab38ed3190bc2752b341/secure_mail/forms.py#L14-L23
train
Validate the key contains an email address.
cltl/KafNafParserPy
KafNafParserPy/markable_data.py
Cmarkable.get_id
def get_id(self): """ Returns the term identifier @rtype: string @return: the term identifier """ if self.type == 'NAF': return self.node.get('id') elif self.type == 'KAF': return self.node.get('mid')
python
def get_id(self): """ Returns the term identifier @rtype: string @return: the term identifier """ if self.type == 'NAF': return self.node.get('id') elif self.type == 'KAF': return self.node.get('mid')
[ "def", "get_id", "(", "self", ")", ":", "if", "self", ".", "type", "==", "'NAF'", ":", "return", "self", ".", "node", ".", "get", "(", "'id'", ")", "elif", "self", ".", "type", "==", "'KAF'", ":", "return", "self", ".", "node", ".", "get", "(", ...
Returns the term identifier @rtype: string @return: the term identifier
[ "Returns", "the", "term", "identifier" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L39-L48
train
Returns the term identifier of the current term.
cltl/KafNafParserPy
KafNafParserPy/markable_data.py
Cmarkable.set_id
def set_id(self,i): """ Sets the identifier for the term @type i: string @param i: lemma identifier """ if self.type == 'NAF': self.node.set('id',i) elif self.type == 'KAF': self.node.set('mid',i)
python
def set_id(self,i): """ Sets the identifier for the term @type i: string @param i: lemma identifier """ if self.type == 'NAF': self.node.set('id',i) elif self.type == 'KAF': self.node.set('mid',i)
[ "def", "set_id", "(", "self", ",", "i", ")", ":", "if", "self", ".", "type", "==", "'NAF'", ":", "self", ".", "node", ".", "set", "(", "'id'", ",", "i", ")", "elif", "self", ".", "type", "==", "'KAF'", ":", "self", ".", "node", ".", "set", "(...
Sets the identifier for the term @type i: string @param i: lemma identifier
[ "Sets", "the", "identifier", "for", "the", "term" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L50-L59
train
Sets the identifier for the term
cltl/KafNafParserPy
KafNafParserPy/markable_data.py
Cmarkable.add_external_reference
def add_external_reference(self,ext_ref): """ Adds an external reference object to the markable @type ext_ref: L{CexternalReference} @param ext_ref: an external reference object """ ext_refs_node = self.node.find('externalReferences') if ext_refs_node is None: ...
python
def add_external_reference(self,ext_ref): """ Adds an external reference object to the markable @type ext_ref: L{CexternalReference} @param ext_ref: an external reference object """ ext_refs_node = self.node.find('externalReferences') if ext_refs_node is None: ...
[ "def", "add_external_reference", "(", "self", ",", "ext_ref", ")", ":", "ext_refs_node", "=", "self", ".", "node", ".", "find", "(", "'externalReferences'", ")", "if", "ext_refs_node", "is", "None", ":", "ext_refs_obj", "=", "CexternalReferences", "(", ")", "s...
Adds an external reference object to the markable @type ext_ref: L{CexternalReference} @param ext_ref: an external reference object
[ "Adds", "an", "external", "reference", "object", "to", "the", "markable" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L116-L129
train
Adds an external reference object to the markable
cltl/KafNafParserPy
KafNafParserPy/markable_data.py
Cmarkable.get_external_references
def get_external_references(self): """ Iterator that returns all the external references of the markable @rtype: L{CexternalReference} @return: the external references """ for ext_ref_node in self.node.findall('externalReferences'): ext_refs_obj = CexternalRef...
python
def get_external_references(self): """ Iterator that returns all the external references of the markable @rtype: L{CexternalReference} @return: the external references """ for ext_ref_node in self.node.findall('externalReferences'): ext_refs_obj = CexternalRef...
[ "def", "get_external_references", "(", "self", ")", ":", "for", "ext_ref_node", "in", "self", ".", "node", ".", "findall", "(", "'externalReferences'", ")", ":", "ext_refs_obj", "=", "CexternalReferences", "(", "ext_ref_node", ")", "for", "ref", "in", "ext_refs_...
Iterator that returns all the external references of the markable @rtype: L{CexternalReference} @return: the external references
[ "Iterator", "that", "returns", "all", "the", "external", "references", "of", "the", "markable" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L132-L141
train
Iterator that returns all the external references of the markable
cltl/KafNafParserPy
KafNafParserPy/markable_data.py
Cmarkables.get_markable
def get_markable(self,markable_id): """ Returns the markable object for the supplied identifier @type markable_id: string @param markable_id: term identifier """ if markable_id in self.idx: return Cmarkable(self.idx[markable_id],self.type) else: ...
python
def get_markable(self,markable_id): """ Returns the markable object for the supplied identifier @type markable_id: string @param markable_id: term identifier """ if markable_id in self.idx: return Cmarkable(self.idx[markable_id],self.type) else: ...
[ "def", "get_markable", "(", "self", ",", "markable_id", ")", ":", "if", "markable_id", "in", "self", ".", "idx", ":", "return", "Cmarkable", "(", "self", ".", "idx", "[", "markable_id", "]", ",", "self", ".", "type", ")", "else", ":", "return", "None" ...
Returns the markable object for the supplied identifier @type markable_id: string @param markable_id: term identifier
[ "Returns", "the", "markable", "object", "for", "the", "supplied", "identifier" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L209-L218
train
Returns the markable object for the supplied identifier
cltl/KafNafParserPy
KafNafParserPy/markable_data.py
Cmarkables.get_mark
def get_mark(self, mark_id): """ Returns the markable object for the supplied identifier @type mark_id: string @param mark_id: term identifier """ if mark_id in self.idx: return Cmarkable(self.idx[mark_id], self.type) else: return None
python
def get_mark(self, mark_id): """ Returns the markable object for the supplied identifier @type mark_id: string @param mark_id: term identifier """ if mark_id in self.idx: return Cmarkable(self.idx[mark_id], self.type) else: return None
[ "def", "get_mark", "(", "self", ",", "mark_id", ")", ":", "if", "mark_id", "in", "self", ".", "idx", ":", "return", "Cmarkable", "(", "self", ".", "idx", "[", "mark_id", "]", ",", "self", ".", "type", ")", "else", ":", "return", "None" ]
Returns the markable object for the supplied identifier @type mark_id: string @param mark_id: term identifier
[ "Returns", "the", "markable", "object", "for", "the", "supplied", "identifier" ]
9bc32e803c176404b255ba317479b8780ed5f569
https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/markable_data.py#L228-L237
train
Returns the markable object for the supplied identifier