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
test
CarddavObject._get_webpages
:rtype: list(list(str))
khard/carddav_object.py
def _get_webpages(self): """ :rtype: list(list(str)) """ urls = [] for child in self.vcard.getChildren(): if child.name == "URL": urls.append(child.value) return sorted(urls)
def _get_webpages(self): """ :rtype: list(list(str)) """ urls = [] for child in self.vcard.getChildren(): if child.name == "URL": urls.append(child.value) return sorted(urls)
[ ":", "rtype", ":", "list", "(", "list", "(", "str", "))" ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/carddav_object.py#L670-L678
[ "def", "_get_webpages", "(", "self", ")", ":", "urls", "=", "[", "]", "for", "child", "in", "self", ".", "vcard", ".", "getChildren", "(", ")", ":", "if", "child", ".", "name", "==", "\"URL\"", ":", "urls", ".", "append", "(", "child", ".", "value"...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
CarddavObject.get_anniversary
:returns: contacts anniversary or None if not available :rtype: datetime.datetime or str
khard/carddav_object.py
def get_anniversary(self): """:returns: contacts anniversary or None if not available :rtype: datetime.datetime or str """ # vcard 4.0 could contain a single text value try: if self.vcard.anniversary.params.get("VALUE")[0] == "text": return self.vc...
def get_anniversary(self): """:returns: contacts anniversary or None if not available :rtype: datetime.datetime or str """ # vcard 4.0 could contain a single text value try: if self.vcard.anniversary.params.get("VALUE")[0] == "text": return self.vc...
[ ":", "returns", ":", "contacts", "anniversary", "or", "None", "if", "not", "available", ":", "rtype", ":", "datetime", ".", "datetime", "or", "str" ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/carddav_object.py#L685-L704
[ "def", "get_anniversary", "(", "self", ")", ":", "# vcard 4.0 could contain a single text value", "try", ":", "if", "self", ".", "vcard", ".", "anniversary", ".", "params", ".", "get", "(", "\"VALUE\"", ")", "[", "0", "]", "==", "\"text\"", ":", "return", "s...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
CarddavObject.get_birthday
:returns: contacts birthday or None if not available :rtype: datetime.datetime or str
khard/carddav_object.py
def get_birthday(self): """:returns: contacts birthday or None if not available :rtype: datetime.datetime or str """ # vcard 4.0 could contain a single text value try: if self.vcard.bday.params.get("VALUE")[0] == "text": return self.vcard.bday.valu...
def get_birthday(self): """:returns: contacts birthday or None if not available :rtype: datetime.datetime or str """ # vcard 4.0 could contain a single text value try: if self.vcard.bday.params.get("VALUE")[0] == "text": return self.vcard.bday.valu...
[ ":", "returns", ":", "contacts", "birthday", "or", "None", "if", "not", "available", ":", "rtype", ":", "datetime", ".", "datetime", "or", "str" ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/carddav_object.py#L753-L768
[ "def", "get_birthday", "(", "self", ")", ":", "# vcard 4.0 could contain a single text value", "try", ":", "if", "self", ".", "vcard", ".", "bday", ".", "params", ".", "get", "(", "\"VALUE\"", ")", "[", "0", "]", "==", "\"text\"", ":", "return", "self", "....
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
CarddavObject._get_types_for_vcard_object
get list of types for phone number, email or post address :param object: vcard class object :type object: vobject.vCard :param default_type: use if the object contains no type :type default_type: str :returns: list of type labels :rtype: list(str)
khard/carddav_object.py
def _get_types_for_vcard_object(self, object, default_type): """ get list of types for phone number, email or post address :param object: vcard class object :type object: vobject.vCard :param default_type: use if the object contains no type :type default_type: str ...
def _get_types_for_vcard_object(self, object, default_type): """ get list of types for phone number, email or post address :param object: vcard class object :type object: vobject.vCard :param default_type: use if the object contains no type :type default_type: str ...
[ "get", "list", "of", "types", "for", "phone", "number", "email", "or", "post", "address", ":", "param", "object", ":", "vcard", "class", "object", ":", "type", "object", ":", "vobject", ".", "vCard", ":", "param", "default_type", ":", "use", "if", "the",...
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/carddav_object.py#L1507-L1553
[ "def", "_get_types_for_vcard_object", "(", "self", ",", "object", ",", "default_type", ")", ":", "type_list", "=", "[", "]", "# try to find label group for custom value type", "if", "object", ".", "group", ":", "for", "label", "in", "self", ".", "vcard", ".", "g...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
CarddavObject._parse_type_value
Parse type value of phone numbers, email and post addresses. :param types: list of type values :type types: list(str) :param value: the corresponding label, required for more verbose exceptions :type value: str :param supported_types: all allowed standard types ...
khard/carddav_object.py
def _parse_type_value(types, value, supported_types): """Parse type value of phone numbers, email and post addresses. :param types: list of type values :type types: list(str) :param value: the corresponding label, required for more verbose exceptions :type value: str...
def _parse_type_value(types, value, supported_types): """Parse type value of phone numbers, email and post addresses. :param types: list of type values :type types: list(str) :param value: the corresponding label, required for more verbose exceptions :type value: str...
[ "Parse", "type", "value", "of", "phone", "numbers", "email", "and", "post", "addresses", "." ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/carddav_object.py#L1556-L1589
[ "def", "_parse_type_value", "(", "types", ",", "value", ",", "supported_types", ")", ":", "custom_types", "=", "[", "]", "standard_types", "=", "[", "]", "pref", "=", "0", "for", "type", "in", "types", ":", "type", "=", "type", ".", "strip", "(", ")", ...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
list_to_string
converts list to string recursively so that nested lists are supported :param input: a list of strings and lists of strings (and so on recursive) :type input: list :param delimiter: the deimiter to use when joining the items :type delimiter: str :returns: the recursively joined list :rtype: str
khard/helpers.py
def list_to_string(input, delimiter): """converts list to string recursively so that nested lists are supported :param input: a list of strings and lists of strings (and so on recursive) :type input: list :param delimiter: the deimiter to use when joining the items :type delimiter: str :returns...
def list_to_string(input, delimiter): """converts list to string recursively so that nested lists are supported :param input: a list of strings and lists of strings (and so on recursive) :type input: list :param delimiter: the deimiter to use when joining the items :type delimiter: str :returns...
[ "converts", "list", "to", "string", "recursively", "so", "that", "nested", "lists", "are", "supported" ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/helpers.py#L59-L72
[ "def", "list_to_string", "(", "input", ",", "delimiter", ")", ":", "if", "isinstance", "(", "input", ",", "list", ")", ":", "return", "delimiter", ".", "join", "(", "list_to_string", "(", "item", ",", "delimiter", ")", "for", "item", "in", "input", ")", ...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
string_to_date
Convert string to date object. :param input: the date string to parse :type input: str :returns: the parsed datetime object :rtype: datetime.datetime
khard/helpers.py
def string_to_date(input): """Convert string to date object. :param input: the date string to parse :type input: str :returns: the parsed datetime object :rtype: datetime.datetime """ # try date formats --mmdd, --mm-dd, yyyymmdd, yyyy-mm-dd and datetime # formats yyyymmddThhmmss, yyyy-m...
def string_to_date(input): """Convert string to date object. :param input: the date string to parse :type input: str :returns: the parsed datetime object :rtype: datetime.datetime """ # try date formats --mmdd, --mm-dd, yyyymmdd, yyyy-mm-dd and datetime # formats yyyymmddThhmmss, yyyy-m...
[ "Convert", "string", "to", "date", "object", "." ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/helpers.py#L81-L107
[ "def", "string_to_date", "(", "input", ")", ":", "# try date formats --mmdd, --mm-dd, yyyymmdd, yyyy-mm-dd and datetime", "# formats yyyymmddThhmmss, yyyy-mm-ddThh:mm:ss, yyyymmddThhmmssZ,", "# yyyy-mm-ddThh:mm:ssZ.", "for", "format_string", "in", "(", "\"--%m%d\"", ",", "\"--%m-%d\"",...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
convert_to_yaml
converts a value list into yaml syntax :param name: name of object (example: phone) :type name: str :param value: object contents :type value: str, list(str), list(list(str)) :param indentation: indent all by number of spaces :type indentation: int :param indexOfColon: use to position : at t...
khard/helpers.py
def convert_to_yaml( name, value, indentation, indexOfColon, show_multi_line_character): """converts a value list into yaml syntax :param name: name of object (example: phone) :type name: str :param value: object contents :type value: str, list(str), list(list(str)) :param indentation: i...
def convert_to_yaml( name, value, indentation, indexOfColon, show_multi_line_character): """converts a value list into yaml syntax :param name: name of object (example: phone) :type name: str :param value: object contents :type value: str, list(str), list(list(str)) :param indentation: i...
[ "converts", "a", "value", "list", "into", "yaml", "syntax", ":", "param", "name", ":", "name", "of", "object", "(", "example", ":", "phone", ")", ":", "type", "name", ":", "str", ":", "param", "value", ":", "object", "contents", ":", "type", "value", ...
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/helpers.py#L120-L182
[ "def", "convert_to_yaml", "(", "name", ",", "value", ",", "indentation", ",", "indexOfColon", ",", "show_multi_line_character", ")", ":", "strings", "=", "[", "]", "if", "isinstance", "(", "value", ",", "list", ")", ":", "# special case for single item lists:", ...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
convert_to_vcard
converts user input into vcard compatible data structures :param name: object name, only required for error messages :type name: str :param value: user input :type value: str or list(str) :param allowed_object_type: set the accepted return type for vcard attribute :type allowed_object_ty...
khard/helpers.py
def convert_to_vcard(name, value, allowed_object_type): """converts user input into vcard compatible data structures :param name: object name, only required for error messages :type name: str :param value: user input :type value: str or list(str) :param allowed_object_type: set the accepted retu...
def convert_to_vcard(name, value, allowed_object_type): """converts user input into vcard compatible data structures :param name: object name, only required for error messages :type name: str :param value: user input :type value: str or list(str) :param allowed_object_type: set the accepted retu...
[ "converts", "user", "input", "into", "vcard", "compatible", "data", "structures", ":", "param", "name", ":", "object", "name", "only", "required", "for", "error", "messages", ":", "type", "name", ":", "str", ":", "param", "value", ":", "user", "input", ":"...
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/helpers.py#L185-L223
[ "def", "convert_to_vcard", "(", "name", ",", "value", ",", "allowed_object_type", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "if", "allowed_object_type", "==", "ObjectType", ".", "list_with_strings", ":", "raise", "ValueError", "(", "\"E...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
AddressBook._compare_uids
Calculate the minimum length of initial substrings of uid1 and uid2 for them to be different. :param uid1: first uid to compare :type uid1: str :param uid2: second uid to compare :type uid2: str :returns: the length of the shortes unequal initial substrings :rtyp...
khard/address_book.py
def _compare_uids(uid1, uid2): """Calculate the minimum length of initial substrings of uid1 and uid2 for them to be different. :param uid1: first uid to compare :type uid1: str :param uid2: second uid to compare :type uid2: str :returns: the length of the shorte...
def _compare_uids(uid1, uid2): """Calculate the minimum length of initial substrings of uid1 and uid2 for them to be different. :param uid1: first uid to compare :type uid1: str :param uid2: second uid to compare :type uid2: str :returns: the length of the shorte...
[ "Calculate", "the", "minimum", "length", "of", "initial", "substrings", "of", "uid1", "and", "uid2", "for", "them", "to", "be", "different", "." ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/address_book.py#L59-L76
[ "def", "_compare_uids", "(", "uid1", ",", "uid2", ")", ":", "sum", "=", "0", "for", "char1", ",", "char2", "in", "zip", "(", "uid1", ",", "uid2", ")", ":", "if", "char1", "==", "char2", ":", "sum", "+=", "1", "else", ":", "break", "return", "sum"...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
AddressBook._search_all
Search in all fields for contacts matching query. :param query: the query to search for :type query: str :yields: all found contacts :rtype: generator(carddav_object.CarddavObject)
khard/address_book.py
def _search_all(self, query): """Search in all fields for contacts matching query. :param query: the query to search for :type query: str :yields: all found contacts :rtype: generator(carddav_object.CarddavObject) """ regexp = re.compile(query, re.IGNORECASE | r...
def _search_all(self, query): """Search in all fields for contacts matching query. :param query: the query to search for :type query: str :yields: all found contacts :rtype: generator(carddav_object.CarddavObject) """ regexp = re.compile(query, re.IGNORECASE | r...
[ "Search", "in", "all", "fields", "for", "contacts", "matching", "query", "." ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/address_book.py#L78-L99
[ "def", "_search_all", "(", "self", ",", "query", ")", ":", "regexp", "=", "re", ".", "compile", "(", "query", ",", "re", ".", "IGNORECASE", "|", "re", ".", "DOTALL", ")", "for", "contact", "in", "self", ".", "contacts", ".", "values", "(", ")", ":"...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
AddressBook._search_names
Search in the name filed for contacts matching query. :param query: the query to search for :type query: str :yields: all found contacts :rtype: generator(carddav_object.CarddavObject)
khard/address_book.py
def _search_names(self, query): """Search in the name filed for contacts matching query. :param query: the query to search for :type query: str :yields: all found contacts :rtype: generator(carddav_object.CarddavObject) """ regexp = re.compile(query, re.IGNORECA...
def _search_names(self, query): """Search in the name filed for contacts matching query. :param query: the query to search for :type query: str :yields: all found contacts :rtype: generator(carddav_object.CarddavObject) """ regexp = re.compile(query, re.IGNORECA...
[ "Search", "in", "the", "name", "filed", "for", "contacts", "matching", "query", "." ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/address_book.py#L101-L114
[ "def", "_search_names", "(", "self", ",", "query", ")", ":", "regexp", "=", "re", ".", "compile", "(", "query", ",", "re", ".", "IGNORECASE", "|", "re", ".", "DOTALL", ")", "for", "contact", "in", "self", ".", "contacts", ".", "values", "(", ")", "...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
AddressBook._search_uid
Search for contacts with a matching uid. :param query: the query to search for :type query: str :yields: all found contacts :rtype: generator(carddav_object.CarddavObject)
khard/address_book.py
def _search_uid(self, query): """Search for contacts with a matching uid. :param query: the query to search for :type query: str :yields: all found contacts :rtype: generator(carddav_object.CarddavObject) """ try: # First we treat the argument as a f...
def _search_uid(self, query): """Search for contacts with a matching uid. :param query: the query to search for :type query: str :yields: all found contacts :rtype: generator(carddav_object.CarddavObject) """ try: # First we treat the argument as a f...
[ "Search", "for", "contacts", "with", "a", "matching", "uid", "." ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/address_book.py#L116-L134
[ "def", "_search_uid", "(", "self", ",", "query", ")", ":", "try", ":", "# First we treat the argument as a full UID and try to match it", "# exactly.", "yield", "self", ".", "contacts", "[", "query", "]", "except", "KeyError", ":", "# If that failed we look for all contac...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
AddressBook.search
Search this address book for contacts matching the query. The method can be one of "all", "name" and "uid". The backend for this address book migth be load()ed if needed. :param query: the query to search for :type query: str :param method: the type of fileds to use when seach...
khard/address_book.py
def search(self, query, method="all"): """Search this address book for contacts matching the query. The method can be one of "all", "name" and "uid". The backend for this address book migth be load()ed if needed. :param query: the query to search for :type query: str :...
def search(self, query, method="all"): """Search this address book for contacts matching the query. The method can be one of "all", "name" and "uid". The backend for this address book migth be load()ed if needed. :param query: the query to search for :type query: str :...
[ "Search", "this", "address", "book", "for", "contacts", "matching", "the", "query", "." ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/address_book.py#L136-L162
[ "def", "search", "(", "self", ",", "query", ",", "method", "=", "\"all\"", ")", ":", "logging", ".", "debug", "(", "'address book %s, searching with %s'", ",", "self", ".", "name", ",", "query", ")", "if", "not", "self", ".", "_loaded", ":", "self", ".",...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
AddressBook.get_short_uid_dict
Create a dictionary of shortend UIDs for all contacts. All arguments are only used if the address book is not yet initialized and will just be handed to self.load(). :param query: see self.load() :type query: str :returns: the contacts mapped by the shortes unique prefix of the...
khard/address_book.py
def get_short_uid_dict(self, query=None): """Create a dictionary of shortend UIDs for all contacts. All arguments are only used if the address book is not yet initialized and will just be handed to self.load(). :param query: see self.load() :type query: str :returns: th...
def get_short_uid_dict(self, query=None): """Create a dictionary of shortend UIDs for all contacts. All arguments are only used if the address book is not yet initialized and will just be handed to self.load(). :param query: see self.load() :type query: str :returns: th...
[ "Create", "a", "dictionary", "of", "shortend", "UIDs", "for", "all", "contacts", "." ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/address_book.py#L164-L200
[ "def", "get_short_uid_dict", "(", "self", ",", "query", "=", "None", ")", ":", "if", "self", ".", "_short_uids", "is", "None", ":", "if", "not", "self", ".", "_loaded", ":", "self", ".", "load", "(", "query", ")", "if", "not", "self", ".", "contacts"...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
AddressBook.get_short_uid
Get the shortend UID for the given UID. :param uid: the full UID to shorten :type uid: str :returns: the shortend uid or the empty string :rtype: str
khard/address_book.py
def get_short_uid(self, uid): """Get the shortend UID for the given UID. :param uid: the full UID to shorten :type uid: str :returns: the shortend uid or the empty string :rtype: str """ if uid: short_uids = self.get_short_uid_dict() for l...
def get_short_uid(self, uid): """Get the shortend UID for the given UID. :param uid: the full UID to shorten :type uid: str :returns: the shortend uid or the empty string :rtype: str """ if uid: short_uids = self.get_short_uid_dict() for l...
[ "Get", "the", "shortend", "UID", "for", "the", "given", "UID", "." ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/address_book.py#L202-L215
[ "def", "get_short_uid", "(", "self", ",", "uid", ")", ":", "if", "uid", ":", "short_uids", "=", "self", ".", "get_short_uid_dict", "(", ")", "for", "length_of_uid", "in", "range", "(", "len", "(", "uid", ")", ",", "0", ",", "-", "1", ")", ":", "if"...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
VdirAddressBook._find_vcard_files
Find all vcard files inside this address book. If a search string is given only files which contents match that will be returned. :param search: a regular expression to limit the results :type search: str :param search_in_source_files: apply search regexp directly on the .vcf f...
khard/address_book.py
def _find_vcard_files(self, search=None, search_in_source_files=False): """Find all vcard files inside this address book. If a search string is given only files which contents match that will be returned. :param search: a regular expression to limit the results :type search: st...
def _find_vcard_files(self, search=None, search_in_source_files=False): """Find all vcard files inside this address book. If a search string is given only files which contents match that will be returned. :param search: a regular expression to limit the results :type search: st...
[ "Find", "all", "vcard", "files", "inside", "this", "address", "book", "." ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/address_book.py#L254-L276
[ "def", "_find_vcard_files", "(", "self", ",", "search", "=", "None", ",", "search_in_source_files", "=", "False", ")", ":", "files", "=", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "\"*.vcf\"", ")", ")", ...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
VdirAddressBook.load
Load all vcard files in this address book from disk. If a search string is given only files which contents match that will be loaded. :param query: a regular expression to limit the results :type query: str :param search_in_source_files: apply search regexp directly on the .vcf...
khard/address_book.py
def load(self, query=None, search_in_source_files=False): """Load all vcard files in this address book from disk. If a search string is given only files which contents match that will be loaded. :param query: a regular expression to limit the results :type query: str :p...
def load(self, query=None, search_in_source_files=False): """Load all vcard files in this address book from disk. If a search string is given only files which contents match that will be loaded. :param query: a regular expression to limit the results :type query: str :p...
[ "Load", "all", "vcard", "files", "in", "this", "address", "book", "from", "disk", "." ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/address_book.py#L278-L337
[ "def", "load", "(", "self", ",", "query", "=", "None", ",", "search_in_source_files", "=", "False", ")", ":", "if", "self", ".", "_loaded", ":", "return", "logging", ".", "debug", "(", "'Loading Vdir %s with query %s'", ",", "self", ".", "name", ",", "quer...
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
AddressBookCollection.get_abook
Get one of the backing abdress books by its name, :param name: the name of the address book to get :type name: str :returns: the matching address book or None :rtype: AddressBook or NoneType
khard/address_book.py
def get_abook(self, name): """Get one of the backing abdress books by its name, :param name: the name of the address book to get :type name: str :returns: the matching address book or None :rtype: AddressBook or NoneType """ for abook in self._abooks: ...
def get_abook(self, name): """Get one of the backing abdress books by its name, :param name: the name of the address book to get :type name: str :returns: the matching address book or None :rtype: AddressBook or NoneType """ for abook in self._abooks: ...
[ "Get", "one", "of", "the", "backing", "abdress", "books", "by", "its", "name" ]
scheibler/khard
python
https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/address_book.py#L378-L389
[ "def", "get_abook", "(", "self", ",", "name", ")", ":", "for", "abook", "in", "self", ".", "_abooks", ":", "if", "abook", ".", "name", "==", "name", ":", "return", "abook" ]
0f69430c2680f1ff5f073a977a3c5b753b96cc17
test
SysHandler.get_table
This function is used in sys command (when user want to find a specific syscall) :param Architecture for syscall table; :param Searching pattern; :param Flag for verbose output :return Return a printable table of matched syscalls
shellen/syscalls/base_handler.py
def get_table(self, arch, pattern, colored=False, verbose=False): ''' This function is used in sys command (when user want to find a specific syscall) :param Architecture for syscall table; :param Searching pattern; :param Flag for verbose output :return Return a printab...
def get_table(self, arch, pattern, colored=False, verbose=False): ''' This function is used in sys command (when user want to find a specific syscall) :param Architecture for syscall table; :param Searching pattern; :param Flag for verbose output :return Return a printab...
[ "This", "function", "is", "used", "in", "sys", "command", "(", "when", "user", "want", "to", "find", "a", "specific", "syscall", ")" ]
merrychap/shellen
python
https://github.com/merrychap/shellen/blob/3514b7ed3a1b7b1660c3f846a52f58ef02f0954c/shellen/syscalls/base_handler.py#L33-L56
[ "def", "get_table", "(", "self", ",", "arch", ",", "pattern", ",", "colored", "=", "False", ",", "verbose", "=", "False", ")", ":", "rawtable", "=", "self", ".", "search", "(", "arch", ",", "pattern", ")", "if", "len", "(", "rawtable", ")", "==", "...
3514b7ed3a1b7b1660c3f846a52f58ef02f0954c
test
Assembler.avail_archs
Initialize the dictionary of architectures for assembling via keystone
shellen/asms/asm.py
def avail_archs(self): ''' Initialize the dictionary of architectures for assembling via keystone''' return { ARM32: (KS_ARCH_ARM, KS_MODE_ARM), ARM64: (KS_ARCH_ARM64, KS_MODE_LITTLE_ENDIAN), ARM_TB: (KS_ARCH_ARM, KS_MODE_THUMB), HEXAGON: (...
def avail_archs(self): ''' Initialize the dictionary of architectures for assembling via keystone''' return { ARM32: (KS_ARCH_ARM, KS_MODE_ARM), ARM64: (KS_ARCH_ARM64, KS_MODE_LITTLE_ENDIAN), ARM_TB: (KS_ARCH_ARM, KS_MODE_THUMB), HEXAGON: (...
[ "Initialize", "the", "dictionary", "of", "architectures", "for", "assembling", "via", "keystone" ]
merrychap/shellen
python
https://github.com/merrychap/shellen/blob/3514b7ed3a1b7b1660c3f846a52f58ef02f0954c/shellen/asms/asm.py#L24-L42
[ "def", "avail_archs", "(", "self", ")", ":", "return", "{", "ARM32", ":", "(", "KS_ARCH_ARM", ",", "KS_MODE_ARM", ")", ",", "ARM64", ":", "(", "KS_ARCH_ARM64", ",", "KS_MODE_LITTLE_ENDIAN", ")", ",", "ARM_TB", ":", "(", "KS_ARCH_ARM", ",", "KS_MODE_THUMB", ...
3514b7ed3a1b7b1660c3f846a52f58ef02f0954c
test
Disassembler.avail_archs
Initialize the dictionary of architectures for disassembling via capstone
shellen/asms/disasm.py
def avail_archs(self): ''' Initialize the dictionary of architectures for disassembling via capstone''' return { ARM32: (CS_ARCH_ARM, CS_MODE_ARM), ARM64: (CS_ARCH_ARM64, CS_MODE_LITTLE_ENDIAN), ARM_TB: (CS_ARCH_ARM, CS_MODE_THUMB), MIPS32: (CS_...
def avail_archs(self): ''' Initialize the dictionary of architectures for disassembling via capstone''' return { ARM32: (CS_ARCH_ARM, CS_MODE_ARM), ARM64: (CS_ARCH_ARM64, CS_MODE_LITTLE_ENDIAN), ARM_TB: (CS_ARCH_ARM, CS_MODE_THUMB), MIPS32: (CS_...
[ "Initialize", "the", "dictionary", "of", "architectures", "for", "disassembling", "via", "capstone" ]
merrychap/shellen
python
https://github.com/merrychap/shellen/blob/3514b7ed3a1b7b1660c3f846a52f58ef02f0954c/shellen/asms/disasm.py#L25-L40
[ "def", "avail_archs", "(", "self", ")", ":", "return", "{", "ARM32", ":", "(", "CS_ARCH_ARM", ",", "CS_MODE_ARM", ")", ",", "ARM64", ":", "(", "CS_ARCH_ARM64", ",", "CS_MODE_LITTLE_ENDIAN", ")", ",", "ARM_TB", ":", "(", "CS_ARCH_ARM", ",", "CS_MODE_THUMB", ...
3514b7ed3a1b7b1660c3f846a52f58ef02f0954c
test
getargspec_permissive
An `inspect.getargspec` with a relaxed sanity check to support Cython. Motivation: A Cython-compiled function is *not* an instance of Python's types.FunctionType. That is the sanity check the standard Py2 library uses in `inspect.getargspec()`. So, an exception is raised when cal...
argh/compat.py
def getargspec_permissive(func): """ An `inspect.getargspec` with a relaxed sanity check to support Cython. Motivation: A Cython-compiled function is *not* an instance of Python's types.FunctionType. That is the sanity check the standard Py2 library uses in `inspect.getargspec()`....
def getargspec_permissive(func): """ An `inspect.getargspec` with a relaxed sanity check to support Cython. Motivation: A Cython-compiled function is *not* an instance of Python's types.FunctionType. That is the sanity check the standard Py2 library uses in `inspect.getargspec()`....
[ "An", "inspect", ".", "getargspec", "with", "a", "relaxed", "sanity", "check", "to", "support", "Cython", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/compat.py#L22-L48
[ "def", "getargspec_permissive", "(", "func", ")", ":", "if", "inspect", ".", "ismethod", "(", "func", ")", ":", "func", "=", "func", ".", "im_func", "# Py2 Stdlib uses isfunction(func) which is too strict for Cython-compiled", "# functions though such have perfectly usable fu...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
dispatch
Parses given list of arguments using given parser, calls the relevant function and prints the result. The target function should expect one positional argument: the :class:`argparse.Namespace` object. However, if the function is decorated with :func:`~argh.decorators.plain_signature`, the positional an...
argh/dispatching.py
def dispatch(parser, argv=None, add_help_command=True, completion=True, pre_call=None, output_file=sys.stdout, errors_file=sys.stderr, raw_output=False, namespace=None, skip_unknown_args=False): """ Parses given list of arguments using given parser, calls the ...
def dispatch(parser, argv=None, add_help_command=True, completion=True, pre_call=None, output_file=sys.stdout, errors_file=sys.stderr, raw_output=False, namespace=None, skip_unknown_args=False): """ Parses given list of arguments using given parser, calls the ...
[ "Parses", "given", "list", "of", "arguments", "using", "given", "parser", "calls", "the", "relevant", "function", "and", "prints", "the", "result", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/dispatching.py#L65-L187
[ "def", "dispatch", "(", "parser", ",", "argv", "=", "None", ",", "add_help_command", "=", "True", ",", "completion", "=", "True", ",", "pre_call", "=", "None", ",", "output_file", "=", "sys", ".", "stdout", ",", "errors_file", "=", "sys", ".", "stderr", ...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
_execute_command
Assumes that `function` is a callable. Tries different approaches to call it (with `namespace_obj` or with ordinary signature). Yields the results line by line. If :class:`~argh.exceptions.CommandError` is raised, its message is appended to the results (i.e. yielded by the generator as a string). ...
argh/dispatching.py
def _execute_command(function, namespace_obj, errors_file, pre_call=None): """ Assumes that `function` is a callable. Tries different approaches to call it (with `namespace_obj` or with ordinary signature). Yields the results line by line. If :class:`~argh.exceptions.CommandError` is raised, its m...
def _execute_command(function, namespace_obj, errors_file, pre_call=None): """ Assumes that `function` is a callable. Tries different approaches to call it (with `namespace_obj` or with ordinary signature). Yields the results line by line. If :class:`~argh.exceptions.CommandError` is raised, its m...
[ "Assumes", "that", "function", "is", "a", "callable", ".", "Tries", "different", "approaches", "to", "call", "it", "(", "with", "namespace_obj", "or", "with", "ordinary", "signature", ")", ".", "Yields", "the", "results", "line", "by", "line", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/dispatching.py#L210-L284
[ "def", "_execute_command", "(", "function", ",", "namespace_obj", ",", "errors_file", ",", "pre_call", "=", "None", ")", ":", "if", "pre_call", ":", "# XXX undocumented because I'm unsure if it's OK", "# Actually used in real projects:", "# * https://google.com/search?q=argh+di...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
dispatch_command
A wrapper for :func:`dispatch` that creates a one-command parser. Uses :attr:`PARSER_FORMATTER`. This:: dispatch_command(foo) ...is a shortcut for:: parser = ArgumentParser() set_default_command(parser, foo) dispatch(parser) This function can be also used as a decora...
argh/dispatching.py
def dispatch_command(function, *args, **kwargs): """ A wrapper for :func:`dispatch` that creates a one-command parser. Uses :attr:`PARSER_FORMATTER`. This:: dispatch_command(foo) ...is a shortcut for:: parser = ArgumentParser() set_default_command(parser, foo) dis...
def dispatch_command(function, *args, **kwargs): """ A wrapper for :func:`dispatch` that creates a one-command parser. Uses :attr:`PARSER_FORMATTER`. This:: dispatch_command(foo) ...is a shortcut for:: parser = ArgumentParser() set_default_command(parser, foo) dis...
[ "A", "wrapper", "for", ":", "func", ":", "dispatch", "that", "creates", "a", "one", "-", "command", "parser", ".", "Uses", ":", "attr", ":", "PARSER_FORMATTER", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/dispatching.py#L287-L306
[ "def", "dispatch_command", "(", "function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "formatter_class", "=", "PARSER_FORMATTER", ")", "set_default_command", "(", "parser", ",", "function", ")",...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
dispatch_commands
A wrapper for :func:`dispatch` that creates a parser, adds commands to the parser and dispatches them. Uses :attr:`PARSER_FORMATTER`. This:: dispatch_commands([foo, bar]) ...is a shortcut for:: parser = ArgumentParser() add_commands(parser, [foo, bar]) dispatch(parser...
argh/dispatching.py
def dispatch_commands(functions, *args, **kwargs): """ A wrapper for :func:`dispatch` that creates a parser, adds commands to the parser and dispatches them. Uses :attr:`PARSER_FORMATTER`. This:: dispatch_commands([foo, bar]) ...is a shortcut for:: parser = ArgumentParser() ...
def dispatch_commands(functions, *args, **kwargs): """ A wrapper for :func:`dispatch` that creates a parser, adds commands to the parser and dispatches them. Uses :attr:`PARSER_FORMATTER`. This:: dispatch_commands([foo, bar]) ...is a shortcut for:: parser = ArgumentParser() ...
[ "A", "wrapper", "for", ":", "func", ":", "dispatch", "that", "creates", "a", "parser", "adds", "commands", "to", "the", "parser", "and", "dispatches", "them", ".", "Uses", ":", "attr", ":", "PARSER_FORMATTER", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/dispatching.py#L309-L328
[ "def", "dispatch_commands", "(", "functions", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "formatter_class", "=", "PARSER_FORMATTER", ")", "add_commands", "(", "parser", ",", "functions", ")", "...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
safe_input
Prompts user for input. Correctly handles prompt message encoding.
argh/io.py
def safe_input(prompt): """ Prompts user for input. Correctly handles prompt message encoding. """ if sys.version_info < (3,0): if isinstance(prompt, compat.text_type): # Python 2.x: unicode → bytes encoding = locale.getpreferredencoding() or 'utf-8' prompt ...
def safe_input(prompt): """ Prompts user for input. Correctly handles prompt message encoding. """ if sys.version_info < (3,0): if isinstance(prompt, compat.text_type): # Python 2.x: unicode → bytes encoding = locale.getpreferredencoding() or 'utf-8' prompt ...
[ "Prompts", "user", "for", "input", ".", "Correctly", "handles", "prompt", "message", "encoding", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/io.py#L32-L47
[ "def", "safe_input", "(", "prompt", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", "0", ")", ":", "if", "isinstance", "(", "prompt", ",", "compat", ".", "text_type", ")", ":", "# Python 2.x: unicode → bytes", "encoding", "=", "locale", ...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
encode_output
Encodes given value so it can be written to given file object. Value may be Unicode, binary string or any other data type. The exact behaviour depends on the Python version: Python 3.x `sys.stdout` is a `_io.TextIOWrapper` instance that accepts `str` (unicode) and breaks on `bytes`. ...
argh/io.py
def encode_output(value, output_file): """ Encodes given value so it can be written to given file object. Value may be Unicode, binary string or any other data type. The exact behaviour depends on the Python version: Python 3.x `sys.stdout` is a `_io.TextIOWrapper` instance that accepts ...
def encode_output(value, output_file): """ Encodes given value so it can be written to given file object. Value may be Unicode, binary string or any other data type. The exact behaviour depends on the Python version: Python 3.x `sys.stdout` is a `_io.TextIOWrapper` instance that accepts ...
[ "Encodes", "given", "value", "so", "it", "can", "be", "written", "to", "given", "file", "object", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/io.py#L50-L96
[ "def", "encode_output", "(", "value", ",", "output_file", ")", ":", "if", "sys", ".", "version_info", ">", "(", "3", ",", "0", ")", ":", "# Python 3: whatever → unicode", "return", "compat", ".", "text_type", "(", "value", ")", "else", ":", "# Python 2: ha...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
dump
Writes given line to given output file. See :func:`encode_output` for details.
argh/io.py
def dump(raw_data, output_file): """ Writes given line to given output file. See :func:`encode_output` for details. """ data = encode_output(raw_data, output_file) output_file.write(data)
def dump(raw_data, output_file): """ Writes given line to given output file. See :func:`encode_output` for details. """ data = encode_output(raw_data, output_file) output_file.write(data)
[ "Writes", "given", "line", "to", "given", "output", "file", ".", "See", ":", "func", ":", "encode_output", "for", "details", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/io.py#L99-L105
[ "def", "dump", "(", "raw_data", ",", "output_file", ")", ":", "data", "=", "encode_output", "(", "raw_data", ",", "output_file", ")", "output_file", ".", "write", "(", "data", ")" ]
dcd3253f2994400a6a58a700c118c53765bc50a4
test
autocomplete
Adds support for shell completion via argcomplete_ by patching given `argparse.ArgumentParser` (sub)class. If completion is not enabled, logs a debug-level message.
argh/completion.py
def autocomplete(parser): """ Adds support for shell completion via argcomplete_ by patching given `argparse.ArgumentParser` (sub)class. If completion is not enabled, logs a debug-level message. """ if COMPLETION_ENABLED: argcomplete.autocomplete(parser) elif 'bash' in os.getenv('SH...
def autocomplete(parser): """ Adds support for shell completion via argcomplete_ by patching given `argparse.ArgumentParser` (sub)class. If completion is not enabled, logs a debug-level message. """ if COMPLETION_ENABLED: argcomplete.autocomplete(parser) elif 'bash' in os.getenv('SH...
[ "Adds", "support", "for", "shell", "completion", "via", "argcomplete_", "by", "patching", "given", "argparse", ".", "ArgumentParser", "(", "sub", ")", "class", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/completion.py#L84-L94
[ "def", "autocomplete", "(", "parser", ")", ":", "if", "COMPLETION_ENABLED", ":", "argcomplete", ".", "autocomplete", "(", "parser", ")", "elif", "'bash'", "in", "os", ".", "getenv", "(", "'SHELL'", ",", "''", ")", ":", "logger", ".", "debug", "(", "'Bash...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
ArghParser.parse_args
Wrapper for :meth:`argparse.ArgumentParser.parse_args`. If `namespace` is not defined, :class:`argh.dispatching.ArghNamespace` is used. This is required for functions to be properly used as commands.
argh/helpers.py
def parse_args(self, args=None, namespace=None): """ Wrapper for :meth:`argparse.ArgumentParser.parse_args`. If `namespace` is not defined, :class:`argh.dispatching.ArghNamespace` is used. This is required for functions to be properly used as commands. """ namespace = na...
def parse_args(self, args=None, namespace=None): """ Wrapper for :meth:`argparse.ArgumentParser.parse_args`. If `namespace` is not defined, :class:`argh.dispatching.ArghNamespace` is used. This is required for functions to be properly used as commands. """ namespace = na...
[ "Wrapper", "for", ":", "meth", ":", "argparse", ".", "ArgumentParser", ".", "parse_args", ".", "If", "namespace", "is", "not", "defined", ":", "class", ":", "argh", ".", "dispatching", ".", "ArghNamespace", "is", "used", ".", "This", "is", "required", "for...
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/helpers.py#L57-L64
[ "def", "parse_args", "(", "self", ",", "args", "=", "None", ",", "namespace", "=", "None", ")", ":", "namespace", "=", "namespace", "or", "ArghNamespace", "(", ")", "return", "super", "(", "ArghParser", ",", "self", ")", ".", "parse_args", "(", "args", ...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
CustomFormatter._expand_help
This method is copied verbatim from ArgumentDefaultsHelpFormatter with a couple of lines added just before the end. Reason: we need to `repr()` default values instead of simply inserting them as is. This helps notice, for example, an empty string as the default value; moreover, it preve...
argh/constants.py
def _expand_help(self, action): """ This method is copied verbatim from ArgumentDefaultsHelpFormatter with a couple of lines added just before the end. Reason: we need to `repr()` default values instead of simply inserting them as is. This helps notice, for example, an empty str...
def _expand_help(self, action): """ This method is copied verbatim from ArgumentDefaultsHelpFormatter with a couple of lines added just before the end. Reason: we need to `repr()` default values instead of simply inserting them as is. This helps notice, for example, an empty str...
[ "This", "method", "is", "copied", "verbatim", "from", "ArgumentDefaultsHelpFormatter", "with", "a", "couple", "of", "lines", "added", "just", "before", "the", "end", ".", "Reason", ":", "we", "need", "to", "repr", "()", "default", "values", "instead", "of", ...
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/constants.py#L55-L91
[ "def", "_expand_help", "(", "self", ",", "action", ")", ":", "params", "=", "dict", "(", "vars", "(", "action", ")", ",", "prog", "=", "self", ".", "_prog", ")", "for", "name", "in", "list", "(", "params", ")", ":", "if", "params", "[", "name", "...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
_guess
Adds types, actions, etc. to given argument specification. For example, ``default=3`` implies ``type=int``. :param arg: a :class:`argh.utils.Arg` instance
argh/assembling.py
def _guess(kwargs): """ Adds types, actions, etc. to given argument specification. For example, ``default=3`` implies ``type=int``. :param arg: a :class:`argh.utils.Arg` instance """ guessed = {} # Parser actions that accept argument 'type' TYPE_AWARE_ACTIONS = 'store', 'append' #...
def _guess(kwargs): """ Adds types, actions, etc. to given argument specification. For example, ``default=3`` implies ``type=int``. :param arg: a :class:`argh.utils.Arg` instance """ guessed = {} # Parser actions that accept argument 'type' TYPE_AWARE_ACTIONS = 'store', 'append' #...
[ "Adds", "types", "actions", "etc", ".", "to", "given", "argument", "specification", ".", "For", "example", "default", "=", "3", "implies", "type", "=", "int", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/assembling.py#L120-L149
[ "def", "_guess", "(", "kwargs", ")", ":", "guessed", "=", "{", "}", "# Parser actions that accept argument 'type'", "TYPE_AWARE_ACTIONS", "=", "'store'", ",", "'append'", "# guess type/action from default value", "value", "=", "kwargs", ".", "get", "(", "'default'", "...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
set_default_command
Sets default command (i.e. a function) for given parser. If `parser.description` is empty and the function has a docstring, it is used as the description. .. note:: An attempt to set default command to a parser which already has subparsers (e.g. added with :func:`~argh.assembling.add_comman...
argh/assembling.py
def set_default_command(parser, function): """ Sets default command (i.e. a function) for given parser. If `parser.description` is empty and the function has a docstring, it is used as the description. .. note:: An attempt to set default command to a parser which already has subpars...
def set_default_command(parser, function): """ Sets default command (i.e. a function) for given parser. If `parser.description` is empty and the function has a docstring, it is used as the description. .. note:: An attempt to set default command to a parser which already has subpars...
[ "Sets", "default", "command", "(", "i", ".", "e", ".", "a", "function", ")", "for", "given", "parser", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/assembling.py#L188-L318
[ "def", "set_default_command", "(", "parser", ",", "function", ")", ":", "if", "parser", ".", "_subparsers", ":", "_require_support_for_default_command_with_subparsers", "(", ")", "spec", "=", "get_arg_spec", "(", "function", ")", "declared_args", "=", "getattr", "("...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
add_commands
Adds given functions as commands to given parser. :param parser: an :class:`argparse.ArgumentParser` instance. :param functions: a list of functions. A subparser is created for each of them. If the function is decorated with :func:`~argh.decorators.arg`, the arguments are pas...
argh/assembling.py
def add_commands(parser, functions, namespace=None, namespace_kwargs=None, func_kwargs=None, # deprecated args: title=None, description=None, help=None): """ Adds given functions as commands to given parser. :param parser: an :class:`argparse.Argu...
def add_commands(parser, functions, namespace=None, namespace_kwargs=None, func_kwargs=None, # deprecated args: title=None, description=None, help=None): """ Adds given functions as commands to given parser. :param parser: an :class:`argparse.Argu...
[ "Adds", "given", "functions", "as", "commands", "to", "given", "parser", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/assembling.py#L321-L459
[ "def", "add_commands", "(", "parser", ",", "functions", ",", "namespace", "=", "None", ",", "namespace_kwargs", "=", "None", ",", "func_kwargs", "=", "None", ",", "# deprecated args:", "title", "=", "None", ",", "description", "=", "None", ",", "help", "=", ...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
add_subcommands
A wrapper for :func:`add_commands`. These examples are equivalent:: add_commands(parser, [get, put], namespace='db', namespace_kwargs={ 'title': 'database commands', 'help': 'CRUD for our silly database' }) ...
argh/assembling.py
def add_subcommands(parser, namespace, functions, **namespace_kwargs): """ A wrapper for :func:`add_commands`. These examples are equivalent:: add_commands(parser, [get, put], namespace='db', namespace_kwargs={ 'title': 'database commands', ...
def add_subcommands(parser, namespace, functions, **namespace_kwargs): """ A wrapper for :func:`add_commands`. These examples are equivalent:: add_commands(parser, [get, put], namespace='db', namespace_kwargs={ 'title': 'database commands', ...
[ "A", "wrapper", "for", ":", "func", ":", "add_commands", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/assembling.py#L484-L502
[ "def", "add_subcommands", "(", "parser", ",", "namespace", ",", "functions", ",", "*", "*", "namespace_kwargs", ")", ":", "add_commands", "(", "parser", ",", "functions", ",", "namespace", "=", "namespace", ",", "namespace_kwargs", "=", "namespace_kwargs", ")" ]
dcd3253f2994400a6a58a700c118c53765bc50a4
test
get_subparsers
Returns the :class:`argparse._SubParsersAction` instance for given :class:`ArgumentParser` instance as would have been returned by :meth:`ArgumentParser.add_subparsers`. The problem with the latter is that it only works once and raises an exception on the second attempt, and the public API seems to lack...
argh/utils.py
def get_subparsers(parser, create=False): """ Returns the :class:`argparse._SubParsersAction` instance for given :class:`ArgumentParser` instance as would have been returned by :meth:`ArgumentParser.add_subparsers`. The problem with the latter is that it only works once and raises an exception on th...
def get_subparsers(parser, create=False): """ Returns the :class:`argparse._SubParsersAction` instance for given :class:`ArgumentParser` instance as would have been returned by :meth:`ArgumentParser.add_subparsers`. The problem with the latter is that it only works once and raises an exception on th...
[ "Returns", "the", ":", "class", ":", "argparse", ".", "_SubParsersAction", "instance", "for", "given", ":", "class", ":", "ArgumentParser", "instance", "as", "would", "have", "been", "returned", "by", ":", "meth", ":", "ArgumentParser", ".", "add_subparsers", ...
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/utils.py#L21-L43
[ "def", "get_subparsers", "(", "parser", ",", "create", "=", "False", ")", ":", "# note that ArgumentParser._subparsers is *not* what is returned by", "# ArgumentParser.add_subparsers().", "if", "parser", ".", "_subparsers", ":", "actions", "=", "[", "a", "for", "a", "in...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
get_arg_spec
Returns argument specification for given function. Omits special arguments of instance methods (`self`) and static methods (usually `cls` or something like this).
argh/utils.py
def get_arg_spec(function): """ Returns argument specification for given function. Omits special arguments of instance methods (`self`) and static methods (usually `cls` or something like this). """ while hasattr(function, '__wrapped__'): function = function.__wrapped__ spec = compa...
def get_arg_spec(function): """ Returns argument specification for given function. Omits special arguments of instance methods (`self`) and static methods (usually `cls` or something like this). """ while hasattr(function, '__wrapped__'): function = function.__wrapped__ spec = compa...
[ "Returns", "argument", "specification", "for", "given", "function", ".", "Omits", "special", "arguments", "of", "instance", "methods", "(", "self", ")", "and", "static", "methods", "(", "usually", "cls", "or", "something", "like", "this", ")", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/utils.py#L46-L57
[ "def", "get_arg_spec", "(", "function", ")", ":", "while", "hasattr", "(", "function", ",", "'__wrapped__'", ")", ":", "function", "=", "function", ".", "__wrapped__", "spec", "=", "compat", ".", "getargspec", "(", "function", ")", "if", "inspect", ".", "i...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
named
Sets given string as command name instead of the function name. The string is used verbatim without further processing. Usage:: @named('load') def do_load_some_stuff_and_keep_the_original_function_name(args): ... The resulting command will be available only as ``load``. To ad...
argh/decorators.py
def named(new_name): """ Sets given string as command name instead of the function name. The string is used verbatim without further processing. Usage:: @named('load') def do_load_some_stuff_and_keep_the_original_function_name(args): ... The resulting command will be a...
def named(new_name): """ Sets given string as command name instead of the function name. The string is used verbatim without further processing. Usage:: @named('load') def do_load_some_stuff_and_keep_the_original_function_name(args): ... The resulting command will be a...
[ "Sets", "given", "string", "as", "command", "name", "instead", "of", "the", "function", "name", ".", "The", "string", "is", "used", "verbatim", "without", "further", "processing", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/decorators.py#L24-L43
[ "def", "named", "(", "new_name", ")", ":", "def", "wrapper", "(", "func", ")", ":", "setattr", "(", "func", ",", "ATTR_NAME", ",", "new_name", ")", "return", "func", "return", "wrapper" ]
dcd3253f2994400a6a58a700c118c53765bc50a4
test
aliases
Defines alternative command name(s) for given function (along with its original name). Usage:: @aliases('co', 'check') def checkout(args): ... The resulting command will be available as ``checkout``, ``check`` and ``co``. .. note:: This decorator only works with a rece...
argh/decorators.py
def aliases(*names): """ Defines alternative command name(s) for given function (along with its original name). Usage:: @aliases('co', 'check') def checkout(args): ... The resulting command will be available as ``checkout``, ``check`` and ``co``. .. note:: This...
def aliases(*names): """ Defines alternative command name(s) for given function (along with its original name). Usage:: @aliases('co', 'check') def checkout(args): ... The resulting command will be available as ``checkout``, ``check`` and ``co``. .. note:: This...
[ "Defines", "alternative", "command", "name", "(", "s", ")", "for", "given", "function", "(", "along", "with", "its", "original", "name", ")", ".", "Usage", "::" ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/decorators.py#L46-L73
[ "def", "aliases", "(", "*", "names", ")", ":", "def", "wrapper", "(", "func", ")", ":", "setattr", "(", "func", ",", "ATTR_ALIASES", ",", "names", ")", "return", "func", "return", "wrapper" ]
dcd3253f2994400a6a58a700c118c53765bc50a4
test
arg
Declares an argument for given function. Does not register the function anywhere, nor does it modify the function in any way. The signature of the decorator matches that of :meth:`argparse.ArgumentParser.add_argument`, only some keywords are not required if they can be easily guessed (e.g. you don't ha...
argh/decorators.py
def arg(*args, **kwargs): """ Declares an argument for given function. Does not register the function anywhere, nor does it modify the function in any way. The signature of the decorator matches that of :meth:`argparse.ArgumentParser.add_argument`, only some keywords are not required if they ca...
def arg(*args, **kwargs): """ Declares an argument for given function. Does not register the function anywhere, nor does it modify the function in any way. The signature of the decorator matches that of :meth:`argparse.ArgumentParser.add_argument`, only some keywords are not required if they ca...
[ "Declares", "an", "argument", "for", "given", "function", ".", "Does", "not", "register", "the", "function", "anywhere", "nor", "does", "it", "modify", "the", "function", "in", "any", "way", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/decorators.py#L76-L132
[ "def", "arg", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "wrapper", "(", "func", ")", ":", "declared_args", "=", "getattr", "(", "func", ",", "ATTR_ARGS", ",", "[", "]", ")", "# The innermost decorator is called first but appears last in the c...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
wrap_errors
Decorator. Wraps given exceptions into :class:`~argh.exceptions.CommandError`. Usage:: @wrap_errors([AssertionError]) def foo(x=None, y=None): assert x or y, 'x or y must be specified' If the assertion fails, its message will be correctly printed and the stack hidden. This help...
argh/decorators.py
def wrap_errors(errors=None, processor=None, *args): """ Decorator. Wraps given exceptions into :class:`~argh.exceptions.CommandError`. Usage:: @wrap_errors([AssertionError]) def foo(x=None, y=None): assert x or y, 'x or y must be specified' If the assertion fails, its mess...
def wrap_errors(errors=None, processor=None, *args): """ Decorator. Wraps given exceptions into :class:`~argh.exceptions.CommandError`. Usage:: @wrap_errors([AssertionError]) def foo(x=None, y=None): assert x or y, 'x or y must be specified' If the assertion fails, its mess...
[ "Decorator", ".", "Wraps", "given", "exceptions", "into", ":", "class", ":", "~argh", ".", "exceptions", ".", "CommandError", ".", "Usage", "::" ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/decorators.py#L135-L172
[ "def", "wrap_errors", "(", "errors", "=", "None", ",", "processor", "=", "None", ",", "*", "args", ")", ":", "def", "wrapper", "(", "func", ")", ":", "if", "errors", ":", "setattr", "(", "func", ",", "ATTR_WRAPPED_EXCEPTIONS", ",", "errors", ")", "if",...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
confirm
A shortcut for typical confirmation prompt. :param action: a string describing the action, e.g. "Apply changes". A question mark will be appended. :param default: `bool` or `None`. Determines what happens when user hits :kbd:`Enter` without typing in a choice. If `True`, defa...
argh/interaction.py
def confirm(action, default=None, skip=False): """ A shortcut for typical confirmation prompt. :param action: a string describing the action, e.g. "Apply changes". A question mark will be appended. :param default: `bool` or `None`. Determines what happens when user hits :kbd:...
def confirm(action, default=None, skip=False): """ A shortcut for typical confirmation prompt. :param action: a string describing the action, e.g. "Apply changes". A question mark will be appended. :param default: `bool` or `None`. Determines what happens when user hits :kbd:...
[ "A", "shortcut", "for", "typical", "confirmation", "prompt", "." ]
neithere/argh
python
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/interaction.py#L22-L84
[ "def", "confirm", "(", "action", ",", "default", "=", "None", ",", "skip", "=", "False", ")", ":", "MAX_ITERATIONS", "=", "3", "if", "skip", ":", "return", "default", "else", ":", "defaults", "=", "{", "None", ":", "(", "'y'", ",", "'n'", ")", ",",...
dcd3253f2994400a6a58a700c118c53765bc50a4
test
Query.select
Select the provided column names from the model, do not return an entity, do not involve the rom session, just get the raw and/or processed column data from Redis. Keyword-only arguments: * *include_pk=False* - whether to include the primary key in the returned data...
rom/query.py
def select(self, *column_names, **kwargs): ''' Select the provided column names from the model, do not return an entity, do not involve the rom session, just get the raw and/or processed column data from Redis. Keyword-only arguments: * *include_pk=False* - whether ...
def select(self, *column_names, **kwargs): ''' Select the provided column names from the model, do not return an entity, do not involve the rom session, just get the raw and/or processed column data from Redis. Keyword-only arguments: * *include_pk=False* - whether ...
[ "Select", "the", "provided", "column", "names", "from", "the", "model", "do", "not", "return", "an", "entity", "do", "not", "involve", "the", "rom", "session", "just", "get", "the", "raw", "and", "/", "or", "processed", "column", "data", "from", "Redis", ...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L107-L180
[ "def", "select", "(", "self", ",", "*", "column_names", ",", "*", "*", "kwargs", ")", ":", "include_pk", "=", "kwargs", ".", "pop", "(", "'include_pk'", ",", "False", ")", "decode", "=", "kwargs", ".", "pop", "(", "'decode'", ",", "True", ")", "ff", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
Query.replace
Copy the Query object, optionally replacing the filters, order_by, or limit information on the copy. This is mostly an internal detail that you can ignore.
rom/query.py
def replace(self, **kwargs): ''' Copy the Query object, optionally replacing the filters, order_by, or limit information on the copy. This is mostly an internal detail that you can ignore. ''' data = { 'model': self._model, 'filters': self._filters...
def replace(self, **kwargs): ''' Copy the Query object, optionally replacing the filters, order_by, or limit information on the copy. This is mostly an internal detail that you can ignore. ''' data = { 'model': self._model, 'filters': self._filters...
[ "Copy", "the", "Query", "object", "optionally", "replacing", "the", "filters", "order_by", "or", "limit", "information", "on", "the", "copy", ".", "This", "is", "mostly", "an", "internal", "detail", "that", "you", "can", "ignore", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L182-L196
[ "def", "replace", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'model'", ":", "self", ".", "_model", ",", "'filters'", ":", "self", ".", "_filters", ",", "'order_by'", ":", "self", ".", "_order_by", ",", "'limit'", ":", "self", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
Query.filter
Only columns/attributes that have been specified as having an index with the ``index=True`` option on the column definition can be filtered with this method. Prefix, suffix, and pattern match filters must be provided using the ``.startswith()``, ``.endswith()``, and the ``.like()`` metho...
rom/query.py
def filter(self, **kwargs): ''' Only columns/attributes that have been specified as having an index with the ``index=True`` option on the column definition can be filtered with this method. Prefix, suffix, and pattern match filters must be provided using the ``.startswith()``, ``...
def filter(self, **kwargs): ''' Only columns/attributes that have been specified as having an index with the ``index=True`` option on the column definition can be filtered with this method. Prefix, suffix, and pattern match filters must be provided using the ``.startswith()``, ``...
[ "Only", "columns", "/", "attributes", "that", "have", "been", "specified", "as", "having", "an", "index", "with", "the", "index", "=", "True", "option", "on", "the", "column", "definition", "can", "be", "filtered", "with", "this", "method", ".", "Prefix", ...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L198-L291
[ "def", "filter", "(", "self", ",", "*", "*", "kwargs", ")", ":", "cur_filters", "=", "list", "(", "self", ".", "_filters", ")", "for", "attr", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "value", "=", "self", ".", "_check", "(", "a...
8b5607a856341df85df33422accc30ba9294dbdb
test
Query.startswith
When provided with keyword arguments of the form ``col=prefix``, this will limit the entities returned to those that have a word with the provided prefix in the specified column(s). This requires that the ``prefix=True`` option was provided during column definition. Usage:: ...
rom/query.py
def startswith(self, **kwargs): ''' When provided with keyword arguments of the form ``col=prefix``, this will limit the entities returned to those that have a word with the provided prefix in the specified column(s). This requires that the ``prefix=True`` option was provided dur...
def startswith(self, **kwargs): ''' When provided with keyword arguments of the form ``col=prefix``, this will limit the entities returned to those that have a word with the provided prefix in the specified column(s). This requires that the ``prefix=True`` option was provided dur...
[ "When", "provided", "with", "keyword", "arguments", "of", "the", "form", "col", "=", "prefix", "this", "will", "limit", "the", "entities", "returned", "to", "those", "that", "have", "a", "word", "with", "the", "provided", "prefix", "in", "the", "specified", ...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L293-L309
[ "def", "startswith", "(", "self", ",", "*", "*", "kwargs", ")", ":", "new", "=", "[", "]", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "v", "=", "self", ".", "_check", "(", "k", ",", "v", ",", "'startswith'", ")", "new"...
8b5607a856341df85df33422accc30ba9294dbdb
test
Query.endswith
When provided with keyword arguments of the form ``col=suffix``, this will limit the entities returned to those that have a word with the provided suffix in the specified column(s). This requires that the ``suffix=True`` option was provided during column definition. Usage:: ...
rom/query.py
def endswith(self, **kwargs): ''' When provided with keyword arguments of the form ``col=suffix``, this will limit the entities returned to those that have a word with the provided suffix in the specified column(s). This requires that the ``suffix=True`` option was provided durin...
def endswith(self, **kwargs): ''' When provided with keyword arguments of the form ``col=suffix``, this will limit the entities returned to those that have a word with the provided suffix in the specified column(s). This requires that the ``suffix=True`` option was provided durin...
[ "When", "provided", "with", "keyword", "arguments", "of", "the", "form", "col", "=", "suffix", "this", "will", "limit", "the", "entities", "returned", "to", "those", "that", "have", "a", "word", "with", "the", "provided", "suffix", "in", "the", "specified", ...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L311-L327
[ "def", "endswith", "(", "self", ",", "*", "*", "kwargs", ")", ":", "new", "=", "[", "]", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "v", "=", "self", ".", "_check", "(", "k", ",", "v", ",", "'endswith'", ")", "new", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
Query.like
When provided with keyword arguments of the form ``col=pattern``, this will limit the entities returned to those that include the provided pattern. Note that 'like' queries require that the ``prefix=True`` option must have been provided as part of the column definition. Patterns allow f...
rom/query.py
def like(self, **kwargs): ''' When provided with keyword arguments of the form ``col=pattern``, this will limit the entities returned to those that include the provided pattern. Note that 'like' queries require that the ``prefix=True`` option must have been provided as part of th...
def like(self, **kwargs): ''' When provided with keyword arguments of the form ``col=pattern``, this will limit the entities returned to those that include the provided pattern. Note that 'like' queries require that the ``prefix=True`` option must have been provided as part of th...
[ "When", "provided", "with", "keyword", "arguments", "of", "the", "form", "col", "=", "pattern", "this", "will", "limit", "the", "entities", "returned", "to", "those", "that", "include", "the", "provided", "pattern", ".", "Note", "that", "like", "queries", "r...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L329-L362
[ "def", "like", "(", "self", ",", "*", "*", "kwargs", ")", ":", "new", "=", "[", "]", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "v", "=", "self", ".", "_check", "(", "k", ",", "v", ",", "'like'", ")", "new", ".", "...
8b5607a856341df85df33422accc30ba9294dbdb
test
Query.order_by
When provided with a column name, will sort the results of your query:: # returns all users, ordered by the created_at column in # descending order User.query.order_by('-created_at').execute()
rom/query.py
def order_by(self, column): ''' When provided with a column name, will sort the results of your query:: # returns all users, ordered by the created_at column in # descending order User.query.order_by('-created_at').execute() ''' cname = column.lstrip(...
def order_by(self, column): ''' When provided with a column name, will sort the results of your query:: # returns all users, ordered by the created_at column in # descending order User.query.order_by('-created_at').execute() ''' cname = column.lstrip(...
[ "When", "provided", "with", "a", "column", "name", "will", "sort", "the", "results", "of", "your", "query", "::" ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L374-L391
[ "def", "order_by", "(", "self", ",", "column", ")", ":", "cname", "=", "column", ".", "lstrip", "(", "'-'", ")", "col", "=", "self", ".", "_check", "(", "cname", ")", "if", "type", "(", "col", ")", ".", "__name__", "in", "(", "'String'", ",", "'T...
8b5607a856341df85df33422accc30ba9294dbdb
test
Query.count
Will return the total count of the objects that match the specified filters.:: # counts the number of users created in the last 24 hours User.query.filter(created_at=(time.time()-86400, time.time())).count()
rom/query.py
def count(self): ''' Will return the total count of the objects that match the specified filters.:: # counts the number of users created in the last 24 hours User.query.filter(created_at=(time.time()-86400, time.time())).count() ''' filters = self._filter...
def count(self): ''' Will return the total count of the objects that match the specified filters.:: # counts the number of users created in the last 24 hours User.query.filter(created_at=(time.time()-86400, time.time())).count() ''' filters = self._filter...
[ "Will", "return", "the", "total", "count", "of", "the", "objects", "that", "match", "the", "specified", "filters", ".", "::" ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L402-L420
[ "def", "count", "(", "self", ")", ":", "filters", "=", "self", ".", "_filters", "if", "self", ".", "_order_by", ":", "filters", "+=", "(", "self", ".", "_order_by", ".", "lstrip", "(", "'-'", ")", ",", ")", "if", "not", "filters", ":", "# We can actu...
8b5607a856341df85df33422accc30ba9294dbdb
test
Query.iter_result
Iterate over the results of your query instead of getting them all with `.all()`. Will only perform a single query. If you expect that your processing will take more than 30 seconds to process 100 items, you should pass `timeout` and `pagesize` to reflect an appropriate timeout and page ...
rom/query.py
def iter_result(self, timeout=30, pagesize=100, no_hscan=False): ''' Iterate over the results of your query instead of getting them all with `.all()`. Will only perform a single query. If you expect that your processing will take more than 30 seconds to process 100 items, you sho...
def iter_result(self, timeout=30, pagesize=100, no_hscan=False): ''' Iterate over the results of your query instead of getting them all with `.all()`. Will only perform a single query. If you expect that your processing will take more than 30 seconds to process 100 items, you sho...
[ "Iterate", "over", "the", "results", "of", "your", "query", "instead", "of", "getting", "them", "all", "with", ".", "all", "()", ".", "Will", "only", "perform", "a", "single", "query", ".", "If", "you", "expect", "that", "your", "processing", "will", "ta...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L429-L452
[ "def", "iter_result", "(", "self", ",", "timeout", "=", "30", ",", "pagesize", "=", "100", ",", "no_hscan", "=", "False", ")", ":", "if", "not", "self", ".", "_filters", "and", "not", "self", ".", "_order_by", ":", "if", "self", ".", "_model", ".", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
Query.cached_result
This will execute the query, returning the key where a ZSET of your results will be stored for pagination, further operations, etc. The timeout must be a positive integer number of seconds for which to set the expiration time on the key (this is to ensure that any cached query results a...
rom/query.py
def cached_result(self, timeout): ''' This will execute the query, returning the key where a ZSET of your results will be stored for pagination, further operations, etc. The timeout must be a positive integer number of seconds for which to set the expiration time on the key (thi...
def cached_result(self, timeout): ''' This will execute the query, returning the key where a ZSET of your results will be stored for pagination, further operations, etc. The timeout must be a positive integer number of seconds for which to set the expiration time on the key (thi...
[ "This", "will", "execute", "the", "query", "returning", "the", "key", "where", "a", "ZSET", "of", "your", "results", "will", "be", "stored", "for", "pagination", "further", "operations", "etc", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L648-L675
[ "def", "cached_result", "(", "self", ",", "timeout", ")", ":", "if", "not", "(", "self", ".", "_filters", "or", "self", ".", "_order_by", ")", ":", "raise", "QueryError", "(", "\"You are missing filter or order criteria\"", ")", "timeout", "=", "int", "(", "...
8b5607a856341df85df33422accc30ba9294dbdb
test
Query.first
Returns only the first result from the query, if any.
rom/query.py
def first(self): ''' Returns only the first result from the query, if any. ''' lim = [0, 1] if self._limit: lim[0] = self._limit[0] if not self._filters and not self._order_by: for ent in self: return ent return None ...
def first(self): ''' Returns only the first result from the query, if any. ''' lim = [0, 1] if self._limit: lim[0] = self._limit[0] if not self._filters and not self._order_by: for ent in self: return ent return None ...
[ "Returns", "only", "the", "first", "result", "from", "the", "query", "if", "any", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L691-L705
[ "def", "first", "(", "self", ")", ":", "lim", "=", "[", "0", ",", "1", "]", "if", "self", ".", "_limit", ":", "lim", "[", "0", "]", "=", "self", ".", "_limit", "[", "0", "]", "if", "not", "self", ".", "_filters", "and", "not", "self", ".", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
Query.delete
Will delete the entities that match at the time the query is executed. Used like:: MyModel.query.filter(email=...).delete() MyModel.query.endswith(email='@host.com').delete() .. warning:: can't be used on models on either side of a ``OneToMany``, ``ManyToOne``, or ...
rom/query.py
def delete(self, blocksize=100): ''' Will delete the entities that match at the time the query is executed. Used like:: MyModel.query.filter(email=...).delete() MyModel.query.endswith(email='@host.com').delete() .. warning:: can't be used on models on either si...
def delete(self, blocksize=100): ''' Will delete the entities that match at the time the query is executed. Used like:: MyModel.query.filter(email=...).delete() MyModel.query.endswith(email='@host.com').delete() .. warning:: can't be used on models on either si...
[ "Will", "delete", "the", "entities", "that", "match", "at", "the", "time", "the", "query", "is", "executed", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/query.py#L707-L735
[ "def", "delete", "(", "self", ",", "blocksize", "=", "100", ")", ":", "from", ".", "columns", "import", "MODELS_REFERENCED", "if", "not", "self", ".", "_model", ".", "_no_fk", "or", "self", ".", "_model", ".", "_namespace", "in", "MODELS_REFERENCED", ":", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
_on_delete
This function handles all on_delete semantics defined on OneToMany columns. This function only exists because 'cascade' is *very* hard to get right.
rom/columns.py
def _on_delete(ent): ''' This function handles all on_delete semantics defined on OneToMany columns. This function only exists because 'cascade' is *very* hard to get right. ''' seen_d = set([ent._pk]) to_delete = [ent] seen_s = set() to_save = [] def _set_default(ent, attr, de=NUL...
def _on_delete(ent): ''' This function handles all on_delete semantics defined on OneToMany columns. This function only exists because 'cascade' is *very* hard to get right. ''' seen_d = set([ent._pk]) to_delete = [ent] seen_s = set() to_save = [] def _set_default(ent, attr, de=NUL...
[ "This", "function", "handles", "all", "on_delete", "semantics", "defined", "on", "OneToMany", "columns", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/columns.py#L51-L115
[ "def", "_on_delete", "(", "ent", ")", ":", "seen_d", "=", "set", "(", "[", "ent", ".", "_pk", "]", ")", "to_delete", "=", "[", "ent", "]", "seen_s", "=", "set", "(", ")", "to_save", "=", "[", "]", "def", "_set_default", "(", "ent", ",", "attr", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
redis_prefix_lua
Performs the actual prefix, suffix, and pattern match operations.
rom/index.py
def redis_prefix_lua(conn, dest, index, prefix, is_first, pattern=None): ''' Performs the actual prefix, suffix, and pattern match operations. ''' tkey = '%s:%s'%(index.partition(':')[0], uuid.uuid4()) start, end = _start_end(prefix) return _redis_prefix_lua(conn, [dest, tkey, index], ...
def redis_prefix_lua(conn, dest, index, prefix, is_first, pattern=None): ''' Performs the actual prefix, suffix, and pattern match operations. ''' tkey = '%s:%s'%(index.partition(':')[0], uuid.uuid4()) start, end = _start_end(prefix) return _redis_prefix_lua(conn, [dest, tkey, index], ...
[ "Performs", "the", "actual", "prefix", "suffix", "and", "pattern", "match", "operations", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/index.py#L386-L395
[ "def", "redis_prefix_lua", "(", "conn", ",", "dest", ",", "index", ",", "prefix", ",", "is_first", ",", "pattern", "=", "None", ")", ":", "tkey", "=", "'%s:%s'", "%", "(", "index", ".", "partition", "(", "':'", ")", "[", "0", "]", ",", "uuid", ".",...
8b5607a856341df85df33422accc30ba9294dbdb
test
estimate_work_lua
Estimates the total work necessary to calculate the prefix match over the given index with the provided prefix.
rom/index.py
def estimate_work_lua(conn, index, prefix): ''' Estimates the total work necessary to calculate the prefix match over the given index with the provided prefix. ''' if index.endswith(':idx'): args = [] if not prefix else list(prefix) if args: args[0] = '-inf' if args[0] is...
def estimate_work_lua(conn, index, prefix): ''' Estimates the total work necessary to calculate the prefix match over the given index with the provided prefix. ''' if index.endswith(':idx'): args = [] if not prefix else list(prefix) if args: args[0] = '-inf' if args[0] is...
[ "Estimates", "the", "total", "work", "necessary", "to", "calculate", "the", "prefix", "match", "over", "the", "given", "index", "with", "the", "provided", "prefix", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/index.py#L482-L497
[ "def", "estimate_work_lua", "(", "conn", ",", "index", ",", "prefix", ")", ":", "if", "index", ".", "endswith", "(", "':idx'", ")", ":", "args", "=", "[", "]", "if", "not", "prefix", "else", "list", "(", "prefix", ")", "if", "args", ":", "args", "[...
8b5607a856341df85df33422accc30ba9294dbdb
test
GeneralIndex.search
Search for model ids that match the provided filters. Arguments: * *filters* - A list of filters that apply to the search of one of the following two forms: 1. ``'column:string'`` - a plain string will match a word in a text search on the column ...
rom/index.py
def search(self, conn, filters, order_by, offset=None, count=None, timeout=None): ''' Search for model ids that match the provided filters. Arguments: * *filters* - A list of filters that apply to the search of one of the following two forms: 1. ``'co...
def search(self, conn, filters, order_by, offset=None, count=None, timeout=None): ''' Search for model ids that match the provided filters. Arguments: * *filters* - A list of filters that apply to the search of one of the following two forms: 1. ``'co...
[ "Search", "for", "model", "ids", "that", "match", "the", "provided", "filters", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/index.py#L220-L288
[ "def", "search", "(", "self", ",", "conn", ",", "filters", ",", "order_by", ",", "offset", "=", "None", ",", "count", "=", "None", ",", "timeout", "=", "None", ")", ":", "# prepare the filters", "pipe", ",", "intersect", ",", "temp_id", "=", "self", "....
8b5607a856341df85df33422accc30ba9294dbdb
test
GeneralIndex.count
Returns the count of the items that match the provided filters. For the meaning of what the ``filters`` argument means, see the ``.search()`` method docs.
rom/index.py
def count(self, conn, filters): ''' Returns the count of the items that match the provided filters. For the meaning of what the ``filters`` argument means, see the ``.search()`` method docs. ''' pipe, intersect, temp_id = self._prepare(conn, filters) pipe.zcard(t...
def count(self, conn, filters): ''' Returns the count of the items that match the provided filters. For the meaning of what the ``filters`` argument means, see the ``.search()`` method docs. ''' pipe, intersect, temp_id = self._prepare(conn, filters) pipe.zcard(t...
[ "Returns", "the", "count", "of", "the", "items", "that", "match", "the", "provided", "filters", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/index.py#L290-L300
[ "def", "count", "(", "self", ",", "conn", ",", "filters", ")", ":", "pipe", ",", "intersect", ",", "temp_id", "=", "self", ".", "_prepare", "(", "conn", ",", "filters", ")", "pipe", ".", "zcard", "(", "temp_id", ")", "pipe", ".", "delete", "(", "te...
8b5607a856341df85df33422accc30ba9294dbdb
test
_connect
Tries to get the _conn attribute from a model. Barring that, gets the global default connection using other methods.
rom/util.py
def _connect(obj): ''' Tries to get the _conn attribute from a model. Barring that, gets the global default connection using other methods. ''' from .columns import MODELS if isinstance(obj, MODELS['Model']): obj = obj.__class__ if hasattr(obj, '_conn'): return obj._conn ...
def _connect(obj): ''' Tries to get the _conn attribute from a model. Barring that, gets the global default connection using other methods. ''' from .columns import MODELS if isinstance(obj, MODELS['Model']): obj = obj.__class__ if hasattr(obj, '_conn'): return obj._conn ...
[ "Tries", "to", "get", "the", "_conn", "attribute", "from", "a", "model", ".", "Barring", "that", "gets", "the", "global", "default", "connection", "using", "other", "methods", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L181-L193
[ "def", "_connect", "(", "obj", ")", ":", "from", ".", "columns", "import", "MODELS", "if", "isinstance", "(", "obj", ",", "MODELS", "[", "'Model'", "]", ")", ":", "obj", "=", "obj", ".", "__class__", "if", "hasattr", "(", "obj", ",", "'_conn'", ")", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
FULL_TEXT
This is a basic full-text index keygen function. Words are lowercased, split by whitespace, and stripped of punctuation from both ends before an inverted index is created for term searching.
rom/util.py
def FULL_TEXT(val): ''' This is a basic full-text index keygen function. Words are lowercased, split by whitespace, and stripped of punctuation from both ends before an inverted index is created for term searching. ''' if isinstance(val, float): val = repr(val) elif val in (None, '')...
def FULL_TEXT(val): ''' This is a basic full-text index keygen function. Words are lowercased, split by whitespace, and stripped of punctuation from both ends before an inverted index is created for term searching. ''' if isinstance(val, float): val = repr(val) elif val in (None, '')...
[ "This", "is", "a", "basic", "full", "-", "text", "index", "keygen", "function", ".", "Words", "are", "lowercased", "split", "by", "whitespace", "and", "stripped", "of", "punctuation", "from", "both", "ends", "before", "an", "inverted", "index", "is", "create...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L254-L272
[ "def", "FULL_TEXT", "(", "val", ")", ":", "if", "isinstance", "(", "val", ",", "float", ")", ":", "val", "=", "repr", "(", "val", ")", "elif", "val", "in", "(", "None", ",", "''", ")", ":", "return", "None", "elif", "not", "isinstance", "(", "val...
8b5607a856341df85df33422accc30ba9294dbdb
test
SIMPLE
This is a basic case-sensitive "sorted order" index keygen function for strings. This will return a value that is suitable to be used for ordering by a 7-byte prefix of a string (that is 7 characters from a byte-string, and 1.75-7 characters from a unicode string, depending on character -> encoding leng...
rom/util.py
def SIMPLE(val): ''' This is a basic case-sensitive "sorted order" index keygen function for strings. This will return a value that is suitable to be used for ordering by a 7-byte prefix of a string (that is 7 characters from a byte-string, and 1.75-7 characters from a unicode string, depending on c...
def SIMPLE(val): ''' This is a basic case-sensitive "sorted order" index keygen function for strings. This will return a value that is suitable to be used for ordering by a 7-byte prefix of a string (that is 7 characters from a byte-string, and 1.75-7 characters from a unicode string, depending on c...
[ "This", "is", "a", "basic", "case", "-", "sensitive", "sorted", "order", "index", "keygen", "function", "for", "strings", ".", "This", "will", "return", "a", "value", "that", "is", "suitable", "to", "be", "used", "for", "ordering", "by", "a", "7", "-", ...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L278-L298
[ "def", "SIMPLE", "(", "val", ")", ":", "if", "not", "val", ":", "return", "None", "if", "not", "isinstance", "(", "val", ",", "six", ".", "string_types", ")", ":", "if", "six", ".", "PY3", "and", "isinstance", "(", "val", ",", "bytes", ")", ":", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
IDENTITY
This is a basic "equality" index keygen, primarily meant to be used for things like:: Model.query.filter(col='value') Where ``FULL_TEXT`` would transform a sentence like "A Simple Sentence" into an inverted index searchable by the words "a", "simple", and/or "sentence", ``IDENTITY`` will only ...
rom/util.py
def IDENTITY(val): ''' This is a basic "equality" index keygen, primarily meant to be used for things like:: Model.query.filter(col='value') Where ``FULL_TEXT`` would transform a sentence like "A Simple Sentence" into an inverted index searchable by the words "a", "simple", and/or "sentenc...
def IDENTITY(val): ''' This is a basic "equality" index keygen, primarily meant to be used for things like:: Model.query.filter(col='value') Where ``FULL_TEXT`` would transform a sentence like "A Simple Sentence" into an inverted index searchable by the words "a", "simple", and/or "sentenc...
[ "This", "is", "a", "basic", "equality", "index", "keygen", "primarily", "meant", "to", "be", "used", "for", "things", "like", "::" ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L312-L329
[ "def", "IDENTITY", "(", "val", ")", ":", "if", "not", "val", ":", "return", "None", "if", "not", "isinstance", "(", "val", ",", "six", ".", "string_types_ex", ")", ":", "val", "=", "str", "(", "val", ")", "return", "[", "val", "]" ]
8b5607a856341df85df33422accc30ba9294dbdb
test
refresh_indices
This utility function will iterate over all entities of a provided model, refreshing their indices. This is primarily useful after adding an index on a column. Arguments: * *model* - the model whose entities you want to reindex * *block_size* - the maximum number of entities you want to fe...
rom/util.py
def refresh_indices(model, block_size=100): ''' This utility function will iterate over all entities of a provided model, refreshing their indices. This is primarily useful after adding an index on a column. Arguments: * *model* - the model whose entities you want to reindex * *blo...
def refresh_indices(model, block_size=100): ''' This utility function will iterate over all entities of a provided model, refreshing their indices. This is primarily useful after adding an index on a column. Arguments: * *model* - the model whose entities you want to reindex * *blo...
[ "This", "utility", "function", "will", "iterate", "over", "all", "entities", "of", "a", "provided", "model", "refreshing", "their", "indices", ".", "This", "is", "primarily", "useful", "after", "adding", "an", "index", "on", "a", "column", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L696-L729
[ "def", "refresh_indices", "(", "model", ",", "block_size", "=", "100", ")", ":", "conn", "=", "_connect", "(", "model", ")", "max_id", "=", "int", "(", "conn", ".", "get", "(", "'%s:%s:'", "%", "(", "model", ".", "_namespace", ",", "model", ".", "_pk...
8b5607a856341df85df33422accc30ba9294dbdb
test
clean_old_index
This utility function will clean out old index data that was accidentally left during item deletion in rom versions <= 0.27.0 . You should run this after you have upgraded all of your clients to version 0.28.0 or later. Arguments: * *model* - the model whose entities you want to reindex * ...
rom/util.py
def clean_old_index(model, block_size=100, **kwargs): ''' This utility function will clean out old index data that was accidentally left during item deletion in rom versions <= 0.27.0 . You should run this after you have upgraded all of your clients to version 0.28.0 or later. Arguments: *...
def clean_old_index(model, block_size=100, **kwargs): ''' This utility function will clean out old index data that was accidentally left during item deletion in rom versions <= 0.27.0 . You should run this after you have upgraded all of your clients to version 0.28.0 or later. Arguments: *...
[ "This", "utility", "function", "will", "clean", "out", "old", "index", "data", "that", "was", "accidentally", "left", "during", "item", "deletion", "in", "rom", "versions", "<", "=", "0", ".", "27", ".", "0", ".", "You", "should", "run", "this", "after",...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L731-L811
[ "def", "clean_old_index", "(", "model", ",", "block_size", "=", "100", ",", "*", "*", "kwargs", ")", ":", "conn", "=", "_connect", "(", "model", ")", "version", "=", "list", "(", "map", "(", "int", ",", "conn", ".", "info", "(", ")", "[", "'redis_v...
8b5607a856341df85df33422accc30ba9294dbdb
test
show_progress
This utility function will print the progress of a passed iterator job as started by ``refresh_indices()`` and ``clean_old_index()``. Usage example:: class RomTest(Model): pass for i in xrange(1000): RomTest().save() util.show_progress(util.clean_old_index(Rom...
rom/util.py
def show_progress(job): ''' This utility function will print the progress of a passed iterator job as started by ``refresh_indices()`` and ``clean_old_index()``. Usage example:: class RomTest(Model): pass for i in xrange(1000): RomTest().save() util.sh...
def show_progress(job): ''' This utility function will print the progress of a passed iterator job as started by ``refresh_indices()`` and ``clean_old_index()``. Usage example:: class RomTest(Model): pass for i in xrange(1000): RomTest().save() util.sh...
[ "This", "utility", "function", "will", "print", "the", "progress", "of", "a", "passed", "iterator", "job", "as", "started", "by", "refresh_indices", "()", "and", "clean_old_index", "()", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L814-L844
[ "def", "show_progress", "(", "job", ")", ":", "start", "=", "time", ".", "time", "(", ")", "last_print", "=", "0", "last_line", "=", "0", "for", "prog", ",", "total", "in", "chain", "(", "job", ",", "[", "(", "1", ",", "1", ")", "]", ")", ":", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
_script_load
Borrowed/modified from my book, Redis in Action: https://github.com/josiahcarlson/redis-in-action/blob/master/python/ch11_listing_source.py Used for Lua scripting support when writing against Redis 2.6+ to allow for multiple unique columns per model.
rom/util.py
def _script_load(script): ''' Borrowed/modified from my book, Redis in Action: https://github.com/josiahcarlson/redis-in-action/blob/master/python/ch11_listing_source.py Used for Lua scripting support when writing against Redis 2.6+ to allow for multiple unique columns per model. ''' script...
def _script_load(script): ''' Borrowed/modified from my book, Redis in Action: https://github.com/josiahcarlson/redis-in-action/blob/master/python/ch11_listing_source.py Used for Lua scripting support when writing against Redis 2.6+ to allow for multiple unique columns per model. ''' script...
[ "Borrowed", "/", "modified", "from", "my", "book", "Redis", "in", "Action", ":", "https", ":", "//", "github", ".", "com", "/", "josiahcarlson", "/", "redis", "-", "in", "-", "action", "/", "blob", "/", "master", "/", "python", "/", "ch11_listing_source"...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L847-L881
[ "def", "_script_load", "(", "script", ")", ":", "script", "=", "script", ".", "encode", "(", "'utf-8'", ")", "if", "isinstance", "(", "script", ",", "six", ".", "text_type", ")", "else", "script", "sha", "=", "[", "None", ",", "sha1", "(", "script", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
EntityLock
Useful when you want exclusive access to an entity across all writers.:: # example import rom class Document(rom.Model): owner = rom.ManyToOne('User', on_delete='restrict') ... def change_owner(document, new_owner): with rom.util.EntityLock(document...
rom/util.py
def EntityLock(entity, acquire_timeout, lock_timeout): ''' Useful when you want exclusive access to an entity across all writers.:: # example import rom class Document(rom.Model): owner = rom.ManyToOne('User', on_delete='restrict') ... def change_owner(...
def EntityLock(entity, acquire_timeout, lock_timeout): ''' Useful when you want exclusive access to an entity across all writers.:: # example import rom class Document(rom.Model): owner = rom.ManyToOne('User', on_delete='restrict') ... def change_owner(...
[ "Useful", "when", "you", "want", "exclusive", "access", "to", "an", "entity", "across", "all", "writers", ".", "::" ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L1000-L1017
[ "def", "EntityLock", "(", "entity", ",", "acquire_timeout", ",", "lock_timeout", ")", ":", "return", "Lock", "(", "entity", ".", "_connection", ",", "entity", ".", "_pk", ",", "acquire_timeout", ",", "lock_timeout", ")" ]
8b5607a856341df85df33422accc30ba9294dbdb
test
Session.add
Adds an entity to the session.
rom/util.py
def add(self, obj): ''' Adds an entity to the session. ''' if self.null_session: return self._init() pk = obj._pk if not pk.endswith(':None'): self.known[pk] = obj self.wknown[pk] = obj
def add(self, obj): ''' Adds an entity to the session. ''' if self.null_session: return self._init() pk = obj._pk if not pk.endswith(':None'): self.known[pk] = obj self.wknown[pk] = obj
[ "Adds", "an", "entity", "to", "the", "session", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L452-L462
[ "def", "add", "(", "self", ",", "obj", ")", ":", "if", "self", ".", "null_session", ":", "return", "self", ".", "_init", "(", ")", "pk", "=", "obj", ".", "_pk", "if", "not", "pk", ".", "endswith", "(", "':None'", ")", ":", "self", ".", "known", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
Session.forget
Forgets about an entity (automatically called when an entity is deleted). Call this to ensure that an entity that you've modified is not automatically saved on ``session.commit()`` .
rom/util.py
def forget(self, obj): ''' Forgets about an entity (automatically called when an entity is deleted). Call this to ensure that an entity that you've modified is not automatically saved on ``session.commit()`` . ''' self._init() self.known.pop(obj._pk, None) ...
def forget(self, obj): ''' Forgets about an entity (automatically called when an entity is deleted). Call this to ensure that an entity that you've modified is not automatically saved on ``session.commit()`` . ''' self._init() self.known.pop(obj._pk, None) ...
[ "Forgets", "about", "an", "entity", "(", "automatically", "called", "when", "an", "entity", "is", "deleted", ")", ".", "Call", "this", "to", "ensure", "that", "an", "entity", "that", "you", "ve", "modified", "is", "not", "automatically", "saved", "on", "se...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L464-L472
[ "def", "forget", "(", "self", ",", "obj", ")", ":", "self", ".", "_init", "(", ")", "self", ".", "known", ".", "pop", "(", "obj", ".", "_pk", ",", "None", ")", "self", ".", "wknown", ".", "pop", "(", "obj", ".", "_pk", ",", "None", ")" ]
8b5607a856341df85df33422accc30ba9294dbdb
test
Session.get
Fetches an entity from the session based on primary key.
rom/util.py
def get(self, pk): ''' Fetches an entity from the session based on primary key. ''' self._init() return self.known.get(pk) or self.wknown.get(pk)
def get(self, pk): ''' Fetches an entity from the session based on primary key. ''' self._init() return self.known.get(pk) or self.wknown.get(pk)
[ "Fetches", "an", "entity", "from", "the", "session", "based", "on", "primary", "key", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L474-L479
[ "def", "get", "(", "self", ",", "pk", ")", ":", "self", ".", "_init", "(", ")", "return", "self", ".", "known", ".", "get", "(", "pk", ")", "or", "self", ".", "wknown", ".", "get", "(", "pk", ")" ]
8b5607a856341df85df33422accc30ba9294dbdb
test
Session.flush
Call ``.save()`` on all modified entities in the session. Use when you want to flush changes to Redis, but don't want to lose your local session cache. See the ``.commit()`` method for arguments and their meanings.
rom/util.py
def flush(self, full=False, all=False, force=False): ''' Call ``.save()`` on all modified entities in the session. Use when you want to flush changes to Redis, but don't want to lose your local session cache. See the ``.commit()`` method for arguments and their meanings. ...
def flush(self, full=False, all=False, force=False): ''' Call ``.save()`` on all modified entities in the session. Use when you want to flush changes to Redis, but don't want to lose your local session cache. See the ``.commit()`` method for arguments and their meanings. ...
[ "Call", ".", "save", "()", "on", "all", "modified", "entities", "in", "the", "session", ".", "Use", "when", "you", "want", "to", "flush", "changes", "to", "Redis", "but", "don", "t", "want", "to", "lose", "your", "local", "session", "cache", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L489-L499
[ "def", "flush", "(", "self", ",", "full", "=", "False", ",", "all", "=", "False", ",", "force", "=", "False", ")", ":", "self", ".", "_init", "(", ")", "return", "self", ".", "save", "(", "*", "self", ".", "known", ".", "values", "(", ")", ",",...
8b5607a856341df85df33422accc30ba9294dbdb
test
Session.commit
Call ``.save()`` on all modified entities in the session. Also forgets all known entities in the session, so this should only be called at the end of a request. Arguments: * *full* - pass ``True`` to force save full entities, not only changes * *all* - pas...
rom/util.py
def commit(self, full=False, all=False, force=False): ''' Call ``.save()`` on all modified entities in the session. Also forgets all known entities in the session, so this should only be called at the end of a request. Arguments: * *full* - pass ``True`` to force sa...
def commit(self, full=False, all=False, force=False): ''' Call ``.save()`` on all modified entities in the session. Also forgets all known entities in the session, so this should only be called at the end of a request. Arguments: * *full* - pass ``True`` to force sa...
[ "Call", ".", "save", "()", "on", "all", "modified", "entities", "in", "the", "session", ".", "Also", "forgets", "all", "known", "entities", "in", "the", "session", "so", "this", "should", "only", "be", "called", "at", "the", "end", "of", "a", "request", ...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L501-L518
[ "def", "commit", "(", "self", ",", "full", "=", "False", ",", "all", "=", "False", ",", "force", "=", "False", ")", ":", "changes", "=", "self", ".", "flush", "(", "full", ",", "all", ",", "force", ")", "self", ".", "known", "=", "{", "}", "ret...
8b5607a856341df85df33422accc30ba9294dbdb
test
Session.save
This method is an alternate API for saving many entities (possibly not tracked by the session). You can call:: session.save(obj) session.save(obj1, obj2, ...) session.save([obj1, obj2, ...]) And the entities will be flushed to Redis. You can pass the keywor...
rom/util.py
def save(self, *objects, **kwargs): ''' This method is an alternate API for saving many entities (possibly not tracked by the session). You can call:: session.save(obj) session.save(obj1, obj2, ...) session.save([obj1, obj2, ...]) And the entities wi...
def save(self, *objects, **kwargs): ''' This method is an alternate API for saving many entities (possibly not tracked by the session). You can call:: session.save(obj) session.save(obj1, obj2, ...) session.save([obj1, obj2, ...]) And the entities wi...
[ "This", "method", "is", "an", "alternate", "API", "for", "saving", "many", "entities", "(", "possibly", "not", "tracked", "by", "the", "session", ")", ".", "You", "can", "call", "::" ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L520-L554
[ "def", "save", "(", "self", ",", "*", "objects", ",", "*", "*", "kwargs", ")", ":", "from", "rom", "import", "Model", "full", "=", "kwargs", ".", "get", "(", "'full'", ")", "all", "=", "kwargs", ".", "get", "(", "'all'", ")", "force", "=", "kwarg...
8b5607a856341df85df33422accc30ba9294dbdb
test
Session.delete
This method offers the ability to delete multiple entities in a single round trip to Redis (assuming your models are all stored on the same server). You can call:: session.delete(obj) session.delete(obj1, obj2, ...) session.delete([obj1, obj2, ...]) The key...
rom/util.py
def delete(self, *objects, **kwargs): ''' This method offers the ability to delete multiple entities in a single round trip to Redis (assuming your models are all stored on the same server). You can call:: session.delete(obj) session.delete(obj1, obj2, ...) ...
def delete(self, *objects, **kwargs): ''' This method offers the ability to delete multiple entities in a single round trip to Redis (assuming your models are all stored on the same server). You can call:: session.delete(obj) session.delete(obj1, obj2, ...) ...
[ "This", "method", "offers", "the", "ability", "to", "delete", "multiple", "entities", "in", "a", "single", "round", "trip", "to", "Redis", "(", "assuming", "your", "models", "are", "all", "stored", "on", "the", "same", "server", ")", ".", "You", "can", "...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L556-L625
[ "def", "delete", "(", "self", ",", "*", "objects", ",", "*", "*", "kwargs", ")", ":", "force", "=", "kwargs", ".", "get", "(", "'force'", ")", "from", ".", "model", "import", "Model", ",", "SKIP_ON_DELETE", "flat", "=", "[", "]", "items", "=", "deq...
8b5607a856341df85df33422accc30ba9294dbdb
test
Session.refresh
This method is an alternate API for refreshing many entities (possibly not tracked by the session). You can call:: session.refresh(obj) session.refresh(obj1, obj2, ...) session.refresh([obj1, obj2, ...]) And all provided entities will be reloaded from Redis. ...
rom/util.py
def refresh(self, *objects, **kwargs): ''' This method is an alternate API for refreshing many entities (possibly not tracked by the session). You can call:: session.refresh(obj) session.refresh(obj1, obj2, ...) session.refresh([obj1, obj2, ...]) And...
def refresh(self, *objects, **kwargs): ''' This method is an alternate API for refreshing many entities (possibly not tracked by the session). You can call:: session.refresh(obj) session.refresh(obj1, obj2, ...) session.refresh([obj1, obj2, ...]) And...
[ "This", "method", "is", "an", "alternate", "API", "for", "refreshing", "many", "entities", "(", "possibly", "not", "tracked", "by", "the", "session", ")", ".", "You", "can", "call", "::" ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L627-L656
[ "def", "refresh", "(", "self", ",", "*", "objects", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_init", "(", ")", "from", "rom", "import", "Model", "force", "=", "kwargs", ".", "get", "(", "'force'", ")", "for", "o", "in", "objects", ":", "i...
8b5607a856341df85df33422accc30ba9294dbdb
test
Session.refresh_all
This method is an alternate API for refreshing all entities tracked by the session. You can call:: session.refresh_all() session.refresh_all(force=True) And all entities known by the session will be reloaded from Redis. To force reloading for modified entities, you can...
rom/util.py
def refresh_all(self, *objects, **kwargs): ''' This method is an alternate API for refreshing all entities tracked by the session. You can call:: session.refresh_all() session.refresh_all(force=True) And all entities known by the session will be reloaded from Re...
def refresh_all(self, *objects, **kwargs): ''' This method is an alternate API for refreshing all entities tracked by the session. You can call:: session.refresh_all() session.refresh_all(force=True) And all entities known by the session will be reloaded from Re...
[ "This", "method", "is", "an", "alternate", "API", "for", "refreshing", "all", "entities", "tracked", "by", "the", "session", ".", "You", "can", "call", "::" ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/util.py#L658-L670
[ "def", "refresh_all", "(", "self", ",", "*", "objects", ",", "*", "*", "kwargs", ")", ":", "self", ".", "refresh", "(", "*", "self", ".", "known", ".", "values", "(", ")", ",", "force", "=", "kwargs", ".", "get", "(", "'force'", ")", ")" ]
8b5607a856341df85df33422accc30ba9294dbdb
test
redis_writer_lua
... Actually write data to Redis. This is an internal detail. Please don't call me directly.
rom/model.py
def redis_writer_lua(conn, pkey, namespace, id, unique, udelete, delete, data, keys, scored, prefix, suffix, geo, old_data, is_delete): ''' ... Actually write data to Redis. This is an internal detail. Please don't call me directly. ''' ldata = [] for pair in data.items(): ...
def redis_writer_lua(conn, pkey, namespace, id, unique, udelete, delete, data, keys, scored, prefix, suffix, geo, old_data, is_delete): ''' ... Actually write data to Redis. This is an internal detail. Please don't call me directly. ''' ldata = [] for pair in data.items(): ...
[ "...", "Actually", "write", "data", "to", "Redis", ".", "This", "is", "an", "internal", "detail", ".", "Please", "don", "t", "call", "me", "directly", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/model.py#L859-L904
[ "def", "redis_writer_lua", "(", "conn", ",", "pkey", ",", "namespace", ",", "id", ",", "unique", ",", "udelete", ",", "delete", ",", "data", ",", "keys", ",", "scored", ",", "prefix", ",", "suffix", ",", "geo", ",", "old_data", ",", "is_delete", ")", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
Model.save
Saves the current entity to Redis. Will only save changed data by default, but you can force a full save by passing ``full=True``. If the underlying entity was deleted and you want to re-save the entity, you can pass ``force=True`` to force a full re-save of the entity.
rom/model.py
def save(self, full=False, force=False): ''' Saves the current entity to Redis. Will only save changed data by default, but you can force a full save by passing ``full=True``. If the underlying entity was deleted and you want to re-save the entity, you can pass ``force=True`` to...
def save(self, full=False, force=False): ''' Saves the current entity to Redis. Will only save changed data by default, but you can force a full save by passing ``full=True``. If the underlying entity was deleted and you want to re-save the entity, you can pass ``force=True`` to...
[ "Saves", "the", "current", "entity", "to", "Redis", ".", "Will", "only", "save", "changed", "data", "by", "default", "but", "you", "can", "force", "a", "full", "save", "by", "passing", "full", "=", "True", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/model.py#L475-L502
[ "def", "save", "(", "self", ",", "full", "=", "False", ",", "force", "=", "False", ")", ":", "# handle the pre-commit hooks", "was_new", "=", "self", ".", "_new", "if", "was_new", ":", "self", ".", "_before_insert", "(", ")", "else", ":", "self", ".", ...
8b5607a856341df85df33422accc30ba9294dbdb
test
Model.delete
Deletes the entity immediately. Also performs any on_delete operations specified as part of column definitions.
rom/model.py
def delete(self, **kwargs): ''' Deletes the entity immediately. Also performs any on_delete operations specified as part of column definitions. ''' if kwargs.get('skip_on_delete_i_really_mean_it') is not SKIP_ON_DELETE: # handle the pre-commit hook self._b...
def delete(self, **kwargs): ''' Deletes the entity immediately. Also performs any on_delete operations specified as part of column definitions. ''' if kwargs.get('skip_on_delete_i_really_mean_it') is not SKIP_ON_DELETE: # handle the pre-commit hook self._b...
[ "Deletes", "the", "entity", "immediately", ".", "Also", "performs", "any", "on_delete", "operations", "specified", "as", "part", "of", "column", "definitions", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/model.py#L504-L521
[ "def", "delete", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'skip_on_delete_i_really_mean_it'", ")", "is", "not", "SKIP_ON_DELETE", ":", "# handle the pre-commit hook", "self", ".", "_before_delete", "(", ")", "# handle any...
8b5607a856341df85df33422accc30ba9294dbdb
test
Model.copy
Creates a shallow copy of the given entity (any entities that can be retrieved from a OneToMany relationship will not be copied).
rom/model.py
def copy(self): ''' Creates a shallow copy of the given entity (any entities that can be retrieved from a OneToMany relationship will not be copied). ''' x = self.to_dict() x.pop(self._pkey) return self.__class__(**x)
def copy(self): ''' Creates a shallow copy of the given entity (any entities that can be retrieved from a OneToMany relationship will not be copied). ''' x = self.to_dict() x.pop(self._pkey) return self.__class__(**x)
[ "Creates", "a", "shallow", "copy", "of", "the", "given", "entity", "(", "any", "entities", "that", "can", "be", "retrieved", "from", "a", "OneToMany", "relationship", "will", "not", "be", "copied", ")", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/model.py#L523-L530
[ "def", "copy", "(", "self", ")", ":", "x", "=", "self", ".", "to_dict", "(", ")", "x", ".", "pop", "(", "self", ".", "_pkey", ")", "return", "self", ".", "__class__", "(", "*", "*", "x", ")" ]
8b5607a856341df85df33422accc30ba9294dbdb
test
Model.get
Will fetch one or more entities of this type from the session or Redis. Used like:: MyModel.get(5) MyModel.get([1, 6, 2, 4]) Passing a list or a tuple will return multiple entities, in the same order that the ids were passed.
rom/model.py
def get(cls, ids): ''' Will fetch one or more entities of this type from the session or Redis. Used like:: MyModel.get(5) MyModel.get([1, 6, 2, 4]) Passing a list or a tuple will return multiple entities, in the same order that the ids were pass...
def get(cls, ids): ''' Will fetch one or more entities of this type from the session or Redis. Used like:: MyModel.get(5) MyModel.get([1, 6, 2, 4]) Passing a list or a tuple will return multiple entities, in the same order that the ids were pass...
[ "Will", "fetch", "one", "or", "more", "entities", "of", "this", "type", "from", "the", "session", "or", "Redis", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/model.py#L533-L573
[ "def", "get", "(", "cls", ",", "ids", ")", ":", "conn", "=", "_connect", "(", "cls", ")", "# prepare the ids", "single", "=", "not", "isinstance", "(", "ids", ",", "(", "list", ",", "tuple", ",", "set", ",", "frozenset", ")", ")", "if", "single", "...
8b5607a856341df85df33422accc30ba9294dbdb
test
Model.get_by
This method offers a simple query method for fetching entities of this type via attribute numeric ranges (such columns must be ``indexed``), or via ``unique`` columns. Some examples:: user = User.get_by(email_address='user@domain.com') # gets up to 25 users created in t...
rom/model.py
def get_by(cls, **kwargs): ''' This method offers a simple query method for fetching entities of this type via attribute numeric ranges (such columns must be ``indexed``), or via ``unique`` columns. Some examples:: user = User.get_by(email_address='user@domain.com')...
def get_by(cls, **kwargs): ''' This method offers a simple query method for fetching entities of this type via attribute numeric ranges (such columns must be ``indexed``), or via ``unique`` columns. Some examples:: user = User.get_by(email_address='user@domain.com')...
[ "This", "method", "offers", "a", "simple", "query", "method", "for", "fetching", "entities", "of", "this", "type", "via", "attribute", "numeric", "ranges", "(", "such", "columns", "must", "be", "indexed", ")", "or", "via", "unique", "columns", "." ]
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/model.py#L576-L663
[ "def", "get_by", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "conn", "=", "_connect", "(", "cls", ")", "model", "=", "cls", ".", "_namespace", "# handle limits and query requirements", "_limit", "=", "kwargs", ".", "pop", "(", "'_limit'", ",", "(", ")...
8b5607a856341df85df33422accc30ba9294dbdb
test
Model.update
Updates multiple attributes in a model. If ``args`` are provided, this method will assign attributes in the order returned by ``list(self._columns)`` until one or both are exhausted. If ``kwargs`` are provided, this method will assign attributes to the names provided, after ``args`` hav...
rom/model.py
def update(self, *args, **kwargs): ''' Updates multiple attributes in a model. If ``args`` are provided, this method will assign attributes in the order returned by ``list(self._columns)`` until one or both are exhausted. If ``kwargs`` are provided, this method will assign attri...
def update(self, *args, **kwargs): ''' Updates multiple attributes in a model. If ``args`` are provided, this method will assign attributes in the order returned by ``list(self._columns)`` until one or both are exhausted. If ``kwargs`` are provided, this method will assign attri...
[ "Updates", "multiple", "attributes", "in", "a", "model", ".", "If", "args", "are", "provided", "this", "method", "will", "assign", "attributes", "in", "the", "order", "returned", "by", "list", "(", "self", ".", "_columns", ")", "until", "one", "or", "both"...
josiahcarlson/rom
python
https://github.com/josiahcarlson/rom/blob/8b5607a856341df85df33422accc30ba9294dbdb/rom/model.py#L673-L687
[ "def", "update", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "sa", "=", "setattr", "for", "a", ",", "v", "in", "zip", "(", "self", ".", "_columns", ",", "args", ")", ":", "sa", "(", "self", ",", "a", ",", "v", ")", "fo...
8b5607a856341df85df33422accc30ba9294dbdb
test
dump
Replacement for pickle.dump() using _LokyPickler.
loky/backend/reduction.py
def dump(obj, file, reducers=None, protocol=None): '''Replacement for pickle.dump() using _LokyPickler.''' global _LokyPickler _LokyPickler(file, reducers=reducers, protocol=protocol).dump(obj)
def dump(obj, file, reducers=None, protocol=None): '''Replacement for pickle.dump() using _LokyPickler.''' global _LokyPickler _LokyPickler(file, reducers=reducers, protocol=protocol).dump(obj)
[ "Replacement", "for", "pickle", ".", "dump", "()", "using", "_LokyPickler", "." ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/backend/reduction.py#L237-L240
[ "def", "dump", "(", "obj", ",", "file", ",", "reducers", "=", "None", ",", "protocol", "=", "None", ")", ":", "global", "_LokyPickler", "_LokyPickler", "(", "file", ",", "reducers", "=", "reducers", ",", "protocol", "=", "protocol", ")", ".", "dump", "...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
_ReducerRegistry.register
Attach a reducer function to a given type in the dispatch table.
loky/backend/reduction.py
def register(cls, type, reduce_func): """Attach a reducer function to a given type in the dispatch table.""" if sys.version_info < (3,): # Python 2 pickler dispatching is not explicitly customizable. # Let us use a closure to workaround this limitation. def dispatcher...
def register(cls, type, reduce_func): """Attach a reducer function to a given type in the dispatch table.""" if sys.version_info < (3,): # Python 2 pickler dispatching is not explicitly customizable. # Let us use a closure to workaround this limitation. def dispatcher...
[ "Attach", "a", "reducer", "function", "to", "a", "given", "type", "in", "the", "dispatch", "table", "." ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/backend/reduction.py#L58-L68
[ "def", "register", "(", "cls", ",", "type", ",", "reduce_func", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", ")", ":", "# Python 2 pickler dispatching is not explicitly customizable.", "# Let us use a closure to workaround this limitation.", "def", "d...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
_sem_open
Construct or retrieve a semaphore with the given name If value is None, try to retrieve an existing named semaphore. Else create a new semaphore with the given value
loky/backend/semlock.py
def _sem_open(name, value=None): """ Construct or retrieve a semaphore with the given name If value is None, try to retrieve an existing named semaphore. Else create a new semaphore with the given value """ if value is None: handle = pthread.sem_open(ctypes.c_char_p(name), 0) else: ...
def _sem_open(name, value=None): """ Construct or retrieve a semaphore with the given name If value is None, try to retrieve an existing named semaphore. Else create a new semaphore with the given value """ if value is None: handle = pthread.sem_open(ctypes.c_char_p(name), 0) else: ...
[ "Construct", "or", "retrieve", "a", "semaphore", "with", "the", "given", "name" ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/backend/semlock.py#L75-L99
[ "def", "_sem_open", "(", "name", ",", "value", "=", "None", ")", ":", "if", "value", "is", "None", ":", "handle", "=", "pthread", ".", "sem_open", "(", "ctypes", ".", "c_char_p", "(", "name", ")", ",", "0", ")", "else", ":", "handle", "=", "pthread...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
cpu_count
Return the number of CPUs the current process can use. The returned number of CPUs accounts for: * the number of CPUs in the system, as given by ``multiprocessing.cpu_count``; * the CPU affinity settings of the current process (available with Python 3.4+ on some Unix systems); * CFS sc...
loky/backend/context.py
def cpu_count(): """Return the number of CPUs the current process can use. The returned number of CPUs accounts for: * the number of CPUs in the system, as given by ``multiprocessing.cpu_count``; * the CPU affinity settings of the current process (available with Python 3.4+ on some Unix...
def cpu_count(): """Return the number of CPUs the current process can use. The returned number of CPUs accounts for: * the number of CPUs in the system, as given by ``multiprocessing.cpu_count``; * the CPU affinity settings of the current process (available with Python 3.4+ on some Unix...
[ "Return", "the", "number", "of", "CPUs", "the", "current", "process", "can", "use", "." ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/backend/context.py#L104-L153
[ "def", "cpu_count", "(", ")", ":", "import", "math", "try", ":", "cpu_count_mp", "=", "mp", ".", "cpu_count", "(", ")", "except", "NotImplementedError", ":", "cpu_count_mp", "=", "1", "# Number of available CPUs given affinity settings", "cpu_count_affinity", "=", "...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
LokyContext.Queue
Returns a queue object
loky/backend/context.py
def Queue(self, maxsize=0, reducers=None): '''Returns a queue object''' from .queues import Queue return Queue(maxsize, reducers=reducers, ctx=self.get_context())
def Queue(self, maxsize=0, reducers=None): '''Returns a queue object''' from .queues import Queue return Queue(maxsize, reducers=reducers, ctx=self.get_context())
[ "Returns", "a", "queue", "object" ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/backend/context.py#L162-L166
[ "def", "Queue", "(", "self", ",", "maxsize", "=", "0", ",", "reducers", "=", "None", ")", ":", "from", ".", "queues", "import", "Queue", "return", "Queue", "(", "maxsize", ",", "reducers", "=", "reducers", ",", "ctx", "=", "self", ".", "get_context", ...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
LokyContext.SimpleQueue
Returns a queue object
loky/backend/context.py
def SimpleQueue(self, reducers=None): '''Returns a queue object''' from .queues import SimpleQueue return SimpleQueue(reducers=reducers, ctx=self.get_context())
def SimpleQueue(self, reducers=None): '''Returns a queue object''' from .queues import SimpleQueue return SimpleQueue(reducers=reducers, ctx=self.get_context())
[ "Returns", "a", "queue", "object" ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/backend/context.py#L168-L171
[ "def", "SimpleQueue", "(", "self", ",", "reducers", "=", "None", ")", ":", "from", ".", "queues", "import", "SimpleQueue", "return", "SimpleQueue", "(", "reducers", "=", "reducers", ",", "ctx", "=", "self", ".", "get_context", "(", ")", ")" ]
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
_get_chunks
Iterates over zip()ed iterables in chunks.
loky/process_executor.py
def _get_chunks(chunksize, *iterables): """Iterates over zip()ed iterables in chunks. """ if sys.version_info < (3, 3): it = itertools.izip(*iterables) else: it = zip(*iterables) while True: chunk = tuple(itertools.islice(it, chunksize)) if not chunk: return ...
def _get_chunks(chunksize, *iterables): """Iterates over zip()ed iterables in chunks. """ if sys.version_info < (3, 3): it = itertools.izip(*iterables) else: it = zip(*iterables) while True: chunk = tuple(itertools.islice(it, chunksize)) if not chunk: return ...
[ "Iterates", "over", "zip", "()", "ed", "iterables", "in", "chunks", "." ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/process_executor.py#L315-L325
[ "def", "_get_chunks", "(", "chunksize", ",", "*", "iterables", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", "3", ")", ":", "it", "=", "itertools", ".", "izip", "(", "*", "iterables", ")", "else", ":", "it", "=", "zip", "(", "*"...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
_sendback_result
Safely send back the given result or exception
loky/process_executor.py
def _sendback_result(result_queue, work_id, result=None, exception=None): """Safely send back the given result or exception""" try: result_queue.put(_ResultItem(work_id, result=result, exception=exception)) except BaseException as e: exc = _ExceptionWithT...
def _sendback_result(result_queue, work_id, result=None, exception=None): """Safely send back the given result or exception""" try: result_queue.put(_ResultItem(work_id, result=result, exception=exception)) except BaseException as e: exc = _ExceptionWithT...
[ "Safely", "send", "back", "the", "given", "result", "or", "exception" ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/process_executor.py#L340-L347
[ "def", "_sendback_result", "(", "result_queue", ",", "work_id", ",", "result", "=", "None", ",", "exception", "=", "None", ")", ":", "try", ":", "result_queue", ".", "put", "(", "_ResultItem", "(", "work_id", ",", "result", "=", "result", ",", "exception",...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
_process_worker
Evaluates calls from call_queue and places the results in result_queue. This worker is run in a separate process. Args: call_queue: A ctx.Queue of _CallItems that will be read and evaluated by the worker. result_queue: A ctx.Queue of _ResultItems that will written to by...
loky/process_executor.py
def _process_worker(call_queue, result_queue, initializer, initargs, processes_management_lock, timeout, worker_exit_lock, current_depth): """Evaluates calls from call_queue and places the results in result_queue. This worker is run in a separate process. Args: ...
def _process_worker(call_queue, result_queue, initializer, initargs, processes_management_lock, timeout, worker_exit_lock, current_depth): """Evaluates calls from call_queue and places the results in result_queue. This worker is run in a separate process. Args: ...
[ "Evaluates", "calls", "from", "call_queue", "and", "places", "the", "results", "in", "result_queue", "." ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/process_executor.py#L350-L465
[ "def", "_process_worker", "(", "call_queue", ",", "result_queue", ",", "initializer", ",", "initargs", ",", "processes_management_lock", ",", "timeout", ",", "worker_exit_lock", ",", "current_depth", ")", ":", "if", "initializer", "is", "not", "None", ":", "try", ...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
_add_call_item_to_queue
Fills call_queue with _WorkItems from pending_work_items. This function never blocks. Args: pending_work_items: A dict mapping work ids to _WorkItems e.g. {5: <_WorkItem...>, 6: <_WorkItem...>, ...} work_ids: A queue.Queue of work ids e.g. Queue([5, 6, ...]). Work ids a...
loky/process_executor.py
def _add_call_item_to_queue(pending_work_items, running_work_items, work_ids, call_queue): """Fills call_queue with _WorkItems from pending_work_items. This function never blocks. Args: pending_work_items: A dict m...
def _add_call_item_to_queue(pending_work_items, running_work_items, work_ids, call_queue): """Fills call_queue with _WorkItems from pending_work_items. This function never blocks. Args: pending_work_items: A dict m...
[ "Fills", "call_queue", "with", "_WorkItems", "from", "pending_work_items", "." ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/process_executor.py#L468-L505
[ "def", "_add_call_item_to_queue", "(", "pending_work_items", ",", "running_work_items", ",", "work_ids", ",", "call_queue", ")", ":", "while", "True", ":", "if", "call_queue", ".", "full", "(", ")", ":", "return", "try", ":", "work_id", "=", "work_ids", ".", ...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
_queue_management_worker
Manages the communication between this process and the worker processes. This function is run in a local thread. Args: executor_reference: A weakref.ref to the ProcessPoolExecutor that owns this thread. Used to determine if the ProcessPoolExecutor has been garbage collected and...
loky/process_executor.py
def _queue_management_worker(executor_reference, executor_flags, processes, pending_work_items, running_work_items, work_ids_queue, call_queue, ...
def _queue_management_worker(executor_reference, executor_flags, processes, pending_work_items, running_work_items, work_ids_queue, call_queue, ...
[ "Manages", "the", "communication", "between", "this", "process", "and", "the", "worker", "processes", "." ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/process_executor.py#L508-L757
[ "def", "_queue_management_worker", "(", "executor_reference", ",", "executor_flags", ",", "processes", ",", "pending_work_items", ",", "running_work_items", ",", "work_ids_queue", ",", "call_queue", ",", "result_queue", ",", "thread_wakeup", ",", "processes_management_lock"...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
ProcessPoolExecutor._ensure_executor_running
ensures all workers and management thread are running
loky/process_executor.py
def _ensure_executor_running(self): """ensures all workers and management thread are running """ with self._processes_management_lock: if len(self._processes) != self._max_workers: self._adjust_process_count() self._start_queue_management_thread()
def _ensure_executor_running(self): """ensures all workers and management thread are running """ with self._processes_management_lock: if len(self._processes) != self._max_workers: self._adjust_process_count() self._start_queue_management_thread()
[ "ensures", "all", "workers", "and", "management", "thread", "are", "running" ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/process_executor.py#L1011-L1017
[ "def", "_ensure_executor_running", "(", "self", ")", ":", "with", "self", ".", "_processes_management_lock", ":", "if", "len", "(", "self", ".", "_processes", ")", "!=", "self", ".", "_max_workers", ":", "self", ".", "_adjust_process_count", "(", ")", "self", ...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
ProcessPoolExecutor.map
Returns an iterator equivalent to map(fn, iter). Args: fn: A callable that will take as many arguments as there are passed iterables. timeout: The maximum number of seconds to wait. If None, then there is no limit on the wait time. chunksize: ...
loky/process_executor.py
def map(self, fn, *iterables, **kwargs): """Returns an iterator equivalent to map(fn, iter). Args: fn: A callable that will take as many arguments as there are passed iterables. timeout: The maximum number of seconds to wait. If None, then there i...
def map(self, fn, *iterables, **kwargs): """Returns an iterator equivalent to map(fn, iter). Args: fn: A callable that will take as many arguments as there are passed iterables. timeout: The maximum number of seconds to wait. If None, then there i...
[ "Returns", "an", "iterator", "equivalent", "to", "map", "(", "fn", "iter", ")", "." ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/process_executor.py#L1046-L1076
[ "def", "map", "(", "self", ",", "fn", ",", "*", "iterables", ",", "*", "*", "kwargs", ")", ":", "timeout", "=", "kwargs", ".", "get", "(", "'timeout'", ",", "None", ")", "chunksize", "=", "kwargs", ".", "get", "(", "'chunksize'", ",", "1", ")", "...
dc2d941d8285a96f3a5b666a4bd04875b0b25984
test
wrap_non_picklable_objects
Wrapper for non-picklable object to use cloudpickle to serialize them. Note that this wrapper tends to slow down the serialization process as it is done with cloudpickle which is typically slower compared to pickle. The proper way to solve serialization issues is to avoid defining functions and objects...
loky/cloudpickle_wrapper.py
def wrap_non_picklable_objects(obj, keep_wrapper=True): """Wrapper for non-picklable object to use cloudpickle to serialize them. Note that this wrapper tends to slow down the serialization process as it is done with cloudpickle which is typically slower compared to pickle. The proper way to solve seri...
def wrap_non_picklable_objects(obj, keep_wrapper=True): """Wrapper for non-picklable object to use cloudpickle to serialize them. Note that this wrapper tends to slow down the serialization process as it is done with cloudpickle which is typically slower compared to pickle. The proper way to solve seri...
[ "Wrapper", "for", "non", "-", "picklable", "object", "to", "use", "cloudpickle", "to", "serialize", "them", "." ]
tomMoral/loky
python
https://github.com/tomMoral/loky/blob/dc2d941d8285a96f3a5b666a4bd04875b0b25984/loky/cloudpickle_wrapper.py#L86-L113
[ "def", "wrap_non_picklable_objects", "(", "obj", ",", "keep_wrapper", "=", "True", ")", ":", "if", "not", "cloudpickle", ":", "raise", "ImportError", "(", "\"could not import cloudpickle. Please install \"", "\"cloudpickle to allow extended serialization. \"", "\"(`pip install ...
dc2d941d8285a96f3a5b666a4bd04875b0b25984