partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
getDomainNames
Retrieve a list of all local domain names represented in the given store.
axiom/userbase.py
def getDomainNames(store): """ Retrieve a list of all local domain names represented in the given store. """ domains = set() domains.update(store.query( LoginMethod, AND(LoginMethod.internal == True, LoginMethod.domain != None)).getColumn("domain").distinct())...
def getDomainNames(store): """ Retrieve a list of all local domain names represented in the given store. """ domains = set() domains.update(store.query( LoginMethod, AND(LoginMethod.internal == True, LoginMethod.domain != None)).getColumn("domain").distinct())...
[ "Retrieve", "a", "list", "of", "all", "local", "domain", "names", "represented", "in", "the", "given", "store", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L627-L636
[ "def", "getDomainNames", "(", "store", ")", ":", "domains", "=", "set", "(", ")", "domains", ".", "update", "(", "store", ".", "query", "(", "LoginMethod", ",", "AND", "(", "LoginMethod", ".", "internal", "==", "True", ",", "LoginMethod", ".", "domain", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
LoginAccount.migrateDown
Assuming that self.avatars is a SubStore which should contain *only* the LoginAccount for the user I represent, remove all LoginAccounts and LoginMethods from that store and copy all methods from the site store down into it.
axiom/userbase.py
def migrateDown(self): """ Assuming that self.avatars is a SubStore which should contain *only* the LoginAccount for the user I represent, remove all LoginAccounts and LoginMethods from that store and copy all methods from the site store down into it. """ ss = sel...
def migrateDown(self): """ Assuming that self.avatars is a SubStore which should contain *only* the LoginAccount for the user I represent, remove all LoginAccounts and LoginMethods from that store and copy all methods from the site store down into it. """ ss = sel...
[ "Assuming", "that", "self", ".", "avatars", "is", "a", "SubStore", "which", "should", "contain", "*", "only", "*", "the", "LoginAccount", "for", "the", "user", "I", "represent", "remove", "all", "LoginAccounts", "and", "LoginMethods", "from", "that", "store", ...
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L189-L204
[ "def", "migrateDown", "(", "self", ")", ":", "ss", "=", "self", ".", "avatars", ".", "open", "(", ")", "def", "_", "(", ")", ":", "oldAccounts", "=", "ss", ".", "query", "(", "LoginAccount", ")", "oldMethods", "=", "ss", ".", "query", "(", "LoginMe...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
LoginAccount.migrateUp
Copy this LoginAccount and all associated LoginMethods from my store (which is assumed to be a SubStore, most likely a user store) into the site store which contains it.
axiom/userbase.py
def migrateUp(self): """ Copy this LoginAccount and all associated LoginMethods from my store (which is assumed to be a SubStore, most likely a user store) into the site store which contains it. """ siteStore = self.store.parent def _(): # No convenien...
def migrateUp(self): """ Copy this LoginAccount and all associated LoginMethods from my store (which is assumed to be a SubStore, most likely a user store) into the site store which contains it. """ siteStore = self.store.parent def _(): # No convenien...
[ "Copy", "this", "LoginAccount", "and", "all", "associated", "LoginMethods", "from", "my", "store", "(", "which", "is", "assumed", "to", "be", "a", "SubStore", "most", "likely", "a", "user", "store", ")", "into", "the", "site", "store", "which", "contains", ...
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L207-L221
[ "def", "migrateUp", "(", "self", ")", ":", "siteStore", "=", "self", ".", "store", ".", "parent", "def", "_", "(", ")", ":", "# No convenience method for the following because needing to do it is", "# *rare*. It *should* be ugly; 99% of the time if you need to do this", "# y...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
LoginAccount.cloneInto
Create a copy of this LoginAccount and all associated LoginMethods in a different Store. Return the copied LoginAccount.
axiom/userbase.py
def cloneInto(self, newStore, avatars): """ Create a copy of this LoginAccount and all associated LoginMethods in a different Store. Return the copied LoginAccount. """ la = LoginAccount(store=newStore, password=self.password, ...
def cloneInto(self, newStore, avatars): """ Create a copy of this LoginAccount and all associated LoginMethods in a different Store. Return the copied LoginAccount. """ la = LoginAccount(store=newStore, password=self.password, ...
[ "Create", "a", "copy", "of", "this", "LoginAccount", "and", "all", "associated", "LoginMethods", "in", "a", "different", "Store", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L224-L243
[ "def", "cloneInto", "(", "self", ",", "newStore", ",", "avatars", ")", ":", "la", "=", "LoginAccount", "(", "store", "=", "newStore", ",", "password", "=", "self", ".", "password", ",", "avatars", "=", "avatars", ",", "disabled", "=", "self", ".", "dis...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
LoginAccount.addLoginMethod
Add a login method to this account, propogating up or down as necessary to site store or user store to maintain consistency.
axiom/userbase.py
def addLoginMethod(self, localpart, domain, protocol=ANY_PROTOCOL, verified=False, internal=False): """ Add a login method to this account, propogating up or down as necessary to site store or user store to maintain consistency. """ # Out takes you west or something if se...
def addLoginMethod(self, localpart, domain, protocol=ANY_PROTOCOL, verified=False, internal=False): """ Add a login method to this account, propogating up or down as necessary to site store or user store to maintain consistency. """ # Out takes you west or something if se...
[ "Add", "a", "login", "method", "to", "this", "account", "propogating", "up", "or", "down", "as", "necessary", "to", "site", "store", "or", "user", "store", "to", "maintain", "consistency", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L250-L275
[ "def", "addLoginMethod", "(", "self", ",", "localpart", ",", "domain", ",", "protocol", "=", "ANY_PROTOCOL", ",", "verified", "=", "False", ",", "internal", "=", "False", ")", ":", "# Out takes you west or something", "if", "self", ".", "store", ".", "parent",...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
LoginAccount.replacePassword
Set this account's password if the current password matches. @param currentPassword: The password to match against the current one. @param newPassword: The new password. @return: A deferred firing when the password has been changed. @raise BadCredentials: If the current password did no...
axiom/userbase.py
def replacePassword(self, currentPassword, newPassword): """ Set this account's password if the current password matches. @param currentPassword: The password to match against the current one. @param newPassword: The new password. @return: A deferred firing when the password ha...
def replacePassword(self, currentPassword, newPassword): """ Set this account's password if the current password matches. @param currentPassword: The password to match against the current one. @param newPassword: The new password. @return: A deferred firing when the password ha...
[ "Set", "this", "account", "s", "password", "if", "the", "current", "password", "matches", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L290-L302
[ "def", "replacePassword", "(", "self", ",", "currentPassword", ",", "newPassword", ")", ":", "if", "unicode", "(", "currentPassword", ")", "!=", "self", ".", "password", ":", "return", "fail", "(", "BadCredentials", "(", ")", ")", "return", "self", ".", "s...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
LoginBase.addAccount
Create a user account, add it to this LoginBase, and return it. This method must be called within a transaction in my store. @param username: the user's name. @param domain: the domain part of the user's name [XXX TODO: this really ought to say something about whether it's a Q2Q domai...
axiom/userbase.py
def addAccount(self, username, domain, password, avatars=None, protocol=u'email', disabled=0, internal=False, verified=True): """ Create a user account, add it to this LoginBase, and return it. This method must be called within a transaction in my store. ...
def addAccount(self, username, domain, password, avatars=None, protocol=u'email', disabled=0, internal=False, verified=True): """ Create a user account, add it to this LoginBase, and return it. This method must be called within a transaction in my store. ...
[ "Create", "a", "user", "account", "add", "it", "to", "this", "LoginBase", "and", "return", "it", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/userbase.py#L465-L533
[ "def", "addAccount", "(", "self", ",", "username", ",", "domain", ",", "password", ",", "avatars", "=", "None", ",", "protocol", "=", "u'email'", ",", "disabled", "=", "0", ",", "internal", "=", "False", ",", "verified", "=", "True", ")", ":", "# unico...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Connection.identifySQLError
Identify an appropriate SQL error object for the given message for the supported versions of sqlite. @return: an SQLError
axiom/_pysqlite2.py
def identifySQLError(self, sql, args, e): """ Identify an appropriate SQL error object for the given message for the supported versions of sqlite. @return: an SQLError """ message = e.args[0] if message.startswith("table") and message.endswith("already exists"): ...
def identifySQLError(self, sql, args, e): """ Identify an appropriate SQL error object for the given message for the supported versions of sqlite. @return: an SQLError """ message = e.args[0] if message.startswith("table") and message.endswith("already exists"): ...
[ "Identify", "an", "appropriate", "SQL", "error", "object", "for", "the", "given", "message", "for", "the", "supported", "versions", "of", "sqlite", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/_pysqlite2.py#L52-L62
[ "def", "identifySQLError", "(", "self", ",", "sql", ",", "args", ",", "e", ")", ":", "message", "=", "e", ".", "args", "[", "0", "]", "if", "message", ".", "startswith", "(", "\"table\"", ")", "and", "message", ".", "endswith", "(", "\"already exists\"...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
createCacheRemoveCallback
Construct a callable to be used as a weakref callback for cache entries. The callable will invoke the provided finalizer, as well as removing the cache entry if the cache still exists and contains an entry for the given key. @type cacheRef: L{weakref.ref} to L{FinalizingCache} @param cacheRef: A ...
axiom/_fincache.py
def createCacheRemoveCallback(cacheRef, key, finalizer): """ Construct a callable to be used as a weakref callback for cache entries. The callable will invoke the provided finalizer, as well as removing the cache entry if the cache still exists and contains an entry for the given key. @type c...
def createCacheRemoveCallback(cacheRef, key, finalizer): """ Construct a callable to be used as a weakref callback for cache entries. The callable will invoke the provided finalizer, as well as removing the cache entry if the cache still exists and contains an entry for the given key. @type c...
[ "Construct", "a", "callable", "to", "be", "used", "as", "a", "weakref", "callback", "for", "cache", "entries", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/_fincache.py#L39-L71
[ "def", "createCacheRemoveCallback", "(", "cacheRef", ",", "key", ",", "finalizer", ")", ":", "def", "remove", "(", "reference", ")", ":", "# Weakref callbacks cannot raise exceptions or DOOM ensues", "try", ":", "finalizer", "(", ")", "except", ":", "logErrorNoMatterW...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
FinalizingCache.cache
Add an entry to the cache. A weakref to the value is stored, rather than a direct reference. The value must have a C{__finalizer__} method that returns a callable which will be invoked when the weakref is broken. @param key: The key identifying the cache entry. @param value: T...
axiom/_fincache.py
def cache(self, key, value): """ Add an entry to the cache. A weakref to the value is stored, rather than a direct reference. The value must have a C{__finalizer__} method that returns a callable which will be invoked when the weakref is broken. @param key: The key iden...
def cache(self, key, value): """ Add an entry to the cache. A weakref to the value is stored, rather than a direct reference. The value must have a C{__finalizer__} method that returns a callable which will be invoked when the weakref is broken. @param key: The key iden...
[ "Add", "an", "entry", "to", "the", "cache", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/_fincache.py#L89-L114
[ "def", "cache", "(", "self", ",", "key", ",", "value", ")", ":", "fin", "=", "value", ".", "__finalizer__", "(", ")", "try", ":", "# It's okay if there's already a cache entry for this key as long", "# as the weakref has already been broken. See the comment in", "# get() fo...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
FinalizingCache.uncache
Remove a key from the cache. As a sanity check, if the specified key is present in the cache, it must have the given value. @param key: The key to remove. @param value: The expected value for the key.
axiom/_fincache.py
def uncache(self, key, value): """ Remove a key from the cache. As a sanity check, if the specified key is present in the cache, it must have the given value. @param key: The key to remove. @param value: The expected value for the key. """ try: ...
def uncache(self, key, value): """ Remove a key from the cache. As a sanity check, if the specified key is present in the cache, it must have the given value. @param key: The key to remove. @param value: The expected value for the key. """ try: ...
[ "Remove", "a", "key", "from", "the", "cache", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/_fincache.py#L117-L137
[ "def", "uncache", "(", "self", ",", "key", ",", "value", ")", ":", "try", ":", "assert", "self", ".", "get", "(", "key", ")", "is", "value", "del", "self", ".", "data", "[", "key", "]", "except", "KeyError", ":", "# If the entry has already been removed ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
FinalizingCache.get
Get an entry from the cache by key. @raise KeyError: if the given key is not present in the cache. @raise CacheFault: (a L{KeyError} subclass) if the given key is present in the cache, but the value it points to is gone.
axiom/_fincache.py
def get(self, key): """ Get an entry from the cache by key. @raise KeyError: if the given key is not present in the cache. @raise CacheFault: (a L{KeyError} subclass) if the given key is present in the cache, but the value it points to is gone. """ o = self....
def get(self, key): """ Get an entry from the cache by key. @raise KeyError: if the given key is not present in the cache. @raise CacheFault: (a L{KeyError} subclass) if the given key is present in the cache, but the value it points to is gone. """ o = self....
[ "Get", "an", "entry", "from", "the", "cache", "by", "key", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/_fincache.py#L140-L163
[ "def", "get", "(", "self", ",", "key", ")", ":", "o", "=", "self", ".", "data", "[", "key", "]", "(", ")", "if", "o", "is", "None", ":", "# On CPython, the weakref callback will always(?) run before any", "# other code has a chance to observe that the weakref is broke...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
parse_question_xml
Parse <question> element in the UBCPI XBlock's content XML. Args: root (lxml.etree.Element): The root of the <question> node in the tree. Returns: dict, a deserialized representation of a question. E.g. { 'text': 'What is the answer to life, the universe and everything?', ...
ubcpi/serialize.py
def parse_question_xml(root): """ Parse <question> element in the UBCPI XBlock's content XML. Args: root (lxml.etree.Element): The root of the <question> node in the tree. Returns: dict, a deserialized representation of a question. E.g. { 'text': 'What is the answer...
def parse_question_xml(root): """ Parse <question> element in the UBCPI XBlock's content XML. Args: root (lxml.etree.Element): The root of the <question> node in the tree. Returns: dict, a deserialized representation of a question. E.g. { 'text': 'What is the answer...
[ "Parse", "<question", ">", "element", "in", "the", "UBCPI", "XBlock", "s", "content", "XML", "." ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L67-L98
[ "def", "parse_question_xml", "(", "root", ")", ":", "question_dict", "=", "dict", "(", ")", "question_prompt_el", "=", "root", ".", "find", "(", "'text'", ")", "if", "question_prompt_el", "is", "not", "None", ":", "question_dict", "[", "'text'", "]", "=", ...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
parse_options_xml
Parse <options> element in the UBCPI XBlock's content XML. Args: root (lxml.etree.Element): The root of the <options> node in the tree. Returns: a list of deserialized representation of options. E.g. [{ 'text': 'Option 1', 'image_url': '', 'image_pos...
ubcpi/serialize.py
def parse_options_xml(root): """ Parse <options> element in the UBCPI XBlock's content XML. Args: root (lxml.etree.Element): The root of the <options> node in the tree. Returns: a list of deserialized representation of options. E.g. [{ 'text': 'Option 1', ...
def parse_options_xml(root): """ Parse <options> element in the UBCPI XBlock's content XML. Args: root (lxml.etree.Element): The root of the <options> node in the tree. Returns: a list of deserialized representation of options. E.g. [{ 'text': 'Option 1', ...
[ "Parse", "<options", ">", "element", "in", "the", "UBCPI", "XBlock", "s", "content", "XML", "." ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L101-L154
[ "def", "parse_options_xml", "(", "root", ")", ":", "options", "=", "[", "]", "correct_option", "=", "None", "rationale", "=", "None", "for", "option_el", "in", "root", ".", "findall", "(", "'option'", ")", ":", "option_dict", "=", "dict", "(", ")", "opti...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
parse_seeds_xml
Parse <seeds> element in the UBCPI XBlock's content XML. Args: root (lxml.etree.Element): The root of the <seeds> node in the tree. Returns: a list of deserialized representation of seeds. E.g. [{ 'answer': 1, # option index starting from one 'rationale': 'This...
ubcpi/serialize.py
def parse_seeds_xml(root): """ Parse <seeds> element in the UBCPI XBlock's content XML. Args: root (lxml.etree.Element): The root of the <seeds> node in the tree. Returns: a list of deserialized representation of seeds. E.g. [{ 'answer': 1, # option index starting ...
def parse_seeds_xml(root): """ Parse <seeds> element in the UBCPI XBlock's content XML. Args: root (lxml.etree.Element): The root of the <seeds> node in the tree. Returns: a list of deserialized representation of seeds. E.g. [{ 'answer': 1, # option index starting ...
[ "Parse", "<seeds", ">", "element", "in", "the", "UBCPI", "XBlock", "s", "content", "XML", "." ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L157-L189
[ "def", "parse_seeds_xml", "(", "root", ")", ":", "seeds", "=", "[", "]", "for", "seed_el", "in", "root", ".", "findall", "(", "'seed'", ")", ":", "seed_dict", "=", "dict", "(", ")", "seed_dict", "[", "'rationale'", "]", "=", "_safe_get_text", "(", "see...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
parse_from_xml
Update the UBCPI XBlock's content from an XML definition. We need to be strict about the XML we accept, to avoid setting the XBlock to an invalid state (which will then be persisted). Args: root (lxml.etree.Element): The XML definition of the XBlock's content. Returns: A dictionary of...
ubcpi/serialize.py
def parse_from_xml(root): """ Update the UBCPI XBlock's content from an XML definition. We need to be strict about the XML we accept, to avoid setting the XBlock to an invalid state (which will then be persisted). Args: root (lxml.etree.Element): The XML definition of the XBlock's content....
def parse_from_xml(root): """ Update the UBCPI XBlock's content from an XML definition. We need to be strict about the XML we accept, to avoid setting the XBlock to an invalid state (which will then be persisted). Args: root (lxml.etree.Element): The XML definition of the XBlock's content....
[ "Update", "the", "UBCPI", "XBlock", "s", "content", "from", "an", "XML", "definition", "." ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L192-L252
[ "def", "parse_from_xml", "(", "root", ")", ":", "# Check that the root has the correct tag", "if", "root", ".", "tag", "!=", "'ubcpi'", ":", "raise", "UpdateFromXmlError", "(", "_", "(", "'Every peer instruction tool must contain an \"ubcpi\" element.'", ")", ")", "displa...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
serialize_options
Serialize the options in peer instruction XBlock to xml Args: options (lxml.etree.Element): The <options> XML element. block (PeerInstructionXBlock): The XBlock with configuration to serialize. Returns: None
ubcpi/serialize.py
def serialize_options(options, block): """ Serialize the options in peer instruction XBlock to xml Args: options (lxml.etree.Element): The <options> XML element. block (PeerInstructionXBlock): The XBlock with configuration to serialize. Returns: None """ for index, opti...
def serialize_options(options, block): """ Serialize the options in peer instruction XBlock to xml Args: options (lxml.etree.Element): The <options> XML element. block (PeerInstructionXBlock): The XBlock with configuration to serialize. Returns: None """ for index, opti...
[ "Serialize", "the", "options", "in", "peer", "instruction", "XBlock", "to", "xml" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L255-L279
[ "def", "serialize_options", "(", "options", ",", "block", ")", ":", "for", "index", ",", "option_dict", "in", "enumerate", "(", "block", ".", "options", ")", ":", "option", "=", "etree", ".", "SubElement", "(", "options", ",", "'option'", ")", "# set corre...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
serialize_seeds
Serialize the seeds in peer instruction XBlock to xml Args: seeds (lxml.etree.Element): The <seeds> XML element. block (PeerInstructionXBlock): The XBlock with configuration to serialize. Returns: None
ubcpi/serialize.py
def serialize_seeds(seeds, block): """ Serialize the seeds in peer instruction XBlock to xml Args: seeds (lxml.etree.Element): The <seeds> XML element. block (PeerInstructionXBlock): The XBlock with configuration to serialize. Returns: None """ for seed_dict in block.se...
def serialize_seeds(seeds, block): """ Serialize the seeds in peer instruction XBlock to xml Args: seeds (lxml.etree.Element): The <seeds> XML element. block (PeerInstructionXBlock): The XBlock with configuration to serialize. Returns: None """ for seed_dict in block.se...
[ "Serialize", "the", "seeds", "in", "peer", "instruction", "XBlock", "to", "xml" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L292-L307
[ "def", "serialize_seeds", "(", "seeds", ",", "block", ")", ":", "for", "seed_dict", "in", "block", ".", "seeds", ":", "seed", "=", "etree", ".", "SubElement", "(", "seeds", ",", "'seed'", ")", "# options in xml starts with 1", "seed", ".", "set", "(", "'op...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
serialize_to_xml
Serialize the Peer Instruction XBlock's content to XML. Args: block (PeerInstructionXBlock): The peer instruction block to serialize. root (etree.Element): The XML root node to update. Returns: etree.Element
ubcpi/serialize.py
def serialize_to_xml(root, block): """ Serialize the Peer Instruction XBlock's content to XML. Args: block (PeerInstructionXBlock): The peer instruction block to serialize. root (etree.Element): The XML root node to update. Returns: etree.Element """ root.tag = 'ubcpi'...
def serialize_to_xml(root, block): """ Serialize the Peer Instruction XBlock's content to XML. Args: block (PeerInstructionXBlock): The peer instruction block to serialize. root (etree.Element): The XML root node to update. Returns: etree.Element """ root.tag = 'ubcpi'...
[ "Serialize", "the", "Peer", "Instruction", "XBlock", "s", "content", "to", "XML", "." ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L310-L348
[ "def", "serialize_to_xml", "(", "root", ",", "block", ")", ":", "root", ".", "tag", "=", "'ubcpi'", "if", "block", ".", "rationale_size", "is", "not", "None", ":", "if", "block", ".", "rationale_size", ".", "get", "(", "'min'", ")", ":", "root", ".", ...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
VolumeGroup.open
Obtains the lvm and vg_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError
lvm2py/vg.py
def open(self): """ Obtains the lvm and vg_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if not self.handle: self.lvm.op...
def open(self): """ Obtains the lvm and vg_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if not self.handle: self.lvm.op...
[ "Obtains", "the", "lvm", "and", "vg_t", "handle", ".", "Usually", "you", "would", "never", "need", "to", "use", "this", "method", "unless", "you", "are", "doing", "operations", "using", "the", "ctypes", "function", "wrappers", "in", "conversion", ".", "py" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L67-L80
[ "def", "open", "(", "self", ")", ":", "if", "not", "self", ".", "handle", ":", "self", ".", "lvm", ".", "open", "(", ")", "self", ".", "__vgh", "=", "lvm_vg_open", "(", "self", ".", "lvm", ".", "handle", ",", "self", ".", "name", ",", "self", "...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.close
Closes the lvm and vg_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError
lvm2py/vg.py
def close(self): """ Closes the lvm and vg_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if self.handle: cl = lvm_vg_clo...
def close(self): """ Closes the lvm and vg_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if self.handle: cl = lvm_vg_clo...
[ "Closes", "the", "lvm", "and", "vg_t", "handle", ".", "Usually", "you", "would", "never", "need", "to", "use", "this", "method", "unless", "you", "are", "doing", "operations", "using", "the", "ctypes", "function", "wrappers", "in", "conversion", ".", "py" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L82-L96
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "handle", ":", "cl", "=", "lvm_vg_close", "(", "self", ".", "handle", ")", "if", "cl", "!=", "0", ":", "raise", "HandleError", "(", "\"Failed to close VG handle after init check.\"", ")", "self", "....
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.uuid
Returns the volume group uuid.
lvm2py/vg.py
def uuid(self): """ Returns the volume group uuid. """ self.open() uuid = lvm_vg_get_uuid(self.handle) self.close() return uuid
def uuid(self): """ Returns the volume group uuid. """ self.open() uuid = lvm_vg_get_uuid(self.handle) self.close() return uuid
[ "Returns", "the", "volume", "group", "uuid", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L120-L127
[ "def", "uuid", "(", "self", ")", ":", "self", ".", "open", "(", ")", "uuid", "=", "lvm_vg_get_uuid", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "uuid" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.extent_count
Returns the volume group extent count.
lvm2py/vg.py
def extent_count(self): """ Returns the volume group extent count. """ self.open() count = lvm_vg_get_extent_count(self.handle) self.close() return count
def extent_count(self): """ Returns the volume group extent count. """ self.open() count = lvm_vg_get_extent_count(self.handle) self.close() return count
[ "Returns", "the", "volume", "group", "extent", "count", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L137-L144
[ "def", "extent_count", "(", "self", ")", ":", "self", ".", "open", "(", ")", "count", "=", "lvm_vg_get_extent_count", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "count" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.free_extent_count
Returns the volume group free extent count.
lvm2py/vg.py
def free_extent_count(self): """ Returns the volume group free extent count. """ self.open() count = lvm_vg_get_free_extent_count(self.handle) self.close() return count
def free_extent_count(self): """ Returns the volume group free extent count. """ self.open() count = lvm_vg_get_free_extent_count(self.handle) self.close() return count
[ "Returns", "the", "volume", "group", "free", "extent", "count", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L147-L154
[ "def", "free_extent_count", "(", "self", ")", ":", "self", ".", "open", "(", ")", "count", "=", "lvm_vg_get_free_extent_count", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "count" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.pv_count
Returns the physical volume count.
lvm2py/vg.py
def pv_count(self): """ Returns the physical volume count. """ self.open() count = lvm_vg_get_pv_count(self.handle) self.close() return count
def pv_count(self): """ Returns the physical volume count. """ self.open() count = lvm_vg_get_pv_count(self.handle) self.close() return count
[ "Returns", "the", "physical", "volume", "count", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L157-L164
[ "def", "pv_count", "(", "self", ")", ":", "self", ".", "open", "(", ")", "count", "=", "lvm_vg_get_pv_count", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "count" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.max_pv_count
Returns the maximum allowed physical volume count.
lvm2py/vg.py
def max_pv_count(self): """ Returns the maximum allowed physical volume count. """ self.open() count = lvm_vg_get_max_pv(self.handle) self.close() return count
def max_pv_count(self): """ Returns the maximum allowed physical volume count. """ self.open() count = lvm_vg_get_max_pv(self.handle) self.close() return count
[ "Returns", "the", "maximum", "allowed", "physical", "volume", "count", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L167-L174
[ "def", "max_pv_count", "(", "self", ")", ":", "self", ".", "open", "(", ")", "count", "=", "lvm_vg_get_max_pv", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "count" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.max_lv_count
Returns the maximum allowed logical volume count.
lvm2py/vg.py
def max_lv_count(self): """ Returns the maximum allowed logical volume count. """ self.open() count = lvm_vg_get_max_lv(self.handle) self.close() return count
def max_lv_count(self): """ Returns the maximum allowed logical volume count. """ self.open() count = lvm_vg_get_max_lv(self.handle) self.close() return count
[ "Returns", "the", "maximum", "allowed", "logical", "volume", "count", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L177-L184
[ "def", "max_lv_count", "(", "self", ")", ":", "self", ".", "open", "(", ")", "count", "=", "lvm_vg_get_max_lv", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "count" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.is_clustered
Returns True if the VG is clustered, False otherwise.
lvm2py/vg.py
def is_clustered(self): """ Returns True if the VG is clustered, False otherwise. """ self.open() clust = lvm_vg_is_clustered(self.handle) self.close() return bool(clust)
def is_clustered(self): """ Returns True if the VG is clustered, False otherwise. """ self.open() clust = lvm_vg_is_clustered(self.handle) self.close() return bool(clust)
[ "Returns", "True", "if", "the", "VG", "is", "clustered", "False", "otherwise", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L187-L194
[ "def", "is_clustered", "(", "self", ")", ":", "self", ".", "open", "(", ")", "clust", "=", "lvm_vg_is_clustered", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "bool", "(", "clust", ")" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.is_exported
Returns True if the VG is exported, False otherwise.
lvm2py/vg.py
def is_exported(self): """ Returns True if the VG is exported, False otherwise. """ self.open() exp = lvm_vg_is_exported(self.handle) self.close() return bool(exp)
def is_exported(self): """ Returns True if the VG is exported, False otherwise. """ self.open() exp = lvm_vg_is_exported(self.handle) self.close() return bool(exp)
[ "Returns", "True", "if", "the", "VG", "is", "exported", "False", "otherwise", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L197-L204
[ "def", "is_exported", "(", "self", ")", ":", "self", ".", "open", "(", ")", "exp", "=", "lvm_vg_is_exported", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "bool", "(", "exp", ")" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.is_partial
Returns True if the VG is partial, False otherwise.
lvm2py/vg.py
def is_partial(self): """ Returns True if the VG is partial, False otherwise. """ self.open() part = lvm_vg_is_partial(self.handle) self.close() return bool(part)
def is_partial(self): """ Returns True if the VG is partial, False otherwise. """ self.open() part = lvm_vg_is_partial(self.handle) self.close() return bool(part)
[ "Returns", "True", "if", "the", "VG", "is", "partial", "False", "otherwise", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L207-L214
[ "def", "is_partial", "(", "self", ")", ":", "self", ".", "open", "(", ")", "part", "=", "lvm_vg_is_partial", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "bool", "(", "part", ")" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.sequence
Returns the volume group sequence number. This number increases everytime the volume group is modified.
lvm2py/vg.py
def sequence(self): """ Returns the volume group sequence number. This number increases everytime the volume group is modified. """ self.open() seq = lvm_vg_get_seqno(self.handle) self.close() return seq
def sequence(self): """ Returns the volume group sequence number. This number increases everytime the volume group is modified. """ self.open() seq = lvm_vg_get_seqno(self.handle) self.close() return seq
[ "Returns", "the", "volume", "group", "sequence", "number", ".", "This", "number", "increases", "everytime", "the", "volume", "group", "is", "modified", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L217-L225
[ "def", "sequence", "(", "self", ")", ":", "self", ".", "open", "(", ")", "seq", "=", "lvm_vg_get_seqno", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "seq" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.size
Returns the volume group size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
lvm2py/vg.py
def size(self, units="MiB"): """ Returns the volume group size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. """ self.open() size = lvm_vg_get_size(self.handle) self.close()...
def size(self, units="MiB"): """ Returns the volume group size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. """ self.open() size = lvm_vg_get_size(self.handle) self.close()...
[ "Returns", "the", "volume", "group", "size", "in", "the", "given", "units", ".", "Default", "units", "are", "MiB", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L227-L238
[ "def", "size", "(", "self", ",", "units", "=", "\"MiB\"", ")", ":", "self", ".", "open", "(", ")", "size", "=", "lvm_vg_get_size", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "size_convert", "(", "size", ",", "units", ...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.free_size
Returns the volume group free size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
lvm2py/vg.py
def free_size(self, units="MiB"): """ Returns the volume group free size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. """ self.open() size = lvm_vg_get_free_size(self.handle) ...
def free_size(self, units="MiB"): """ Returns the volume group free size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. """ self.open() size = lvm_vg_get_free_size(self.handle) ...
[ "Returns", "the", "volume", "group", "free", "size", "in", "the", "given", "units", ".", "Default", "units", "are", "MiB", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L240-L251
[ "def", "free_size", "(", "self", ",", "units", "=", "\"MiB\"", ")", ":", "self", ".", "open", "(", ")", "size", "=", "lvm_vg_get_free_size", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "size_convert", "(", "size", ",", ...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.extent_size
Returns the volume group extent size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB.
lvm2py/vg.py
def extent_size(self, units="MiB"): """ Returns the volume group extent size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. """ self.open() size = lvm_vg_get_extent_size(self.handle)...
def extent_size(self, units="MiB"): """ Returns the volume group extent size in the given units. Default units are MiB. *Args:* * units (str): Unit label ('MiB', 'GiB', etc...). Default is MiB. """ self.open() size = lvm_vg_get_extent_size(self.handle)...
[ "Returns", "the", "volume", "group", "extent", "size", "in", "the", "given", "units", ".", "Default", "units", "are", "MiB", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L253-L264
[ "def", "extent_size", "(", "self", ",", "units", "=", "\"MiB\"", ")", ":", "self", ".", "open", "(", ")", "size", "=", "lvm_vg_get_extent_size", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "size_convert", "(", "size", ","...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.add_pv
Initializes a device as a physical volume and adds it to the volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") vg.add_pv("/dev/sdbX") *Args:* * device (str): An existing device. *Raises:* * Val...
lvm2py/vg.py
def add_pv(self, device): """ Initializes a device as a physical volume and adds it to the volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") vg.add_pv("/dev/sdbX") *Args:* * device (str): An existing d...
def add_pv(self, device): """ Initializes a device as a physical volume and adds it to the volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") vg.add_pv("/dev/sdbX") *Args:* * device (str): An existing d...
[ "Initializes", "a", "device", "as", "a", "physical", "volume", "and", "adds", "it", "to", "the", "volume", "group", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L272-L304
[ "def", "add_pv", "(", "self", ",", "device", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "device", ")", ":", "raise", "ValueError", "(", "\"%s does not exist.\"", "%", "device", ")", "self", ".", "open", "(", ")", "ext", "=", "lvm_v...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.get_pv
Returns the physical volume associated with the given device:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") vg.get_pv("/dev/sdb1") *Args:* * device (str): An existing device. *Raises:* * ValueError, Hand...
lvm2py/vg.py
def get_pv(self, device): """ Returns the physical volume associated with the given device:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") vg.get_pv("/dev/sdb1") *Args:* * device (str): An existing device. ...
def get_pv(self, device): """ Returns the physical volume associated with the given device:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") vg.get_pv("/dev/sdb1") *Args:* * device (str): An existing device. ...
[ "Returns", "the", "physical", "volume", "associated", "with", "the", "given", "device", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L306-L326
[ "def", "get_pv", "(", "self", ",", "device", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "device", ")", ":", "raise", "ValueError", "(", "\"%s does not exist.\"", "%", "device", ")", "return", "PhysicalVolume", "(", "self", ",", "name",...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.remove_pv
Removes a physical volume from the volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") pv = vg.pvscan()[0] vg.remove_pv(pv) *Args:* * pv (obj): A PhysicalVolume instance. *Raises:* * ...
lvm2py/vg.py
def remove_pv(self, pv): """ Removes a physical volume from the volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") pv = vg.pvscan()[0] vg.remove_pv(pv) *Args:* * pv (obj): A PhysicalVolu...
def remove_pv(self, pv): """ Removes a physical volume from the volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") pv = vg.pvscan()[0] vg.remove_pv(pv) *Args:* * pv (obj): A PhysicalVolu...
[ "Removes", "a", "physical", "volume", "from", "the", "volume", "group", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L348-L380
[ "def", "remove_pv", "(", "self", ",", "pv", ")", ":", "name", "=", "pv", ".", "name", "self", ".", "open", "(", ")", "rm", "=", "lvm_vg_reduce", "(", "self", ".", "handle", ",", "name", ")", "if", "rm", "!=", "0", ":", "self", ".", "close", "("...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.pvscan
Probes the volume group for physical volumes and returns a list of PhysicalVolume instances:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") pvs = vg.pvscan() *Raises:* * HandleError
lvm2py/vg.py
def pvscan(self): """ Probes the volume group for physical volumes and returns a list of PhysicalVolume instances:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") pvs = vg.pvscan() *Raises:* * HandleError ...
def pvscan(self): """ Probes the volume group for physical volumes and returns a list of PhysicalVolume instances:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") pvs = vg.pvscan() *Raises:* * HandleError ...
[ "Probes", "the", "volume", "group", "for", "physical", "volumes", "and", "returns", "a", "list", "of", "PhysicalVolume", "instances", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L382-L412
[ "def", "pvscan", "(", "self", ")", ":", "self", ".", "open", "(", ")", "pv_list", "=", "[", "]", "pv_handles", "=", "lvm_vg_list_pvs", "(", "self", ".", "handle", ")", "if", "not", "bool", "(", "pv_handles", ")", ":", "return", "pv_list", "pvh", "=",...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.lvscan
Probes the volume group for logical volumes and returns a list of LogicalVolume instances:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") lvs = vg.lvscan() *Raises:* * HandleError
lvm2py/vg.py
def lvscan(self): """ Probes the volume group for logical volumes and returns a list of LogicalVolume instances:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") lvs = vg.lvscan() *Raises:* * HandleError "...
def lvscan(self): """ Probes the volume group for logical volumes and returns a list of LogicalVolume instances:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") lvs = vg.lvscan() *Raises:* * HandleError "...
[ "Probes", "the", "volume", "group", "for", "logical", "volumes", "and", "returns", "a", "list", "of", "LogicalVolume", "instances", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L414-L444
[ "def", "lvscan", "(", "self", ")", ":", "self", ".", "open", "(", ")", "lv_list", "=", "[", "]", "lv_handles", "=", "lvm_vg_list_lvs", "(", "self", ".", "handle", ")", "if", "not", "bool", "(", "lv_handles", ")", ":", "return", "lv_list", "lvh", "=",...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.create_lv
Creates a logical volume and returns the LogicalVolume instance associated with the lv_t handle:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lv = vg.create_lv("mylv", 40, "MiB") *Args:* * name (str): The des...
lvm2py/vg.py
def create_lv(self, name, length, units): """ Creates a logical volume and returns the LogicalVolume instance associated with the lv_t handle:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lv = vg.create_lv("mylv", 40, "MiB") ...
def create_lv(self, name, length, units): """ Creates a logical volume and returns the LogicalVolume instance associated with the lv_t handle:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lv = vg.create_lv("mylv", 40, "MiB") ...
[ "Creates", "a", "logical", "volume", "and", "returns", "the", "LogicalVolume", "instance", "associated", "with", "the", "lv_t", "handle", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L446-L485
[ "def", "create_lv", "(", "self", ",", "name", ",", "length", ",", "units", ")", ":", "if", "units", "!=", "\"%\"", ":", "size", "=", "size_units", "[", "units", "]", "*", "length", "else", ":", "if", "not", "(", "0", "<", "length", "<=", "100", "...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.remove_lv
Removes a logical volume from the volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lv = vg.lvscan()[0] vg.remove_lv(lv) *Args:* * lv (obj): A LogicalVolume instance. *Raises:* * ...
lvm2py/vg.py
def remove_lv(self, lv): """ Removes a logical volume from the volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lv = vg.lvscan()[0] vg.remove_lv(lv) *Args:* * lv (obj): A LogicalVolume...
def remove_lv(self, lv): """ Removes a logical volume from the volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lv = vg.lvscan()[0] vg.remove_lv(lv) *Args:* * lv (obj): A LogicalVolume...
[ "Removes", "a", "logical", "volume", "from", "the", "volume", "group", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L487-L515
[ "def", "remove_lv", "(", "self", ",", "lv", ")", ":", "lv", ".", "open", "(", ")", "rm", "=", "lvm_vg_remove_lv", "(", "lv", ".", "handle", ")", "lv", ".", "close", "(", ")", "if", "rm", "!=", "0", ":", "raise", "CommitError", "(", "\"Failed to rem...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.remove_all_lvs
Removes all logical volumes from the volume group. *Raises:* * HandleError, CommitError
lvm2py/vg.py
def remove_all_lvs(self): """ Removes all logical volumes from the volume group. *Raises:* * HandleError, CommitError """ lvs = self.lvscan() for lv in lvs: self.remove_lv(lv)
def remove_all_lvs(self): """ Removes all logical volumes from the volume group. *Raises:* * HandleError, CommitError """ lvs = self.lvscan() for lv in lvs: self.remove_lv(lv)
[ "Removes", "all", "logical", "volumes", "from", "the", "volume", "group", "." ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L517-L527
[ "def", "remove_all_lvs", "(", "self", ")", ":", "lvs", "=", "self", ".", "lvscan", "(", ")", "for", "lv", "in", "lvs", ":", "self", ".", "remove_lv", "(", "lv", ")" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
VolumeGroup.set_extent_size
Sets the volume group extent size in the given units:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") vg.set_extent_size(2, "MiB") *Args:* * length (int): The desired length size. * units (str): The desired units...
lvm2py/vg.py
def set_extent_size(self, length, units): """ Sets the volume group extent size in the given units:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") vg.set_extent_size(2, "MiB") *Args:* * length (int): The desired ...
def set_extent_size(self, length, units): """ Sets the volume group extent size in the given units:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") vg.set_extent_size(2, "MiB") *Args:* * length (int): The desired ...
[ "Sets", "the", "volume", "group", "extent", "size", "in", "the", "given", "units", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L541-L571
[ "def", "set_extent_size", "(", "self", ",", "length", ",", "units", ")", ":", "size", "=", "length", "*", "size_units", "[", "units", "]", "self", ".", "open", "(", ")", "ext", "=", "lvm_vg_set_extent_size", "(", "self", ".", "handle", ",", "c_ulong", ...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
Matrix.set_pair
Set the value for a pair of terms. Args: term1 (str) term2 (str) value (mixed)
textplot/matrix.py
def set_pair(self, term1, term2, value, **kwargs): """ Set the value for a pair of terms. Args: term1 (str) term2 (str) value (mixed) """ key = self.key(term1, term2) self.keys.update([term1, term2]) self.pairs[key] = value
def set_pair(self, term1, term2, value, **kwargs): """ Set the value for a pair of terms. Args: term1 (str) term2 (str) value (mixed) """ key = self.key(term1, term2) self.keys.update([term1, term2]) self.pairs[key] = value
[ "Set", "the", "value", "for", "a", "pair", "of", "terms", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/matrix.py#L50-L63
[ "def", "set_pair", "(", "self", ",", "term1", ",", "term2", ",", "value", ",", "*", "*", "kwargs", ")", ":", "key", "=", "self", ".", "key", "(", "term1", ",", "term2", ")", "self", ".", "keys", ".", "update", "(", "[", "term1", ",", "term2", "...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Matrix.get_pair
Get the value for a pair of terms. Args: term1 (str) term2 (str) Returns: The stored value.
textplot/matrix.py
def get_pair(self, term1, term2): """ Get the value for a pair of terms. Args: term1 (str) term2 (str) Returns: The stored value. """ key = self.key(term1, term2) return self.pairs.get(key, None)
def get_pair(self, term1, term2): """ Get the value for a pair of terms. Args: term1 (str) term2 (str) Returns: The stored value. """ key = self.key(term1, term2) return self.pairs.get(key, None)
[ "Get", "the", "value", "for", "a", "pair", "of", "terms", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/matrix.py#L66-L80
[ "def", "get_pair", "(", "self", ",", "term1", ",", "term2", ")", ":", "key", "=", "self", ".", "key", "(", "term1", ",", "term2", ")", "return", "self", ".", "pairs", ".", "get", "(", "key", ",", "None", ")" ]
889b949a637d99097ecec44ed4bfee53b1964dee
train
Matrix.index
Index all term pair distances. Args: text (Text): The source text. terms (list): Terms to index.
textplot/matrix.py
def index(self, text, terms=None, **kwargs): """ Index all term pair distances. Args: text (Text): The source text. terms (list): Terms to index. """ self.clear() # By default, use all terms. terms = terms or text.terms.keys() ...
def index(self, text, terms=None, **kwargs): """ Index all term pair distances. Args: text (Text): The source text. terms (list): Terms to index. """ self.clear() # By default, use all terms. terms = terms or text.terms.keys() ...
[ "Index", "all", "term", "pair", "distances", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/matrix.py#L83-L105
[ "def", "index", "(", "self", ",", "text", ",", "terms", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "clear", "(", ")", "# By default, use all terms.", "terms", "=", "terms", "or", "text", ".", "terms", ".", "keys", "(", ")", "pairs",...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Matrix.anchored_pairs
Get distances between an anchor term and all other terms. Args: anchor (str): The anchor term. Returns: OrderedDict: The distances, in descending order.
textplot/matrix.py
def anchored_pairs(self, anchor): """ Get distances between an anchor term and all other terms. Args: anchor (str): The anchor term. Returns: OrderedDict: The distances, in descending order. """ pairs = OrderedDict() for term in self.k...
def anchored_pairs(self, anchor): """ Get distances between an anchor term and all other terms. Args: anchor (str): The anchor term. Returns: OrderedDict: The distances, in descending order. """ pairs = OrderedDict() for term in self.k...
[ "Get", "distances", "between", "an", "anchor", "term", "and", "all", "other", "terms", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/matrix.py#L108-L126
[ "def", "anchored_pairs", "(", "self", ",", "anchor", ")", ":", "pairs", "=", "OrderedDict", "(", ")", "for", "term", "in", "self", ".", "keys", ":", "score", "=", "self", ".", "get_pair", "(", "anchor", ",", "term", ")", "if", "score", ":", "pairs", ...
889b949a637d99097ecec44ed4bfee53b1964dee
train
from_rgb
Return the nearest xterm 256 color code from rgb input.
x256/x256.py
def from_rgb(r, g=None, b=None): """ Return the nearest xterm 256 color code from rgb input. """ c = r if isinstance(r, list) else [r, g, b] best = {} for index, item in enumerate(colors): d = __distance(item, c) if(not best or d <= best['distance']): best = {'distan...
def from_rgb(r, g=None, b=None): """ Return the nearest xterm 256 color code from rgb input. """ c = r if isinstance(r, list) else [r, g, b] best = {} for index, item in enumerate(colors): d = __distance(item, c) if(not best or d <= best['distance']): best = {'distan...
[ "Return", "the", "nearest", "xterm", "256", "color", "code", "from", "rgb", "input", "." ]
magarcia/python-x256
python
https://github.com/magarcia/python-x256/blob/d4bc9f763a34eb15cce4f23a2e09eff3adc8a032/x256/x256.py#L283-L298
[ "def", "from_rgb", "(", "r", ",", "g", "=", "None", ",", "b", "=", "None", ")", ":", "c", "=", "r", "if", "isinstance", "(", "r", ",", "list", ")", "else", "[", "r", ",", "g", ",", "b", "]", "best", "=", "{", "}", "for", "index", ",", "it...
d4bc9f763a34eb15cce4f23a2e09eff3adc8a032
train
entry
Parse command line arguments and run utilities.
x256/x256.py
def entry(): """Parse command line arguments and run utilities.""" parser = argparse.ArgumentParser() parser.add_argument( 'action', help='Action to take', choices=['from_hex', 'to_rgb', 'to_hex'], ) parser.add_argument( 'value', help='Value for the action', ) parsed ...
def entry(): """Parse command line arguments and run utilities.""" parser = argparse.ArgumentParser() parser.add_argument( 'action', help='Action to take', choices=['from_hex', 'to_rgb', 'to_hex'], ) parser.add_argument( 'value', help='Value for the action', ) parsed ...
[ "Parse", "command", "line", "arguments", "and", "run", "utilities", "." ]
magarcia/python-x256
python
https://github.com/magarcia/python-x256/blob/d4bc9f763a34eb15cce4f23a2e09eff3adc8a032/x256/x256.py#L321-L339
[ "def", "entry", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'action'", ",", "help", "=", "'Action to take'", ",", "choices", "=", "[", "'from_hex'", ",", "'to_rgb'", ",", "'to_hex'", "]", ...
d4bc9f763a34eb15cce4f23a2e09eff3adc8a032
train
makeSoftwareVersion
Return the SoftwareVersion object from store corresponding to the version object, creating it if it doesn't already exist.
axiom/listversions.py
def makeSoftwareVersion(store, version, systemVersion): """ Return the SoftwareVersion object from store corresponding to the version object, creating it if it doesn't already exist. """ return store.findOrCreate(SoftwareVersion, systemVersion=systemVersion, ...
def makeSoftwareVersion(store, version, systemVersion): """ Return the SoftwareVersion object from store corresponding to the version object, creating it if it doesn't already exist. """ return store.findOrCreate(SoftwareVersion, systemVersion=systemVersion, ...
[ "Return", "the", "SoftwareVersion", "object", "from", "store", "corresponding", "to", "the", "version", "object", "creating", "it", "if", "it", "doesn", "t", "already", "exist", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/listversions.py#L91-L102
[ "def", "makeSoftwareVersion", "(", "store", ",", "version", ",", "systemVersion", ")", ":", "return", "store", ".", "findOrCreate", "(", "SoftwareVersion", ",", "systemVersion", "=", "systemVersion", ",", "package", "=", "unicode", "(", "version", ".", "package"...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
listVersionHistory
List the software package version history of store.
axiom/listversions.py
def listVersionHistory(store): """ List the software package version history of store. """ q = store.query(SystemVersion, sort=SystemVersion.creation.descending) return [sv.longWindedRepr() for sv in q]
def listVersionHistory(store): """ List the software package version history of store. """ q = store.query(SystemVersion, sort=SystemVersion.creation.descending) return [sv.longWindedRepr() for sv in q]
[ "List", "the", "software", "package", "version", "history", "of", "store", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/listversions.py#L106-L111
[ "def", "listVersionHistory", "(", "store", ")", ":", "q", "=", "store", ".", "query", "(", "SystemVersion", ",", "sort", "=", "SystemVersion", ".", "creation", ".", "descending", ")", "return", "[", "sv", ".", "longWindedRepr", "(", ")", "for", "sv", "in...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
checkSystemVersion
Check if the current version is different from the previously recorded version. If it is, or if there is no previously recorded version, create a version matching the current config.
axiom/listversions.py
def checkSystemVersion(s, versions=None): """ Check if the current version is different from the previously recorded version. If it is, or if there is no previously recorded version, create a version matching the current config. """ if versions is None: versions = getSystemVersions() ...
def checkSystemVersion(s, versions=None): """ Check if the current version is different from the previously recorded version. If it is, or if there is no previously recorded version, create a version matching the current config. """ if versions is None: versions = getSystemVersions() ...
[ "Check", "if", "the", "current", "version", "is", "different", "from", "the", "previously", "recorded", "version", ".", "If", "it", "is", "or", "if", "there", "is", "no", "previously", "recorded", "version", "create", "a", "version", "matching", "the", "curr...
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/listversions.py#L121-L142
[ "def", "checkSystemVersion", "(", "s", ",", "versions", "=", "None", ")", ":", "if", "versions", "is", "None", ":", "versions", "=", "getSystemVersions", "(", ")", "currentVersionMap", "=", "dict", "(", "[", "(", "v", ".", "package", ",", "v", ")", "fo...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
SoftwareVersion.asVersion
Convert the version data in this item to a L{twisted.python.versions.Version}.
axiom/listversions.py
def asVersion(self): """ Convert the version data in this item to a L{twisted.python.versions.Version}. """ return versions.Version(self.package, self.major, self.minor, self.micro)
def asVersion(self): """ Convert the version data in this item to a L{twisted.python.versions.Version}. """ return versions.Version(self.package, self.major, self.minor, self.micro)
[ "Convert", "the", "version", "data", "in", "this", "item", "to", "a", "L", "{", "twisted", ".", "python", ".", "versions", ".", "Version", "}", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/listversions.py#L78-L83
[ "def", "asVersion", "(", "self", ")", ":", "return", "versions", ".", "Version", "(", "self", ".", "package", ",", "self", ".", "major", ",", "self", ".", "minor", ",", "self", ".", "micro", ")" ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
SHEET.reset
clears all columns
PyOriginTools/workbook.py
def reset(self): """clears all columns""" self.colNames,self.colDesc,self.colUnits,self.colComments,\ self.colTypes,self.colData=[],[],[],[],[],[]
def reset(self): """clears all columns""" self.colNames,self.colDesc,self.colUnits,self.colComments,\ self.colTypes,self.colData=[],[],[],[],[],[]
[ "clears", "all", "columns" ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L42-L45
[ "def", "reset", "(", "self", ")", ":", "self", ".", "colNames", ",", "self", ".", "colDesc", ",", "self", ".", "colUnits", ",", "self", ".", "colComments", ",", "self", ".", "colTypes", ",", "self", ".", "colData", "=", "[", "]", ",", "[", "]", "...
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
SHEET.colAdd
column types: 0: Y 1: Disregard 2: Y Error 3: X 4: Label 5: Z 6: X Error
PyOriginTools/workbook.py
def colAdd(self,name="",desc="",unit="",comment="",coltype=0,data=[],pos=None): """ column types: 0: Y 1: Disregard 2: Y Error 3: X 4: Label 5: Z 6: X Error """ if pos is None: pos=len(self.co...
def colAdd(self,name="",desc="",unit="",comment="",coltype=0,data=[],pos=None): """ column types: 0: Y 1: Disregard 2: Y Error 3: X 4: Label 5: Z 6: X Error """ if pos is None: pos=len(self.co...
[ "column", "types", ":", "0", ":", "Y", "1", ":", "Disregard", "2", ":", "Y", "Error", "3", ":", "X", "4", ":", "Label", "5", ":", "Z", "6", ":", "X", "Error" ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L49-L68
[ "def", "colAdd", "(", "self", ",", "name", "=", "\"\"", ",", "desc", "=", "\"\"", ",", "unit", "=", "\"\"", ",", "comment", "=", "\"\"", ",", "coltype", "=", "0", ",", "data", "=", "[", "]", ",", "pos", "=", "None", ")", ":", "if", "pos", "is...
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
SHEET.colDelete
delete a column at a single index. Negative numbers count from the end.
PyOriginTools/workbook.py
def colDelete(self,colI=-1): """delete a column at a single index. Negative numbers count from the end.""" # print("DELETING COLUMN: [%d] %s"%(colI,self.colDesc[colI])) self.colNames.pop(colI) self.colDesc.pop(colI) self.colUnits.pop(colI) self.colComments.pop(colI) ...
def colDelete(self,colI=-1): """delete a column at a single index. Negative numbers count from the end.""" # print("DELETING COLUMN: [%d] %s"%(colI,self.colDesc[colI])) self.colNames.pop(colI) self.colDesc.pop(colI) self.colUnits.pop(colI) self.colComments.pop(colI) ...
[ "delete", "a", "column", "at", "a", "single", "index", ".", "Negative", "numbers", "count", "from", "the", "end", "." ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L70-L79
[ "def", "colDelete", "(", "self", ",", "colI", "=", "-", "1", ")", ":", "# print(\"DELETING COLUMN: [%d] %s\"%(colI,self.colDesc[colI]))", "self", ".", "colNames", ".", "pop", "(", "colI", ")", "self", ".", "colDesc", ".", "pop", "(", "colI", ")", "self"...
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
SHEET.onex
delete all X columns except the first one.
PyOriginTools/workbook.py
def onex(self): """ delete all X columns except the first one. """ xCols=[i for i in range(self.nCols) if self.colTypes[i]==3] if len(xCols)>1: for colI in xCols[1:][::-1]: self.colDelete(colI)
def onex(self): """ delete all X columns except the first one. """ xCols=[i for i in range(self.nCols) if self.colTypes[i]==3] if len(xCols)>1: for colI in xCols[1:][::-1]: self.colDelete(colI)
[ "delete", "all", "X", "columns", "except", "the", "first", "one", "." ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L81-L88
[ "def", "onex", "(", "self", ")", ":", "xCols", "=", "[", "i", "for", "i", "in", "range", "(", "self", ".", "nCols", ")", "if", "self", ".", "colTypes", "[", "i", "]", "==", "3", "]", "if", "len", "(", "xCols", ")", ">", "1", ":", "for", "co...
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
SHEET.alignXY
aligns XY pairs (or XYYY etc) by X value.
PyOriginTools/workbook.py
def alignXY(self): """aligns XY pairs (or XYYY etc) by X value.""" # figure out what data we have and will align to xVals=[] xCols=[x for x in range(self.nCols) if self.colTypes[x]==3] yCols=[x for x in range(self.nCols) if self.colTypes[x]==0] xCols,yCols=np.array(xCols...
def alignXY(self): """aligns XY pairs (or XYYY etc) by X value.""" # figure out what data we have and will align to xVals=[] xCols=[x for x in range(self.nCols) if self.colTypes[x]==3] yCols=[x for x in range(self.nCols) if self.colTypes[x]==0] xCols,yCols=np.array(xCols...
[ "aligns", "XY", "pairs", "(", "or", "XYYY", "etc", ")", "by", "X", "value", "." ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L90-L127
[ "def", "alignXY", "(", "self", ")", ":", "# figure out what data we have and will align to", "xVals", "=", "[", "]", "xCols", "=", "[", "x", "for", "x", "in", "range", "(", "self", ".", "nCols", ")", "if", "self", ".", "colTypes", "[", "x", "]", "==", ...
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
SHEET.wiggle
Slightly changes value of every cell in the worksheet. Used for testing.
PyOriginTools/workbook.py
def wiggle(self,noiseLevel=.1): """Slightly changes value of every cell in the worksheet. Used for testing.""" noise=(np.random.rand(*self.data.shape))-.5 self.data=self.data+noise*noiseLevel
def wiggle(self,noiseLevel=.1): """Slightly changes value of every cell in the worksheet. Used for testing.""" noise=(np.random.rand(*self.data.shape))-.5 self.data=self.data+noise*noiseLevel
[ "Slightly", "changes", "value", "of", "every", "cell", "in", "the", "worksheet", ".", "Used", "for", "testing", "." ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L131-L134
[ "def", "wiggle", "(", "self", ",", "noiseLevel", "=", ".1", ")", ":", "noise", "=", "(", "np", ".", "random", ".", "rand", "(", "*", "self", ".", "data", ".", "shape", ")", ")", "-", ".5", "self", ".", "data", "=", "self", ".", "data", "+", "...
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
SHEET.pull
pull data into this OR.SHEET from a real book/sheet in Origin
PyOriginTools/workbook.py
def pull(self,bookName=None,sheetName=None): """pull data into this OR.SHEET from a real book/sheet in Origin""" # tons of validation if bookName is None and self.bookName: bookName=self.bookName if sheetName is None and self.sheetName: sheetName=self.sheetName if bookName is No...
def pull(self,bookName=None,sheetName=None): """pull data into this OR.SHEET from a real book/sheet in Origin""" # tons of validation if bookName is None and self.bookName: bookName=self.bookName if sheetName is None and self.sheetName: sheetName=self.sheetName if bookName is No...
[ "pull", "data", "into", "this", "OR", ".", "SHEET", "from", "a", "real", "book", "/", "sheet", "in", "Origin" ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L138-L160
[ "def", "pull", "(", "self", ",", "bookName", "=", "None", ",", "sheetName", "=", "None", ")", ":", "# tons of validation", "if", "bookName", "is", "None", "and", "self", ".", "bookName", ":", "bookName", "=", "self", ".", "bookName", "if", "sheetName", "...
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
SHEET.push
pull this OR.SHEET into a real book/sheet in Origin
PyOriginTools/workbook.py
def push(self,bookName=None,sheetName=None,overwrite=False): """pull this OR.SHEET into a real book/sheet in Origin""" # tons of validation if bookName: self.bookName=bookName if sheetName: self.sheetName=sheetName if not self.sheetName in OR.sheetNames(bookName): pri...
def push(self,bookName=None,sheetName=None,overwrite=False): """pull this OR.SHEET into a real book/sheet in Origin""" # tons of validation if bookName: self.bookName=bookName if sheetName: self.sheetName=sheetName if not self.sheetName in OR.sheetNames(bookName): pri...
[ "pull", "this", "OR", ".", "SHEET", "into", "a", "real", "book", "/", "sheet", "in", "Origin" ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L162-L186
[ "def", "push", "(", "self", ",", "bookName", "=", "None", ",", "sheetName", "=", "None", ",", "overwrite", "=", "False", ")", ":", "# tons of validation", "if", "bookName", ":", "self", ".", "bookName", "=", "bookName", "if", "sheetName", ":", "self", "....
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
SHEET.nRows
returns maximum number of rows based on the longest colData
PyOriginTools/workbook.py
def nRows(self): """returns maximum number of rows based on the longest colData""" if self.nCols: return max([len(x) for x in self.colData]) else: return 0
def nRows(self): """returns maximum number of rows based on the longest colData""" if self.nCols: return max([len(x) for x in self.colData]) else: return 0
[ "returns", "maximum", "number", "of", "rows", "based", "on", "the", "longest", "colData" ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L191-L194
[ "def", "nRows", "(", "self", ")", ":", "if", "self", ".", "nCols", ":", "return", "max", "(", "[", "len", "(", "x", ")", "for", "x", "in", "self", ".", "colData", "]", ")", "else", ":", "return", "0" ]
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
SHEET.data
return all of colData as a 2D numpy array.
PyOriginTools/workbook.py
def data(self): """return all of colData as a 2D numpy array.""" data=np.empty((self.nRows,self.nCols),dtype=np.float) data[:]=np.nan # make everything nan by default for colNum,colData in enumerate(self.colData): validIs=np.where([np.isreal(v) for v in colData])[0] ...
def data(self): """return all of colData as a 2D numpy array.""" data=np.empty((self.nRows,self.nCols),dtype=np.float) data[:]=np.nan # make everything nan by default for colNum,colData in enumerate(self.colData): validIs=np.where([np.isreal(v) for v in colData])[0] ...
[ "return", "all", "of", "colData", "as", "a", "2D", "numpy", "array", "." ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L204-L214
[ "def", "data", "(", "self", ")", ":", "data", "=", "np", ".", "empty", "(", "(", "self", ".", "nRows", ",", "self", ".", "nCols", ")", ",", "dtype", "=", "np", ".", "float", ")", "data", "[", ":", "]", "=", "np", ".", "nan", "# make everything ...
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
SHEET.data
Given a 2D numpy array, fill colData with it.
PyOriginTools/workbook.py
def data(self,data): """Given a 2D numpy array, fill colData with it.""" assert type(data) is np.ndarray assert data.shape[1] == self.nCols for i in range(self.nCols): self.colData[i]=data[:,i].tolist()
def data(self,data): """Given a 2D numpy array, fill colData with it.""" assert type(data) is np.ndarray assert data.shape[1] == self.nCols for i in range(self.nCols): self.colData[i]=data[:,i].tolist()
[ "Given", "a", "2D", "numpy", "array", "fill", "colData", "with", "it", "." ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/workbook.py#L217-L222
[ "def", "data", "(", "self", ",", "data", ")", ":", "assert", "type", "(", "data", ")", "is", "np", ".", "ndarray", "assert", "data", ".", "shape", "[", "1", "]", "==", "self", ".", "nCols", "for", "i", "in", "range", "(", "self", ".", "nCols", ...
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
Spinbox.focusout
Change style on focus out events.
tkcolorpicker/spinbox.py
def focusout(self, event): """Change style on focus out events.""" bc = self.style.lookup("TEntry", "bordercolor", ("!focus",)) dc = self.style.lookup("TEntry", "darkcolor", ("!focus",)) lc = self.style.lookup("TEntry", "lightcolor", ("!focus",)) self.style.configure("%s.spinbox....
def focusout(self, event): """Change style on focus out events.""" bc = self.style.lookup("TEntry", "bordercolor", ("!focus",)) dc = self.style.lookup("TEntry", "darkcolor", ("!focus",)) lc = self.style.lookup("TEntry", "lightcolor", ("!focus",)) self.style.configure("%s.spinbox....
[ "Change", "style", "on", "focus", "out", "events", "." ]
j4321/tkColorPicker
python
https://github.com/j4321/tkColorPicker/blob/ee2d583115e0c7ad7f29795763fc6b4ddc4e8c1d/tkcolorpicker/spinbox.py#L99-L105
[ "def", "focusout", "(", "self", ",", "event", ")", ":", "bc", "=", "self", ".", "style", ".", "lookup", "(", "\"TEntry\"", ",", "\"bordercolor\"", ",", "(", "\"!focus\"", ",", ")", ")", "dc", "=", "self", ".", "style", ".", "lookup", "(", "\"TEntry\"...
ee2d583115e0c7ad7f29795763fc6b4ddc4e8c1d
train
Spinbox.focusin
Change style on focus in events.
tkcolorpicker/spinbox.py
def focusin(self, event): """Change style on focus in events.""" self.old_value = self.get() bc = self.style.lookup("TEntry", "bordercolor", ("focus",)) dc = self.style.lookup("TEntry", "darkcolor", ("focus",)) lc = self.style.lookup("TEntry", "lightcolor", ("focus",)) se...
def focusin(self, event): """Change style on focus in events.""" self.old_value = self.get() bc = self.style.lookup("TEntry", "bordercolor", ("focus",)) dc = self.style.lookup("TEntry", "darkcolor", ("focus",)) lc = self.style.lookup("TEntry", "lightcolor", ("focus",)) se...
[ "Change", "style", "on", "focus", "in", "events", "." ]
j4321/tkColorPicker
python
https://github.com/j4321/tkColorPicker/blob/ee2d583115e0c7ad7f29795763fc6b4ddc4e8c1d/tkcolorpicker/spinbox.py#L107-L114
[ "def", "focusin", "(", "self", ",", "event", ")", ":", "self", ".", "old_value", "=", "self", ".", "get", "(", ")", "bc", "=", "self", ".", "style", ".", "lookup", "(", "\"TEntry\"", ",", "\"bordercolor\"", ",", "(", "\"focus\"", ",", ")", ")", "dc...
ee2d583115e0c7ad7f29795763fc6b4ddc4e8c1d
train
LVM.open
Obtains the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError
lvm2py/lvm.py
def open(self): """ Obtains the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if not self.handle: try: ...
def open(self): """ Obtains the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if not self.handle: try: ...
[ "Obtains", "the", "lvm", "handle", ".", "Usually", "you", "would", "never", "need", "to", "use", "this", "method", "unless", "you", "are", "trying", "to", "do", "operations", "using", "the", "ctypes", "function", "wrappers", "in", "conversion", ".", "py" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L57-L73
[ "def", "open", "(", "self", ")", ":", "if", "not", "self", ".", "handle", ":", "try", ":", "path", "=", "self", ".", "system_dir", "except", "AttributeError", ":", "path", "=", "''", "self", ".", "__handle", "=", "lvm_init", "(", "path", ")", "if", ...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
LVM.close
Closes the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError
lvm2py/lvm.py
def close(self): """ Closes the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if self.handle: q = lvm_quit(self...
def close(self): """ Closes the lvm handle. Usually you would never need to use this method unless you are trying to do operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if self.handle: q = lvm_quit(self...
[ "Closes", "the", "lvm", "handle", ".", "Usually", "you", "would", "never", "need", "to", "use", "this", "method", "unless", "you", "are", "trying", "to", "do", "operations", "using", "the", "ctypes", "function", "wrappers", "in", "conversion", ".", "py" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L75-L88
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "handle", ":", "q", "=", "lvm_quit", "(", "self", ".", "handle", ")", "if", "q", "!=", "0", ":", "raise", "HandleError", "(", "\"Failed to close LVM handle.\"", ")", "self", ".", "__handle", "="...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
LVM.get_vg
Returns an instance of VolumeGroup. The name parameter should be an existing volume group. By default, all volume groups are open in "read" mode:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") To open a volume group with write permissions set the mode pa...
lvm2py/lvm.py
def get_vg(self, name, mode="r"): """ Returns an instance of VolumeGroup. The name parameter should be an existing volume group. By default, all volume groups are open in "read" mode:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") To open...
def get_vg(self, name, mode="r"): """ Returns an instance of VolumeGroup. The name parameter should be an existing volume group. By default, all volume groups are open in "read" mode:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg") To open...
[ "Returns", "an", "instance", "of", "VolumeGroup", ".", "The", "name", "parameter", "should", "be", "an", "existing", "volume", "group", ".", "By", "default", "all", "volume", "groups", "are", "open", "in", "read", "mode", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L130-L157
[ "def", "get_vg", "(", "self", ",", "name", ",", "mode", "=", "\"r\"", ")", ":", "vg", "=", "VolumeGroup", "(", "self", ",", "name", "=", "name", ",", "mode", "=", "mode", ")", "return", "vg" ]
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
LVM.create_vg
Returns a new instance of VolumeGroup with the given name and added physycal volumes (devices):: from lvm2py import * lvm = LVM() vg = lvm.create_vg("myvg", ["/dev/sdb1", "/dev/sdb2"]) *Args:* * name (str): A volume group name. * ...
lvm2py/lvm.py
def create_vg(self, name, devices): """ Returns a new instance of VolumeGroup with the given name and added physycal volumes (devices):: from lvm2py import * lvm = LVM() vg = lvm.create_vg("myvg", ["/dev/sdb1", "/dev/sdb2"]) *Args:* * ...
def create_vg(self, name, devices): """ Returns a new instance of VolumeGroup with the given name and added physycal volumes (devices):: from lvm2py import * lvm = LVM() vg = lvm.create_vg("myvg", ["/dev/sdb1", "/dev/sdb2"]) *Args:* * ...
[ "Returns", "a", "new", "instance", "of", "VolumeGroup", "with", "the", "given", "name", "and", "added", "physycal", "volumes", "(", "devices", ")", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L159-L198
[ "def", "create_vg", "(", "self", ",", "name", ",", "devices", ")", ":", "self", ".", "open", "(", ")", "vgh", "=", "lvm_vg_create", "(", "self", ".", "handle", ",", "name", ")", "if", "not", "bool", "(", "vgh", ")", ":", "self", ".", "close", "("...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
LVM.remove_vg
Removes a volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lvm.remove_vg(vg) *Args:* * vg (obj): A VolumeGroup instance. *Raises:* * HandleError, CommitError .. note:: ...
lvm2py/lvm.py
def remove_vg(self, vg): """ Removes a volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lvm.remove_vg(vg) *Args:* * vg (obj): A VolumeGroup instance. *Raises:* * HandleErro...
def remove_vg(self, vg): """ Removes a volume group:: from lvm2py import * lvm = LVM() vg = lvm.get_vg("myvg", "w") lvm.remove_vg(vg) *Args:* * vg (obj): A VolumeGroup instance. *Raises:* * HandleErro...
[ "Removes", "a", "volume", "group", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L200-L232
[ "def", "remove_vg", "(", "self", ",", "vg", ")", ":", "vg", ".", "open", "(", ")", "rm", "=", "lvm_vg_remove", "(", "vg", ".", "handle", ")", "if", "rm", "!=", "0", ":", "vg", ".", "close", "(", ")", "raise", "CommitError", "(", "\"Failed to remove...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
LVM.vgscan
Probes the system for volume groups and returns a list of VolumeGroup instances:: from lvm2py import * lvm = LVM() vgs = lvm.vgscan() *Raises:* * HandleError
lvm2py/lvm.py
def vgscan(self): """ Probes the system for volume groups and returns a list of VolumeGroup instances:: from lvm2py import * lvm = LVM() vgs = lvm.vgscan() *Raises:* * HandleError """ vg_list = [] self.open() ...
def vgscan(self): """ Probes the system for volume groups and returns a list of VolumeGroup instances:: from lvm2py import * lvm = LVM() vgs = lvm.vgscan() *Raises:* * HandleError """ vg_list = [] self.open() ...
[ "Probes", "the", "system", "for", "volume", "groups", "and", "returns", "a", "list", "of", "VolumeGroup", "instances", "::" ]
xzased/lvm2py
python
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/lvm.py#L234-L266
[ "def", "vgscan", "(", "self", ")", ":", "vg_list", "=", "[", "]", "self", ".", "open", "(", ")", "names", "=", "lvm_list_vg_names", "(", "self", ".", "handle", ")", "if", "not", "bool", "(", "names", ")", ":", "return", "vg_list", "vgnames", "=", "...
34ce69304531a474c2fe4a4009ca445a8c103cd6
train
Text.from_file
Create a text from a file. Args: path (str): The file path.
textplot/text.py
def from_file(cls, path): """ Create a text from a file. Args: path (str): The file path. """ with open(path, 'r', errors='replace') as f: return cls(f.read())
def from_file(cls, path): """ Create a text from a file. Args: path (str): The file path. """ with open(path, 'r', errors='replace') as f: return cls(f.read())
[ "Create", "a", "text", "from", "a", "file", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L22-L32
[ "def", "from_file", "(", "cls", ",", "path", ")", ":", "with", "open", "(", "path", ",", "'r'", ",", "errors", "=", "'replace'", ")", "as", "f", ":", "return", "cls", "(", "f", ".", "read", "(", ")", ")" ]
889b949a637d99097ecec44ed4bfee53b1964dee
train
Text.load_stopwords
Load a set of stopwords. Args: path (str): The stopwords file path.
textplot/text.py
def load_stopwords(self, path): """ Load a set of stopwords. Args: path (str): The stopwords file path. """ if path: with open(path) as f: self.stopwords = set(f.read().splitlines()) else: self.stopwords = set( ...
def load_stopwords(self, path): """ Load a set of stopwords. Args: path (str): The stopwords file path. """ if path: with open(path) as f: self.stopwords = set(f.read().splitlines()) else: self.stopwords = set( ...
[ "Load", "a", "set", "of", "stopwords", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L50-L69
[ "def", "load_stopwords", "(", "self", ",", "path", ")", ":", "if", "path", ":", "with", "open", "(", "path", ")", "as", "f", ":", "self", ".", "stopwords", "=", "set", "(", "f", ".", "read", "(", ")", ".", "splitlines", "(", ")", ")", "else", "...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Text.tokenize
Tokenize the text.
textplot/text.py
def tokenize(self): """ Tokenize the text. """ self.tokens = [] self.terms = OrderedDict() # Generate tokens. for token in utils.tokenize(self.text): # Ignore stopwords. if token['unstemmed'] in self.stopwords: self.toke...
def tokenize(self): """ Tokenize the text. """ self.tokens = [] self.terms = OrderedDict() # Generate tokens. for token in utils.tokenize(self.text): # Ignore stopwords. if token['unstemmed'] in self.stopwords: self.toke...
[ "Tokenize", "the", "text", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L72-L95
[ "def", "tokenize", "(", "self", ")", ":", "self", ".", "tokens", "=", "[", "]", "self", ".", "terms", "=", "OrderedDict", "(", ")", "# Generate tokens.", "for", "token", "in", "utils", ".", "tokenize", "(", "self", ".", "text", ")", ":", "# Ignore stop...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Text.term_counts
Returns: OrderedDict: An ordered dictionary of term counts.
textplot/text.py
def term_counts(self): """ Returns: OrderedDict: An ordered dictionary of term counts. """ counts = OrderedDict() for term in self.terms: counts[term] = len(self.terms[term]) return utils.sort_dict(counts)
def term_counts(self): """ Returns: OrderedDict: An ordered dictionary of term counts. """ counts = OrderedDict() for term in self.terms: counts[term] = len(self.terms[term]) return utils.sort_dict(counts)
[ "Returns", ":", "OrderedDict", ":", "An", "ordered", "dictionary", "of", "term", "counts", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L98-L109
[ "def", "term_counts", "(", "self", ")", ":", "counts", "=", "OrderedDict", "(", ")", "for", "term", "in", "self", ".", "terms", ":", "counts", "[", "term", "]", "=", "len", "(", "self", ".", "terms", "[", "term", "]", ")", "return", "utils", ".", ...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Text.term_count_buckets
Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text.
textplot/text.py
def term_count_buckets(self): """ Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text. """ buckets = {} for term, count in self.term_counts().items(): if count in buckets: buckets[count...
def term_count_buckets(self): """ Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text. """ buckets = {} for term, count in self.term_counts().items(): if count in buckets: buckets[count...
[ "Returns", ":", "dict", ":", "A", "dictionary", "that", "maps", "occurrence", "counts", "to", "the", "terms", "that", "appear", "that", "many", "times", "in", "the", "text", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L112-L125
[ "def", "term_count_buckets", "(", "self", ")", ":", "buckets", "=", "{", "}", "for", "term", ",", "count", "in", "self", ".", "term_counts", "(", ")", ".", "items", "(", ")", ":", "if", "count", "in", "buckets", ":", "buckets", "[", "count", "]", "...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Text.most_frequent_terms
Get the X most frequent terms in the text, and then probe down to get any other terms that have the same count as the last term. Args: depth (int): The number of terms. Returns: set: The set of frequent terms.
textplot/text.py
def most_frequent_terms(self, depth): """ Get the X most frequent terms in the text, and then probe down to get any other terms that have the same count as the last term. Args: depth (int): The number of terms. Returns: set: The set of frequent terms. ...
def most_frequent_terms(self, depth): """ Get the X most frequent terms in the text, and then probe down to get any other terms that have the same count as the last term. Args: depth (int): The number of terms. Returns: set: The set of frequent terms. ...
[ "Get", "the", "X", "most", "frequent", "terms", "in", "the", "text", "and", "then", "probe", "down", "to", "get", "any", "other", "terms", "that", "have", "the", "same", "count", "as", "the", "last", "term", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L128-L152
[ "def", "most_frequent_terms", "(", "self", ",", "depth", ")", ":", "counts", "=", "self", ".", "term_counts", "(", ")", "# Get the top X terms and the instance count of the last word.", "top_terms", "=", "set", "(", "list", "(", "counts", ".", "keys", "(", ")", ...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Text.unstem
Given a stemmed term, get the most common unstemmed variant. Args: term (str): A stemmed term. Returns: str: The unstemmed token.
textplot/text.py
def unstem(self, term): """ Given a stemmed term, get the most common unstemmed variant. Args: term (str): A stemmed term. Returns: str: The unstemmed token. """ originals = [] for i in self.terms[term]: originals.append(sel...
def unstem(self, term): """ Given a stemmed term, get the most common unstemmed variant. Args: term (str): A stemmed term. Returns: str: The unstemmed token. """ originals = [] for i in self.terms[term]: originals.append(sel...
[ "Given", "a", "stemmed", "term", "get", "the", "most", "common", "unstemmed", "variant", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L155-L172
[ "def", "unstem", "(", "self", ",", "term", ")", ":", "originals", "=", "[", "]", "for", "i", "in", "self", ".", "terms", "[", "term", "]", ":", "originals", ".", "append", "(", "self", ".", "tokens", "[", "i", "]", "[", "'unstemmed'", "]", ")", ...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Text.kde
Estimate the kernel density of the instances of term in the text. Args: term (str): A stemmed term. bandwidth (int): The kernel bandwidth. samples (int): The number of evenly-spaced sample points. kernel (str): The kernel function. Returns: n...
textplot/text.py
def kde(self, term, bandwidth=2000, samples=1000, kernel='gaussian'): """ Estimate the kernel density of the instances of term in the text. Args: term (str): A stemmed term. bandwidth (int): The kernel bandwidth. samples (int): The number of evenly-spaced sa...
def kde(self, term, bandwidth=2000, samples=1000, kernel='gaussian'): """ Estimate the kernel density of the instances of term in the text. Args: term (str): A stemmed term. bandwidth (int): The kernel bandwidth. samples (int): The number of evenly-spaced sa...
[ "Estimate", "the", "kernel", "density", "of", "the", "instances", "of", "term", "in", "the", "text", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L176-L202
[ "def", "kde", "(", "self", ",", "term", ",", "bandwidth", "=", "2000", ",", "samples", "=", "1000", ",", "kernel", "=", "'gaussian'", ")", ":", "# Get the offsets of the term instances.", "terms", "=", "np", ".", "array", "(", "self", ".", "terms", "[", ...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Text.score_intersect
Compute the geometric area of the overlap between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float
textplot/text.py
def score_intersect(self, term1, term2, **kwargs): """ Compute the geometric area of the overlap between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kwargs) ...
def score_intersect(self, term1, term2, **kwargs): """ Compute the geometric area of the overlap between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kwargs) ...
[ "Compute", "the", "geometric", "area", "of", "the", "overlap", "between", "the", "kernel", "density", "estimates", "of", "two", "terms", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L205-L223
[ "def", "score_intersect", "(", "self", ",", "term1", ",", "term2", ",", "*", "*", "kwargs", ")", ":", "t1_kde", "=", "self", ".", "kde", "(", "term1", ",", "*", "*", "kwargs", ")", "t2_kde", "=", "self", ".", "kde", "(", "term2", ",", "*", "*", ...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Text.score_cosine
Compute a weighting score based on the cosine distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float
textplot/text.py
def score_cosine(self, term1, term2, **kwargs): """ Compute a weighting score based on the cosine distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kw...
def score_cosine(self, term1, term2, **kwargs): """ Compute a weighting score based on the cosine distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kw...
[ "Compute", "a", "weighting", "score", "based", "on", "the", "cosine", "distance", "between", "the", "kernel", "density", "estimates", "of", "two", "terms", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L226-L242
[ "def", "score_cosine", "(", "self", ",", "term1", ",", "term2", ",", "*", "*", "kwargs", ")", ":", "t1_kde", "=", "self", ".", "kde", "(", "term1", ",", "*", "*", "kwargs", ")", "t2_kde", "=", "self", ".", "kde", "(", "term2", ",", "*", "*", "k...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Text.score_braycurtis
Compute a weighting score based on the "City Block" distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float
textplot/text.py
def score_braycurtis(self, term1, term2, **kwargs): """ Compute a weighting score based on the "City Block" distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(t...
def score_braycurtis(self, term1, term2, **kwargs): """ Compute a weighting score based on the "City Block" distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(t...
[ "Compute", "a", "weighting", "score", "based", "on", "the", "City", "Block", "distance", "between", "the", "kernel", "density", "estimates", "of", "two", "terms", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L245-L261
[ "def", "score_braycurtis", "(", "self", ",", "term1", ",", "term2", ",", "*", "*", "kwargs", ")", ":", "t1_kde", "=", "self", ".", "kde", "(", "term1", ",", "*", "*", "kwargs", ")", "t2_kde", "=", "self", ".", "kde", "(", "term2", ",", "*", "*", ...
889b949a637d99097ecec44ed4bfee53b1964dee
train
Text.plot_term_kdes
Plot kernel density estimates for multiple words. Args: words (list): A list of unstemmed terms.
textplot/text.py
def plot_term_kdes(self, words, **kwargs): """ Plot kernel density estimates for multiple words. Args: words (list): A list of unstemmed terms. """ stem = PorterStemmer().stem for word in words: kde = self.kde(stem(word), **kwargs) ...
def plot_term_kdes(self, words, **kwargs): """ Plot kernel density estimates for multiple words. Args: words (list): A list of unstemmed terms. """ stem = PorterStemmer().stem for word in words: kde = self.kde(stem(word), **kwargs) ...
[ "Plot", "kernel", "density", "estimates", "for", "multiple", "words", "." ]
davidmcclure/textplot
python
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L264-L279
[ "def", "plot_term_kdes", "(", "self", ",", "words", ",", "*", "*", "kwargs", ")", ":", "stem", "=", "PorterStemmer", "(", ")", ".", "stem", "for", "word", "in", "words", ":", "kde", "=", "self", ".", "kde", "(", "stem", "(", "word", ")", ",", "*"...
889b949a637d99097ecec44ed4bfee53b1964dee
train
MongoFormFieldGenerator.generate
Tries to lookup a matching formfield generator (lowercase field-classname) and raises a NotImplementedError of no generator can be found.
mongoforms/fields.py
def generate(self, field_name, field): """Tries to lookup a matching formfield generator (lowercase field-classname) and raises a NotImplementedError of no generator can be found. """ if hasattr(self, 'generate_%s' % field.__class__.__name__.lower()): generator = get...
def generate(self, field_name, field): """Tries to lookup a matching formfield generator (lowercase field-classname) and raises a NotImplementedError of no generator can be found. """ if hasattr(self, 'generate_%s' % field.__class__.__name__.lower()): generator = get...
[ "Tries", "to", "lookup", "a", "matching", "formfield", "generator", "(", "lowercase", "field", "-", "classname", ")", "and", "raises", "a", "NotImplementedError", "of", "no", "generator", "can", "be", "found", "." ]
stephrdev/django-mongoforms
python
https://github.com/stephrdev/django-mongoforms/blob/6fa46824c438555c703f293d682ca92710938985/mongoforms/fields.py#L49-L65
[ "def", "generate", "(", "self", ",", "field_name", ",", "field", ")", ":", "if", "hasattr", "(", "self", ",", "'generate_%s'", "%", "field", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", ")", ":", "generator", "=", "getattr", "(", "self", ...
6fa46824c438555c703f293d682ca92710938985
train
List._fixIndex
@param truncate: If true, negative indices which go past the beginning of the list will be evaluated as zero. For example:: >>> L = List([1,2,3,4,5]) >>> len(L) 5 >>> L....
axiom/sequence.py
def _fixIndex(self, index, truncate=False): """ @param truncate: If true, negative indices which go past the beginning of the list will be evaluated as zero. For example:: >>> L = List([1,2,3,4,5]) >>> l...
def _fixIndex(self, index, truncate=False): """ @param truncate: If true, negative indices which go past the beginning of the list will be evaluated as zero. For example:: >>> L = List([1,2,3,4,5]) >>> l...
[ "@param", "truncate", ":", "If", "true", "negative", "indices", "which", "go", "past", "the", "beginning", "of", "the", "list", "will", "be", "evaluated", "as", "zero", ".", "For", "example", "::" ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/sequence.py#L40-L60
[ "def", "_fixIndex", "(", "self", ",", "index", ",", "truncate", "=", "False", ")", ":", "assert", "not", "isinstance", "(", "index", ",", "slice", ")", ",", "'slices are not supported (yet)'", "if", "index", "<", "0", ":", "index", "+=", "self", ".", "le...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
overlapping
Return an L{axiom.iaxiom.IComparison} (an object that can be passed as the 'comparison' argument to Store.query/.sum/.count) which will constrain a query against 2 attributes for ranges which overlap with the given arguments. For a database with Items of class O which represent values in this confi...
axiom/queryutil.py
def overlapping(startAttribute, # X endAttribute, # Y startValue, # A endValue, # B ): """ Return an L{axiom.iaxiom.IComparison} (an object that can be passed as the 'comparison' argument to Store.query/.sum/.count) which will const...
def overlapping(startAttribute, # X endAttribute, # Y startValue, # A endValue, # B ): """ Return an L{axiom.iaxiom.IComparison} (an object that can be passed as the 'comparison' argument to Store.query/.sum/.count) which will const...
[ "Return", "an", "L", "{", "axiom", ".", "iaxiom", ".", "IComparison", "}", "(", "an", "object", "that", "can", "be", "passed", "as", "the", "comparison", "argument", "to", "Store", ".", "query", "/", ".", "sum", "/", ".", "count", ")", "which", "will...
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/queryutil.py#L21-L88
[ "def", "overlapping", "(", "startAttribute", ",", "# X", "endAttribute", ",", "# Y", "startValue", ",", "# A", "endValue", ",", "# B", ")", ":", "assert", "startValue", "<=", "endValue", "return", "OR", "(", "AND", "(", "startAttribute", ">=", "startValue", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
_tupleCompare
Compare two 'in-database tuples'. Useful when sorting by a compound key and slicing into the middle of that query.
axiom/queryutil.py
def _tupleCompare(tuple1, ineq, tuple2, eq=lambda a,b: (a==b), ander=AND, orer=OR): """ Compare two 'in-database tuples'. Useful when sorting by a compound key and slicing into the middle of that query. """ orholder = [] for limit in range(len...
def _tupleCompare(tuple1, ineq, tuple2, eq=lambda a,b: (a==b), ander=AND, orer=OR): """ Compare two 'in-database tuples'. Useful when sorting by a compound key and slicing into the middle of that query. """ orholder = [] for limit in range(len...
[ "Compare", "two", "in", "-", "database", "tuples", ".", "Useful", "when", "sorting", "by", "a", "compound", "key", "and", "slicing", "into", "the", "middle", "of", "that", "query", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/queryutil.py#L90-L105
[ "def", "_tupleCompare", "(", "tuple1", ",", "ineq", ",", "tuple2", ",", "eq", "=", "lambda", "a", ",", "b", ":", "(", "a", "==", "b", ")", ",", "ander", "=", "AND", ",", "orer", "=", "OR", ")", ":", "orholder", "=", "[", "]", "for", "limit", ...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
truncate_rationale
Truncates the rationale for analytics event emission if necessary Args: rationale (string): the string value of the rationale max_length (int): the max length for truncation Returns: truncated_value (string): the possibly truncated version of the rationale was_truncated (bool):...
ubcpi/ubcpi.py
def truncate_rationale(rationale, max_length=MAX_RATIONALE_SIZE_IN_EVENT): """ Truncates the rationale for analytics event emission if necessary Args: rationale (string): the string value of the rationale max_length (int): the max length for truncation Returns: truncated_value ...
def truncate_rationale(rationale, max_length=MAX_RATIONALE_SIZE_IN_EVENT): """ Truncates the rationale for analytics event emission if necessary Args: rationale (string): the string value of the rationale max_length (int): the max length for truncation Returns: truncated_value ...
[ "Truncates", "the", "rationale", "for", "analytics", "event", "emission", "if", "necessary" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/ubcpi.py#L33-L49
[ "def", "truncate_rationale", "(", "rationale", ",", "max_length", "=", "MAX_RATIONALE_SIZE_IN_EVENT", ")", ":", "if", "isinstance", "(", "rationale", ",", "basestring", ")", "and", "max_length", "is", "not", "None", "and", "len", "(", "rationale", ")", ">", "m...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
validate_options
Validate the options that course author set up and return errors in a dict if there is any
ubcpi/ubcpi.py
def validate_options(options): """ Validate the options that course author set up and return errors in a dict if there is any """ errors = [] if int(options['rationale_size']['min']) < 1: errors.append(_('Minimum Characters')) if int(options['rationale_size']['max']) < 0 or int(options[...
def validate_options(options): """ Validate the options that course author set up and return errors in a dict if there is any """ errors = [] if int(options['rationale_size']['min']) < 1: errors.append(_('Minimum Characters')) if int(options['rationale_size']['max']) < 0 or int(options[...
[ "Validate", "the", "options", "that", "course", "author", "set", "up", "and", "return", "errors", "in", "a", "dict", "if", "there", "is", "any" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/ubcpi.py#L52-L74
[ "def", "validate_options", "(", "options", ")", ":", "errors", "=", "[", "]", "if", "int", "(", "options", "[", "'rationale_size'", "]", "[", "'min'", "]", ")", "<", "1", ":", "errors", ".", "append", "(", "_", "(", "'Minimum Characters'", ")", ")", ...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
MissingDataFetcherMixin.get_student_item_dict
Create a student_item_dict from our surrounding context. See also: submissions.api for details. Args: anonymous_user_id(str): A unique anonymous_user_id for (user, course) pair. Returns: (dict): The student item associated with this XBlock instance. This ...
ubcpi/ubcpi.py
def get_student_item_dict(self, anonymous_user_id=None): """Create a student_item_dict from our surrounding context. See also: submissions.api for details. Args: anonymous_user_id(str): A unique anonymous_user_id for (user, course) pair. Returns: (dict): The stu...
def get_student_item_dict(self, anonymous_user_id=None): """Create a student_item_dict from our surrounding context. See also: submissions.api for details. Args: anonymous_user_id(str): A unique anonymous_user_id for (user, course) pair. Returns: (dict): The stu...
[ "Create", "a", "student_item_dict", "from", "our", "surrounding", "context", "." ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/ubcpi.py#L87-L123
[ "def", "get_student_item_dict", "(", "self", ",", "anonymous_user_id", "=", "None", ")", ":", "item_id", "=", "self", ".", "_serialize_opaque_key", "(", "self", ".", "scope_ids", ".", "usage_id", ")", "# This is not the real way course_ids should work, but this is a", "...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
get_answers_for_student
Retrieve answers from backend for a student and question Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. Returns: Answers: answers for the student
ubcpi/persistence.py
def get_answers_for_student(student_item): """ Retrieve answers from backend for a student and question Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. Returns: Answers: answers for the st...
def get_answers_for_student(student_item): """ Retrieve answers from backend for a student and question Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. Returns: Answers: answers for the st...
[ "Retrieve", "answers", "from", "backend", "for", "a", "student", "and", "question" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L25-L42
[ "def", "get_answers_for_student", "(", "student_item", ")", ":", "submissions", "=", "sub_api", ".", "get_submissions", "(", "student_item", ")", "if", "not", "submissions", ":", "return", "Answers", "(", ")", "latest_submission", "=", "submissions", "[", "0", "...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
add_answer_for_student
Add an answer for a student to the backend Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. vote (int): the option that student voted for rationale (str): the reason why the student vote for the...
ubcpi/persistence.py
def add_answer_for_student(student_item, vote, rationale): """ Add an answer for a student to the backend Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. vote (int): the option that student vot...
def add_answer_for_student(student_item, vote, rationale): """ Add an answer for a student to the backend Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. vote (int): the option that student vot...
[ "Add", "an", "answer", "for", "a", "student", "to", "the", "backend" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L45-L60
[ "def", "add_answer_for_student", "(", "student_item", ",", "vote", ",", "rationale", ")", ":", "answers", "=", "get_answers_for_student", "(", "student_item", ")", "answers", ".", "add_answer", "(", "vote", ",", "rationale", ")", "sub_api", ".", "create_submission...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
Answers._safe_get
Get an answer data (vote or rationale) by revision Args: revision (int): the revision number for student answer, could be 0 (original) or 1 (revised) key (str); key for retrieve answer data, could be VOTE_KEY or RATIONALE_KEY Returns: ...
ubcpi/persistence.py
def _safe_get(self, revision, key): """ Get an answer data (vote or rationale) by revision Args: revision (int): the revision number for student answer, could be 0 (original) or 1 (revised) key (str); key for retrieve answer data, could be VOTE_KEY or ...
def _safe_get(self, revision, key): """ Get an answer data (vote or rationale) by revision Args: revision (int): the revision number for student answer, could be 0 (original) or 1 (revised) key (str); key for retrieve answer data, could be VOTE_KEY or ...
[ "Get", "an", "answer", "data", "(", "vote", "or", "rationale", ")", "by", "revision" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L77-L93
[ "def", "_safe_get", "(", "self", ",", "revision", ",", "key", ")", ":", "if", "self", ".", "has_revision", "(", "revision", ")", ":", "return", "self", ".", "raw_answers", "[", "revision", "]", ".", "get", "(", "key", ")", "else", ":", "return", "Non...
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
Answers.add_answer
Add an answer Args: vote (int): the option that student voted for rationale (str): the reason why the student vote for the option
ubcpi/persistence.py
def add_answer(self, vote, rationale): """ Add an answer Args: vote (int): the option that student voted for rationale (str): the reason why the student vote for the option """ self.raw_answers.append({ VOTE_KEY: vote, RATIONALE_KE...
def add_answer(self, vote, rationale): """ Add an answer Args: vote (int): the option that student voted for rationale (str): the reason why the student vote for the option """ self.raw_answers.append({ VOTE_KEY: vote, RATIONALE_KE...
[ "Add", "an", "answer" ]
ubc/ubcpi
python
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L134-L145
[ "def", "add_answer", "(", "self", ",", "vote", ",", "rationale", ")", ":", "self", ".", "raw_answers", ".", "append", "(", "{", "VOTE_KEY", ":", "vote", ",", "RATIONALE_KEY", ":", "rationale", ",", "}", ")" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
train
exceptionToString
when you "except Exception as e", give me the e and I'll give you a string.
documentation/PyOrigin-examples/examples.py
def exceptionToString(e,silent=False): """when you "except Exception as e", give me the e and I'll give you a string.""" exc_type, exc_obj, exc_tb = sys.exc_info() s=("\n"+"="*50+"\n") s+="EXCEPTION THROWN UNEXPECTEDLY\n" s+=" FILE: %s\n"%os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] s+=...
def exceptionToString(e,silent=False): """when you "except Exception as e", give me the e and I'll give you a string.""" exc_type, exc_obj, exc_tb = sys.exc_info() s=("\n"+"="*50+"\n") s+="EXCEPTION THROWN UNEXPECTEDLY\n" s+=" FILE: %s\n"%os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] s+=...
[ "when", "you", "except", "Exception", "as", "e", "give", "me", "the", "e", "and", "I", "ll", "give", "you", "a", "string", "." ]
swharden/PyOriginTools
python
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/documentation/PyOrigin-examples/examples.py#L38-L51
[ "def", "exceptionToString", "(", "e", ",", "silent", "=", "False", ")", ":", "exc_type", ",", "exc_obj", ",", "exc_tb", "=", "sys", ".", "exc_info", "(", ")", "s", "=", "(", "\"\\n\"", "+", "\"=\"", "*", "50", "+", "\"\\n\"", ")", "s", "+=", "\"EXC...
536fb8e11234ffdc27e26b1800e0358179ca7d26
train
SubStore.createNew
Create a new SubStore, allocating a new file space for it.
axiom/substore.py
def createNew(cls, store, pathSegments): """ Create a new SubStore, allocating a new file space for it. """ if isinstance(pathSegments, basestring): raise ValueError( 'Received %r instead of a sequence' % (pathSegments,)) if store.dbdir is None: ...
def createNew(cls, store, pathSegments): """ Create a new SubStore, allocating a new file space for it. """ if isinstance(pathSegments, basestring): raise ValueError( 'Received %r instead of a sequence' % (pathSegments,)) if store.dbdir is None: ...
[ "Create", "a", "new", "SubStore", "allocating", "a", "new", "file", "space", "for", "it", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/substore.py#L25-L39
[ "def", "createNew", "(", "cls", ",", "store", ",", "pathSegments", ")", ":", "if", "isinstance", "(", "pathSegments", ",", "basestring", ")", ":", "raise", "ValueError", "(", "'Received %r instead of a sequence'", "%", "(", "pathSegments", ",", ")", ")", "if",...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
SubStore.createStore
Create the actual Store this Substore represents.
axiom/substore.py
def createStore(self, debug, journalMode=None): """ Create the actual Store this Substore represents. """ if self.storepath is None: self.store._memorySubstores.append(self) # don't fall out of cache if self.store.filesdir is None: filesdir = None ...
def createStore(self, debug, journalMode=None): """ Create the actual Store this Substore represents. """ if self.storepath is None: self.store._memorySubstores.append(self) # don't fall out of cache if self.store.filesdir is None: filesdir = None ...
[ "Create", "the", "actual", "Store", "this", "Substore", "represents", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/substore.py#L62-L84
[ "def", "createStore", "(", "self", ",", "debug", ",", "journalMode", "=", "None", ")", ":", "if", "self", ".", "storepath", "is", "None", ":", "self", ".", "store", ".", "_memorySubstores", ".", "append", "(", "self", ")", "# don't fall out of cache", "if"...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
upgradeCatalog1to2
Create _TagName instances which version 2 of Catalog automatically creates for use in determining the tagNames result, but which version 1 of Catalog did not create.
axiom/tags.py
def upgradeCatalog1to2(oldCatalog): """ Create _TagName instances which version 2 of Catalog automatically creates for use in determining the tagNames result, but which version 1 of Catalog did not create. """ newCatalog = oldCatalog.upgradeVersion('tag_catalog', 1, 2, ...
def upgradeCatalog1to2(oldCatalog): """ Create _TagName instances which version 2 of Catalog automatically creates for use in determining the tagNames result, but which version 1 of Catalog did not create. """ newCatalog = oldCatalog.upgradeVersion('tag_catalog', 1, 2, ...
[ "Create", "_TagName", "instances", "which", "version", "2", "of", "Catalog", "automatically", "creates", "for", "use", "in", "determining", "the", "tagNames", "result", "but", "which", "version", "1", "of", "Catalog", "did", "not", "create", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/tags.py#L110-L122
[ "def", "upgradeCatalog1to2", "(", "oldCatalog", ")", ":", "newCatalog", "=", "oldCatalog", ".", "upgradeVersion", "(", "'tag_catalog'", ",", "1", ",", "2", ",", "tagCount", "=", "oldCatalog", ".", "tagCount", ")", "tags", "=", "newCatalog", ".", "store", "."...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
train
Catalog.tagNames
Return an iterator of unicode strings - the unique tag names which have been applied objects in this catalog.
axiom/tags.py
def tagNames(self): """ Return an iterator of unicode strings - the unique tag names which have been applied objects in this catalog. """ return self.store.query(_TagName, _TagName.catalog == self).getColumn("name")
def tagNames(self): """ Return an iterator of unicode strings - the unique tag names which have been applied objects in this catalog. """ return self.store.query(_TagName, _TagName.catalog == self).getColumn("name")
[ "Return", "an", "iterator", "of", "unicode", "strings", "-", "the", "unique", "tag", "names", "which", "have", "been", "applied", "objects", "in", "this", "catalog", "." ]
twisted/axiom
python
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/tags.py#L83-L88
[ "def", "tagNames", "(", "self", ")", ":", "return", "self", ".", "store", ".", "query", "(", "_TagName", ",", "_TagName", ".", "catalog", "==", "self", ")", ".", "getColumn", "(", "\"name\"", ")" ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68