repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
jamieleshaw/lurklib
lurklib/core.py
_Core.readable
def readable(self, timeout=2): """ Checks whether self.recv() will block or not. Optional arguments: * timeout=1 - Wait for the socket to be readable, for timeout amount of time. """ with self.lock: if len(self._buffer) > self._index: ...
python
def readable(self, timeout=2): """ Checks whether self.recv() will block or not. Optional arguments: * timeout=1 - Wait for the socket to be readable, for timeout amount of time. """ with self.lock: if len(self._buffer) > self._index: ...
[ "def", "readable", "(", "self", ",", "timeout", "=", "2", ")", ":", "with", "self", ".", "lock", ":", "if", "len", "(", "self", ".", "_buffer", ")", ">", "self", ".", "_index", ":", "return", "True", "else", ":", "if", "self", ".", "_select", "("...
Checks whether self.recv() will block or not. Optional arguments: * timeout=1 - Wait for the socket to be readable, for timeout amount of time.
[ "Checks", "whether", "self", ".", "recv", "()", "will", "block", "or", "not", ".", "Optional", "arguments", ":", "*", "timeout", "=", "1", "-", "Wait", "for", "the", "socket", "to", "be", "readable", "for", "timeout", "amount", "of", "time", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/core.py#L166-L180
jamieleshaw/lurklib
lurklib/core.py
_Core.stepback
def stepback(self, append=False): """ Stepbacks/reverses the buffer. Optional arguments: * append=False - If True, appends the data onto the buffer; else, it just steps the index back. """ if append: data = self._buffer[self._index - 1]...
python
def stepback(self, append=False): """ Stepbacks/reverses the buffer. Optional arguments: * append=False - If True, appends the data onto the buffer; else, it just steps the index back. """ if append: data = self._buffer[self._index - 1]...
[ "def", "stepback", "(", "self", ",", "append", "=", "False", ")", ":", "if", "append", ":", "data", "=", "self", ".", "_buffer", "[", "self", ".", "_index", "-", "1", "]", "self", ".", "_buffer", ".", "append", "(", "data", ")", "else", ":", "sel...
Stepbacks/reverses the buffer. Optional arguments: * append=False - If True, appends the data onto the buffer; else, it just steps the index back.
[ "Stepbacks", "/", "reverses", "the", "buffer", ".", "Optional", "arguments", ":", "*", "append", "=", "False", "-", "If", "True", "appends", "the", "data", "onto", "the", "buffer", ";", "else", "it", "just", "steps", "the", "index", "back", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/core.py#L187-L198
jamieleshaw/lurklib
lurklib/core.py
_Core._from_
def _from_(self, who): """ Processes nick!user@host data. Returns a tuple containing, the nick, user and host. If a valid hostmask isn't found, return the data as is. Required arguments: * who - nick!user@host data. """ try: host = who.split('@...
python
def _from_(self, who): """ Processes nick!user@host data. Returns a tuple containing, the nick, user and host. If a valid hostmask isn't found, return the data as is. Required arguments: * who - nick!user@host data. """ try: host = who.split('@...
[ "def", "_from_", "(", "self", ",", "who", ")", ":", "try", ":", "host", "=", "who", ".", "split", "(", "'@'", ",", "1", ")", "nickident", "=", "host", "[", "0", "]", ".", "split", "(", "'!'", ",", "1", ")", "nick", "=", "nickident", "[", "0",...
Processes nick!user@host data. Returns a tuple containing, the nick, user and host. If a valid hostmask isn't found, return the data as is. Required arguments: * who - nick!user@host data.
[ "Processes", "nick!user" ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/core.py#L200-L216
jamieleshaw/lurklib
lurklib/core.py
_Core._recv
def _recv(self, rm_colon=False, blocking=True, expected_replies=None, default_rvalue=[''], ignore_unexpected_replies=True, rm_first=True, recur_limit=10): """ Receives and processes an IRC protocol message. Optional arguments: * rm_colon=False - If True: ...
python
def _recv(self, rm_colon=False, blocking=True, expected_replies=None, default_rvalue=[''], ignore_unexpected_replies=True, rm_first=True, recur_limit=10): """ Receives and processes an IRC protocol message. Optional arguments: * rm_colon=False - If True: ...
[ "def", "_recv", "(", "self", ",", "rm_colon", "=", "False", ",", "blocking", "=", "True", ",", "expected_replies", "=", "None", ",", "default_rvalue", "=", "[", "''", "]", ",", "ignore_unexpected_replies", "=", "True", ",", "rm_first", "=", "True", ",", ...
Receives and processes an IRC protocol message. Optional arguments: * rm_colon=False - If True: If the message is > 3 items long: Remove the colon(if found) from the [3] item. Else: Remove the colon(if fo...
[ "Receives", "and", "processes", "an", "IRC", "protocol", "message", ".", "Optional", "arguments", ":", "*", "rm_colon", "=", "False", "-", "If", "True", ":", "If", "the", "message", "is", ">", "3", "items", "long", ":", "Remove", "the", "colon", "(", "...
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/core.py#L218-L284
jamieleshaw/lurklib
lurklib/core.py
_Core.recv
def recv(self, timeout=None): """ High-level IRC buffering system and processor. Optional arguments: * timeout=None - Time to wait before returning None. Defaults to waiting forever. """ with self.lock: if timeout != None: if self.r...
python
def recv(self, timeout=None): """ High-level IRC buffering system and processor. Optional arguments: * timeout=None - Time to wait before returning None. Defaults to waiting forever. """ with self.lock: if timeout != None: if self.r...
[ "def", "recv", "(", "self", ",", "timeout", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "if", "timeout", "!=", "None", ":", "if", "self", ".", "readable", "(", "timeout", ")", "==", "False", ":", "return", "None", "data", "=", "self", ...
High-level IRC buffering system and processor. Optional arguments: * timeout=None - Time to wait before returning None. Defaults to waiting forever.
[ "High", "-", "level", "IRC", "buffering", "system", "and", "processor", ".", "Optional", "arguments", ":", "*", "timeout", "=", "None", "-", "Time", "to", "wait", "before", "returning", "None", ".", "Defaults", "to", "waiting", "forever", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/core.py#L286-L435
jamieleshaw/lurklib
lurklib/core.py
_Core.compare
def compare(self, first, second): """ Case in-sensitive comparison of two strings. Required arguments: * first - The first string to compare. * second - The second string to compare. """ if first.lower() == second.lower(): return True else: ...
python
def compare(self, first, second): """ Case in-sensitive comparison of two strings. Required arguments: * first - The first string to compare. * second - The second string to compare. """ if first.lower() == second.lower(): return True else: ...
[ "def", "compare", "(", "self", ",", "first", ",", "second", ")", ":", "if", "first", ".", "lower", "(", ")", "==", "second", ".", "lower", "(", ")", ":", "return", "True", "else", ":", "return", "False" ]
Case in-sensitive comparison of two strings. Required arguments: * first - The first string to compare. * second - The second string to compare.
[ "Case", "in", "-", "sensitive", "comparison", "of", "two", "strings", ".", "Required", "arguments", ":", "*", "first", "-", "The", "first", "string", "to", "compare", ".", "*", "second", "-", "The", "second", "string", "to", "compare", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/core.py#L437-L447
jut-io/jut-python-tools
jut/commands/upload.py
post
def post(json_data, url, dry_run=False): """ POST json data to the url provided and verify the requests was successful """ if dry_run: info('POST: %s' % json.dumps(json_data, indent=4)) else: response = SESSION.post(url, data=json.d...
python
def post(json_data, url, dry_run=False): """ POST json data to the url provided and verify the requests was successful """ if dry_run: info('POST: %s' % json.dumps(json_data, indent=4)) else: response = SESSION.post(url, data=json.d...
[ "def", "post", "(", "json_data", ",", "url", ",", "dry_run", "=", "False", ")", ":", "if", "dry_run", ":", "info", "(", "'POST: %s'", "%", "json", ".", "dumps", "(", "json_data", ",", "indent", "=", "4", ")", ")", "else", ":", "response", "=", "SES...
POST json data to the url provided and verify the requests was successful
[ "POST", "json", "data", "to", "the", "url", "provided", "and", "verify", "the", "requests", "was", "successful" ]
train
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/commands/upload.py#L19-L36
jut-io/jut-python-tools
jut/commands/upload.py
push_json_file
def push_json_file(json_file, url, dry_run=False, batch_size=100, anonymize_fields=[], remove_fields=[], rename_fields=[]): """ read the json file provided and POST in batches no bigger than the ...
python
def push_json_file(json_file, url, dry_run=False, batch_size=100, anonymize_fields=[], remove_fields=[], rename_fields=[]): """ read the json file provided and POST in batches no bigger than the ...
[ "def", "push_json_file", "(", "json_file", ",", "url", ",", "dry_run", "=", "False", ",", "batch_size", "=", "100", ",", "anonymize_fields", "=", "[", "]", ",", "remove_fields", "=", "[", "]", ",", "rename_fields", "=", "[", "]", ")", ":", "batch", "="...
read the json file provided and POST in batches no bigger than the batch_size specified to the specified url.
[ "read", "the", "json", "file", "provided", "and", "POST", "in", "batches", "no", "bigger", "than", "the", "batch_size", "specified", "to", "the", "specified", "url", "." ]
train
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/commands/upload.py#L43-L93
jmgilman/Neolib
neolib/shop/MainShop.py
MainShop.load
def load(self): """ Loads the shop name and inventory """ pg = self.usr.getPage("http://www.neopets.com/objects.phtml?type=shop&obj_type=" + self.id) self.name = pg.find("td", "contentModuleHeader").text.strip() self.inventory = MainShopInventory(self.usr, self.id)
python
def load(self): """ Loads the shop name and inventory """ pg = self.usr.getPage("http://www.neopets.com/objects.phtml?type=shop&obj_type=" + self.id) self.name = pg.find("td", "contentModuleHeader").text.strip() self.inventory = MainShopInventory(self.usr, self.id)
[ "def", "load", "(", "self", ")", ":", "pg", "=", "self", ".", "usr", ".", "getPage", "(", "\"http://www.neopets.com/objects.phtml?type=shop&obj_type=\"", "+", "self", ".", "id", ")", "self", ".", "name", "=", "pg", ".", "find", "(", "\"td\"", ",", "\"conte...
Loads the shop name and inventory
[ "Loads", "the", "shop", "name", "and", "inventory" ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/shop/MainShop.py#L48-L54
alfred82santa/aio-service-client
service_client/utils.py
random_token
def random_token(length=10): """ Builds a random string. :param length: Token length. **Default:** 10 :type length: int :return: str """ return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(length))
python
def random_token(length=10): """ Builds a random string. :param length: Token length. **Default:** 10 :type length: int :return: str """ return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(length))
[ "def", "random_token", "(", "length", "=", "10", ")", ":", "return", "''", ".", "join", "(", "random", ".", "choice", "(", "string", ".", "ascii_uppercase", "+", "string", ".", "digits", ")", "for", "_", "in", "range", "(", "length", ")", ")" ]
Builds a random string. :param length: Token length. **Default:** 10 :type length: int :return: str
[ "Builds", "a", "random", "string", "." ]
train
https://github.com/alfred82santa/aio-service-client/blob/dd9ad49e23067b22178534915aa23ba24f6ff39b/service_client/utils.py#L43-L52
sci-bots/mpm
mpm/commands.py
home_dir
def home_dir(): ''' Returns: str : Path to home directory (or ``Documents`` directory on Windows). ''' if os.name == 'nt': from win32com.shell import shell, shellcon return shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, 0, 0) else: return os.path.expanduser('~')
python
def home_dir(): ''' Returns: str : Path to home directory (or ``Documents`` directory on Windows). ''' if os.name == 'nt': from win32com.shell import shell, shellcon return shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, 0, 0) else: return os.path.expanduser('~')
[ "def", "home_dir", "(", ")", ":", "if", "os", ".", "name", "==", "'nt'", ":", "from", "win32com", ".", "shell", "import", "shell", ",", "shellcon", "return", "shell", ".", "SHGetFolderPath", "(", "0", ",", "shellcon", ".", "CSIDL_PERSONAL", ",", "0", "...
Returns: str : Path to home directory (or ``Documents`` directory on Windows).
[ "Returns", ":" ]
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/commands.py#L31-L42
sci-bots/mpm
mpm/commands.py
get_plugins_directory
def get_plugins_directory(config_path=None, microdrop_user_root=None): ''' Resolve plugins directory. Plugins directory is resolved as follows, highest-priority first: 1. ``plugins`` directory specified in provided :data:`config_path`. 2. ``plugins`` sub-directory of specified MicroDrop profile ...
python
def get_plugins_directory(config_path=None, microdrop_user_root=None): ''' Resolve plugins directory. Plugins directory is resolved as follows, highest-priority first: 1. ``plugins`` directory specified in provided :data:`config_path`. 2. ``plugins`` sub-directory of specified MicroDrop profile ...
[ "def", "get_plugins_directory", "(", "config_path", "=", "None", ",", "microdrop_user_root", "=", "None", ")", ":", "RESOLVED_BY_NONE", "=", "'default'", "RESOLVED_BY_CONFIG_ARG", "=", "'config_path argument'", "RESOLVED_BY_PROFILE_ARG", "=", "'microdrop_user_root argument'",...
Resolve plugins directory. Plugins directory is resolved as follows, highest-priority first: 1. ``plugins`` directory specified in provided :data:`config_path`. 2. ``plugins`` sub-directory of specified MicroDrop profile path (i.e., :data:`microdrop_user_root`) 3. ``plugins`` sub-directory ...
[ "Resolve", "plugins", "directory", "." ]
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/commands.py#L45-L123
sci-bots/mpm
mpm/commands.py
plugin_request
def plugin_request(plugin_str): ''' Extract plugin name and version specifiers from plugin descriptor string. .. versionchanged:: 0.25.2 Import from `pip_helpers` locally to avoid error `sci-bots/mpm#5`_. .. _sci-bots/mpm#5: https://github.com/sci-bots/mpm/issues/5 ''' from pip_hel...
python
def plugin_request(plugin_str): ''' Extract plugin name and version specifiers from plugin descriptor string. .. versionchanged:: 0.25.2 Import from `pip_helpers` locally to avoid error `sci-bots/mpm#5`_. .. _sci-bots/mpm#5: https://github.com/sci-bots/mpm/issues/5 ''' from pip_hel...
[ "def", "plugin_request", "(", "plugin_str", ")", ":", "from", "pip_helpers", "import", "CRE_PACKAGE", "match", "=", "CRE_PACKAGE", ".", "match", "(", "plugin_str", ")", "if", "not", "match", ":", "raise", "ValueError", "(", "'Invalid plugin descriptor. Must be like ...
Extract plugin name and version specifiers from plugin descriptor string. .. versionchanged:: 0.25.2 Import from `pip_helpers` locally to avoid error `sci-bots/mpm#5`_. .. _sci-bots/mpm#5: https://github.com/sci-bots/mpm/issues/5
[ "Extract", "plugin", "name", "and", "version", "specifiers", "from", "plugin", "descriptor", "string", "." ]
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/commands.py#L126-L141
sci-bots/mpm
mpm/commands.py
install
def install(plugin_package, plugins_directory, server_url=DEFAULT_SERVER_URL): ''' Parameters ---------- plugin_package : str Name of plugin package hosted on MicroDrop plugin index. Version constraints are also supported (e.g., ``"foo", "foo==1.0", "foo>=1.0"``, etc.) See `vers...
python
def install(plugin_package, plugins_directory, server_url=DEFAULT_SERVER_URL): ''' Parameters ---------- plugin_package : str Name of plugin package hosted on MicroDrop plugin index. Version constraints are also supported (e.g., ``"foo", "foo==1.0", "foo>=1.0"``, etc.) See `vers...
[ "def", "install", "(", "plugin_package", ",", "plugins_directory", ",", "server_url", "=", "DEFAULT_SERVER_URL", ")", ":", "import", "pip_helpers", "if", "path", "(", "plugin_package", ")", ".", "isfile", "(", ")", ":", "plugin_is_file", "=", "True", "with", "...
Parameters ---------- plugin_package : str Name of plugin package hosted on MicroDrop plugin index. Version constraints are also supported (e.g., ``"foo", "foo==1.0", "foo>=1.0"``, etc.) See `version specifiers`_ reference for more details. plugins_directory : str Pa...
[ "Parameters", "----------", "plugin_package", ":", "str", "Name", "of", "plugin", "package", "hosted", "on", "MicroDrop", "plugin", "index", ".", "Version", "constraints", "are", "also", "supported", "(", "e", ".", "g", ".", "foo", "foo", "==", "1", ".", "...
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/commands.py#L144-L243
sci-bots/mpm
mpm/commands.py
extract_metadata
def extract_metadata(fileobj): ''' Extract metadata from plugin archive file-like object (e.g., opened file, ``StringIO``). Parameters ---------- fileobj : file-like MicroDrop plugin archive file object. Returns ------- dict Metadata dictionary for plugin. ''' ...
python
def extract_metadata(fileobj): ''' Extract metadata from plugin archive file-like object (e.g., opened file, ``StringIO``). Parameters ---------- fileobj : file-like MicroDrop plugin archive file object. Returns ------- dict Metadata dictionary for plugin. ''' ...
[ "def", "extract_metadata", "(", "fileobj", ")", ":", "tar", "=", "tarfile", ".", "open", "(", "mode", "=", "\"r:gz\"", ",", "fileobj", "=", "fileobj", ")", "plugin_path", "=", "path", "(", "tmp", ".", "mkdtemp", "(", "prefix", "=", "'mpm-'", ")", ")", ...
Extract metadata from plugin archive file-like object (e.g., opened file, ``StringIO``). Parameters ---------- fileobj : file-like MicroDrop plugin archive file object. Returns ------- dict Metadata dictionary for plugin.
[ "Extract", "metadata", "from", "plugin", "archive", "file", "-", "like", "object", "(", "e", ".", "g", ".", "opened", "file", "StringIO", ")", "." ]
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/commands.py#L246-L270
sci-bots/mpm
mpm/commands.py
install_fileobj
def install_fileobj(fileobj, plugin_path): ''' Extract and install plugin from file-like object (e.g., opened file, ``StringIO``). Parameters ---------- fileobj : file-like MicroDrop plugin file object to extract and install. plugin_path : path Target plugin install director...
python
def install_fileobj(fileobj, plugin_path): ''' Extract and install plugin from file-like object (e.g., opened file, ``StringIO``). Parameters ---------- fileobj : file-like MicroDrop plugin file object to extract and install. plugin_path : path Target plugin install director...
[ "def", "install_fileobj", "(", "fileobj", ",", "plugin_path", ")", ":", "plugin_path", "=", "path", "(", "plugin_path", ")", "tar", "=", "tarfile", ".", "open", "(", "mode", "=", "\"r:gz\"", ",", "fileobj", "=", "fileobj", ")", "try", ":", "tar", ".", ...
Extract and install plugin from file-like object (e.g., opened file, ``StringIO``). Parameters ---------- fileobj : file-like MicroDrop plugin file object to extract and install. plugin_path : path Target plugin install directory path. Returns ------- (path, dict) ...
[ "Extract", "and", "install", "plugin", "from", "file", "-", "like", "object", "(", "e", ".", "g", ".", "opened", "file", "StringIO", ")", "." ]
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/commands.py#L273-L304
sci-bots/mpm
mpm/commands.py
uninstall
def uninstall(plugin_package, plugins_directory): ''' Parameters ---------- plugin_package : str Name of plugin package hosted on MicroDrop plugin index. plugins_directory : str Path to MicroDrop user plugins directory. ''' # Check existing version (if any). plugin_path =...
python
def uninstall(plugin_package, plugins_directory): ''' Parameters ---------- plugin_package : str Name of plugin package hosted on MicroDrop plugin index. plugins_directory : str Path to MicroDrop user plugins directory. ''' # Check existing version (if any). plugin_path =...
[ "def", "uninstall", "(", "plugin_package", ",", "plugins_directory", ")", ":", "# Check existing version (if any).", "plugin_path", "=", "plugins_directory", ".", "joinpath", "(", "plugin_package", ")", "if", "not", "plugin_path", ".", "isdir", "(", ")", ":", "raise...
Parameters ---------- plugin_package : str Name of plugin package hosted on MicroDrop plugin index. plugins_directory : str Path to MicroDrop user plugins directory.
[ "Parameters", "----------", "plugin_package", ":", "str", "Name", "of", "plugin", "package", "hosted", "on", "MicroDrop", "plugin", "index", ".", "plugins_directory", ":", "str", "Path", "to", "MicroDrop", "user", "plugins", "directory", "." ]
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/commands.py#L307-L338
sci-bots/mpm
mpm/commands.py
freeze
def freeze(plugins_directory): ''' Parameters ---------- plugins_directory : str Path to MicroDrop user plugins directory. Returns ------- list List of package strings corresponding to installed plugin versions. ''' # Check existing version (if any). package_vers...
python
def freeze(plugins_directory): ''' Parameters ---------- plugins_directory : str Path to MicroDrop user plugins directory. Returns ------- list List of package strings corresponding to installed plugin versions. ''' # Check existing version (if any). package_vers...
[ "def", "freeze", "(", "plugins_directory", ")", ":", "# Check existing version (if any).", "package_versions", "=", "[", "]", "for", "plugin_path_i", "in", "plugins_directory", ".", "dirs", "(", ")", ":", "try", ":", "plugin_metadata", "=", "yaml", ".", "load", ...
Parameters ---------- plugins_directory : str Path to MicroDrop user plugins directory. Returns ------- list List of package strings corresponding to installed plugin versions.
[ "Parameters", "----------", "plugins_directory", ":", "str", "Path", "to", "MicroDrop", "user", "plugins", "directory", "." ]
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/commands.py#L341-L365
sci-bots/mpm
mpm/commands.py
search
def search(plugin_package, server_url=DEFAULT_SERVER_URL): ''' Parameters ---------- plugin_package : str Name of plugin package hosted on MicroDrop plugin index. Version constraints are also supported (e.g., ``"foo", "foo==1.0", "foo>=1.0"``, etc.) See `version specifiers`_ ref...
python
def search(plugin_package, server_url=DEFAULT_SERVER_URL): ''' Parameters ---------- plugin_package : str Name of plugin package hosted on MicroDrop plugin index. Version constraints are also supported (e.g., ``"foo", "foo==1.0", "foo>=1.0"``, etc.) See `version specifiers`_ ref...
[ "def", "search", "(", "plugin_package", ",", "server_url", "=", "DEFAULT_SERVER_URL", ")", ":", "import", "pip_helpers", "# Look up latest release matching specifiers.", "return", "pip_helpers", ".", "get_releases", "(", "plugin_package", ",", "server_url", "=", "server_u...
Parameters ---------- plugin_package : str Name of plugin package hosted on MicroDrop plugin index. Version constraints are also supported (e.g., ``"foo", "foo==1.0", "foo>=1.0"``, etc.) See `version specifiers`_ reference for more details. server_url : str URL of JS...
[ "Parameters", "----------", "plugin_package", ":", "str", "Name", "of", "plugin", "package", "hosted", "on", "MicroDrop", "plugin", "index", ".", "Version", "constraints", "are", "also", "supported", "(", "e", ".", "g", ".", "foo", "foo", "==", "1", ".", "...
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/commands.py#L368-L399
billyoverton/tweetqueue
tweetqueue/__main__.py
tweetqueue
def tweetqueue(ctx, dry_run, config): """A command line tool for time-delaying your tweets.""" ctx.obj = {} ctx.obj['DRYRUN'] = dry_run # If the subcommand is "config", bypass all setup code if ctx.invoked_subcommand == 'config': return # If the config file wasn't provided, attempt to ...
python
def tweetqueue(ctx, dry_run, config): """A command line tool for time-delaying your tweets.""" ctx.obj = {} ctx.obj['DRYRUN'] = dry_run # If the subcommand is "config", bypass all setup code if ctx.invoked_subcommand == 'config': return # If the config file wasn't provided, attempt to ...
[ "def", "tweetqueue", "(", "ctx", ",", "dry_run", ",", "config", ")", ":", "ctx", ".", "obj", "=", "{", "}", "ctx", ".", "obj", "[", "'DRYRUN'", "]", "=", "dry_run", "# If the subcommand is \"config\", bypass all setup code", "if", "ctx", ".", "invoked_subcomma...
A command line tool for time-delaying your tweets.
[ "A", "command", "line", "tool", "for", "time", "-", "delaying", "your", "tweets", "." ]
train
https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L19-L73
billyoverton/tweetqueue
tweetqueue/__main__.py
tweet
def tweet(ctx, message): """Sends a tweet directly to your timeline""" if not valid_tweet(message): click.echo("Message is too long for twitter.") click.echo("Message:" + message) ctx.exit(2) if not ctx.obj['DRYRUN']: ctx.obj['TWEEPY_API'].update_status(message) else: ...
python
def tweet(ctx, message): """Sends a tweet directly to your timeline""" if not valid_tweet(message): click.echo("Message is too long for twitter.") click.echo("Message:" + message) ctx.exit(2) if not ctx.obj['DRYRUN']: ctx.obj['TWEEPY_API'].update_status(message) else: ...
[ "def", "tweet", "(", "ctx", ",", "message", ")", ":", "if", "not", "valid_tweet", "(", "message", ")", ":", "click", ".", "echo", "(", "\"Message is too long for twitter.\"", ")", "click", ".", "echo", "(", "\"Message:\"", "+", "message", ")", "ctx", ".", ...
Sends a tweet directly to your timeline
[ "Sends", "a", "tweet", "directly", "to", "your", "timeline" ]
train
https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L78-L88
billyoverton/tweetqueue
tweetqueue/__main__.py
queue
def queue(ctx, message): """Adds a message to your twitter queue""" if not valid_tweet(message): click.echo("Message is too long for twitter.") click.echo("Message: " + message) ctx.exit(2) if ctx.obj['DRYRUN']: click.echo("Message not queue due to dry-run mode.") ct...
python
def queue(ctx, message): """Adds a message to your twitter queue""" if not valid_tweet(message): click.echo("Message is too long for twitter.") click.echo("Message: " + message) ctx.exit(2) if ctx.obj['DRYRUN']: click.echo("Message not queue due to dry-run mode.") ct...
[ "def", "queue", "(", "ctx", ",", "message", ")", ":", "if", "not", "valid_tweet", "(", "message", ")", ":", "click", ".", "echo", "(", "\"Message is too long for twitter.\"", ")", "click", ".", "echo", "(", "\"Message: \"", "+", "message", ")", "ctx", ".",...
Adds a message to your twitter queue
[ "Adds", "a", "message", "to", "your", "twitter", "queue" ]
train
https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L93-L104
billyoverton/tweetqueue
tweetqueue/__main__.py
dequeue
def dequeue(ctx): """Sends a tweet from the queue""" tweet =ctx.obj['TWEETLIST'].peek() if tweet is None: click.echo("Nothing to dequeue.") ctx.exit(1) if ctx.obj['DRYRUN']: click.echo(tweet) else: tweet = ctx.obj['TWEETLIST'].pop() ctx.obj['TWEEPY_API'].upd...
python
def dequeue(ctx): """Sends a tweet from the queue""" tweet =ctx.obj['TWEETLIST'].peek() if tweet is None: click.echo("Nothing to dequeue.") ctx.exit(1) if ctx.obj['DRYRUN']: click.echo(tweet) else: tweet = ctx.obj['TWEETLIST'].pop() ctx.obj['TWEEPY_API'].upd...
[ "def", "dequeue", "(", "ctx", ")", ":", "tweet", "=", "ctx", ".", "obj", "[", "'TWEETLIST'", "]", ".", "peek", "(", ")", "if", "tweet", "is", "None", ":", "click", ".", "echo", "(", "\"Nothing to dequeue.\"", ")", "ctx", ".", "exit", "(", "1", ")",...
Sends a tweet from the queue
[ "Sends", "a", "tweet", "from", "the", "queue" ]
train
https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L108-L120
billyoverton/tweetqueue
tweetqueue/__main__.py
config
def config(ctx): """Creates a tweetqueue configuration file""" home_directory = os.path.expanduser('~') default_config_file = os.path.join(home_directory, '.tweetqueue') default_database_file = os.path.join(home_directory, '.tweetqueue.db') config = {} config['API_KEY'] = click.prompt('API Key...
python
def config(ctx): """Creates a tweetqueue configuration file""" home_directory = os.path.expanduser('~') default_config_file = os.path.join(home_directory, '.tweetqueue') default_database_file = os.path.join(home_directory, '.tweetqueue.db') config = {} config['API_KEY'] = click.prompt('API Key...
[ "def", "config", "(", "ctx", ")", ":", "home_directory", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "default_config_file", "=", "os", ".", "path", ".", "join", "(", "home_directory", ",", "'.tweetqueue'", ")", "default_database_file", "=", ...
Creates a tweetqueue configuration file
[ "Creates", "a", "tweetqueue", "configuration", "file" ]
train
https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L124-L143
billyoverton/tweetqueue
tweetqueue/__main__.py
delete
def delete(ctx,tweet): """Deletes a tweet from the queue with a given ID""" if not ctx.obj['DRYRUN']: try: ctx.obj['TWEETLIST'].delete(tweet) except ValueError as e: click.echo("Now tweet was found with that id.") ctx.exit(1) else: click.echo("Not ...
python
def delete(ctx,tweet): """Deletes a tweet from the queue with a given ID""" if not ctx.obj['DRYRUN']: try: ctx.obj['TWEETLIST'].delete(tweet) except ValueError as e: click.echo("Now tweet was found with that id.") ctx.exit(1) else: click.echo("Not ...
[ "def", "delete", "(", "ctx", ",", "tweet", ")", ":", "if", "not", "ctx", ".", "obj", "[", "'DRYRUN'", "]", ":", "try", ":", "ctx", ".", "obj", "[", "'TWEETLIST'", "]", ".", "delete", "(", "tweet", ")", "except", "ValueError", "as", "e", ":", "cli...
Deletes a tweet from the queue with a given ID
[ "Deletes", "a", "tweet", "from", "the", "queue", "with", "a", "given", "ID" ]
train
https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L148-L157
unionbilling/union-python
union/client.py
UnionClient.make_request
def make_request(self, model, action, url_params={}, post_data=None): ''' Send request to API then validate, parse, and return the response ''' url = self._create_url(model, **url_params) headers = self._headers(action) try: response = requests.request(action...
python
def make_request(self, model, action, url_params={}, post_data=None): ''' Send request to API then validate, parse, and return the response ''' url = self._create_url(model, **url_params) headers = self._headers(action) try: response = requests.request(action...
[ "def", "make_request", "(", "self", ",", "model", ",", "action", ",", "url_params", "=", "{", "}", ",", "post_data", "=", "None", ")", ":", "url", "=", "self", ".", "_create_url", "(", "model", ",", "*", "*", "url_params", ")", "headers", "=", "self"...
Send request to API then validate, parse, and return the response
[ "Send", "request", "to", "API", "then", "validate", "parse", "and", "return", "the", "response" ]
train
https://github.com/unionbilling/union-python/blob/551e4fc1a0b395b632781d80527a3660a7c67c0c/union/client.py#L98-L113
praekelt/jmbo-show
show/models.py
Show.get_primary_contributors
def get_primary_contributors(self): """ Returns a list of primary contributors, with primary being defined as those contributors that have the highest role assigned (in terms of priority). Only permitted contributors are returned. """ primary_credits = [] credits ...
python
def get_primary_contributors(self): """ Returns a list of primary contributors, with primary being defined as those contributors that have the highest role assigned (in terms of priority). Only permitted contributors are returned. """ primary_credits = [] credits ...
[ "def", "get_primary_contributors", "(", "self", ")", ":", "primary_credits", "=", "[", "]", "credits", "=", "self", ".", "credits", ".", "exclude", "(", "credit_option", "=", "None", ")", ".", "order_by", "(", "'credit_option__role_priority'", ")", "if", "cred...
Returns a list of primary contributors, with primary being defined as those contributors that have the highest role assigned (in terms of priority). Only permitted contributors are returned.
[ "Returns", "a", "list", "of", "primary", "contributors", "with", "primary", "being", "defined", "as", "those", "contributors", "that", "have", "the", "highest", "role", "assigned", "(", "in", "terms", "of", "priority", ")", ".", "Only", "permitted", "contribut...
train
https://github.com/praekelt/jmbo-show/blob/9e10b1722647945db70c4af6b6d8b0506a0dd683/show/models.py#L101-L123
aksas/pypo4sel
core/pypo4sel/core/waiter.py
wait
def wait(method, timeout, fail_on_timeout=None, **kwargs): """ Wait ``timeout`` seconds until ``method(**kwargs)`` returns a ``value`` that *bool(value)==True*. Returns last ``value``. If time expired and ``fail_on_timeout`` specified, then raise TimeoutException. :param method: :param timeout...
python
def wait(method, timeout, fail_on_timeout=None, **kwargs): """ Wait ``timeout`` seconds until ``method(**kwargs)`` returns a ``value`` that *bool(value)==True*. Returns last ``value``. If time expired and ``fail_on_timeout`` specified, then raise TimeoutException. :param method: :param timeout...
[ "def", "wait", "(", "method", ",", "timeout", ",", "fail_on_timeout", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "Waiter", "(", "lambda", "value", ":", "bool", "(", "value", ")", ")", ".", "start", "(", "method", ",", "timeout", ",", ...
Wait ``timeout`` seconds until ``method(**kwargs)`` returns a ``value`` that *bool(value)==True*. Returns last ``value``. If time expired and ``fail_on_timeout`` specified, then raise TimeoutException. :param method: :param timeout: :param fail_on_timeout: :param kwargs: :return:
[ "Wait", "timeout", "seconds", "until", "method", "(", "**", "kwargs", ")", "returns", "a", "value", "that", "*", "bool", "(", "value", ")", "==", "True", "*", ".", "Returns", "last", "value", ".", "If", "time", "expired", "and", "fail_on_timeout", "speci...
train
https://github.com/aksas/pypo4sel/blob/935b5f9bfa6682aefdef8a43ebcbcf274dec752c/core/pypo4sel/core/waiter.py#L43-L55
aksas/pypo4sel
core/pypo4sel/core/waiter.py
wait_not
def wait_not(method, timeout, fail_on_timeout=None, **kwargs): """ Wait ``timeout`` seconds until ``method(**kwargs)`` returns a ``value`` that *not value==True*. Returns last ``value``. If time expired and ``fail_on_timeout`` specified, then raise TimeoutException. :param method: :param timeo...
python
def wait_not(method, timeout, fail_on_timeout=None, **kwargs): """ Wait ``timeout`` seconds until ``method(**kwargs)`` returns a ``value`` that *not value==True*. Returns last ``value``. If time expired and ``fail_on_timeout`` specified, then raise TimeoutException. :param method: :param timeo...
[ "def", "wait_not", "(", "method", ",", "timeout", ",", "fail_on_timeout", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "Waiter", "(", "lambda", "value", ":", "not", "value", ")", ".", "start", "(", "method", ",", "timeout", ",", "fail_on_t...
Wait ``timeout`` seconds until ``method(**kwargs)`` returns a ``value`` that *not value==True*. Returns last ``value``. If time expired and ``fail_on_timeout`` specified, then raise TimeoutException. :param method: :param timeout: :param fail_on_timeout: :param kwargs: :return:
[ "Wait", "timeout", "seconds", "until", "method", "(", "**", "kwargs", ")", "returns", "a", "value", "that", "*", "not", "value", "==", "True", "*", ".", "Returns", "last", "value", ".", "If", "time", "expired", "and", "fail_on_timeout", "specified", "then"...
train
https://github.com/aksas/pypo4sel/blob/935b5f9bfa6682aefdef8a43ebcbcf274dec752c/core/pypo4sel/core/waiter.py#L58-L70
aksas/pypo4sel
core/pypo4sel/core/waiter.py
wait_displayed
def wait_displayed(element, timeout=None, fail_on_timeout=None): """ Wait until element becomes visible or time out. Returns true is element became visible, otherwise false. If timeout is not specified or 0, then uses specific element wait timeout. :param element: :param timeout: :param fail...
python
def wait_displayed(element, timeout=None, fail_on_timeout=None): """ Wait until element becomes visible or time out. Returns true is element became visible, otherwise false. If timeout is not specified or 0, then uses specific element wait timeout. :param element: :param timeout: :param fail...
[ "def", "wait_displayed", "(", "element", ",", "timeout", "=", "None", ",", "fail_on_timeout", "=", "None", ")", ":", "return", "wait", "(", "lambda", ":", "element", ".", "is_displayed", "(", ")", ",", "timeout", "or", "element", ".", "wait_timeout", ",", ...
Wait until element becomes visible or time out. Returns true is element became visible, otherwise false. If timeout is not specified or 0, then uses specific element wait timeout. :param element: :param timeout: :param fail_on_timeout: :return:
[ "Wait", "until", "element", "becomes", "visible", "or", "time", "out", ".", "Returns", "true", "is", "element", "became", "visible", "otherwise", "false", ".", "If", "timeout", "is", "not", "specified", "or", "0", "then", "uses", "specific", "element", "wait...
train
https://github.com/aksas/pypo4sel/blob/935b5f9bfa6682aefdef8a43ebcbcf274dec752c/core/pypo4sel/core/waiter.py#L73-L83
aksas/pypo4sel
core/pypo4sel/core/waiter.py
wait_not_displayed
def wait_not_displayed(element, timeout=None, fail_on_timeout=None): """ Wait until element becomes invisible or time out. Returns true is element became invisible, otherwise false. If timeout is not specified or 0, then uses specific element wait timeout. :param element: :param timeout: :pa...
python
def wait_not_displayed(element, timeout=None, fail_on_timeout=None): """ Wait until element becomes invisible or time out. Returns true is element became invisible, otherwise false. If timeout is not specified or 0, then uses specific element wait timeout. :param element: :param timeout: :pa...
[ "def", "wait_not_displayed", "(", "element", ",", "timeout", "=", "None", ",", "fail_on_timeout", "=", "None", ")", ":", "return", "wait", "(", "lambda", ":", "not", "element", ".", "is_displayed", "(", ")", ",", "timeout", "or", "element", ".", "wait_time...
Wait until element becomes invisible or time out. Returns true is element became invisible, otherwise false. If timeout is not specified or 0, then uses specific element wait timeout. :param element: :param timeout: :param fail_on_timeout: :return:
[ "Wait", "until", "element", "becomes", "invisible", "or", "time", "out", ".", "Returns", "true", "is", "element", "became", "invisible", "otherwise", "false", ".", "If", "timeout", "is", "not", "specified", "or", "0", "then", "uses", "specific", "element", "...
train
https://github.com/aksas/pypo4sel/blob/935b5f9bfa6682aefdef8a43ebcbcf274dec752c/core/pypo4sel/core/waiter.py#L86-L96
ramrod-project/database-brain
schema/brain/queries/writes.py
waiting_filter
def waiting_filter(lte_time, conn=None): """ generates a filter for status==waiting and time older than lte_time """ if RBO.index_list().contains(IDX_OUTPUT_JOB_ID).run(conn): return (r.row[START_FIELD] <= lte_time) else: return ((r.row[STATUS_FIELD] == WAITING) & (r....
python
def waiting_filter(lte_time, conn=None): """ generates a filter for status==waiting and time older than lte_time """ if RBO.index_list().contains(IDX_OUTPUT_JOB_ID).run(conn): return (r.row[START_FIELD] <= lte_time) else: return ((r.row[STATUS_FIELD] == WAITING) & (r....
[ "def", "waiting_filter", "(", "lte_time", ",", "conn", "=", "None", ")", ":", "if", "RBO", ".", "index_list", "(", ")", ".", "contains", "(", "IDX_OUTPUT_JOB_ID", ")", ".", "run", "(", "conn", ")", ":", "return", "(", "r", ".", "row", "[", "START_FIE...
generates a filter for status==waiting and time older than lte_time
[ "generates", "a", "filter", "for", "status", "==", "waiting", "and", "time", "older", "than", "lte_time" ]
train
https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/writes.py#L20-L29
ramrod-project/database-brain
schema/brain/queries/writes.py
expire_filter
def expire_filter(lte_time, conn=None): """ generates a filter for status==waiting and time older than lte_time """ if RBO.index_list().contains(IDX_OUTPUT_JOB_ID).run(conn): return (r.row[EXPIRE_FIELD] <= lte_time) else: return ( ( (r.row[STATUS_FIELD...
python
def expire_filter(lte_time, conn=None): """ generates a filter for status==waiting and time older than lte_time """ if RBO.index_list().contains(IDX_OUTPUT_JOB_ID).run(conn): return (r.row[EXPIRE_FIELD] <= lte_time) else: return ( ( (r.row[STATUS_FIELD...
[ "def", "expire_filter", "(", "lte_time", ",", "conn", "=", "None", ")", ":", "if", "RBO", ".", "index_list", "(", ")", ".", "contains", "(", "IDX_OUTPUT_JOB_ID", ")", ".", "run", "(", "conn", ")", ":", "return", "(", "r", ".", "row", "[", "EXPIRE_FIE...
generates a filter for status==waiting and time older than lte_time
[ "generates", "a", "filter", "for", "status", "==", "waiting", "and", "time", "older", "than", "lte_time" ]
train
https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/writes.py#L32-L46
ramrod-project/database-brain
schema/brain/queries/writes.py
insert_jobs
def insert_jobs(jobs, verify_jobs=True, conn=None): """ insert_jobs function inserts data into Brain.Jobs table jobs must be in Job format :param jobs: <list> of Jobs :param verify_jobs: <bool> :param conn: <rethinkdb.DefaultConnection> :return: <dict> rethinkdb insert response value "...
python
def insert_jobs(jobs, verify_jobs=True, conn=None): """ insert_jobs function inserts data into Brain.Jobs table jobs must be in Job format :param jobs: <list> of Jobs :param verify_jobs: <bool> :param conn: <rethinkdb.DefaultConnection> :return: <dict> rethinkdb insert response value "...
[ "def", "insert_jobs", "(", "jobs", ",", "verify_jobs", "=", "True", ",", "conn", "=", "None", ")", ":", "assert", "isinstance", "(", "jobs", ",", "list", ")", "if", "verify_jobs", "and", "not", "verify", "(", "{", "Jobs", ".", "DESCRIPTOR", ".", "name"...
insert_jobs function inserts data into Brain.Jobs table jobs must be in Job format :param jobs: <list> of Jobs :param verify_jobs: <bool> :param conn: <rethinkdb.DefaultConnection> :return: <dict> rethinkdb insert response value
[ "insert_jobs", "function", "inserts", "data", "into", "Brain", ".", "Jobs", "table" ]
train
https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/writes.py#L74-L90
ramrod-project/database-brain
schema/brain/queries/writes.py
update_job_status
def update_job_status(job_id, status, conn=None): """Updates a job to a new status :param job_id: <str> the id of the job :param status: <str> new status :param conn: <connection> a database connection (default: {None}) :return: <dict> the update dicts for the job and the output """ if sta...
python
def update_job_status(job_id, status, conn=None): """Updates a job to a new status :param job_id: <str> the id of the job :param status: <str> new status :param conn: <connection> a database connection (default: {None}) :return: <dict> the update dicts for the job and the output """ if sta...
[ "def", "update_job_status", "(", "job_id", ",", "status", ",", "conn", "=", "None", ")", ":", "if", "status", "not", "in", "VALID_STATES", ":", "raise", "ValueError", "(", "\"Invalid status\"", ")", "job_update", "=", "RBJ", ".", "get", "(", "job_id", ")",...
Updates a job to a new status :param job_id: <str> the id of the job :param status: <str> new status :param conn: <connection> a database connection (default: {None}) :return: <dict> the update dicts for the job and the output
[ "Updates", "a", "job", "to", "a", "new", "status" ]
train
https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/writes.py#L95-L117
ramrod-project/database-brain
schema/brain/queries/writes.py
write_output
def write_output(job_id, content, conn=None): """writes output to the output table :param job_id: <str> id of the job :param content: <str> output to write :param conn: """ output_job = get_job_by_id(job_id, conn) results = {} if output_job is not None: entry = { OUT...
python
def write_output(job_id, content, conn=None): """writes output to the output table :param job_id: <str> id of the job :param content: <str> output to write :param conn: """ output_job = get_job_by_id(job_id, conn) results = {} if output_job is not None: entry = { OUT...
[ "def", "write_output", "(", "job_id", ",", "content", ",", "conn", "=", "None", ")", ":", "output_job", "=", "get_job_by_id", "(", "job_id", ",", "conn", ")", "results", "=", "{", "}", "if", "output_job", "is", "not", "None", ":", "entry", "=", "{", ...
writes output to the output table :param job_id: <str> id of the job :param content: <str> output to write :param conn:
[ "writes", "output", "to", "the", "output", "table" ]
train
https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/writes.py#L122-L137
ramrod-project/database-brain
schema/brain/queries/writes.py
create_plugin
def create_plugin(plugin_name, conn=None): """ Creates a new plugin :param plugin_name: <str> :param conn: :return: <dict> rethinkdb response """ results = {} if not plugin_exists(plugin_name, conn=conn): results = RPX.table_create(plugin_name, ...
python
def create_plugin(plugin_name, conn=None): """ Creates a new plugin :param plugin_name: <str> :param conn: :return: <dict> rethinkdb response """ results = {} if not plugin_exists(plugin_name, conn=conn): results = RPX.table_create(plugin_name, ...
[ "def", "create_plugin", "(", "plugin_name", ",", "conn", "=", "None", ")", ":", "results", "=", "{", "}", "if", "not", "plugin_exists", "(", "plugin_name", ",", "conn", "=", "conn", ")", ":", "results", "=", "RPX", ".", "table_create", "(", "plugin_name"...
Creates a new plugin :param plugin_name: <str> :param conn: :return: <dict> rethinkdb response
[ "Creates", "a", "new", "plugin" ]
train
https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/writes.py#L142-L154
ramrod-project/database-brain
schema/brain/queries/writes.py
destroy_plugin
def destroy_plugin(plugin_name, conn=None): """ Creates a new plugin :param plugin_name: <str> :param conn: :return: <dict> rethinkdb response """ results = {} if plugin_exists(plugin_name, conn=conn): results = RPX.table_drop(plugin_name).run(conn) return results
python
def destroy_plugin(plugin_name, conn=None): """ Creates a new plugin :param plugin_name: <str> :param conn: :return: <dict> rethinkdb response """ results = {} if plugin_exists(plugin_name, conn=conn): results = RPX.table_drop(plugin_name).run(conn) return results
[ "def", "destroy_plugin", "(", "plugin_name", ",", "conn", "=", "None", ")", ":", "results", "=", "{", "}", "if", "plugin_exists", "(", "plugin_name", ",", "conn", "=", "conn", ")", ":", "results", "=", "RPX", ".", "table_drop", "(", "plugin_name", ")", ...
Creates a new plugin :param plugin_name: <str> :param conn: :return: <dict> rethinkdb response
[ "Creates", "a", "new", "plugin" ]
train
https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/writes.py#L159-L170
Pringley/rw
rw/__init__.py
generate_words
def generate_words(numberofwords, wordlist, secure=None): """Generate a list of random words from wordlist.""" if not secure: chooser = random.choice else: chooser = random.SystemRandom().choice return [chooser(wordlist) for _ in range(numberofwords)]
python
def generate_words(numberofwords, wordlist, secure=None): """Generate a list of random words from wordlist.""" if not secure: chooser = random.choice else: chooser = random.SystemRandom().choice return [chooser(wordlist) for _ in range(numberofwords)]
[ "def", "generate_words", "(", "numberofwords", ",", "wordlist", ",", "secure", "=", "None", ")", ":", "if", "not", "secure", ":", "chooser", "=", "random", ".", "choice", "else", ":", "chooser", "=", "random", ".", "SystemRandom", "(", ")", ".", "choice"...
Generate a list of random words from wordlist.
[ "Generate", "a", "list", "of", "random", "words", "from", "wordlist", "." ]
train
https://github.com/Pringley/rw/blob/0d1d9933030621c60e051a8bea3b5f520aa33efd/rw/__init__.py#L28-L34
Pringley/rw
rw/__init__.py
load_stream
def load_stream(filename): """Load a file stream from the package resources.""" rawfile = pkg_resources.resource_stream(__name__, filename) if six.PY2: return rawfile return io.TextIOWrapper(rawfile, 'utf-8')
python
def load_stream(filename): """Load a file stream from the package resources.""" rawfile = pkg_resources.resource_stream(__name__, filename) if six.PY2: return rawfile return io.TextIOWrapper(rawfile, 'utf-8')
[ "def", "load_stream", "(", "filename", ")", ":", "rawfile", "=", "pkg_resources", ".", "resource_stream", "(", "__name__", ",", "filename", ")", "if", "six", ".", "PY2", ":", "return", "rawfile", "return", "io", ".", "TextIOWrapper", "(", "rawfile", ",", "...
Load a file stream from the package resources.
[ "Load", "a", "file", "stream", "from", "the", "package", "resources", "." ]
train
https://github.com/Pringley/rw/blob/0d1d9933030621c60e051a8bea3b5f520aa33efd/rw/__init__.py#L40-L45
Pringley/rw
rw/__init__.py
cli
def cli(): """Run the command line interface.""" args = docopt.docopt(__doc__, version=__VERSION__) secure = args['--secure'] numberofwords = int(args['<numberofwords>']) dictpath = args['--dict'] if dictpath is not None: dictfile = open(dictpath) else: dictfile = load_strea...
python
def cli(): """Run the command line interface.""" args = docopt.docopt(__doc__, version=__VERSION__) secure = args['--secure'] numberofwords = int(args['<numberofwords>']) dictpath = args['--dict'] if dictpath is not None: dictfile = open(dictpath) else: dictfile = load_strea...
[ "def", "cli", "(", ")", ":", "args", "=", "docopt", ".", "docopt", "(", "__doc__", ",", "version", "=", "__VERSION__", ")", "secure", "=", "args", "[", "'--secure'", "]", "numberofwords", "=", "int", "(", "args", "[", "'<numberofwords>'", "]", ")", "di...
Run the command line interface.
[ "Run", "the", "command", "line", "interface", "." ]
train
https://github.com/Pringley/rw/blob/0d1d9933030621c60e051a8bea3b5f520aa33efd/rw/__init__.py#L47-L62
jmgilman/Neolib
neolib/inventory/UserInventory.py
UserInventory.load
def load(self): """Loads a user's inventory Queries the user's inventory, parses each item, and adds each item to the inventory. Note this class should not be used directly, but rather usr.inventory should be used to access a user's inventory. Parameters ...
python
def load(self): """Loads a user's inventory Queries the user's inventory, parses each item, and adds each item to the inventory. Note this class should not be used directly, but rather usr.inventory should be used to access a user's inventory. Parameters ...
[ "def", "load", "(", "self", ")", ":", "self", ".", "items", "=", "{", "}", "pg", "=", "self", ".", "usr", ".", "getPage", "(", "\"http://www.neopets.com/objects.phtml?type=inventory\"", ")", "# Indicates an empty inventory", "if", "\"You aren't carrying anything\"", ...
Loads a user's inventory Queries the user's inventory, parses each item, and adds each item to the inventory. Note this class should not be used directly, but rather usr.inventory should be used to access a user's inventory. Parameters usr (User) - The use...
[ "Loads", "a", "user", "s", "inventory", "Queries", "the", "user", "s", "inventory", "parses", "each", "item", "and", "adds", "each", "item", "to", "the", "inventory", ".", "Note", "this", "class", "should", "not", "be", "used", "directly", "but", "rather",...
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/inventory/UserInventory.py#L40-L80
doctorzeb8/django-era
era/utils/functools.py
unidec
def unidec(fnx): ''' @unidec def render(view, request, flag=True): pass @render def first_view(request): pass @render(flag=False) def second_view(request): pass ''' return lambda *ax, **kx: ( wraps(ax[0])(lambda *ay, **ky: fnx(ax[0], *ay, **ky)) \ ...
python
def unidec(fnx): ''' @unidec def render(view, request, flag=True): pass @render def first_view(request): pass @render(flag=False) def second_view(request): pass ''' return lambda *ax, **kx: ( wraps(ax[0])(lambda *ay, **ky: fnx(ax[0], *ay, **ky)) \ ...
[ "def", "unidec", "(", "fnx", ")", ":", "return", "lambda", "*", "ax", ",", "*", "*", "kx", ":", "(", "wraps", "(", "ax", "[", "0", "]", ")", "(", "lambda", "*", "ay", ",", "*", "*", "ky", ":", "fnx", "(", "ax", "[", "0", "]", ",", "*", ...
@unidec def render(view, request, flag=True): pass @render def first_view(request): pass @render(flag=False) def second_view(request): pass
[ "@unidec", "def", "render", "(", "view", "request", "flag", "=", "True", ")", ":", "pass" ]
train
https://github.com/doctorzeb8/django-era/blob/6fd433ef6081c5be295df22bcea70dc2642baaa4/era/utils/functools.py#L23-L43
nyergler/sphinx-classy-code
src/classycode/directives.py
parselinenos
def parselinenos(spec, nlines=None): """Parse a line class spec into a dict of line no: class name """ items = {} parts = spec.split(',') for part in parts: line_class = LINECLASS_RE.match(part) start = int(line_class.group('start')) if line_class.group('range'): ...
python
def parselinenos(spec, nlines=None): """Parse a line class spec into a dict of line no: class name """ items = {} parts = spec.split(',') for part in parts: line_class = LINECLASS_RE.match(part) start = int(line_class.group('start')) if line_class.group('range'): ...
[ "def", "parselinenos", "(", "spec", ",", "nlines", "=", "None", ")", ":", "items", "=", "{", "}", "parts", "=", "spec", ".", "split", "(", "','", ")", "for", "part", "in", "parts", ":", "line_class", "=", "LINECLASS_RE", ".", "match", "(", "part", ...
Parse a line class spec into a dict of line no: class name
[ "Parse", "a", "line", "class", "spec", "into", "a", "dict", "of", "line", "no", ":", "class", "name" ]
train
https://github.com/nyergler/sphinx-classy-code/blob/924a2e622cf2b4fbb76745e2e6ae3948ccce5bca/src/classycode/directives.py#L10-L34
minhhoit/yacms
yacms/pages/page_processors.py
processor_for
def processor_for(content_model_or_slug, exact_page=False): """ Decorator that registers the decorated function as a page processor for the given content model or slug. When a page exists that forms the prefix of custom urlpatterns in a project (eg: the blog page and app), the page will be adde...
python
def processor_for(content_model_or_slug, exact_page=False): """ Decorator that registers the decorated function as a page processor for the given content model or slug. When a page exists that forms the prefix of custom urlpatterns in a project (eg: the blog page and app), the page will be adde...
[ "def", "processor_for", "(", "content_model_or_slug", ",", "exact_page", "=", "False", ")", ":", "content_model", "=", "None", "slug", "=", "\"\"", "if", "isinstance", "(", "content_model_or_slug", ",", "(", "str", ",", "_str", ")", ")", ":", "try", ":", "...
Decorator that registers the decorated function as a page processor for the given content model or slug. When a page exists that forms the prefix of custom urlpatterns in a project (eg: the blog page and app), the page will be added to the template context. Passing in ``True`` for the ``exact_page`...
[ "Decorator", "that", "registers", "the", "decorated", "function", "as", "a", "page", "processor", "for", "the", "given", "content", "model", "or", "slug", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/page_processors.py#L17-L53
minhhoit/yacms
yacms/pages/page_processors.py
autodiscover
def autodiscover(): """ Taken from ``django.contrib.admin.autodiscover`` and used to run any calls to the ``processor_for`` decorator. """ global LOADED if LOADED: return LOADED = True for app in get_app_name_list(): try: module = import_module(app) ex...
python
def autodiscover(): """ Taken from ``django.contrib.admin.autodiscover`` and used to run any calls to the ``processor_for`` decorator. """ global LOADED if LOADED: return LOADED = True for app in get_app_name_list(): try: module = import_module(app) ex...
[ "def", "autodiscover", "(", ")", ":", "global", "LOADED", "if", "LOADED", ":", "return", "LOADED", "=", "True", "for", "app", "in", "get_app_name_list", "(", ")", ":", "try", ":", "module", "=", "import_module", "(", "app", ")", "except", "ImportError", ...
Taken from ``django.contrib.admin.autodiscover`` and used to run any calls to the ``processor_for`` decorator.
[ "Taken", "from", "django", ".", "contrib", ".", "admin", ".", "autodiscover", "and", "used", "to", "run", "any", "calls", "to", "the", "processor_for", "decorator", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/page_processors.py#L59-L78
praekelt/jmbo-poll
poll/models.py
Poll.can_vote_on_poll
def can_vote_on_poll(self, request): """Based on jmbo.models.can_vote.""" # can't vote if liking is closed if self.votes_closed: return False, 'closed' # can't vote if liking is disabled if not self.votes_enabled: return False, 'disabled' # anon...
python
def can_vote_on_poll(self, request): """Based on jmbo.models.can_vote.""" # can't vote if liking is closed if self.votes_closed: return False, 'closed' # can't vote if liking is disabled if not self.votes_enabled: return False, 'disabled' # anon...
[ "def", "can_vote_on_poll", "(", "self", ",", "request", ")", ":", "# can't vote if liking is closed", "if", "self", ".", "votes_closed", ":", "return", "False", ",", "'closed'", "# can't vote if liking is disabled", "if", "not", "self", ".", "votes_enabled", ":", "r...
Based on jmbo.models.can_vote.
[ "Based", "on", "jmbo", ".", "models", ".", "can_vote", "." ]
train
https://github.com/praekelt/jmbo-poll/blob/322cd398372139e9db74a37cb2ce8ab1c2ef17fd/poll/models.py#L30-L54
praekelt/jmbo-poll
poll/models.py
Poll.vote_count
def vote_count(self): """ Returns the total number of votes cast across all the poll's options. """ return Vote.objects.filter( content_type=ContentType.objects.get(app_label='poll', model='polloption'), object_id__in=[o.id for o in self.polloption_set.all...
python
def vote_count(self): """ Returns the total number of votes cast across all the poll's options. """ return Vote.objects.filter( content_type=ContentType.objects.get(app_label='poll', model='polloption'), object_id__in=[o.id for o in self.polloption_set.all...
[ "def", "vote_count", "(", "self", ")", ":", "return", "Vote", ".", "objects", ".", "filter", "(", "content_type", "=", "ContentType", ".", "objects", ".", "get", "(", "app_label", "=", "'poll'", ",", "model", "=", "'polloption'", ")", ",", "object_id__in",...
Returns the total number of votes cast across all the poll's options.
[ "Returns", "the", "total", "number", "of", "votes", "cast", "across", "all", "the", "poll", "s", "options", "." ]
train
https://github.com/praekelt/jmbo-poll/blob/322cd398372139e9db74a37cb2ce8ab1c2ef17fd/poll/models.py#L58-L66
praekelt/jmbo-poll
poll/models.py
PollOption.vote_count
def vote_count(self): """ Returns the total number of votes cast for this poll options. """ return Vote.objects.filter( content_type=ContentType.objects.get_for_model(self), object_id=self.id ).aggregate(Sum('vote'))['vote__sum'] or 0
python
def vote_count(self): """ Returns the total number of votes cast for this poll options. """ return Vote.objects.filter( content_type=ContentType.objects.get_for_model(self), object_id=self.id ).aggregate(Sum('vote'))['vote__sum'] or 0
[ "def", "vote_count", "(", "self", ")", ":", "return", "Vote", ".", "objects", ".", "filter", "(", "content_type", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "self", ")", ",", "object_id", "=", "self", ".", "id", ")", ".", "aggregate",...
Returns the total number of votes cast for this poll options.
[ "Returns", "the", "total", "number", "of", "votes", "cast", "for", "this", "poll", "options", "." ]
train
https://github.com/praekelt/jmbo-poll/blob/322cd398372139e9db74a37cb2ce8ab1c2ef17fd/poll/models.py#L82-L90
praekelt/jmbo-poll
poll/models.py
PollOption.percentage
def percentage(self): """ Returns the percentage of votes cast for this poll option in relation to all of its poll's other options. """ total_vote_count = self.poll.vote_count if total_vote_count: return self.vote_count * 100.0 / total_vote_count retur...
python
def percentage(self): """ Returns the percentage of votes cast for this poll option in relation to all of its poll's other options. """ total_vote_count = self.poll.vote_count if total_vote_count: return self.vote_count * 100.0 / total_vote_count retur...
[ "def", "percentage", "(", "self", ")", ":", "total_vote_count", "=", "self", ".", "poll", ".", "vote_count", "if", "total_vote_count", ":", "return", "self", ".", "vote_count", "*", "100.0", "/", "total_vote_count", "return", "0" ]
Returns the percentage of votes cast for this poll option in relation to all of its poll's other options.
[ "Returns", "the", "percentage", "of", "votes", "cast", "for", "this", "poll", "option", "in", "relation", "to", "all", "of", "its", "poll", "s", "other", "options", "." ]
train
https://github.com/praekelt/jmbo-poll/blob/322cd398372139e9db74a37cb2ce8ab1c2ef17fd/poll/models.py#L92-L100
ECESeniorDesign/lazy_record
lazy_record/query.py
does_not_mutate
def does_not_mutate(func): """Prevents methods from mutating the receiver""" def wrapper(self, *args, **kwargs): new = self.copy() return func(new, *args, **kwargs) wrapper.__name__ = func.__name__ wrapper.__doc__ = func.__doc__ return wrapper
python
def does_not_mutate(func): """Prevents methods from mutating the receiver""" def wrapper(self, *args, **kwargs): new = self.copy() return func(new, *args, **kwargs) wrapper.__name__ = func.__name__ wrapper.__doc__ = func.__doc__ return wrapper
[ "def", "does_not_mutate", "(", "func", ")", ":", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "new", "=", "self", ".", "copy", "(", ")", "return", "func", "(", "new", ",", "*", "args", ",", "*", "*", "kwar...
Prevents methods from mutating the receiver
[ "Prevents", "methods", "from", "mutating", "the", "receiver" ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L10-L17
ECESeniorDesign/lazy_record
lazy_record/query.py
Query.find_by
def find_by(self, **kwargs): """ Find first record subject to restrictions in +kwargs+, raising RecordNotFound if no such record exists. """ result = self.where(**kwargs).first() if result: return result else: raise RecordNotFound(kwargs)
python
def find_by(self, **kwargs): """ Find first record subject to restrictions in +kwargs+, raising RecordNotFound if no such record exists. """ result = self.where(**kwargs).first() if result: return result else: raise RecordNotFound(kwargs)
[ "def", "find_by", "(", "self", ",", "*", "*", "kwargs", ")", ":", "result", "=", "self", ".", "where", "(", "*", "*", "kwargs", ")", ".", "first", "(", ")", "if", "result", ":", "return", "result", "else", ":", "raise", "RecordNotFound", "(", "kwar...
Find first record subject to restrictions in +kwargs+, raising RecordNotFound if no such record exists.
[ "Find", "first", "record", "subject", "to", "restrictions", "in", "+", "kwargs", "+", "raising", "RecordNotFound", "if", "no", "such", "record", "exists", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L68-L77
ECESeniorDesign/lazy_record
lazy_record/query.py
Query.first
def first(self, count=1): """ Returns the first record in the query (sorting by id unless modified by `order_by`), returning None if the query has no records. """ if count == 0: raise QueryInvalid("Count cannot be zero.") self.limit_count = count recor...
python
def first(self, count=1): """ Returns the first record in the query (sorting by id unless modified by `order_by`), returning None if the query has no records. """ if count == 0: raise QueryInvalid("Count cannot be zero.") self.limit_count = count recor...
[ "def", "first", "(", "self", ",", "count", "=", "1", ")", ":", "if", "count", "==", "0", ":", "raise", "QueryInvalid", "(", "\"Count cannot be zero.\"", ")", "self", ".", "limit_count", "=", "count", "records", "=", "self", ".", "_do_query", "(", ")", ...
Returns the first record in the query (sorting by id unless modified by `order_by`), returning None if the query has no records.
[ "Returns", "the", "first", "record", "in", "the", "query", "(", "sorting", "by", "id", "unless", "modified", "by", "order_by", ")", "returning", "None", "if", "the", "query", "has", "no", "records", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L80-L95
ECESeniorDesign/lazy_record
lazy_record/query.py
Query.last
def last(self, count=1): """ Returns the last record in the query (sorting by id unless modified by `order_by`, whereupon it reverses the order passed in `order_by`). Returns None if the query has no records. """ if self._order_with: order = self._order_with.v...
python
def last(self, count=1): """ Returns the last record in the query (sorting by id unless modified by `order_by`, whereupon it reverses the order passed in `order_by`). Returns None if the query has no records. """ if self._order_with: order = self._order_with.v...
[ "def", "last", "(", "self", ",", "count", "=", "1", ")", ":", "if", "self", ".", "_order_with", ":", "order", "=", "self", ".", "_order_with", ".", "values", "(", ")", "[", "0", "]", "order", "=", "\"desc\"", "if", "order", "==", "\"asc\"", "else",...
Returns the last record in the query (sorting by id unless modified by `order_by`, whereupon it reverses the order passed in `order_by`). Returns None if the query has no records.
[ "Returns", "the", "last", "record", "in", "the", "query", "(", "sorting", "by", "id", "unless", "modified", "by", "order_by", "whereupon", "it", "reverses", "the", "order", "passed", "in", "order_by", ")", ".", "Returns", "None", "if", "the", "query", "has...
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L98-L113
ECESeniorDesign/lazy_record
lazy_record/query.py
Query.order_by
def order_by(self, **kwargs): """ Orders the query by the key passed in +kwargs+. Only pass one key, as it cannot sort by multiple columns at once. Raises QueryInvalid if this method is called when there is already a custom order (i.e. this method was already called on this query...
python
def order_by(self, **kwargs): """ Orders the query by the key passed in +kwargs+. Only pass one key, as it cannot sort by multiple columns at once. Raises QueryInvalid if this method is called when there is already a custom order (i.e. this method was already called on this query...
[ "def", "order_by", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Only get one thing from kwargs (we can only order by one thing...)", "if", "self", ".", "_order_with", ":", "raise", "QueryInvalid", "(", "\"Cannot order by more than one column\"", ")", "self", ".", ...
Orders the query by the key passed in +kwargs+. Only pass one key, as it cannot sort by multiple columns at once. Raises QueryInvalid if this method is called when there is already a custom order (i.e. this method was already called on this query). Analog to "ORDER BY" in SQL.
[ "Orders", "the", "query", "by", "the", "key", "passed", "in", "+", "kwargs", "+", ".", "Only", "pass", "one", "key", "as", "it", "cannot", "sort", "by", "multiple", "columns", "at", "once", ".", "Raises", "QueryInvalid", "if", "this", "method", "is", "...
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L116-L127
ECESeniorDesign/lazy_record
lazy_record/query.py
Query.where
def where(self, *custom_restrictions, **restrictions): """ Restricts the records to the query subject to the passed +restrictions+. Analog to "WHERE" in SQL. Can pass multiple restrictions, and can invoke this method multiple times per query. """ for attr, value in restri...
python
def where(self, *custom_restrictions, **restrictions): """ Restricts the records to the query subject to the passed +restrictions+. Analog to "WHERE" in SQL. Can pass multiple restrictions, and can invoke this method multiple times per query. """ for attr, value in restri...
[ "def", "where", "(", "self", ",", "*", "custom_restrictions", ",", "*", "*", "restrictions", ")", ":", "for", "attr", ",", "value", "in", "restrictions", ".", "items", "(", ")", ":", "self", ".", "where_query", "[", "attr", "]", "=", "value", "if", "...
Restricts the records to the query subject to the passed +restrictions+. Analog to "WHERE" in SQL. Can pass multiple restrictions, and can invoke this method multiple times per query.
[ "Restricts", "the", "records", "to", "the", "query", "subject", "to", "the", "passed", "+", "restrictions", "+", ".", "Analog", "to", "WHERE", "in", "SQL", ".", "Can", "pass", "multiple", "restrictions", "and", "can", "invoke", "this", "method", "multiple", ...
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L130-L140
ECESeniorDesign/lazy_record
lazy_record/query.py
Query.joins
def joins(self, table): """ Analog to "INNER JOIN" in SQL on the passed +table+. Use only once per query. """ def do_join(table, model): while model is not associations.model_from_name(table): # ex) Category -> Forum -> Thread -> Post ...
python
def joins(self, table): """ Analog to "INNER JOIN" in SQL on the passed +table+. Use only once per query. """ def do_join(table, model): while model is not associations.model_from_name(table): # ex) Category -> Forum -> Thread -> Post ...
[ "def", "joins", "(", "self", ",", "table", ")", ":", "def", "do_join", "(", "table", ",", "model", ")", ":", "while", "model", "is", "not", "associations", ".", "model_from_name", "(", "table", ")", ":", "# ex) Category -> Forum -> Thread -> Post", "# Category...
Analog to "INNER JOIN" in SQL on the passed +table+. Use only once per query.
[ "Analog", "to", "INNER", "JOIN", "in", "SQL", "on", "the", "passed", "+", "table", "+", ".", "Use", "only", "once", "per", "query", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L143-L193
ECESeniorDesign/lazy_record
lazy_record/query.py
Query.create
def create(self, **attributes): """ Creates a new record suject to the restructions in the query and with the passed +attributes+. Operates using `build`. """ record = self.build(**attributes) record.save() return record
python
def create(self, **attributes): """ Creates a new record suject to the restructions in the query and with the passed +attributes+. Operates using `build`. """ record = self.build(**attributes) record.save() return record
[ "def", "create", "(", "self", ",", "*", "*", "attributes", ")", ":", "record", "=", "self", ".", "build", "(", "*", "*", "attributes", ")", "record", ".", "save", "(", ")", "return", "record" ]
Creates a new record suject to the restructions in the query and with the passed +attributes+. Operates using `build`.
[ "Creates", "a", "new", "record", "suject", "to", "the", "restructions", "in", "the", "query", "and", "with", "the", "passed", "+", "attributes", "+", ".", "Operates", "using", "build", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L259-L266
ECESeniorDesign/lazy_record
lazy_record/query.py
Query.build
def build(self, **kwargs): """ Builds a new record subject to the restrictions in the query. Will build intermediate (join table) records as needed, and links them to the returned record so that they are saved when the returned record is. """ build_args = dict(sel...
python
def build(self, **kwargs): """ Builds a new record subject to the restrictions in the query. Will build intermediate (join table) records as needed, and links them to the returned record so that they are saved when the returned record is. """ build_args = dict(sel...
[ "def", "build", "(", "self", ",", "*", "*", "kwargs", ")", ":", "build_args", "=", "dict", "(", "self", ".", "where_query", ")", "build_args", ".", "update", "(", "kwargs", ")", "record", "=", "self", ".", "model", "(", "*", "*", "record_args", "(", ...
Builds a new record subject to the restrictions in the query. Will build intermediate (join table) records as needed, and links them to the returned record so that they are saved when the returned record is.
[ "Builds", "a", "new", "record", "subject", "to", "the", "restrictions", "in", "the", "query", ".", "Will", "build", "intermediate", "(", "join", "table", ")", "records", "as", "needed", "and", "links", "them", "to", "the", "returned", "record", "so", "that...
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L268-L296
ECESeniorDesign/lazy_record
lazy_record/query.py
Query.append
def append(self, record): """ Adds the passed +record+ to satisfy the query. Only intended to be used in conjunction with associations (i.e. do not use if self.record is None). Intended use case (DO THIS): post.comments.append(comment) NOT THIS: Query(...
python
def append(self, record): """ Adds the passed +record+ to satisfy the query. Only intended to be used in conjunction with associations (i.e. do not use if self.record is None). Intended use case (DO THIS): post.comments.append(comment) NOT THIS: Query(...
[ "def", "append", "(", "self", ",", "record", ")", ":", "if", "self", ".", "record", ":", "self", ".", "_validate_record", "(", "record", ")", "if", "self", ".", "join_args", ":", "# As always, the related record is created when the primary", "# record is saved", "...
Adds the passed +record+ to satisfy the query. Only intended to be used in conjunction with associations (i.e. do not use if self.record is None). Intended use case (DO THIS): post.comments.append(comment) NOT THIS: Query(Post).where(content="foo").append(post)
[ "Adds", "the", "passed", "+", "record", "+", "to", "satisfy", "the", "query", ".", "Only", "intended", "to", "be", "used", "in", "conjunction", "with", "associations", "(", "i", ".", "e", ".", "do", "not", "use", "if", "self", ".", "record", "is", "N...
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L298-L347
ECESeniorDesign/lazy_record
lazy_record/query.py
Query.delete
def delete(self, record): """ Removes a record from an query. Does not destroy the passed +record+, but marks any joining records for destruction (in the case of a many-to-many relationship) or sets the foreign key of +record+ to None (in the case of a one-to-many relationship). ...
python
def delete(self, record): """ Removes a record from an query. Does not destroy the passed +record+, but marks any joining records for destruction (in the case of a many-to-many relationship) or sets the foreign key of +record+ to None (in the case of a one-to-many relationship). ...
[ "def", "delete", "(", "self", ",", "record", ")", ":", "# note: does (and should) not delete or destroy the record", "if", "self", ".", "record", ":", "self", ".", "_validate_record", "(", "record", ")", "if", "self", ".", "join_args", ":", "# Need to find out who h...
Removes a record from an query. Does not destroy the passed +record+, but marks any joining records for destruction (in the case of a many-to-many relationship) or sets the foreign key of +record+ to None (in the case of a one-to-many relationship). Only intended to be used in conjunctio...
[ "Removes", "a", "record", "from", "an", "query", ".", "Does", "not", "destroy", "the", "passed", "+", "record", "+", "but", "marks", "any", "joining", "records", "for", "destruction", "(", "in", "the", "case", "of", "a", "many", "-", "to", "-", "many",...
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L349-L388
polysquare/polysquare-generic-file-linter
polysquarelinter/technical_words_dictionary.py
create
def create(technical_terms_filename, spellchecker_cache_path): """Create a Dictionary at spellchecker_cache_path with technical words.""" user_dictionary = os.path.join(os.getcwd(), "DICTIONARY") user_words = read_dictionary_file(user_dictionary) technical_terms_set = set(user_words) if technical_...
python
def create(technical_terms_filename, spellchecker_cache_path): """Create a Dictionary at spellchecker_cache_path with technical words.""" user_dictionary = os.path.join(os.getcwd(), "DICTIONARY") user_words = read_dictionary_file(user_dictionary) technical_terms_set = set(user_words) if technical_...
[ "def", "create", "(", "technical_terms_filename", ",", "spellchecker_cache_path", ")", ":", "user_dictionary", "=", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "\"DICTIONARY\"", ")", "user_words", "=", "read_dictionary_file", "(", ...
Create a Dictionary at spellchecker_cache_path with technical words.
[ "Create", "a", "Dictionary", "at", "spellchecker_cache_path", "with", "technical", "words", "." ]
train
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/technical_words_dictionary.py#L15-L30
jjangsangy/kan
kan/structures.py
GoogleBooksAPIClient.connect
def connect(self, agent='Python'): """ Context manager for HTTP Connection state and ensures proper handling of network sockets, sends a GET request. Exception is raised at the yield statement. :yield request: FileIO<Socket> """ headers = {'User-Agent': agent} ...
python
def connect(self, agent='Python'): """ Context manager for HTTP Connection state and ensures proper handling of network sockets, sends a GET request. Exception is raised at the yield statement. :yield request: FileIO<Socket> """ headers = {'User-Agent': agent} ...
[ "def", "connect", "(", "self", ",", "agent", "=", "'Python'", ")", ":", "headers", "=", "{", "'User-Agent'", ":", "agent", "}", "request", "=", "urlopen", "(", "Request", "(", "self", ".", "url", ",", "headers", "=", "headers", ")", ")", "try", ":", ...
Context manager for HTTP Connection state and ensures proper handling of network sockets, sends a GET request. Exception is raised at the yield statement. :yield request: FileIO<Socket>
[ "Context", "manager", "for", "HTTP", "Connection", "state", "and", "ensures", "proper", "handling", "of", "network", "sockets", "sends", "a", "GET", "request", "." ]
train
https://github.com/jjangsangy/kan/blob/7da9d9ec5dc6b8bbb86cfd27d737978a406d9fa6/kan/structures.py#L118-L132
jjangsangy/kan
kan/structures.py
GoogleBooksAPIClient.reader
def reader(self): """ Reads raw text from the connection stream. Ensures proper exception handling. :return bytes: request """ request_stream = '' with self.connect() as request: if request.msg != 'OK': raise HTTPError requ...
python
def reader(self): """ Reads raw text from the connection stream. Ensures proper exception handling. :return bytes: request """ request_stream = '' with self.connect() as request: if request.msg != 'OK': raise HTTPError requ...
[ "def", "reader", "(", "self", ")", ":", "request_stream", "=", "''", "with", "self", ".", "connect", "(", ")", "as", "request", ":", "if", "request", ".", "msg", "!=", "'OK'", ":", "raise", "HTTPError", "request_stream", "=", "request", ".", "read", "(...
Reads raw text from the connection stream. Ensures proper exception handling. :return bytes: request
[ "Reads", "raw", "text", "from", "the", "connection", "stream", ".", "Ensures", "proper", "exception", "handling", "." ]
train
https://github.com/jjangsangy/kan/blob/7da9d9ec5dc6b8bbb86cfd27d737978a406d9fa6/kan/structures.py#L135-L147
jjangsangy/kan
kan/structures.py
GoogleBooksAPIClient.json
def json(self): """ Serializes json text stream into python dictionary. :return dict: json """ _json = json.loads(self.reader) if _json.get('error', None): raise HTTPError(_json['error']['errors']) return _json
python
def json(self): """ Serializes json text stream into python dictionary. :return dict: json """ _json = json.loads(self.reader) if _json.get('error', None): raise HTTPError(_json['error']['errors']) return _json
[ "def", "json", "(", "self", ")", ":", "_json", "=", "json", ".", "loads", "(", "self", ".", "reader", ")", "if", "_json", ".", "get", "(", "'error'", ",", "None", ")", ":", "raise", "HTTPError", "(", "_json", "[", "'error'", "]", "[", "'errors'", ...
Serializes json text stream into python dictionary. :return dict: json
[ "Serializes", "json", "text", "stream", "into", "python", "dictionary", "." ]
train
https://github.com/jjangsangy/kan/blob/7da9d9ec5dc6b8bbb86cfd27d737978a406d9fa6/kan/structures.py#L150-L159
hmenager/pyacd
pyacd/qa.py
Qa.parse_command_lines
def parse_command_lines(self, acd_def): """ parse the command line to generate an abstract job order dictionary, based on the parameters defined in the ACD structure of job order is that for each defined parameter, there is a dictionary entry containing its value and the value of...
python
def parse_command_lines(self, acd_def): """ parse the command line to generate an abstract job order dictionary, based on the parameters defined in the ACD structure of job order is that for each defined parameter, there is a dictionary entry containing its value and the value of...
[ "def", "parse_command_lines", "(", "self", ",", "acd_def", ")", ":", "command_line_string", "=", "' '", ".", "join", "(", "[", "cl", ".", "command_line", "for", "cl", "in", "self", ".", "command_lines", "]", ")", "command_line_string", "=", "command_line_strin...
parse the command line to generate an abstract job order dictionary, based on the parameters defined in the ACD structure of job order is that for each defined parameter, there is a dictionary entry containing its value and the value of its various qualifiers
[ "parse", "the", "command", "line", "to", "generate", "an", "abstract", "job", "order", "dictionary", "based", "on", "the", "parameters", "defined", "in", "the", "ACD", "structure", "of", "job", "order", "is", "that", "for", "each", "defined", "parameter", "t...
train
https://github.com/hmenager/pyacd/blob/3aa93f227e4321f506c851de4c73157f8336e9e3/pyacd/qa.py#L105-L244
alfred82santa/dirty-loader
dirty_loader/__init__.py
import_class
def import_class(classpath, package=None): """ Load and return a class """ if '.' in classpath: module, classname = classpath.rsplit('.', 1) if package and not module.startswith('.'): module = '.{0}'.format(module) mod = import_module(module, package) else: ...
python
def import_class(classpath, package=None): """ Load and return a class """ if '.' in classpath: module, classname = classpath.rsplit('.', 1) if package and not module.startswith('.'): module = '.{0}'.format(module) mod = import_module(module, package) else: ...
[ "def", "import_class", "(", "classpath", ",", "package", "=", "None", ")", ":", "if", "'.'", "in", "classpath", ":", "module", ",", "classname", "=", "classpath", ".", "rsplit", "(", "'.'", ",", "1", ")", "if", "package", "and", "not", "module", ".", ...
Load and return a class
[ "Load", "and", "return", "a", "class" ]
train
https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L423-L436
alfred82santa/dirty-loader
dirty_loader/__init__.py
Loader.register_module
def register_module(self, module, idx=-1): """ Register a module. You could indicate position inside inner list. :param module: must be a string or a module object to register. :type module: str :param idx: position where you want to insert new module. By default it is inserted ...
python
def register_module(self, module, idx=-1): """ Register a module. You could indicate position inside inner list. :param module: must be a string or a module object to register. :type module: str :param idx: position where you want to insert new module. By default it is inserted ...
[ "def", "register_module", "(", "self", ",", "module", ",", "idx", "=", "-", "1", ")", ":", "if", "module", "in", "self", ".", "_modules", ":", "raise", "AlreadyRegisteredError", "(", "\"Module '{0}' is already registered on loader.\"", ".", "format", "(", "modul...
Register a module. You could indicate position inside inner list. :param module: must be a string or a module object to register. :type module: str :param idx: position where you want to insert new module. By default it is inserted at the end. :type idx: int
[ "Register", "a", "module", ".", "You", "could", "indicate", "position", "inside", "inner", "list", "." ]
train
https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L40-L56
alfred82santa/dirty-loader
dirty_loader/__init__.py
Loader.unregister_module
def unregister_module(self, module): """ Unregister a module. :param module: must be a string or a module object to unregistered :type module: str """ if module not in self._modules: raise NoRegisteredError("Module '{0}' is not registered on loader.".format(...
python
def unregister_module(self, module): """ Unregister a module. :param module: must be a string or a module object to unregistered :type module: str """ if module not in self._modules: raise NoRegisteredError("Module '{0}' is not registered on loader.".format(...
[ "def", "unregister_module", "(", "self", ",", "module", ")", ":", "if", "module", "not", "in", "self", ".", "_modules", ":", "raise", "NoRegisteredError", "(", "\"Module '{0}' is not registered on loader.\"", ".", "format", "(", "module", ")", ")", "self", ".", ...
Unregister a module. :param module: must be a string or a module object to unregistered :type module: str
[ "Unregister", "a", "module", "." ]
train
https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L58-L69
alfred82santa/dirty-loader
dirty_loader/__init__.py
Loader.load_class
def load_class(self, classname): """ Loads a class looking for it in each module registered. :param classname: Class name you want to load. :type classname: str :return: Class object :rtype: type """ module_list = self._get_module_list() for mod...
python
def load_class(self, classname): """ Loads a class looking for it in each module registered. :param classname: Class name you want to load. :type classname: str :return: Class object :rtype: type """ module_list = self._get_module_list() for mod...
[ "def", "load_class", "(", "self", ",", "classname", ")", ":", "module_list", "=", "self", ".", "_get_module_list", "(", ")", "for", "module", "in", "module_list", ":", "try", ":", "return", "import_class", "(", "classname", ",", "module", ".", "__name__", ...
Loads a class looking for it in each module registered. :param classname: Class name you want to load. :type classname: str :return: Class object :rtype: type
[ "Loads", "a", "class", "looking", "for", "it", "in", "each", "module", "registered", "." ]
train
https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L81-L99
alfred82santa/dirty-loader
dirty_loader/__init__.py
Loader.factory
def factory(self, classname, *args, **kwargs): """ Creates an instance of class looking for it in each module registered. You can add needed params to instance the class. :param classname: Class name you want to create an instance. :type classname: str :return: An instan...
python
def factory(self, classname, *args, **kwargs): """ Creates an instance of class looking for it in each module registered. You can add needed params to instance the class. :param classname: Class name you want to create an instance. :type classname: str :return: An instan...
[ "def", "factory", "(", "self", ",", "classname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "klass", "=", "self", ".", "load_class", "(", "classname", ")", "return", "self", ".", "get_factory_by_class", "(", "klass", ")", "(", "*", "args", ...
Creates an instance of class looking for it in each module registered. You can add needed params to instance the class. :param classname: Class name you want to create an instance. :type classname: str :return: An instance of classname :rtype: object
[ "Creates", "an", "instance", "of", "class", "looking", "for", "it", "in", "each", "module", "registered", ".", "You", "can", "add", "needed", "params", "to", "instance", "the", "class", "." ]
train
https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L105-L118
alfred82santa/dirty-loader
dirty_loader/__init__.py
Loader.get_factory_by_class
def get_factory_by_class(self, klass): """ Returns a custom factory for class. By default it will return the class itself. :param klass: Class type :type klass: type :return: Class factory :rtype: callable """ for check, factory in self._factories.items()...
python
def get_factory_by_class(self, klass): """ Returns a custom factory for class. By default it will return the class itself. :param klass: Class type :type klass: type :return: Class factory :rtype: callable """ for check, factory in self._factories.items()...
[ "def", "get_factory_by_class", "(", "self", ",", "klass", ")", ":", "for", "check", ",", "factory", "in", "self", ".", "_factories", ".", "items", "(", ")", ":", "if", "klass", "is", "check", ":", "return", "factory", "(", "self", ",", "klass", ")", ...
Returns a custom factory for class. By default it will return the class itself. :param klass: Class type :type klass: type :return: Class factory :rtype: callable
[ "Returns", "a", "custom", "factory", "for", "class", ".", "By", "default", "it", "will", "return", "the", "class", "itself", "." ]
train
https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L120-L135
alfred82santa/dirty-loader
dirty_loader/__init__.py
LoaderNamespace.register_module
def register_module(self, module, namespace=None): """ Register a module. :param module: must be a string or a module object to register. :type module: str :param namespace: Namespace tag. If it is None module will be used as namespace tag :type namespace: str ""...
python
def register_module(self, module, namespace=None): """ Register a module. :param module: must be a string or a module object to register. :type module: str :param namespace: Namespace tag. If it is None module will be used as namespace tag :type namespace: str ""...
[ "def", "register_module", "(", "self", ",", "module", ",", "namespace", "=", "None", ")", ":", "namespace", "=", "namespace", "if", "namespace", "is", "not", "None", "else", "module", "if", "isinstance", "(", "module", ",", "str", ")", "else", "module", ...
Register a module. :param module: must be a string or a module object to register. :type module: str :param namespace: Namespace tag. If it is None module will be used as namespace tag :type namespace: str
[ "Register", "a", "module", "." ]
train
https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L262-L273
alfred82santa/dirty-loader
dirty_loader/__init__.py
LoaderNamespace.register_namespace
def register_namespace(self, namespace, module): """ Register a namespace. :param namespace: Namespace tag. :type namespace: str :param module: must be a string or a module object to register. :type module: str """ if namespace in self._namespaces: ...
python
def register_namespace(self, namespace, module): """ Register a namespace. :param namespace: Namespace tag. :type namespace: str :param module: must be a string or a module object to register. :type module: str """ if namespace in self._namespaces: ...
[ "def", "register_namespace", "(", "self", ",", "namespace", ",", "module", ")", ":", "if", "namespace", "in", "self", ".", "_namespaces", ":", "raise", "AlreadyRegisteredError", "(", "\"Namespace '{0}' is already registered on loader.\"", ".", "format", "(", "namespac...
Register a namespace. :param namespace: Namespace tag. :type namespace: str :param module: must be a string or a module object to register. :type module: str
[ "Register", "a", "namespace", "." ]
train
https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L275-L287
alfred82santa/dirty-loader
dirty_loader/__init__.py
LoaderNamespace.unregister_module
def unregister_module(self, module): """ Unregister a module. :param module: must be a string or a module object to unregistered :type module: str """ if module not in self._namespaces.values(): raise NoRegisteredError("Module '{0}' is not registered on loade...
python
def unregister_module(self, module): """ Unregister a module. :param module: must be a string or a module object to unregistered :type module: str """ if module not in self._namespaces.values(): raise NoRegisteredError("Module '{0}' is not registered on loade...
[ "def", "unregister_module", "(", "self", ",", "module", ")", ":", "if", "module", "not", "in", "self", ".", "_namespaces", ".", "values", "(", ")", ":", "raise", "NoRegisteredError", "(", "\"Module '{0}' is not registered on loader.\"", ".", "format", "(", "modu...
Unregister a module. :param module: must be a string or a module object to unregistered :type module: str
[ "Unregister", "a", "module", "." ]
train
https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L289-L301
alfred82santa/dirty-loader
dirty_loader/__init__.py
LoaderNamespace.unregister_namespace
def unregister_namespace(self, namespace): """ Unregister a namespace. :param namespace: Namespace tag. :type namespace: str """ if namespace not in self._namespaces: raise NoRegisteredError("Namespace '{0}' is not registered on loader.".format(namespace)) ...
python
def unregister_namespace(self, namespace): """ Unregister a namespace. :param namespace: Namespace tag. :type namespace: str """ if namespace not in self._namespaces: raise NoRegisteredError("Namespace '{0}' is not registered on loader.".format(namespace)) ...
[ "def", "unregister_namespace", "(", "self", ",", "namespace", ")", ":", "if", "namespace", "not", "in", "self", ".", "_namespaces", ":", "raise", "NoRegisteredError", "(", "\"Namespace '{0}' is not registered on loader.\"", ".", "format", "(", "namespace", ")", ")",...
Unregister a namespace. :param namespace: Namespace tag. :type namespace: str
[ "Unregister", "a", "namespace", "." ]
train
https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L303-L313
alfred82santa/dirty-loader
dirty_loader/__init__.py
LoaderNamespace.load_class
def load_class(self, classname, namespace=None): """ Loads a class looking for it in each module registered. It's possible to load a class from specific namespace using **namespace** parameter or using classname as "namespace:classname". :param classname: Class name you want to load. ...
python
def load_class(self, classname, namespace=None): """ Loads a class looking for it in each module registered. It's possible to load a class from specific namespace using **namespace** parameter or using classname as "namespace:classname". :param classname: Class name you want to load. ...
[ "def", "load_class", "(", "self", ",", "classname", ",", "namespace", "=", "None", ")", ":", "if", "namespace", "is", "None", "and", "':'", "in", "classname", ":", "namespace", ",", "classname", "=", "classname", ".", "split", "(", "':'", ",", "1", ")"...
Loads a class looking for it in each module registered. It's possible to load a class from specific namespace using **namespace** parameter or using classname as "namespace:classname". :param classname: Class name you want to load. :type classname: str :param namespace: Specific namespa...
[ "Loads", "a", "class", "looking", "for", "it", "in", "each", "module", "registered", ".", "It", "s", "possible", "to", "load", "a", "class", "from", "specific", "namespace", "using", "**", "namespace", "**", "parameter", "or", "using", "classname", "as", "...
train
https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L333-L359
alfred82santa/aio-service-client
service_client/__init__.py
ServiceClient.close
def close(self): """ Close service client and its plugins. """ self._execute_plugin_hooks_sync(hook='close') if not self.session.closed: ensure_future(self.session.close(), loop=self.loop)
python
def close(self): """ Close service client and its plugins. """ self._execute_plugin_hooks_sync(hook='close') if not self.session.closed: ensure_future(self.session.close(), loop=self.loop)
[ "def", "close", "(", "self", ")", ":", "self", ".", "_execute_plugin_hooks_sync", "(", "hook", "=", "'close'", ")", "if", "not", "self", ".", "session", ".", "closed", ":", "ensure_future", "(", "self", ".", "session", ".", "close", "(", ")", ",", "loo...
Close service client and its plugins.
[ "Close", "service", "client", "and", "its", "plugins", "." ]
train
https://github.com/alfred82santa/aio-service-client/blob/dd9ad49e23067b22178534915aa23ba24f6ff39b/service_client/__init__.py#L222-L229
gabrielfalcao/dominic
dominic/xpath/__init__.py
api
def api(f): """Decorator for functions and methods that are part of the external module API and that can throw XPathError exceptions. The call stack for these exceptions can be very large, and not very interesting to the user. This decorator rethrows XPathErrors to trim the stack. """ def...
python
def api(f): """Decorator for functions and methods that are part of the external module API and that can throw XPathError exceptions. The call stack for these exceptions can be very large, and not very interesting to the user. This decorator rethrows XPathErrors to trim the stack. """ def...
[ "def", "api", "(", "f", ")", ":", "def", "api_function", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "XPathError", ",", "e", ":", "raise", "e", "api_f...
Decorator for functions and methods that are part of the external module API and that can throw XPathError exceptions. The call stack for these exceptions can be very large, and not very interesting to the user. This decorator rethrows XPathErrors to trim the stack.
[ "Decorator", "for", "functions", "and", "methods", "that", "are", "part", "of", "the", "external", "module", "API", "and", "that", "can", "throw", "XPathError", "exceptions", "." ]
train
https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/__init__.py#L10-L26
tomokinakamaru/mapletree
mapletree/defaults/routings/routetree.py
RouteTree.get
def get(self, path, strict): """ Gets the item for `path`. If `strict` is true, this method returns `None` when matching path is not found. Otherwise, this returns the result item of prefix searching. :param path: Path to get :param strict: Searching mode :type path: lis...
python
def get(self, path, strict): """ Gets the item for `path`. If `strict` is true, this method returns `None` when matching path is not found. Otherwise, this returns the result item of prefix searching. :param path: Path to get :param strict: Searching mode :type path: lis...
[ "def", "get", "(", "self", ",", "path", ",", "strict", ")", ":", "item", ",", "pathinfo", "=", "self", ".", "_get", "(", "path", ",", "strict", ")", "if", "item", "is", "None", ":", "if", "strict", ":", "return", "None", ",", "pathinfo", "else", ...
Gets the item for `path`. If `strict` is true, this method returns `None` when matching path is not found. Otherwise, this returns the result item of prefix searching. :param path: Path to get :param strict: Searching mode :type path: list :type strict: bool
[ "Gets", "the", "item", "for", "path", ".", "If", "strict", "is", "true", "this", "method", "returns", "None", "when", "matching", "path", "is", "not", "found", ".", "Otherwise", "this", "returns", "the", "result", "item", "of", "prefix", "searching", "." ]
train
https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/routings/routetree.py#L25-L45
tomokinakamaru/mapletree
mapletree/defaults/routings/routetree.py
RouteTree.set
def set(self, path, item, replace): """ Sets item for `path` and returns the item. Replaces existing item with `item` when `replace` is true :param path: Path for item :param item: New item :param replace: Updating mode :type path: list :type item: object ...
python
def set(self, path, item, replace): """ Sets item for `path` and returns the item. Replaces existing item with `item` when `replace` is true :param path: Path for item :param item: New item :param replace: Updating mode :type path: list :type item: object ...
[ "def", "set", "(", "self", ",", "path", ",", "item", ",", "replace", ")", ":", "if", "len", "(", "path", ")", "==", "0", ":", "if", "self", ".", "_item", "is", "None", "or", "replace", ":", "self", ".", "_item", "=", "item", "return", "self", "...
Sets item for `path` and returns the item. Replaces existing item with `item` when `replace` is true :param path: Path for item :param item: New item :param replace: Updating mode :type path: list :type item: object :type replace: bool
[ "Sets", "item", "for", "path", "and", "returns", "the", "item", ".", "Replaces", "existing", "item", "with", "item", "when", "replace", "is", "true" ]
train
https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/routings/routetree.py#L47-L74
knagra/farnsworth
events/ajax.py
build_ajax_rsvps
def build_ajax_rsvps(event, user_profile): """Return link and list strings for a given event.""" if user_profile in event.rsvps.all(): link_string = True else: link_string = False if not event.rsvps.all().count(): list_string = 'No RSVPs.' else: list_string = 'RSVPs:...
python
def build_ajax_rsvps(event, user_profile): """Return link and list strings for a given event.""" if user_profile in event.rsvps.all(): link_string = True else: link_string = False if not event.rsvps.all().count(): list_string = 'No RSVPs.' else: list_string = 'RSVPs:...
[ "def", "build_ajax_rsvps", "(", "event", ",", "user_profile", ")", ":", "if", "user_profile", "in", "event", ".", "rsvps", ".", "all", "(", ")", ":", "link_string", "=", "True", "else", ":", "link_string", "=", "False", "if", "not", "event", ".", "rsvps"...
Return link and list strings for a given event.
[ "Return", "link", "and", "list", "strings", "for", "a", "given", "event", "." ]
train
https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/events/ajax.py#L12-L37
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
ServiceProxy._call
def _call(self, method_proxy, *args): """ Executed when a L{ServiceMethodProxy} is called. Adds a request to the underlying gateway. """ request = self._gw.addRequest(method_proxy, *args) if self._auto_execute: response = self._gw.execute_single(request) ...
python
def _call(self, method_proxy, *args): """ Executed when a L{ServiceMethodProxy} is called. Adds a request to the underlying gateway. """ request = self._gw.addRequest(method_proxy, *args) if self._auto_execute: response = self._gw.execute_single(request) ...
[ "def", "_call", "(", "self", ",", "method_proxy", ",", "*", "args", ")", ":", "request", "=", "self", ".", "_gw", ".", "addRequest", "(", "method_proxy", ",", "*", "args", ")", "if", "self", ".", "_auto_execute", ":", "response", "=", "self", ".", "_...
Executed when a L{ServiceMethodProxy} is called. Adds a request to the underlying gateway.
[ "Executed", "when", "a", "L", "{", "ServiceMethodProxy", "}", "is", "called", ".", "Adds", "a", "request", "to", "the", "underlying", "gateway", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L93-L114
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
RequestWrapper.setResponse
def setResponse(self, response): """ A response has been received by the gateway """ self.response = response self.result = self.response.body if isinstance(self.result, remoting.ErrorFault): self.result.raiseException()
python
def setResponse(self, response): """ A response has been received by the gateway """ self.response = response self.result = self.response.body if isinstance(self.result, remoting.ErrorFault): self.result.raiseException()
[ "def", "setResponse", "(", "self", ",", "response", ")", ":", "self", ".", "response", "=", "response", "self", ".", "result", "=", "self", ".", "response", ".", "body", "if", "isinstance", "(", "self", ".", "result", ",", "remoting", ".", "ErrorFault", ...
A response has been received by the gateway
[ "A", "response", "has", "been", "received", "by", "the", "gateway" ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L152-L160
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
RemotingService.addHeader
def addHeader(self, name, value, must_understand=False): """ Sets a persistent header to send with each request. @param name: Header name. """ self.headers[name] = value self.headers.set_required(name, must_understand)
python
def addHeader(self, name, value, must_understand=False): """ Sets a persistent header to send with each request. @param name: Header name. """ self.headers[name] = value self.headers.set_required(name, must_understand)
[ "def", "addHeader", "(", "self", ",", "name", ",", "value", ",", "must_understand", "=", "False", ")", ":", "self", ".", "headers", "[", "name", "]", "=", "value", "self", ".", "headers", ".", "set_required", "(", "name", ",", "must_understand", ")" ]
Sets a persistent header to send with each request. @param name: Header name.
[ "Sets", "a", "persistent", "header", "to", "send", "with", "each", "request", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L253-L260
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
RemotingService.getService
def getService(self, name, auto_execute=True): """ Returns a L{ServiceProxy} for the supplied name. Sets up an object that can have method calls made to it that build the AMF requests. @rtype: L{ServiceProxy} """ if not isinstance(name, basestring): raise Typ...
python
def getService(self, name, auto_execute=True): """ Returns a L{ServiceProxy} for the supplied name. Sets up an object that can have method calls made to it that build the AMF requests. @rtype: L{ServiceProxy} """ if not isinstance(name, basestring): raise Typ...
[ "def", "getService", "(", "self", ",", "name", ",", "auto_execute", "=", "True", ")", ":", "if", "not", "isinstance", "(", "name", ",", "basestring", ")", ":", "raise", "TypeError", "(", "'string type required'", ")", "return", "ServiceProxy", "(", "self", ...
Returns a L{ServiceProxy} for the supplied name. Sets up an object that can have method calls made to it that build the AMF requests. @rtype: L{ServiceProxy}
[ "Returns", "a", "L", "{", "ServiceProxy", "}", "for", "the", "supplied", "name", ".", "Sets", "up", "an", "object", "that", "can", "have", "method", "calls", "made", "to", "it", "that", "build", "the", "AMF", "requests", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L274-L284
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
RemotingService.getRequest
def getRequest(self, id_): """ Gets a request based on the id. :raise LookupError: Request not found. """ for request in self.requests: if request.id == id_: return request raise LookupError("Request %r not found" % (id_,))
python
def getRequest(self, id_): """ Gets a request based on the id. :raise LookupError: Request not found. """ for request in self.requests: if request.id == id_: return request raise LookupError("Request %r not found" % (id_,))
[ "def", "getRequest", "(", "self", ",", "id_", ")", ":", "for", "request", "in", "self", ".", "requests", ":", "if", "request", ".", "id", "==", "id_", ":", "return", "request", "raise", "LookupError", "(", "\"Request %r not found\"", "%", "(", "id_", ","...
Gets a request based on the id. :raise LookupError: Request not found.
[ "Gets", "a", "request", "based", "on", "the", "id", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L286-L296
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
RemotingService.addRequest
def addRequest(self, service, *args): """ Adds a request to be sent to the remoting gateway. """ wrapper = RequestWrapper(self, '/%d' % self.request_number, service, *args) self.request_number += 1 self.requests.append(wrapper) if self.logger: ...
python
def addRequest(self, service, *args): """ Adds a request to be sent to the remoting gateway. """ wrapper = RequestWrapper(self, '/%d' % self.request_number, service, *args) self.request_number += 1 self.requests.append(wrapper) if self.logger: ...
[ "def", "addRequest", "(", "self", ",", "service", ",", "*", "args", ")", ":", "wrapper", "=", "RequestWrapper", "(", "self", ",", "'/%d'", "%", "self", ".", "request_number", ",", "service", ",", "*", "args", ")", "self", ".", "request_number", "+=", "...
Adds a request to be sent to the remoting gateway.
[ "Adds", "a", "request", "to", "be", "sent", "to", "the", "remoting", "gateway", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L298-L311
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
RemotingService.removeRequest
def removeRequest(self, service, *args): """ Removes a request from the pending request list. """ if isinstance(service, RequestWrapper): if self.logger: self.logger.debug('Removing request: %s', self.requests[self.requests.index(service)]...
python
def removeRequest(self, service, *args): """ Removes a request from the pending request list. """ if isinstance(service, RequestWrapper): if self.logger: self.logger.debug('Removing request: %s', self.requests[self.requests.index(service)]...
[ "def", "removeRequest", "(", "self", ",", "service", ",", "*", "args", ")", ":", "if", "isinstance", "(", "service", ",", "RequestWrapper", ")", ":", "if", "self", ".", "logger", ":", "self", ".", "logger", ".", "debug", "(", "'Removing request: %s'", ",...
Removes a request from the pending request list.
[ "Removes", "a", "request", "from", "the", "pending", "request", "list", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L313-L335
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
RemotingService.getAMFRequest
def getAMFRequest(self, requests): """ Builds an AMF request {LEnvelope<pyamf.remoting.Envelope>} from a supplied list of requests. """ envelope = remoting.Envelope(self.amf_version) if self.logger: self.logger.debug('AMF version: %s' % self.amf_version) ...
python
def getAMFRequest(self, requests): """ Builds an AMF request {LEnvelope<pyamf.remoting.Envelope>} from a supplied list of requests. """ envelope = remoting.Envelope(self.amf_version) if self.logger: self.logger.debug('AMF version: %s' % self.amf_version) ...
[ "def", "getAMFRequest", "(", "self", ",", "requests", ")", ":", "envelope", "=", "remoting", ".", "Envelope", "(", "self", ".", "amf_version", ")", "if", "self", ".", "logger", ":", "self", ".", "logger", ".", "debug", "(", "'AMF version: %s'", "%", "sel...
Builds an AMF request {LEnvelope<pyamf.remoting.Envelope>} from a supplied list of requests.
[ "Builds", "an", "AMF", "request", "{", "LEnvelope<pyamf", ".", "remoting", ".", "Envelope", ">", "}", "from", "a", "supplied", "list", "of", "requests", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L337-L355
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
RemotingService.execute_single
def execute_single(self, request): """ Builds, sends and handles the response to a single request, returning the response. """ if self.logger: self.logger.debug('Executing single request: %s', request) self.removeRequest(request) body = remoting.enco...
python
def execute_single(self, request): """ Builds, sends and handles the response to a single request, returning the response. """ if self.logger: self.logger.debug('Executing single request: %s', request) self.removeRequest(request) body = remoting.enco...
[ "def", "execute_single", "(", "self", ",", "request", ")", ":", "if", "self", ".", "logger", ":", "self", ".", "logger", ".", "debug", "(", "'Executing single request: %s'", ",", "request", ")", "self", ".", "removeRequest", "(", "request", ")", "body", "=...
Builds, sends and handles the response to a single request, returning the response.
[ "Builds", "sends", "and", "handles", "the", "response", "to", "a", "single", "request", "returning", "the", "response", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L370-L390
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
RemotingService.execute
def execute(self): """ Builds, sends and handles the responses to all requests listed in C{self.requests}. """ requests = self.requests[:] for r in requests: self.removeRequest(r) body = remoting.encode(self.getAMFRequest(requests), stric...
python
def execute(self): """ Builds, sends and handles the responses to all requests listed in C{self.requests}. """ requests = self.requests[:] for r in requests: self.removeRequest(r) body = remoting.encode(self.getAMFRequest(requests), stric...
[ "def", "execute", "(", "self", ")", ":", "requests", "=", "self", ".", "requests", "[", ":", "]", "for", "r", "in", "requests", ":", "self", ".", "removeRequest", "(", "r", ")", "body", "=", "remoting", ".", "encode", "(", "self", ".", "getAMFRequest...
Builds, sends and handles the responses to all requests listed in C{self.requests}.
[ "Builds", "sends", "and", "handles", "the", "responses", "to", "all", "requests", "listed", "in", "C", "{", "self", ".", "requests", "}", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L392-L413
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
RemotingService._getResponse
def _getResponse(self, http_request): """ Gets and handles the HTTP response from the remote gateway. """ if self.logger: self.logger.debug('Sending POST request to %s', self._root_url) try: fbh = self.opener(http_request) except urllib2.URLError,...
python
def _getResponse(self, http_request): """ Gets and handles the HTTP response from the remote gateway. """ if self.logger: self.logger.debug('Sending POST request to %s', self._root_url) try: fbh = self.opener(http_request) except urllib2.URLError,...
[ "def", "_getResponse", "(", "self", ",", "http_request", ")", ":", "if", "self", ".", "logger", ":", "self", ".", "logger", ".", "debug", "(", "'Sending POST request to %s'", ",", "self", ".", "_root_url", ")", "try", ":", "fbh", "=", "self", ".", "opene...
Gets and handles the HTTP response from the remote gateway.
[ "Gets", "and", "handles", "the", "HTTP", "response", "from", "the", "remote", "gateway", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L415-L487
jmgilman/Neolib
neolib/pyamf/remoting/client/__init__.py
RemotingService.setCredentials
def setCredentials(self, username, password): """ Sets authentication credentials for accessing the remote gateway. """ self.addHeader('Credentials', dict(userid=username.decode('utf-8'), password=password.decode('utf-8')), True)
python
def setCredentials(self, username, password): """ Sets authentication credentials for accessing the remote gateway. """ self.addHeader('Credentials', dict(userid=username.decode('utf-8'), password=password.decode('utf-8')), True)
[ "def", "setCredentials", "(", "self", ",", "username", ",", "password", ")", ":", "self", ".", "addHeader", "(", "'Credentials'", ",", "dict", "(", "userid", "=", "username", ".", "decode", "(", "'utf-8'", ")", ",", "password", "=", "password", ".", "dec...
Sets authentication credentials for accessing the remote gateway.
[ "Sets", "authentication", "credentials", "for", "accessing", "the", "remote", "gateway", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L489-L494
neuroticnerd/armory
armory/gevent.py
patch_gevent_hub
def patch_gevent_hub(): """ This patches the error handler in the gevent Hub object. """ from gevent.hub import Hub def patched_handle_error(self, context, etype, value, tb): """ Patched to not print KeyboardInterrupt exceptions. """ if isinstance(value, str): value = etype(valu...
python
def patch_gevent_hub(): """ This patches the error handler in the gevent Hub object. """ from gevent.hub import Hub def patched_handle_error(self, context, etype, value, tb): """ Patched to not print KeyboardInterrupt exceptions. """ if isinstance(value, str): value = etype(valu...
[ "def", "patch_gevent_hub", "(", ")", ":", "from", "gevent", ".", "hub", "import", "Hub", "def", "patched_handle_error", "(", "self", ",", "context", ",", "etype", ",", "value", ",", "tb", ")", ":", "\"\"\" Patched to not print KeyboardInterrupt exceptions. \"\"\"", ...
This patches the error handler in the gevent Hub object.
[ "This", "patches", "the", "error", "handler", "in", "the", "gevent", "Hub", "object", "." ]
train
https://github.com/neuroticnerd/armory/blob/d37c5ca1dbdd60dddb968e35f0bbe4bc1299dca1/armory/gevent.py#L15-L31
abe-winter/pg13-py
pg13/scope.py
col2name
def col2name(col_item): "helper for SyntheticTable.columns. takes something from SelectX.cols, returns a string column name" if isinstance(col_item, sqparse2.NameX): return col_item.name elif isinstance(col_item, sqparse2.AliasX): return col_item.alias else: raise TypeError(type(col_item), col_item)
python
def col2name(col_item): "helper for SyntheticTable.columns. takes something from SelectX.cols, returns a string column name" if isinstance(col_item, sqparse2.NameX): return col_item.name elif isinstance(col_item, sqparse2.AliasX): return col_item.alias else: raise TypeError(type(col_item), col_item)
[ "def", "col2name", "(", "col_item", ")", ":", "if", "isinstance", "(", "col_item", ",", "sqparse2", ".", "NameX", ")", ":", "return", "col_item", ".", "name", "elif", "isinstance", "(", "col_item", ",", "sqparse2", ".", "AliasX", ")", ":", "return", "col...
helper for SyntheticTable.columns. takes something from SelectX.cols, returns a string column name
[ "helper", "for", "SyntheticTable", ".", "columns", ".", "takes", "something", "from", "SelectX", ".", "cols", "returns", "a", "string", "column", "name" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/scope.py#L9-L13
abe-winter/pg13-py
pg13/scope.py
Scope.add
def add(self, name, target): "target should be a Table or SyntheticTable" if not isinstance(target, (table.Table, SyntheticTable)): raise TypeError(type(target), target) if name in self: # note: this is critical for avoiding cycles raise ScopeCollisionError('scope already has', name) s...
python
def add(self, name, target): "target should be a Table or SyntheticTable" if not isinstance(target, (table.Table, SyntheticTable)): raise TypeError(type(target), target) if name in self: # note: this is critical for avoiding cycles raise ScopeCollisionError('scope already has', name) s...
[ "def", "add", "(", "self", ",", "name", ",", "target", ")", ":", "if", "not", "isinstance", "(", "target", ",", "(", "table", ".", "Table", ",", "SyntheticTable", ")", ")", ":", "raise", "TypeError", "(", "type", "(", "target", ")", ",", "target", ...
target should be a Table or SyntheticTable
[ "target", "should", "be", "a", "Table", "or", "SyntheticTable" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/scope.py#L34-L41
abe-winter/pg13-py
pg13/scope.py
Scope.resolve_column
def resolve_column(self, ref): "ref is a NameX or AttrX. return (canonical_table_name, column_name)." if isinstance(ref, sqparse2.AttrX): if ref.parent.name not in self: raise ScopeUnkError('unk table or table alias', ref.parent.name) return ref.parent.name, ref.attr.name elif isinstance...
python
def resolve_column(self, ref): "ref is a NameX or AttrX. return (canonical_table_name, column_name)." if isinstance(ref, sqparse2.AttrX): if ref.parent.name not in self: raise ScopeUnkError('unk table or table alias', ref.parent.name) return ref.parent.name, ref.attr.name elif isinstance...
[ "def", "resolve_column", "(", "self", ",", "ref", ")", ":", "if", "isinstance", "(", "ref", ",", "sqparse2", ".", "AttrX", ")", ":", "if", "ref", ".", "parent", ".", "name", "not", "in", "self", ":", "raise", "ScopeUnkError", "(", "'unk table or table al...
ref is a NameX or AttrX. return (canonical_table_name, column_name).
[ "ref", "is", "a", "NameX", "or", "AttrX", ".", "return", "(", "canonical_table_name", "column_name", ")", "." ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/scope.py#L46-L68
abe-winter/pg13-py
pg13/scope.py
Scope.from_fromx
def from_fromx(class_, tables, fromx, ctes=()): """Build a Scope given TablesDict, from-expression and optional list of CTEs. fromx is a list of expressions (e.g. SelectX.tables). The list elts can be: 1. string (i.e. tablename) 2. AliasX(SelectX as name) 3. AliasX(name as name) """ if...
python
def from_fromx(class_, tables, fromx, ctes=()): """Build a Scope given TablesDict, from-expression and optional list of CTEs. fromx is a list of expressions (e.g. SelectX.tables). The list elts can be: 1. string (i.e. tablename) 2. AliasX(SelectX as name) 3. AliasX(name as name) """ if...
[ "def", "from_fromx", "(", "class_", ",", "tables", ",", "fromx", ",", "ctes", "=", "(", ")", ")", ":", "if", "ctes", ":", "raise", "NotImplementedError", "# note: I don't think any other part of the program supports CTEs yet either", "scope_", "=", "class_", "(", "f...
Build a Scope given TablesDict, from-expression and optional list of CTEs. fromx is a list of expressions (e.g. SelectX.tables). The list elts can be: 1. string (i.e. tablename) 2. AliasX(SelectX as name) 3. AliasX(name as name)
[ "Build", "a", "Scope", "given", "TablesDict", "from", "-", "expression", "and", "optional", "list", "of", "CTEs", ".", "fromx", "is", "a", "list", "of", "expressions", "(", "e", ".", "g", ".", "SelectX", ".", "tables", ")", ".", "The", "list", "elts", ...
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/scope.py#L71-L91
Tinche/django-bower-cache
registry/views.py
PackagesRetrieveView.clone_from_upstream
def clone_from_upstream(pkg_name, repo_url): """Clone a non-existent package using the upstream registry.""" msg = "Spawning a cloning task for %s from upstream due to API req." LOG.info(msg % pkg_name) upstream_url = settings.UPSTREAM_BOWER_REGISTRY upstream_pkg = bowerlib.get_...
python
def clone_from_upstream(pkg_name, repo_url): """Clone a non-existent package using the upstream registry.""" msg = "Spawning a cloning task for %s from upstream due to API req." LOG.info(msg % pkg_name) upstream_url = settings.UPSTREAM_BOWER_REGISTRY upstream_pkg = bowerlib.get_...
[ "def", "clone_from_upstream", "(", "pkg_name", ",", "repo_url", ")", ":", "msg", "=", "\"Spawning a cloning task for %s from upstream due to API req.\"", "LOG", ".", "info", "(", "msg", "%", "pkg_name", ")", "upstream_url", "=", "settings", ".", "UPSTREAM_BOWER_REGISTRY...
Clone a non-existent package using the upstream registry.
[ "Clone", "a", "non", "-", "existent", "package", "using", "the", "upstream", "registry", "." ]
train
https://github.com/Tinche/django-bower-cache/blob/5245b2ee80c33c09d85ce0bf8f047825d9df2118/registry/views.py#L79-L97