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
rackerlabs/rackspace-python-neutronclient
neutronclient/neutron/v2_0/__init__.py
ListCommand.retrieve_list
def retrieve_list(self, parsed_args): """Retrieve a list of resources from Neutron server.""" neutron_client = self.get_client() _extra_values = parse_args_to_dict(self.values_specs) _merge_args(self, parsed_args, _extra_values, self.values_specs) search_opts ...
python
def retrieve_list(self, parsed_args): """Retrieve a list of resources from Neutron server.""" neutron_client = self.get_client() _extra_values = parse_args_to_dict(self.values_specs) _merge_args(self, parsed_args, _extra_values, self.values_specs) search_opts ...
[ "def", "retrieve_list", "(", "self", ",", "parsed_args", ")", ":", "neutron_client", "=", "self", ".", "get_client", "(", ")", "_extra_values", "=", "parse_args_to_dict", "(", "self", ".", "values_specs", ")", "_merge_args", "(", "self", ",", "parsed_args", ",...
Retrieve a list of resources from Neutron server.
[ "Retrieve", "a", "list", "of", "resources", "from", "Neutron", "server", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/neutron/v2_0/__init__.py#L707-L733
treycucco/bidon
bidon/db/access/pg_advisory_lock.py
lock_key
def lock_key(group_id, item_id, group_width=8): """Creates a lock ID where the lower bits are the group ID and the upper bits are the item ID. This allows the use of a bigint namespace for items, with a limited space for grouping. :group_id: an integer identifying the group. Must be less than 2 ^ ...
python
def lock_key(group_id, item_id, group_width=8): """Creates a lock ID where the lower bits are the group ID and the upper bits are the item ID. This allows the use of a bigint namespace for items, with a limited space for grouping. :group_id: an integer identifying the group. Must be less than 2 ^ ...
[ "def", "lock_key", "(", "group_id", ",", "item_id", ",", "group_width", "=", "8", ")", ":", "if", "group_id", ">=", "(", "1", "<<", "group_width", ")", ":", "raise", "Exception", "(", "\"Group ID is too big\"", ")", "if", "item_id", ">=", "(", "1", "<<",...
Creates a lock ID where the lower bits are the group ID and the upper bits are the item ID. This allows the use of a bigint namespace for items, with a limited space for grouping. :group_id: an integer identifying the group. Must be less than 2 ^ :group_width: :item_id: item_id an integer. must be...
[ "Creates", "a", "lock", "ID", "where", "the", "lower", "bits", "are", "the", "group", "ID", "and", "the", "upper", "bits", "are", "the", "item", "ID", ".", "This", "allows", "the", "use", "of", "a", "bigint", "namespace", "for", "items", "with", "a", ...
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/pg_advisory_lock.py#L16-L30
treycucco/bidon
bidon/db/access/pg_advisory_lock.py
release_lock
def release_lock(dax, key, lock_mode=LockMode.wait): """Manually release a pg advisory lock. :dax: a DataAccess instance :key: either a big int or a 2-tuple of integers :lock_mode: a member of the LockMode enum """ lock_fxn = _lock_fxn("unlock", lock_mode, False) return dax.get_scalar( dax.callproc(l...
python
def release_lock(dax, key, lock_mode=LockMode.wait): """Manually release a pg advisory lock. :dax: a DataAccess instance :key: either a big int or a 2-tuple of integers :lock_mode: a member of the LockMode enum """ lock_fxn = _lock_fxn("unlock", lock_mode, False) return dax.get_scalar( dax.callproc(l...
[ "def", "release_lock", "(", "dax", ",", "key", ",", "lock_mode", "=", "LockMode", ".", "wait", ")", ":", "lock_fxn", "=", "_lock_fxn", "(", "\"unlock\"", ",", "lock_mode", ",", "False", ")", "return", "dax", ".", "get_scalar", "(", "dax", ".", "callproc"...
Manually release a pg advisory lock. :dax: a DataAccess instance :key: either a big int or a 2-tuple of integers :lock_mode: a member of the LockMode enum
[ "Manually", "release", "a", "pg", "advisory", "lock", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/pg_advisory_lock.py#L47-L56
treycucco/bidon
bidon/db/access/pg_advisory_lock.py
advisory_lock
def advisory_lock(dax, key, lock_mode=LockMode.wait, xact=False): """A context manager for obtaining a lock, executing code, and then releasing the lock. A boolean value is passed to the block indicating whether or not the lock was obtained. :dax: a DataAccess instance :key: either a big int or a 2-tuple ...
python
def advisory_lock(dax, key, lock_mode=LockMode.wait, xact=False): """A context manager for obtaining a lock, executing code, and then releasing the lock. A boolean value is passed to the block indicating whether or not the lock was obtained. :dax: a DataAccess instance :key: either a big int or a 2-tuple ...
[ "def", "advisory_lock", "(", "dax", ",", "key", ",", "lock_mode", "=", "LockMode", ".", "wait", ",", "xact", "=", "False", ")", ":", "if", "lock_mode", "==", "LockMode", ".", "wait", ":", "obtain_lock", "(", "dax", ",", "key", ",", "lock_mode", ",", ...
A context manager for obtaining a lock, executing code, and then releasing the lock. A boolean value is passed to the block indicating whether or not the lock was obtained. :dax: a DataAccess instance :key: either a big int or a 2-tuple of integers :lock_mode: a member of the LockMode enum. Determines how...
[ "A", "context", "manager", "for", "obtaining", "a", "lock", "executing", "code", "and", "then", "releasing", "the", "lock", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/pg_advisory_lock.py#L60-L98
treycucco/bidon
bidon/db/access/pg_advisory_lock.py
_lock_fxn
def _lock_fxn(direction, lock_mode, xact): """Builds a pg advisory lock function name based on various options. :direction: one of "lock" or "unlock" :lock_mode: a member of the LockMode enum :xact: a boolean, if True the lock will be automatically released at the end of the transaction and cannot be ...
python
def _lock_fxn(direction, lock_mode, xact): """Builds a pg advisory lock function name based on various options. :direction: one of "lock" or "unlock" :lock_mode: a member of the LockMode enum :xact: a boolean, if True the lock will be automatically released at the end of the transaction and cannot be ...
[ "def", "_lock_fxn", "(", "direction", ",", "lock_mode", ",", "xact", ")", ":", "if", "direction", "==", "\"unlock\"", "or", "lock_mode", "==", "LockMode", ".", "wait", ":", "try_mode", "=", "\"\"", "else", ":", "try_mode", "=", "\"_try\"", "if", "direction...
Builds a pg advisory lock function name based on various options. :direction: one of "lock" or "unlock" :lock_mode: a member of the LockMode enum :xact: a boolean, if True the lock will be automatically released at the end of the transaction and cannot be manually released.
[ "Builds", "a", "pg", "advisory", "lock", "function", "name", "based", "on", "various", "options", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/pg_advisory_lock.py#L101-L119
leosartaj/sub
sub/main.py
fileExists
def fileExists(fName, dire=pDir()): """ Check if a file exists """ if os.path.isfile(os.path.join(dire, fName)): return True return False
python
def fileExists(fName, dire=pDir()): """ Check if a file exists """ if os.path.isfile(os.path.join(dire, fName)): return True return False
[ "def", "fileExists", "(", "fName", ",", "dire", "=", "pDir", "(", ")", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "join", "(", "dire", ",", "fName", ")", ")", ":", "return", "True", "return", "False" ]
Check if a file exists
[ "Check", "if", "a", "file", "exists" ]
train
https://github.com/leosartaj/sub/blob/9a8e55a5326c3b41357eedd235e7c36f253db2e0/sub/main.py#L21-L27
leosartaj/sub
sub/main.py
get_hash
def get_hash(fName, readSize, dire=pDir()): """ creates the required hash """ if not fileExists(fName, dire): return -1 readSize = readSize * 1024 # bytes to be read fName = os.path.join(dire, fName) # name coupled with path with open(fName, 'rb') as f: size = os.path.getsize...
python
def get_hash(fName, readSize, dire=pDir()): """ creates the required hash """ if not fileExists(fName, dire): return -1 readSize = readSize * 1024 # bytes to be read fName = os.path.join(dire, fName) # name coupled with path with open(fName, 'rb') as f: size = os.path.getsize...
[ "def", "get_hash", "(", "fName", ",", "readSize", ",", "dire", "=", "pDir", "(", ")", ")", ":", "if", "not", "fileExists", "(", "fName", ",", "dire", ")", ":", "return", "-", "1", "readSize", "=", "readSize", "*", "1024", "# bytes to be read", "fName",...
creates the required hash
[ "creates", "the", "required", "hash" ]
train
https://github.com/leosartaj/sub/blob/9a8e55a5326c3b41357eedd235e7c36f253db2e0/sub/main.py#L37-L52
leosartaj/sub
sub/main.py
download_file
def download_file(fName, time, dire=pDir()): """ download the required subtitle """ # hash gen_hash = get_hash(fName, 64, dire) if gen_hash == -1: return -1 # making request user_agent = {'User-agent': 'SubDB/1.0 (sub/0.1; http://github.com/leosartaj/sub)'} param = {'action'...
python
def download_file(fName, time, dire=pDir()): """ download the required subtitle """ # hash gen_hash = get_hash(fName, 64, dire) if gen_hash == -1: return -1 # making request user_agent = {'User-agent': 'SubDB/1.0 (sub/0.1; http://github.com/leosartaj/sub)'} param = {'action'...
[ "def", "download_file", "(", "fName", ",", "time", ",", "dire", "=", "pDir", "(", ")", ")", ":", "# hash", "gen_hash", "=", "get_hash", "(", "fName", ",", "64", ",", "dire", ")", "if", "gen_hash", "==", "-", "1", ":", "return", "-", "1", "# making ...
download the required subtitle
[ "download", "the", "required", "subtitle" ]
train
https://github.com/leosartaj/sub/blob/9a8e55a5326c3b41357eedd235e7c36f253db2e0/sub/main.py#L54-L80
leosartaj/sub
sub/main.py
file_downloaded
def file_downloaded(dwn, fName, verbose=False): """ print for downloaded file """ if verbose: if dwn == 200: fName, fExt = os.path.splitext(fName) print 'Downloaded ' + fName + '.srt' return True elif dwn != -1: print 'Tried downloading got...
python
def file_downloaded(dwn, fName, verbose=False): """ print for downloaded file """ if verbose: if dwn == 200: fName, fExt = os.path.splitext(fName) print 'Downloaded ' + fName + '.srt' return True elif dwn != -1: print 'Tried downloading got...
[ "def", "file_downloaded", "(", "dwn", ",", "fName", ",", "verbose", "=", "False", ")", ":", "if", "verbose", ":", "if", "dwn", "==", "200", ":", "fName", ",", "fExt", "=", "os", ".", "path", ".", "splitext", "(", "fName", ")", "print", "'Downloaded '...
print for downloaded file
[ "print", "for", "downloaded", "file" ]
train
https://github.com/leosartaj/sub/blob/9a8e55a5326c3b41357eedd235e7c36f253db2e0/sub/main.py#L82-L93
leosartaj/sub
sub/main.py
download
def download(name, options): """ download a file or all files in a directory """ dire = os.path.dirname(name) # returns the directory name fName = os.path.basename(name) # returns the filename fNameOnly, fExt = os.path.splitext(fName) dwn = 0 if fileExists(fName, dire) and not fileExis...
python
def download(name, options): """ download a file or all files in a directory """ dire = os.path.dirname(name) # returns the directory name fName = os.path.basename(name) # returns the filename fNameOnly, fExt = os.path.splitext(fName) dwn = 0 if fileExists(fName, dire) and not fileExis...
[ "def", "download", "(", "name", ",", "options", ")", ":", "dire", "=", "os", ".", "path", ".", "dirname", "(", "name", ")", "# returns the directory name", "fName", "=", "os", ".", "path", ".", "basename", "(", "name", ")", "# returns the filename", "fName...
download a file or all files in a directory
[ "download", "a", "file", "or", "all", "files", "in", "a", "directory" ]
train
https://github.com/leosartaj/sub/blob/9a8e55a5326c3b41357eedd235e7c36f253db2e0/sub/main.py#L95-L115
ulf1/oxyba
oxyba/clean_dateobject_to_string.py
clean_dateobject_to_string
def clean_dateobject_to_string(x): """Convert a Pandas Timestamp object or datetime object to 'YYYY-MM-DD' string Parameters ---------- x : str, list, tuple, numpy.ndarray, pandas.DataFrame A Pandas Timestamp object or datetime object, or an array of these objects Returns -...
python
def clean_dateobject_to_string(x): """Convert a Pandas Timestamp object or datetime object to 'YYYY-MM-DD' string Parameters ---------- x : str, list, tuple, numpy.ndarray, pandas.DataFrame A Pandas Timestamp object or datetime object, or an array of these objects Returns -...
[ "def", "clean_dateobject_to_string", "(", "x", ")", ":", "import", "numpy", "as", "np", "import", "pandas", "as", "pd", "def", "proc_elem", "(", "e", ")", ":", "try", ":", "return", "e", ".", "strftime", "(", "\"%Y-%m-%d\"", ")", "except", "Exception", "...
Convert a Pandas Timestamp object or datetime object to 'YYYY-MM-DD' string Parameters ---------- x : str, list, tuple, numpy.ndarray, pandas.DataFrame A Pandas Timestamp object or datetime object, or an array of these objects Returns ------- y : str, list, tuple, numpy.nda...
[ "Convert", "a", "Pandas", "Timestamp", "object", "or", "datetime", "object", "to", "YYYY", "-", "MM", "-", "DD", "string" ]
train
https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/clean_dateobject_to_string.py#L2-L66
sys-git/certifiable
certifiable/operators.py
AND
def AND(*args, **kwargs): """ ALL args must not raise an exception when called incrementally. If an exception is specified, raise it, otherwise raise the callable's exception. :params iterable[Certifier] args: The certifiers to call :param callable kwargs['exc']: Callable that exce...
python
def AND(*args, **kwargs): """ ALL args must not raise an exception when called incrementally. If an exception is specified, raise it, otherwise raise the callable's exception. :params iterable[Certifier] args: The certifiers to call :param callable kwargs['exc']: Callable that exce...
[ "def", "AND", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "arg", "in", "args", ":", "try", ":", "arg", "(", ")", "except", "CertifierError", "as", "e", ":", "exc", "=", "kwargs", ".", "get", "(", "'exc'", ",", "None", ")", "if",...
ALL args must not raise an exception when called incrementally. If an exception is specified, raise it, otherwise raise the callable's exception. :params iterable[Certifier] args: The certifiers to call :param callable kwargs['exc']: Callable that excepts the unexpectedly raised exception ...
[ "ALL", "args", "must", "not", "raise", "an", "exception", "when", "called", "incrementally", ".", "If", "an", "exception", "is", "specified", "raise", "it", "otherwise", "raise", "the", "callable", "s", "exception", "." ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/operators.py#L34-L55
sys-git/certifiable
certifiable/operators.py
NAND
def NAND(*args, **kwargs): """ ALL args must raise an exception when called overall. Raise the specified exception on failure OR the first exception. :params iterable[Certifier] args: The certifiers to call :param callable kwargs['exc']: Callable that excepts the unexpectedly raised...
python
def NAND(*args, **kwargs): """ ALL args must raise an exception when called overall. Raise the specified exception on failure OR the first exception. :params iterable[Certifier] args: The certifiers to call :param callable kwargs['exc']: Callable that excepts the unexpectedly raised...
[ "def", "NAND", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "errors", "=", "[", "]", "for", "arg", "in", "args", ":", "try", ":", "arg", "(", ")", "except", "CertifierError", "as", "e", ":", "errors", ".", "append", "(", "e", ")", "if",...
ALL args must raise an exception when called overall. Raise the specified exception on failure OR the first exception. :params iterable[Certifier] args: The certifiers to call :param callable kwargs['exc']: Callable that excepts the unexpectedly raised exception as argument and return an ...
[ "ALL", "args", "must", "raise", "an", "exception", "when", "called", "overall", ".", "Raise", "the", "specified", "exception", "on", "failure", "OR", "the", "first", "exception", "." ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/operators.py#L58-L83
sys-git/certifiable
certifiable/operators.py
XOR
def XOR(a, b, exc=CertifierValueError('Expected at least one certified value')): """ Only one arg must not raise a Certifier exception when called overall. Raise the specified exception on failure. :params Certifier a: The first certifiers to call :params Certifier b: The second cer...
python
def XOR(a, b, exc=CertifierValueError('Expected at least one certified value')): """ Only one arg must not raise a Certifier exception when called overall. Raise the specified exception on failure. :params Certifier a: The first certifiers to call :params Certifier b: The second cer...
[ "def", "XOR", "(", "a", ",", "b", ",", "exc", "=", "CertifierValueError", "(", "'Expected at least one certified value'", ")", ")", ":", "errors", "=", "[", "]", "for", "certifier", "in", "[", "a", ",", "b", "]", ":", "try", ":", "certifier", "(", ")",...
Only one arg must not raise a Certifier exception when called overall. Raise the specified exception on failure. :params Certifier a: The first certifiers to call :params Certifier b: The second certifiers to call :param Exception exc: Callable that is raised if XOR fails.
[ "Only", "one", "arg", "must", "not", "raise", "a", "Certifier", "exception", "when", "called", "overall", ".", "Raise", "the", "specified", "exception", "on", "failure", "." ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/operators.py#L86-L108
FujiMakoto/IPS-Vagrant
ips_vagrant/cli.py
cli
def cli(ctx, verbose, config): """ IPS Vagrant Management Utility """ assert isinstance(ctx, Context) # Set up the logger verbose = verbose if (verbose <= 3) else 3 log_levels = {1: logging.WARN, 2: logging.INFO, 3: logging.DEBUG} log_level = log_levels[verbose] ctx.log = logging.ge...
python
def cli(ctx, verbose, config): """ IPS Vagrant Management Utility """ assert isinstance(ctx, Context) # Set up the logger verbose = verbose if (verbose <= 3) else 3 log_levels = {1: logging.WARN, 2: logging.INFO, 3: logging.DEBUG} log_level = log_levels[verbose] ctx.log = logging.ge...
[ "def", "cli", "(", "ctx", ",", "verbose", ",", "config", ")", ":", "assert", "isinstance", "(", "ctx", ",", "Context", ")", "# Set up the logger", "verbose", "=", "verbose", "if", "(", "verbose", "<=", "3", ")", "else", "3", "log_levels", "=", "{", "1"...
IPS Vagrant Management Utility
[ "IPS", "Vagrant", "Management", "Utility" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/cli.py#L119-L155
FujiMakoto/IPS-Vagrant
ips_vagrant/cli.py
Context.db
def db(self): """ Get a loaded database session """ if self.database is NotImplemented: self.database = Session return self.database
python
def db(self): """ Get a loaded database session """ if self.database is NotImplemented: self.database = Session return self.database
[ "def", "db", "(", "self", ")", ":", "if", "self", ".", "database", "is", "NotImplemented", ":", "self", ".", "database", "=", "Session", "return", "self", ".", "database" ]
Get a loaded database session
[ "Get", "a", "loaded", "database", "session" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/cli.py#L37-L44
FujiMakoto/IPS-Vagrant
ips_vagrant/cli.py
Context.load_config
def load_config(self, path): """ (Re-)load the configuration file """ self.config_path = path self.config.read(self.config_path)
python
def load_config(self, path): """ (Re-)load the configuration file """ self.config_path = path self.config.read(self.config_path)
[ "def", "load_config", "(", "self", ",", "path", ")", ":", "self", ".", "config_path", "=", "path", "self", ".", "config", ".", "read", "(", "self", ".", "config_path", ")" ]
(Re-)load the configuration file
[ "(", "Re", "-", ")", "load", "the", "configuration", "file" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/cli.py#L46-L51
FujiMakoto/IPS-Vagrant
ips_vagrant/cli.py
Context.get_login
def get_login(self, use_session=True): """ Get an active login session @param use_session: Use a saved session file if available @type use_session: bool """ # Should we try and return an existing login session? if use_session and self._login.check(): ...
python
def get_login(self, use_session=True): """ Get an active login session @param use_session: Use a saved session file if available @type use_session: bool """ # Should we try and return an existing login session? if use_session and self._login.check(): ...
[ "def", "get_login", "(", "self", ",", "use_session", "=", "True", ")", ":", "# Should we try and return an existing login session?", "if", "use_session", "and", "self", ".", "_login", ".", "check", "(", ")", ":", "self", ".", "cookiejar", "=", "self", ".", "_l...
Get an active login session @param use_session: Use a saved session file if available @type use_session: bool
[ "Get", "an", "active", "login", "session" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/cli.py#L53-L74
FujiMakoto/IPS-Vagrant
ips_vagrant/cli.py
IpsvCLI.list_commands
def list_commands(self, ctx): """ List CLI commands @type ctx: Context @rtype: list """ commands_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'commands') command_list = [name for __, name, ispkg in pkgutil.iter_modules([commands_path]) if ...
python
def list_commands(self, ctx): """ List CLI commands @type ctx: Context @rtype: list """ commands_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'commands') command_list = [name for __, name, ispkg in pkgutil.iter_modules([commands_path]) if ...
[ "def", "list_commands", "(", "self", ",", "ctx", ")", ":", "commands_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "__file__", ")", ")", ",", "'commands'", ")", "co...
List CLI commands @type ctx: Context @rtype: list
[ "List", "CLI", "commands" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/cli.py#L82-L91
FujiMakoto/IPS-Vagrant
ips_vagrant/cli.py
IpsvCLI.get_command
def get_command(self, ctx, name): """ Get a bound command method @type ctx: Context @param name: Command name @type name: str @rtype: object """ try: mod = importlib.import_module('ips_vagrant.commands.{name}'.format(name=name)) ...
python
def get_command(self, ctx, name): """ Get a bound command method @type ctx: Context @param name: Command name @type name: str @rtype: object """ try: mod = importlib.import_module('ips_vagrant.commands.{name}'.format(name=name)) ...
[ "def", "get_command", "(", "self", ",", "ctx", ",", "name", ")", ":", "try", ":", "mod", "=", "importlib", ".", "import_module", "(", "'ips_vagrant.commands.{name}'", ".", "format", "(", "name", "=", "name", ")", ")", "return", "mod", ".", "cli", "except...
Get a bound command method @type ctx: Context @param name: Command name @type name: str @rtype: object
[ "Get", "a", "bound", "command", "method" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/cli.py#L93-L105
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_custom_argv
def _custom_argv(argv): """Overwrite argv[1:] with argv, restore on exit.""" backup_argv = sys.argv sys.argv = backup_argv[:1] + argv try: yield finally: sys.argv = backup_argv
python
def _custom_argv(argv): """Overwrite argv[1:] with argv, restore on exit.""" backup_argv = sys.argv sys.argv = backup_argv[:1] + argv try: yield finally: sys.argv = backup_argv
[ "def", "_custom_argv", "(", "argv", ")", ":", "backup_argv", "=", "sys", ".", "argv", "sys", ".", "argv", "=", "backup_argv", "[", ":", "1", "]", "+", "argv", "try", ":", "yield", "finally", ":", "sys", ".", "argv", "=", "backup_argv" ]
Overwrite argv[1:] with argv, restore on exit.
[ "Overwrite", "argv", "[", "1", ":", "]", "with", "argv", "restore", "on", "exit", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L42-L49
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_patched_pep257
def _patched_pep257(): """Monkey-patch pep257 after imports to avoid info logging.""" import pep257 if getattr(pep257, "log", None): def _dummy(*args, **kwargs): del args del kwargs old_log_info = pep257.log.info pep257.log.info = _dummy # suppress(unused-a...
python
def _patched_pep257(): """Monkey-patch pep257 after imports to avoid info logging.""" import pep257 if getattr(pep257, "log", None): def _dummy(*args, **kwargs): del args del kwargs old_log_info = pep257.log.info pep257.log.info = _dummy # suppress(unused-a...
[ "def", "_patched_pep257", "(", ")", ":", "import", "pep257", "if", "getattr", "(", "pep257", ",", "\"log\"", ",", "None", ")", ":", "def", "_dummy", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "del", "args", "del", "kwargs", "old_log_info", ...
Monkey-patch pep257 after imports to avoid info logging.
[ "Monkey", "-", "patch", "pep257", "after", "imports", "to", "avoid", "info", "logging", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L53-L68
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_stamped_deps
def _stamped_deps(stamp_directory, func, dependencies, *args, **kwargs): """Run func, assumed to have dependencies as its first argument.""" if not isinstance(dependencies, list): jobstamps_dependencies = [dependencies] else: jobstamps_dependencies = dependencies kwargs.update({ ...
python
def _stamped_deps(stamp_directory, func, dependencies, *args, **kwargs): """Run func, assumed to have dependencies as its first argument.""" if not isinstance(dependencies, list): jobstamps_dependencies = [dependencies] else: jobstamps_dependencies = dependencies kwargs.update({ ...
[ "def", "_stamped_deps", "(", "stamp_directory", ",", "func", ",", "dependencies", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "dependencies", ",", "list", ")", ":", "jobstamps_dependencies", "=", "[", "dependencies", ...
Run func, assumed to have dependencies as its first argument.
[ "Run", "func", "assumed", "to", "have", "dependencies", "as", "its", "first", "argument", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L71-L82
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_debug_linter_status
def _debug_linter_status(linter, filename, show_lint_files): """Indicate that we are running this linter if required.""" if show_lint_files: print("{linter}: {filename}".format(linter=linter, filename=filename))
python
def _debug_linter_status(linter, filename, show_lint_files): """Indicate that we are running this linter if required.""" if show_lint_files: print("{linter}: {filename}".format(linter=linter, filename=filename))
[ "def", "_debug_linter_status", "(", "linter", ",", "filename", ",", "show_lint_files", ")", ":", "if", "show_lint_files", ":", "print", "(", "\"{linter}: {filename}\"", ".", "format", "(", "linter", "=", "linter", ",", "filename", "=", "filename", ")", ")" ]
Indicate that we are running this linter if required.
[ "Indicate", "that", "we", "are", "running", "this", "linter", "if", "required", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L99-L102
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_run_flake8_internal
def _run_flake8_internal(filename): """Run flake8.""" from flake8.engine import get_style_guide from pep8 import BaseReport from prospector.message import Message, Location return_dict = dict() cwd = os.getcwd() class Flake8MergeReporter(BaseReport): """An implementation of pep8.B...
python
def _run_flake8_internal(filename): """Run flake8.""" from flake8.engine import get_style_guide from pep8 import BaseReport from prospector.message import Message, Location return_dict = dict() cwd = os.getcwd() class Flake8MergeReporter(BaseReport): """An implementation of pep8.B...
[ "def", "_run_flake8_internal", "(", "filename", ")", ":", "from", "flake8", ".", "engine", "import", "get_style_guide", "from", "pep8", "import", "BaseReport", "from", "prospector", ".", "message", "import", "Message", ",", "Location", "return_dict", "=", "dict", ...
Run flake8.
[ "Run", "flake8", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L105-L158
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_run_flake8
def _run_flake8(filename, stamp_file_name, show_lint_files): """Run flake8, cached by stamp_file_name.""" _debug_linter_status("flake8", filename, show_lint_files) return _stamped_deps(stamp_file_name, _run_flake8_internal, filename)
python
def _run_flake8(filename, stamp_file_name, show_lint_files): """Run flake8, cached by stamp_file_name.""" _debug_linter_status("flake8", filename, show_lint_files) return _stamped_deps(stamp_file_name, _run_flake8_internal, filename)
[ "def", "_run_flake8", "(", "filename", ",", "stamp_file_name", ",", "show_lint_files", ")", ":", "_debug_linter_status", "(", "\"flake8\"", ",", "filename", ",", "show_lint_files", ")", "return", "_stamped_deps", "(", "stamp_file_name", ",", "_run_flake8_internal", ",...
Run flake8, cached by stamp_file_name.
[ "Run", "flake8", "cached", "by", "stamp_file_name", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L161-L166
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_run_prospector_on
def _run_prospector_on(filenames, tools, disabled_linters, show_lint_files, ignore_codes=None): """Run prospector on filename, using the specified tools. This function enables us to run different tools on different ...
python
def _run_prospector_on(filenames, tools, disabled_linters, show_lint_files, ignore_codes=None): """Run prospector on filename, using the specified tools. This function enables us to run different tools on different ...
[ "def", "_run_prospector_on", "(", "filenames", ",", "tools", ",", "disabled_linters", ",", "show_lint_files", ",", "ignore_codes", "=", "None", ")", ":", "from", "prospector", ".", "run", "import", "Prospector", ",", "ProspectorConfig", "assert", "tools", "tools",...
Run prospector on filename, using the specified tools. This function enables us to run different tools on different classes of files, which is necessary in the case of tests.
[ "Run", "prospector", "on", "filename", "using", "the", "specified", "tools", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L191-L235
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_run_prospector
def _run_prospector(filename, stamp_file_name, disabled_linters, show_lint_files): """Run prospector.""" linter_tools = [ "pep257", "pep8", "pyflakes" ] if can_run_pylint(): linter_tools.append("pylint") # ...
python
def _run_prospector(filename, stamp_file_name, disabled_linters, show_lint_files): """Run prospector.""" linter_tools = [ "pep257", "pep8", "pyflakes" ] if can_run_pylint(): linter_tools.append("pylint") # ...
[ "def", "_run_prospector", "(", "filename", ",", "stamp_file_name", ",", "disabled_linters", ",", "show_lint_files", ")", ":", "linter_tools", "=", "[", "\"pep257\"", ",", "\"pep8\"", ",", "\"pyflakes\"", "]", "if", "can_run_pylint", "(", ")", ":", "linter_tools", ...
Run prospector.
[ "Run", "prospector", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L244-L286
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_run_pyroma
def _run_pyroma(setup_file, show_lint_files): """Run pyroma.""" from pyroma import projectdata, ratings from prospector.message import Message, Location _debug_linter_status("pyroma", setup_file, show_lint_files) return_dict = dict() data = projectdata.get_data(os.getcwd()) all_tests = ra...
python
def _run_pyroma(setup_file, show_lint_files): """Run pyroma.""" from pyroma import projectdata, ratings from prospector.message import Message, Location _debug_linter_status("pyroma", setup_file, show_lint_files) return_dict = dict() data = projectdata.get_data(os.getcwd()) all_tests = ra...
[ "def", "_run_pyroma", "(", "setup_file", ",", "show_lint_files", ")", ":", "from", "pyroma", "import", "projectdata", ",", "ratings", "from", "prospector", ".", "message", "import", "Message", ",", "Location", "_debug_linter_status", "(", "\"pyroma\"", ",", "setup...
Run pyroma.
[ "Run", "pyroma", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L289-L311
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_run_polysquare_style_linter
def _run_polysquare_style_linter(matched_filenames, cache_dir, show_lint_files): """Run polysquare-generic-file-linter on matched_filenames.""" from polysquarelinter import linter as lint from prospector.message import Message, Location ...
python
def _run_polysquare_style_linter(matched_filenames, cache_dir, show_lint_files): """Run polysquare-generic-file-linter on matched_filenames.""" from polysquarelinter import linter as lint from prospector.message import Message, Location ...
[ "def", "_run_polysquare_style_linter", "(", "matched_filenames", ",", "cache_dir", ",", "show_lint_files", ")", ":", "from", "polysquarelinter", "import", "linter", "as", "lint", "from", "prospector", ".", "message", "import", "Message", ",", "Location", "return_dict"...
Run polysquare-generic-file-linter on matched_filenames.
[ "Run", "polysquare", "-", "generic", "-", "file", "-", "linter", "on", "matched_filenames", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L322-L355
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_run_spellcheck_linter
def _run_spellcheck_linter(matched_filenames, cache_dir, show_lint_files): """Run spellcheck-linter on matched_filenames.""" from polysquarelinter import lint_spelling_only as lint from prospector.message import Message, Location for filename in matched_filenames: _debug_linter_status("spellche...
python
def _run_spellcheck_linter(matched_filenames, cache_dir, show_lint_files): """Run spellcheck-linter on matched_filenames.""" from polysquarelinter import lint_spelling_only as lint from prospector.message import Message, Location for filename in matched_filenames: _debug_linter_status("spellche...
[ "def", "_run_spellcheck_linter", "(", "matched_filenames", ",", "cache_dir", ",", "show_lint_files", ")", ":", "from", "polysquarelinter", "import", "lint_spelling_only", "as", "lint", "from", "prospector", ".", "message", "import", "Message", ",", "Location", "for", ...
Run spellcheck-linter on matched_filenames.
[ "Run", "spellcheck", "-", "linter", "on", "matched_filenames", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L358-L389
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_run_markdownlint
def _run_markdownlint(matched_filenames, show_lint_files): """Run markdownlint on matched_filenames.""" from prospector.message import Message, Location for filename in matched_filenames: _debug_linter_status("mdl", filename, show_lint_files) try: proc = subprocess.Popen(["mdl"] + matc...
python
def _run_markdownlint(matched_filenames, show_lint_files): """Run markdownlint on matched_filenames.""" from prospector.message import Message, Location for filename in matched_filenames: _debug_linter_status("mdl", filename, show_lint_files) try: proc = subprocess.Popen(["mdl"] + matc...
[ "def", "_run_markdownlint", "(", "matched_filenames", ",", "show_lint_files", ")", ":", "from", "prospector", ".", "message", "import", "Message", ",", "Location", "for", "filename", "in", "matched_filenames", ":", "_debug_linter_status", "(", "\"mdl\"", ",", "filen...
Run markdownlint on matched_filenames.
[ "Run", "markdownlint", "on", "matched_filenames", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L392-L418
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_get_cache_dir
def _get_cache_dir(candidate): """Get the current cache directory.""" if candidate: return candidate import distutils.dist # suppress(import-error) import distutils.command.build # suppress(import-error) build_cmd = distutils.command.build.build(distutils.dist.Distribution()) build_cm...
python
def _get_cache_dir(candidate): """Get the current cache directory.""" if candidate: return candidate import distutils.dist # suppress(import-error) import distutils.command.build # suppress(import-error) build_cmd = distutils.command.build.build(distutils.dist.Distribution()) build_cm...
[ "def", "_get_cache_dir", "(", "candidate", ")", ":", "if", "candidate", ":", "return", "candidate", "import", "distutils", ".", "dist", "# suppress(import-error)", "import", "distutils", ".", "command", ".", "build", "# suppress(import-error)", "build_cmd", "=", "di...
Get the current cache directory.
[ "Get", "the", "current", "cache", "directory", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L426-L444
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_all_files_matching_ext
def _all_files_matching_ext(start, ext): """Get all files matching :ext: from :start: directory.""" md_files = [] for root, _, files in os.walk(start): md_files += fnfilter([os.path.join(root, f) for f in files], "*." + ext) return md_files
python
def _all_files_matching_ext(start, ext): """Get all files matching :ext: from :start: directory.""" md_files = [] for root, _, files in os.walk(start): md_files += fnfilter([os.path.join(root, f) for f in files], "*." + ext) return md_files
[ "def", "_all_files_matching_ext", "(", "start", ",", "ext", ")", ":", "md_files", "=", "[", "]", "for", "root", ",", "_", ",", "files", "in", "os", ".", "walk", "(", "start", ")", ":", "md_files", "+=", "fnfilter", "(", "[", "os", ".", "path", ".",...
Get all files matching :ext: from :start: directory.
[ "Get", "all", "files", "matching", ":", "ext", ":", "from", ":", "start", ":", "directory", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L447-L454
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
_is_excluded
def _is_excluded(filename, exclusions): """Return true if filename matches any of exclusions.""" for exclusion in exclusions: if fnmatch(filename, exclusion): return True return False
python
def _is_excluded(filename, exclusions): """Return true if filename matches any of exclusions.""" for exclusion in exclusions: if fnmatch(filename, exclusion): return True return False
[ "def", "_is_excluded", "(", "filename", ",", "exclusions", ")", ":", "for", "exclusion", "in", "exclusions", ":", "if", "fnmatch", "(", "filename", ",", "exclusion", ")", ":", "return", "True", "return", "False" ]
Return true if filename matches any of exclusions.
[ "Return", "true", "if", "filename", "matches", "any", "of", "exclusions", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L457-L463
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
PolysquareLintCommand._file_lines
def _file_lines(self, filename): """Get lines for filename, caching opened files.""" try: return self._file_lines_cache[filename] except KeyError: if os.path.isfile(filename): with open(filename) as python_file: self._file_lines_cache[f...
python
def _file_lines(self, filename): """Get lines for filename, caching opened files.""" try: return self._file_lines_cache[filename] except KeyError: if os.path.isfile(filename): with open(filename) as python_file: self._file_lines_cache[f...
[ "def", "_file_lines", "(", "self", ",", "filename", ")", ":", "try", ":", "return", "self", ".", "_file_lines_cache", "[", "filename", "]", "except", "KeyError", ":", "if", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "with", "open", "(...
Get lines for filename, caching opened files.
[ "Get", "lines", "for", "filename", "caching", "opened", "files", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L479-L490
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
PolysquareLintCommand._suppressed
def _suppressed(self, filename, line, code): """Return true if linter error code is suppressed inline. The suppression format is suppress(CODE1,CODE2,CODE3) etc. """ if code in self.suppress_codes: return True lines = self._file_lines(filename) # File is ze...
python
def _suppressed(self, filename, line, code): """Return true if linter error code is suppressed inline. The suppression format is suppress(CODE1,CODE2,CODE3) etc. """ if code in self.suppress_codes: return True lines = self._file_lines(filename) # File is ze...
[ "def", "_suppressed", "(", "self", ",", "filename", ",", "line", ",", "code", ")", ":", "if", "code", "in", "self", ".", "suppress_codes", ":", "return", "True", "lines", "=", "self", ".", "_file_lines", "(", "filename", ")", "# File is zero length, cannot b...
Return true if linter error code is suppressed inline. The suppression format is suppress(CODE1,CODE2,CODE3) etc.
[ "Return", "true", "if", "linter", "error", "code", "is", "suppressed", "inline", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L492-L522
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
PolysquareLintCommand._get_md_files
def _get_md_files(self): """Get all markdown files.""" all_f = _all_files_matching_ext(os.getcwd(), "md") exclusions = [ "*.egg/*", "*.eggs/*", "*build/*" ] + self.exclusions return sorted([f for f in all_f if not _is_excluded(f, exclusions)])
python
def _get_md_files(self): """Get all markdown files.""" all_f = _all_files_matching_ext(os.getcwd(), "md") exclusions = [ "*.egg/*", "*.eggs/*", "*build/*" ] + self.exclusions return sorted([f for f in all_f if not _is_excluded(f, exclusions)])
[ "def", "_get_md_files", "(", "self", ")", ":", "all_f", "=", "_all_files_matching_ext", "(", "os", ".", "getcwd", "(", ")", ",", "\"md\"", ")", "exclusions", "=", "[", "\"*.egg/*\"", ",", "\"*.eggs/*\"", ",", "\"*build/*\"", "]", "+", "self", ".", "exclusi...
Get all markdown files.
[ "Get", "all", "markdown", "files", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L524-L532
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
PolysquareLintCommand._get_files_to_lint
def _get_files_to_lint(self, external_directories): """Get files to lint.""" all_f = [] for external_dir in external_directories: all_f.extend(_all_files_matching_ext(external_dir, "py")) packages = self.distribution.packages or list() for package in packages: ...
python
def _get_files_to_lint(self, external_directories): """Get files to lint.""" all_f = [] for external_dir in external_directories: all_f.extend(_all_files_matching_ext(external_dir, "py")) packages = self.distribution.packages or list() for package in packages: ...
[ "def", "_get_files_to_lint", "(", "self", ",", "external_directories", ")", ":", "all_f", "=", "[", "]", "for", "external_dir", "in", "external_directories", ":", "all_f", ".", "extend", "(", "_all_files_matching_ext", "(", "external_dir", ",", "\"py\"", ")", ")...
Get files to lint.
[ "Get", "files", "to", "lint", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L534-L559
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
PolysquareLintCommand._map_over_linters
def _map_over_linters(self, py_files, non_test_files, md_files, stamp_directory, mapper): """Run mapper over passed in files, returning a list of results.""" dispatch = [ ...
python
def _map_over_linters(self, py_files, non_test_files, md_files, stamp_directory, mapper): """Run mapper over passed in files, returning a list of results.""" dispatch = [ ...
[ "def", "_map_over_linters", "(", "self", ",", "py_files", ",", "non_test_files", ",", "md_files", ",", "stamp_directory", ",", "mapper", ")", ":", "dispatch", "=", "[", "(", "\"flake8\"", ",", "lambda", ":", "mapper", "(", "_run_flake8", ",", "py_files", ","...
Run mapper over passed in files, returning a list of results.
[ "Run", "mapper", "over", "passed", "in", "files", "returning", "a", "list", "of", "results", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L562-L621
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
PolysquareLintCommand.run
def run(self): # suppress(unused-function) """Run linters.""" import parmap from prospector.formatters.pylint import PylintFormatter cwd = os.getcwd() files = self._get_files_to_lint([os.path.join(cwd, "test")]) if not files: sys_exit(0) return ...
python
def run(self): # suppress(unused-function) """Run linters.""" import parmap from prospector.formatters.pylint import PylintFormatter cwd = os.getcwd() files = self._get_files_to_lint([os.path.join(cwd, "test")]) if not files: sys_exit(0) return ...
[ "def", "run", "(", "self", ")", ":", "# suppress(unused-function)", "import", "parmap", "from", "prospector", ".", "formatters", ".", "pylint", "import", "PylintFormatter", "cwd", "=", "os", ".", "getcwd", "(", ")", "files", "=", "self", ".", "_get_files_to_li...
Run linters.
[ "Run", "linters", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L623-L685
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
PolysquareLintCommand.initialize_options
def initialize_options(self): # suppress(unused-function) """Set all options to their initial values.""" self._file_lines_cache = dict() self.suppress_codes = list() self.exclusions = list() self.cache_directory = "" self.stamp_directory = "" self.disable_linters...
python
def initialize_options(self): # suppress(unused-function) """Set all options to their initial values.""" self._file_lines_cache = dict() self.suppress_codes = list() self.exclusions = list() self.cache_directory = "" self.stamp_directory = "" self.disable_linters...
[ "def", "initialize_options", "(", "self", ")", ":", "# suppress(unused-function)", "self", ".", "_file_lines_cache", "=", "dict", "(", ")", "self", ".", "suppress_codes", "=", "list", "(", ")", "self", ".", "exclusions", "=", "list", "(", ")", "self", ".", ...
Set all options to their initial values.
[ "Set", "all", "options", "to", "their", "initial", "values", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L687-L695
polysquare/polysquare-setuptools-lint
polysquare_setuptools_lint/__init__.py
PolysquareLintCommand.finalize_options
def finalize_options(self): # suppress(unused-function) """Finalize all options.""" for option in ["suppress-codes", "exclusions", "disable-linters"]: attribute = option.replace("-", "_") if isinstance(getattr(self, attribute), str): setattr(self, attribute, geta...
python
def finalize_options(self): # suppress(unused-function) """Finalize all options.""" for option in ["suppress-codes", "exclusions", "disable-linters"]: attribute = option.replace("-", "_") if isinstance(getattr(self, attribute), str): setattr(self, attribute, geta...
[ "def", "finalize_options", "(", "self", ")", ":", "# suppress(unused-function)", "for", "option", "in", "[", "\"suppress-codes\"", ",", "\"exclusions\"", ",", "\"disable-linters\"", "]", ":", "attribute", "=", "option", ".", "replace", "(", "\"-\"", ",", "\"_\"", ...
Finalize all options.
[ "Finalize", "all", "options", "." ]
train
https://github.com/polysquare/polysquare-setuptools-lint/blob/5df5a6401c7ad6a90b42230eeb99c82cc56952b6/polysquare_setuptools_lint/__init__.py#L697-L723
zbanks/shmooze
shmooze/lib/database.py
Database.create_top_schema
def create_top_schema(self): """ (Category --->) Item <---> Module <---> LogEntry <---> is a many-to-many relationship ---> is a foreign key relationship (- Category: represents a group of Items which form a top list) - Item: something that can be played multiple time...
python
def create_top_schema(self): """ (Category --->) Item <---> Module <---> LogEntry <---> is a many-to-many relationship ---> is a foreign key relationship (- Category: represents a group of Items which form a top list) - Item: something that can be played multiple time...
[ "def", "create_top_schema", "(", "self", ")", ":", "self", ".", "execute", "(", "\"\"\"CREATE TABLE IF NOT EXISTS top_module (\n uuid TEXT,\n add_timestamp DATETIME\n );\"\"\"", ")", "self", ".", "execute", "(", "\"\"\"CREATE TABLE IF NOT EXISTS top_categ...
(Category --->) Item <---> Module <---> LogEntry <---> is a many-to-many relationship ---> is a foreign key relationship (- Category: represents a group of Items which form a top list) - Item: something that can be played multiple times and is grouped by to build a top list ...
[ "(", "Category", "---", ">", ")", "Item", "<", "---", ">", "Module", "<", "---", ">", "LogEntry" ]
train
https://github.com/zbanks/shmooze/blob/7ae615e172c174d6fe184a8bf90f8ad075bf58ed/shmooze/lib/database.py#L72-L120
tsileo/globster
globster.py
normalize_pattern
def normalize_pattern(pattern): """Converts backslashes in path patterns to forward slashes. Doesn't normalize regular expressions - they may contain escapes. """ if not (pattern.startswith('RE:') or pattern.startswith('!RE:')): pattern = _slashes.sub('/', pattern) if len(pattern) > 1: ...
python
def normalize_pattern(pattern): """Converts backslashes in path patterns to forward slashes. Doesn't normalize regular expressions - they may contain escapes. """ if not (pattern.startswith('RE:') or pattern.startswith('!RE:')): pattern = _slashes.sub('/', pattern) if len(pattern) > 1: ...
[ "def", "normalize_pattern", "(", "pattern", ")", ":", "if", "not", "(", "pattern", ".", "startswith", "(", "'RE:'", ")", "or", "pattern", ".", "startswith", "(", "'!RE:'", ")", ")", ":", "pattern", "=", "_slashes", ".", "sub", "(", "'/'", ",", "pattern...
Converts backslashes in path patterns to forward slashes. Doesn't normalize regular expressions - they may contain escapes.
[ "Converts", "backslashes", "in", "path", "patterns", "to", "forward", "slashes", "." ]
train
https://github.com/tsileo/globster/blob/9628bce60207b150d39b409cddc3fadb34e70841/globster.py#L366-L375
tsileo/globster
globster.py
Replacer.add
def add(self, pat, fun): r"""Add a pattern and replacement. The pattern must not contain capturing groups. The replacement might be either a string template in which \& will be replaced with the match, or a function that will get the matching text as argument. It does not get ma...
python
def add(self, pat, fun): r"""Add a pattern and replacement. The pattern must not contain capturing groups. The replacement might be either a string template in which \& will be replaced with the match, or a function that will get the matching text as argument. It does not get ma...
[ "def", "add", "(", "self", ",", "pat", ",", "fun", ")", ":", "self", ".", "_pat", "=", "None", "self", ".", "_pats", ".", "append", "(", "pat", ")", "self", ".", "_funs", ".", "append", "(", "fun", ")" ]
r"""Add a pattern and replacement. The pattern must not contain capturing groups. The replacement might be either a string template in which \& will be replaced with the match, or a function that will get the matching text as argument. It does not get match object, because capturing is ...
[ "r", "Add", "a", "pattern", "and", "replacement", "." ]
train
https://github.com/tsileo/globster/blob/9628bce60207b150d39b409cddc3fadb34e70841/globster.py#L60-L71
tsileo/globster
globster.py
Replacer.add_replacer
def add_replacer(self, replacer): r"""Add all patterns from another replacer. All patterns and replacements from replacer are appended to the ones already defined. """ self._pat = None self._pats.extend(replacer._pats) self._funs.extend(replacer._funs)
python
def add_replacer(self, replacer): r"""Add all patterns from another replacer. All patterns and replacements from replacer are appended to the ones already defined. """ self._pat = None self._pats.extend(replacer._pats) self._funs.extend(replacer._funs)
[ "def", "add_replacer", "(", "self", ",", "replacer", ")", ":", "self", ".", "_pat", "=", "None", "self", ".", "_pats", ".", "extend", "(", "replacer", ".", "_pats", ")", "self", ".", "_funs", ".", "extend", "(", "replacer", ".", "_funs", ")" ]
r"""Add all patterns from another replacer. All patterns and replacements from replacer are appended to the ones already defined.
[ "r", "Add", "all", "patterns", "from", "another", "replacer", "." ]
train
https://github.com/tsileo/globster/blob/9628bce60207b150d39b409cddc3fadb34e70841/globster.py#L73-L81
tsileo/globster
globster.py
Globster.match
def match(self, filename): """Searches for a pattern that matches the given filename. :return A matching pattern or None if there is no matching pattern. """ try: for regex, patterns in self._regex_patterns: match = regex.match(filename) deb...
python
def match(self, filename): """Searches for a pattern that matches the given filename. :return A matching pattern or None if there is no matching pattern. """ try: for regex, patterns in self._regex_patterns: match = regex.match(filename) deb...
[ "def", "match", "(", "self", ",", "filename", ")", ":", "try", ":", "for", "regex", ",", "patterns", "in", "self", ".", "_regex_patterns", ":", "match", "=", "regex", ".", "match", "(", "filename", ")", "debug_template", "=", "\"%s against %s: %%s\"", "%",...
Searches for a pattern that matches the given filename. :return A matching pattern or None if there is no matching pattern.
[ "Searches", "for", "a", "pattern", "that", "matches", "the", "given", "filename", "." ]
train
https://github.com/tsileo/globster/blob/9628bce60207b150d39b409cddc3fadb34e70841/globster.py#L239-L274
tsileo/globster
globster.py
Globster.is_pattern_valid
def is_pattern_valid(pattern): """Returns True if pattern is valid. :param pattern: Normalized pattern. is_pattern_valid() assumes pattern to be normalized. see: globbing.normalize_pattern """ result = True translator = Globster.pattern_info[Globster.identify(pat...
python
def is_pattern_valid(pattern): """Returns True if pattern is valid. :param pattern: Normalized pattern. is_pattern_valid() assumes pattern to be normalized. see: globbing.normalize_pattern """ result = True translator = Globster.pattern_info[Globster.identify(pat...
[ "def", "is_pattern_valid", "(", "pattern", ")", ":", "result", "=", "True", "translator", "=", "Globster", ".", "pattern_info", "[", "Globster", ".", "identify", "(", "pattern", ")", "]", "[", "\"translator\"", "]", "tpattern", "=", "'(%s)'", "%", "translato...
Returns True if pattern is valid. :param pattern: Normalized pattern. is_pattern_valid() assumes pattern to be normalized. see: globbing.normalize_pattern
[ "Returns", "True", "if", "pattern", "is", "valid", "." ]
train
https://github.com/tsileo/globster/blob/9628bce60207b150d39b409cddc3fadb34e70841/globster.py#L292-L307
tsileo/globster
globster.py
ExceptionGlobster.match
def match(self, filename): """Searches for a pattern that matches the given filename. :return A matching pattern or None if there is no matching pattern. """ double_neg = self._ignores[2].match(filename) if double_neg: return "!!%s" % double_neg ...
python
def match(self, filename): """Searches for a pattern that matches the given filename. :return A matching pattern or None if there is no matching pattern. """ double_neg = self._ignores[2].match(filename) if double_neg: return "!!%s" % double_neg ...
[ "def", "match", "(", "self", ",", "filename", ")", ":", "double_neg", "=", "self", ".", "_ignores", "[", "2", "]", ".", "match", "(", "filename", ")", "if", "double_neg", ":", "return", "\"!!%s\"", "%", "double_neg", "elif", "self", ".", "_ignores", "[...
Searches for a pattern that matches the given filename. :return A matching pattern or None if there is no matching pattern.
[ "Searches", "for", "a", "pattern", "that", "matches", "the", "given", "filename", "." ]
train
https://github.com/tsileo/globster/blob/9628bce60207b150d39b409cddc3fadb34e70841/globster.py#L332-L346
cbrand/vpnchooser
src/vpnchooser/resources/device.py
DeviceResource.put
def put(self, device_id: int) -> Device: """ Updates the Device Resource with the name. """ device = self._get_or_abort(device_id) self.update(device) session.commit() session.add(device) return device
python
def put(self, device_id: int) -> Device: """ Updates the Device Resource with the name. """ device = self._get_or_abort(device_id) self.update(device) session.commit() session.add(device) return device
[ "def", "put", "(", "self", ",", "device_id", ":", "int", ")", "->", "Device", ":", "device", "=", "self", ".", "_get_or_abort", "(", "device_id", ")", "self", ".", "update", "(", "device", ")", "session", ".", "commit", "(", ")", "session", ".", "add...
Updates the Device Resource with the name.
[ "Updates", "the", "Device", "Resource", "with", "the", "name", "." ]
train
https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/resources/device.py#L114-L123
cbrand/vpnchooser
src/vpnchooser/resources/device.py
DeviceResource.delete
def delete(self, device_id: int): """ Deletes the resource with the given name. """ device = self._get_or_abort(device_id) session.delete(device) session.commit() return '', 204
python
def delete(self, device_id: int): """ Deletes the resource with the given name. """ device = self._get_or_abort(device_id) session.delete(device) session.commit() return '', 204
[ "def", "delete", "(", "self", ",", "device_id", ":", "int", ")", ":", "device", "=", "self", ".", "_get_or_abort", "(", "device_id", ")", "session", ".", "delete", "(", "device", ")", "session", ".", "commit", "(", ")", "return", "''", ",", "204" ]
Deletes the resource with the given name.
[ "Deletes", "the", "resource", "with", "the", "given", "name", "." ]
train
https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/resources/device.py#L126-L133
bogdan-kulynych/defaultcontext
defaultcontext/wrappers.py
optional_arg_class_decorator
def optional_arg_class_decorator(fn): """ Based on: https://stackoverflow.com/questions/3888158/python-making-decorators-with-optional-arguments """ @functools.wraps(fn) def wrapped_decorator(*args, **kwargs): if len(args) == 1 and isinstance(args[0], type) and not kwargs: re...
python
def optional_arg_class_decorator(fn): """ Based on: https://stackoverflow.com/questions/3888158/python-making-decorators-with-optional-arguments """ @functools.wraps(fn) def wrapped_decorator(*args, **kwargs): if len(args) == 1 and isinstance(args[0], type) and not kwargs: re...
[ "def", "optional_arg_class_decorator", "(", "fn", ")", ":", "@", "functools", ".", "wraps", "(", "fn", ")", "def", "wrapped_decorator", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", "==", "1", "and", "isinstance", ...
Based on: https://stackoverflow.com/questions/3888158/python-making-decorators-with-optional-arguments
[ "Based", "on", ":", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "3888158", "/", "python", "-", "making", "-", "decorators", "-", "with", "-", "optional", "-", "arguments" ]
train
https://github.com/bogdan-kulynych/defaultcontext/blob/ec9bb96552dfb3d42a1103da1772b024414dd801/defaultcontext/wrappers.py#L46-L59
bogdan-kulynych/defaultcontext
defaultcontext/wrappers.py
with_default_context
def with_default_context(cls, use_empty_init=False, global_default_factory=None): """ :param use_empty_init: If set to True, object constructed without arguments will be a global default object of the class. :param global_default_factory: Function that constructs a global ...
python
def with_default_context(cls, use_empty_init=False, global_default_factory=None): """ :param use_empty_init: If set to True, object constructed without arguments will be a global default object of the class. :param global_default_factory: Function that constructs a global ...
[ "def", "with_default_context", "(", "cls", ",", "use_empty_init", "=", "False", ",", "global_default_factory", "=", "None", ")", ":", "if", "use_empty_init", ":", "if", "global_default_factory", "is", "not", "None", ":", "warnings", ".", "warn", "(", "\"Either f...
:param use_empty_init: If set to True, object constructed without arguments will be a global default object of the class. :param global_default_factory: Function that constructs a global default object of the class. N.B. Either `use_empty_init` should be set to True, or the `global_...
[ ":", "param", "use_empty_init", ":", "If", "set", "to", "True", "object", "constructed", "without", "arguments", "will", "be", "a", "global", "default", "object", "of", "the", "class", ".", ":", "param", "global_default_factory", ":", "Function", "that", "cons...
train
https://github.com/bogdan-kulynych/defaultcontext/blob/ec9bb96552dfb3d42a1103da1772b024414dd801/defaultcontext/wrappers.py#L63-L85
idlesign/django-xross
xross/utils.py
xross_listener
def xross_listener(http_method=None, **xross_attrs): """Instructs xross to handle AJAX calls right from the moment it is called. This should be placed in a view decorated with `@xross_view()`. :param str http_method: GET or POST. To be used as a source of data for xross. :param dict xross_attrs: xros...
python
def xross_listener(http_method=None, **xross_attrs): """Instructs xross to handle AJAX calls right from the moment it is called. This should be placed in a view decorated with `@xross_view()`. :param str http_method: GET or POST. To be used as a source of data for xross. :param dict xross_attrs: xros...
[ "def", "xross_listener", "(", "http_method", "=", "None", ",", "*", "*", "xross_attrs", ")", ":", "handler", "=", "currentframe", "(", ")", ".", "f_back", ".", "f_locals", "[", "'request'", "]", ".", "_xross_handler", "handler", ".", "set_attrs", "(", "*",...
Instructs xross to handle AJAX calls right from the moment it is called. This should be placed in a view decorated with `@xross_view()`. :param str http_method: GET or POST. To be used as a source of data for xross. :param dict xross_attrs: xross handler attributes. Those attributes will be avail...
[ "Instructs", "xross", "to", "handle", "AJAX", "calls", "right", "from", "the", "moment", "it", "is", "called", "." ]
train
https://github.com/idlesign/django-xross/blob/414edbab2069c4ba77773d0ef3c8fc830b336efa/xross/utils.py#L30-L45
idlesign/django-xross
xross/utils.py
xross_view
def xross_view(*op_functions): """This decorator should be used to decorate application views that require xross functionality. :param list op_functions: operations (functions, methods) responsible for handling xross requests. Function names considered to be operations names. Using them clients will a...
python
def xross_view(*op_functions): """This decorator should be used to decorate application views that require xross functionality. :param list op_functions: operations (functions, methods) responsible for handling xross requests. Function names considered to be operations names. Using them clients will a...
[ "def", "xross_view", "(", "*", "op_functions", ")", ":", "operations_dict", "=", "construct_operations_dict", "(", "*", "op_functions", ")", "def", "get_request", "(", "src", ")", ":", "return", "src", "if", "isinstance", "(", "src", ",", "HttpRequest", ")", ...
This decorator should be used to decorate application views that require xross functionality. :param list op_functions: operations (functions, methods) responsible for handling xross requests. Function names considered to be operations names. Using them clients will address those functions (e.g. x...
[ "This", "decorator", "should", "be", "used", "to", "decorate", "application", "views", "that", "require", "xross", "functionality", "." ]
train
https://github.com/idlesign/django-xross/blob/414edbab2069c4ba77773d0ef3c8fc830b336efa/xross/utils.py#L48-L123
ikanor/intercept
intercept/intercept.py
intercept
def intercept(actions: dict={}): """ Decorates a function and handles any exceptions that may rise. Args: actions: A dictionary ``<exception type>: <action>``. Available actions\ are :class:`raises` and :class:`returns`. Returns: Any value declared using a :class:`returns` ...
python
def intercept(actions: dict={}): """ Decorates a function and handles any exceptions that may rise. Args: actions: A dictionary ``<exception type>: <action>``. Available actions\ are :class:`raises` and :class:`returns`. Returns: Any value declared using a :class:`returns` ...
[ "def", "intercept", "(", "actions", ":", "dict", "=", "{", "}", ")", ":", "for", "action", "in", "actions", ".", "values", "(", ")", ":", "if", "type", "(", "action", ")", "is", "not", "returns", "and", "type", "(", "action", ")", "is", "not", "r...
Decorates a function and handles any exceptions that may rise. Args: actions: A dictionary ``<exception type>: <action>``. Available actions\ are :class:`raises` and :class:`returns`. Returns: Any value declared using a :class:`returns` action. Raises: AnyException: if...
[ "Decorates", "a", "function", "and", "handles", "any", "exceptions", "that", "may", "rise", "." ]
train
https://github.com/ikanor/intercept/blob/7aea4eed4f0942f2f781c560d4fdafd10fbbcc2d/intercept/intercept.py#L7-L102
jirutka/sublimedsl
sublimedsl/keymap.py
Keymap.dump
def dump(self, fp=sys.stdout, **kwargs): """ Serialize this keymap as a JSON formatted stream to the *fp*. Arguments: fp: A ``.write()``-supporting file-like object to write the generated JSON to (default is ``sys.stdout``). **kwargs: Options to be passed into :f...
python
def dump(self, fp=sys.stdout, **kwargs): """ Serialize this keymap as a JSON formatted stream to the *fp*. Arguments: fp: A ``.write()``-supporting file-like object to write the generated JSON to (default is ``sys.stdout``). **kwargs: Options to be passed into :f...
[ "def", "dump", "(", "self", ",", "fp", "=", "sys", ".", "stdout", ",", "*", "*", "kwargs", ")", ":", "fp", ".", "write", "(", "FILE_HEADER", ")", "fp", ".", "write", "(", "self", ".", "to_json", "(", "*", "*", "kwargs", ")", ")", "fp", ".", "...
Serialize this keymap as a JSON formatted stream to the *fp*. Arguments: fp: A ``.write()``-supporting file-like object to write the generated JSON to (default is ``sys.stdout``). **kwargs: Options to be passed into :func:`json.dumps`.
[ "Serialize", "this", "keymap", "as", "a", "JSON", "formatted", "stream", "to", "the", "*", "fp", "*", "." ]
train
https://github.com/jirutka/sublimedsl/blob/ca9fc79ab06e6efd79a6d5b37cb716688d4affc2/sublimedsl/keymap.py#L96-L106
jirutka/sublimedsl
sublimedsl/keymap.py
Keymap.extend
def extend(self, *bindings): """ Append the given bindings to this keymap. Arguments: *bindings (Binding): Bindings to be added. Returns: Keymap: self """ self._bindings.extend(self._preprocess(bindings)) return self
python
def extend(self, *bindings): """ Append the given bindings to this keymap. Arguments: *bindings (Binding): Bindings to be added. Returns: Keymap: self """ self._bindings.extend(self._preprocess(bindings)) return self
[ "def", "extend", "(", "self", ",", "*", "bindings", ")", ":", "self", ".", "_bindings", ".", "extend", "(", "self", ".", "_preprocess", "(", "bindings", ")", ")", "return", "self" ]
Append the given bindings to this keymap. Arguments: *bindings (Binding): Bindings to be added. Returns: Keymap: self
[ "Append", "the", "given", "bindings", "to", "this", "keymap", "." ]
train
https://github.com/jirutka/sublimedsl/blob/ca9fc79ab06e6efd79a6d5b37cb716688d4affc2/sublimedsl/keymap.py#L108-L117
jirutka/sublimedsl
sublimedsl/keymap.py
Binding.to
def to(self, command, **args): """ Bind the keys to the specified *command* with some *args*. Arguments: command (str): Name of the ST command (e.g. ``insert_snippet``). **args: Arguments for the command. Returns: Binding: self """ self.comman...
python
def to(self, command, **args): """ Bind the keys to the specified *command* with some *args*. Arguments: command (str): Name of the ST command (e.g. ``insert_snippet``). **args: Arguments for the command. Returns: Binding: self """ self.comman...
[ "def", "to", "(", "self", ",", "command", ",", "*", "*", "args", ")", ":", "self", ".", "command", "=", "command", "self", ".", "args", "=", "args", "return", "self" ]
Bind the keys to the specified *command* with some *args*. Arguments: command (str): Name of the ST command (e.g. ``insert_snippet``). **args: Arguments for the command. Returns: Binding: self
[ "Bind", "the", "keys", "to", "the", "specified", "*", "command", "*", "with", "some", "*", "args", "*", "." ]
train
https://github.com/jirutka/sublimedsl/blob/ca9fc79ab06e6efd79a6d5b37cb716688d4affc2/sublimedsl/keymap.py#L171-L182
jirutka/sublimedsl
sublimedsl/keymap.py
Binding.when
def when(self, key): """ Specify context, i.e. condition that must be met. Arguments: key (str): Name of the context whose value you want to query. Returns: Context: """ ctx = Context(key, self) self.context.append(ctx) return ctx
python
def when(self, key): """ Specify context, i.e. condition that must be met. Arguments: key (str): Name of the context whose value you want to query. Returns: Context: """ ctx = Context(key, self) self.context.append(ctx) return ctx
[ "def", "when", "(", "self", ",", "key", ")", ":", "ctx", "=", "Context", "(", "key", ",", "self", ")", "self", ".", "context", ".", "append", "(", "ctx", ")", "return", "ctx" ]
Specify context, i.e. condition that must be met. Arguments: key (str): Name of the context whose value you want to query. Returns: Context:
[ "Specify", "context", "i", ".", "e", ".", "condition", "that", "must", "be", "met", "." ]
train
https://github.com/jirutka/sublimedsl/blob/ca9fc79ab06e6efd79a6d5b37cb716688d4affc2/sublimedsl/keymap.py#L184-L194
FujiMakoto/IPS-Vagrant
ips_vagrant/commands/list/__init__.py
cli
def cli(ctx, dname, site): """ List all domains if no <domain> is provided. If <domain> is provided but <site> is not, lists all sites hosted under <domain>. If both <domain> and <site> are provided, lists information on the specified site. """ assert isinstance(ctx, Context) if dname: ...
python
def cli(ctx, dname, site): """ List all domains if no <domain> is provided. If <domain> is provided but <site> is not, lists all sites hosted under <domain>. If both <domain> and <site> are provided, lists information on the specified site. """ assert isinstance(ctx, Context) if dname: ...
[ "def", "cli", "(", "ctx", ",", "dname", ",", "site", ")", ":", "assert", "isinstance", "(", "ctx", ",", "Context", ")", "if", "dname", ":", "dname", "=", "domain_parse", "(", "dname", ")", ".", "hostname", "domain", "=", "Session", ".", "query", "(",...
List all domains if no <domain> is provided. If <domain> is provided but <site> is not, lists all sites hosted under <domain>. If both <domain> and <site> are provided, lists information on the specified site.
[ "List", "all", "domains", "if", "no", "<domain", ">", "is", "provided", ".", "If", "<domain", ">", "is", "provided", "but", "<site", ">", "is", "not", "lists", "all", "sites", "hosted", "under", "<domain", ">", ".", "If", "both", "<domain", ">", "and",...
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/commands/list/__init__.py#L12-L73
wlwang41/cb
cb/commands.py
Command._split_source_page
def _split_source_page(self, path): """Split the source file texts by triple-dashed lines. shit code """ with codecs.open(path, "rb", "utf-8") as fd: textlist = fd.readlines() metadata_notation = "---\n" if textlist[0] != metadata_notation: loggi...
python
def _split_source_page(self, path): """Split the source file texts by triple-dashed lines. shit code """ with codecs.open(path, "rb", "utf-8") as fd: textlist = fd.readlines() metadata_notation = "---\n" if textlist[0] != metadata_notation: loggi...
[ "def", "_split_source_page", "(", "self", ",", "path", ")", ":", "with", "codecs", ".", "open", "(", "path", ",", "\"rb\"", ",", "\"utf-8\"", ")", "as", "fd", ":", "textlist", "=", "fd", ".", "readlines", "(", ")", "metadata_notation", "=", "\"---\\n\"",...
Split the source file texts by triple-dashed lines. shit code
[ "Split", "the", "source", "file", "texts", "by", "triple", "-", "dashed", "lines", "." ]
train
https://github.com/wlwang41/cb/blob/0a7faa427e3e6593980687dfe1a882ac99d743f6/cb/commands.py#L89-L121
wlwang41/cb
cb/commands.py
Command._get_feed_data
def _get_feed_data(self, file_paths): """ get data to display in feed file """ rv = {} for i in file_paths: # TODO(crow): only support first category _ = i.split('/') category = _[-2] name = _[-1].split('.')[0] page_config, md =...
python
def _get_feed_data(self, file_paths): """ get data to display in feed file """ rv = {} for i in file_paths: # TODO(crow): only support first category _ = i.split('/') category = _[-2] name = _[-1].split('.')[0] page_config, md =...
[ "def", "_get_feed_data", "(", "self", ",", "file_paths", ")", ":", "rv", "=", "{", "}", "for", "i", "in", "file_paths", ":", "# TODO(crow): only support first category", "_", "=", "i", ".", "split", "(", "'/'", ")", "category", "=", "_", "[", "-", "2", ...
get data to display in feed file
[ "get", "data", "to", "display", "in", "feed", "file" ]
train
https://github.com/wlwang41/cb/blob/0a7faa427e3e6593980687dfe1a882ac99d743f6/cb/commands.py#L206-L228
wlwang41/cb
cb/commands.py
Command._generate_feed
def _generate_feed(self, feed_data): """ render feed file with data """ atom_feed = self._render_html('atom.xml', feed_data) feed_path = os.path.join(os.getcwd(), 'public', 'atom.xml') with codecs.open(feed_path, 'wb', 'utf-8') as f: f.write(atom_feed)
python
def _generate_feed(self, feed_data): """ render feed file with data """ atom_feed = self._render_html('atom.xml', feed_data) feed_path = os.path.join(os.getcwd(), 'public', 'atom.xml') with codecs.open(feed_path, 'wb', 'utf-8') as f: f.write(atom_feed)
[ "def", "_generate_feed", "(", "self", ",", "feed_data", ")", ":", "atom_feed", "=", "self", ".", "_render_html", "(", "'atom.xml'", ",", "feed_data", ")", "feed_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "'publ...
render feed file with data
[ "render", "feed", "file", "with", "data" ]
train
https://github.com/wlwang41/cb/blob/0a7faa427e3e6593980687dfe1a882ac99d743f6/cb/commands.py#L230-L238
treycucco/bidon
bidon/util/date.py
parse_date
def parse_date(val, fmt=None): """Returns a date object parsed from :val:. :param val: a string to be parsed as a date :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format strings will be used to try to parse the date. """ if isinstanc...
python
def parse_date(val, fmt=None): """Returns a date object parsed from :val:. :param val: a string to be parsed as a date :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format strings will be used to try to parse the date. """ if isinstanc...
[ "def", "parse_date", "(", "val", ",", "fmt", "=", "None", ")", ":", "if", "isinstance", "(", "val", ",", "date", ")", ":", "return", "val", "else", ":", "return", "parse_datetime", "(", "val", ",", "fmt", ")", ".", "date", "(", ")" ]
Returns a date object parsed from :val:. :param val: a string to be parsed as a date :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format strings will be used to try to parse the date.
[ "Returns", "a", "date", "object", "parsed", "from", ":", "val", ":", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/date.py#L19-L30
treycucco/bidon
bidon/util/date.py
parse_time
def parse_time(val, fmt=None): """Returns a time object parsed from :val:. :param val: a string to be parsed as a time :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format strings will be used to try to parse the time. """ if isinstance(val, time): ...
python
def parse_time(val, fmt=None): """Returns a time object parsed from :val:. :param val: a string to be parsed as a time :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format strings will be used to try to parse the time. """ if isinstance(val, time): ...
[ "def", "parse_time", "(", "val", ",", "fmt", "=", "None", ")", ":", "if", "isinstance", "(", "val", ",", "time", ")", ":", "return", "val", "else", ":", "return", "parse_datetime", "(", "val", ",", "fmt", ")", ".", "time", "(", ")" ]
Returns a time object parsed from :val:. :param val: a string to be parsed as a time :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format strings will be used to try to parse the time.
[ "Returns", "a", "time", "object", "parsed", "from", ":", "val", ":", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/date.py#L33-L43
treycucco/bidon
bidon/util/date.py
parse_datetime
def parse_datetime(val, fmt=None): """Returns a datetime object parsed from :val:. :param val: a string to be parsed as a date :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format strings will be used to try to parse the date. """ if isinstance(val,...
python
def parse_datetime(val, fmt=None): """Returns a datetime object parsed from :val:. :param val: a string to be parsed as a date :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format strings will be used to try to parse the date. """ if isinstance(val,...
[ "def", "parse_datetime", "(", "val", ",", "fmt", "=", "None", ")", ":", "if", "isinstance", "(", "val", ",", "datetime", ")", ":", "return", "val", "else", ":", "return", "_parse_datetime", "(", "_normalize_tz", "(", "str", "(", "val", ")", ")", ",", ...
Returns a datetime object parsed from :val:. :param val: a string to be parsed as a date :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format strings will be used to try to parse the date.
[ "Returns", "a", "datetime", "object", "parsed", "from", ":", "val", ":", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/date.py#L46-L56
treycucco/bidon
bidon/util/date.py
_parse_datetime
def _parse_datetime(val, fmt=None): """Returns a datetime object parsed from :val:. The timezone, if any, on the string must be in the format that python can parse. :param val: a string to be parsed as a date :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format ...
python
def _parse_datetime(val, fmt=None): """Returns a datetime object parsed from :val:. The timezone, if any, on the string must be in the format that python can parse. :param val: a string to be parsed as a date :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format ...
[ "def", "_parse_datetime", "(", "val", ",", "fmt", "=", "None", ")", ":", "if", "fmt", "is", "None", ":", "fmt", "=", "_DEFAULT_FORMATS", "if", "isinstance", "(", "fmt", ",", "str", ")", ":", "return", "datetime", ".", "strptime", "(", "val", ",", "fm...
Returns a datetime object parsed from :val:. The timezone, if any, on the string must be in the format that python can parse. :param val: a string to be parsed as a date :param fmt: a format string, a tuple of format strings, or None. If None a built in list of format strings will be used to try to...
[ "Returns", "a", "datetime", "object", "parsed", "from", ":", "val", ":", ".", "The", "timezone", "if", "any", "on", "the", "string", "must", "be", "in", "the", "format", "that", "python", "can", "parse", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/date.py#L59-L78
treycucco/bidon
bidon/util/date.py
_normalize_tz
def _normalize_tz(val): """Normalizes all valid ISO8601 time zone variants to the one python will parse. :val: a timestamp string without a timezone, or with a timezone in one of the ISO8601 accepted formats. """ match = _TZ_RE.match(val) if match: ts, tz = match.groups() if len(tz) == 5: ...
python
def _normalize_tz(val): """Normalizes all valid ISO8601 time zone variants to the one python will parse. :val: a timestamp string without a timezone, or with a timezone in one of the ISO8601 accepted formats. """ match = _TZ_RE.match(val) if match: ts, tz = match.groups() if len(tz) == 5: ...
[ "def", "_normalize_tz", "(", "val", ")", ":", "match", "=", "_TZ_RE", ".", "match", "(", "val", ")", "if", "match", ":", "ts", ",", "tz", "=", "match", ".", "groups", "(", ")", "if", "len", "(", "tz", ")", "==", "5", ":", "# If the length of the tz...
Normalizes all valid ISO8601 time zone variants to the one python will parse. :val: a timestamp string without a timezone, or with a timezone in one of the ISO8601 accepted formats.
[ "Normalizes", "all", "valid", "ISO8601", "time", "zone", "variants", "to", "the", "one", "python", "will", "parse", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/date.py#L81-L106
treycucco/bidon
bidon/util/date.py
_join_date_and_time
def _join_date_and_time(dates, times, joiner): """Returns a tuple of all date and time format strings joined together by :joiner:. :dates: an enumerable of date format strings :times: an enumerable of time format strings :joiner: a string to join a date and time format together """ return tuple("{}{}{}"....
python
def _join_date_and_time(dates, times, joiner): """Returns a tuple of all date and time format strings joined together by :joiner:. :dates: an enumerable of date format strings :times: an enumerable of time format strings :joiner: a string to join a date and time format together """ return tuple("{}{}{}"....
[ "def", "_join_date_and_time", "(", "dates", ",", "times", ",", "joiner", ")", ":", "return", "tuple", "(", "\"{}{}{}\"", ".", "format", "(", "d", ",", "joiner", ",", "t", ")", "for", "(", "d", ",", "t", ")", "in", "itertools", ".", "product", "(", ...
Returns a tuple of all date and time format strings joined together by :joiner:. :dates: an enumerable of date format strings :times: an enumerable of time format strings :joiner: a string to join a date and time format together
[ "Returns", "a", "tuple", "of", "all", "date", "and", "time", "format", "strings", "joined", "together", "by", ":", "joiner", ":", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/date.py#L109-L117
eallik/spinoff
spinoff/remoting/mock.py
MockNetwork.node
def node(self, nodeid): """Creates a new node with the specified name, with `MockSocket` instances as incoming and outgoing sockets. Returns the implementation object created for the node from the cls, args and address specified, and the sockets. `cls` must be a callable that takes the insock a...
python
def node(self, nodeid): """Creates a new node with the specified name, with `MockSocket` instances as incoming and outgoing sockets. Returns the implementation object created for the node from the cls, args and address specified, and the sockets. `cls` must be a callable that takes the insock a...
[ "def", "node", "(", "self", ",", "nodeid", ")", ":", "_assert_valid_nodeid", "(", "nodeid", ")", "# addr = 'tcp://' + nodeid", "# insock = MockInSocket(addEndpoints=lambda endpoints: self.bind(addr, insock, endpoints))", "# outsock = lambda: MockOutSocket(addr, self)", "return", "Nod...
Creates a new node with the specified name, with `MockSocket` instances as incoming and outgoing sockets. Returns the implementation object created for the node from the cls, args and address specified, and the sockets. `cls` must be a callable that takes the insock and outsock, and the specified args ...
[ "Creates", "a", "new", "node", "with", "the", "specified", "name", "with", "MockSocket", "instances", "as", "incoming", "and", "outgoing", "sockets", "." ]
train
https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/remoting/mock.py#L33-L45
eallik/spinoff
spinoff/remoting/mock.py
MockNetwork.transmit
def transmit(self): """Puts all currently pending sent messages to the insock buffer of the recipient of the message. This is more useful than immediate "delivery" because it allows full flexibility of the order in which tests set up nodes and mock actors on those nodes, and of the order in whi...
python
def transmit(self): """Puts all currently pending sent messages to the insock buffer of the recipient of the message. This is more useful than immediate "delivery" because it allows full flexibility of the order in which tests set up nodes and mock actors on those nodes, and of the order in whi...
[ "def", "transmit", "(", "self", ")", ":", "if", "not", "self", ".", "queue", ":", "return", "deliverable", "=", "[", "]", "for", "src", ",", "dst", ",", "msg", "in", "self", ".", "queue", ":", "_assert_valid_addr", "(", "src", ")", "_assert_valid_addr"...
Puts all currently pending sent messages to the insock buffer of the recipient of the message. This is more useful than immediate "delivery" because it allows full flexibility of the order in which tests set up nodes and mock actors on those nodes, and of the order in which messages are sent out from a...
[ "Puts", "all", "currently", "pending", "sent", "messages", "to", "the", "insock", "buffer", "of", "the", "recipient", "of", "the", "message", "." ]
train
https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/remoting/mock.py#L90-L122
Bystroushaak/zeo_connector
src/zeo_connector/zeo_conf_wrapper.py
ZEOConfWrapper._get_db
def _get_db(self): """ Open the connection to the database based on the configuration file. """ if self._connection: try: self._connection.close() except Exception: pass return DB(storageFromFile(open(self.conf_path)))
python
def _get_db(self): """ Open the connection to the database based on the configuration file. """ if self._connection: try: self._connection.close() except Exception: pass return DB(storageFromFile(open(self.conf_path)))
[ "def", "_get_db", "(", "self", ")", ":", "if", "self", ".", "_connection", ":", "try", ":", "self", ".", "_connection", ".", "close", "(", ")", "except", "Exception", ":", "pass", "return", "DB", "(", "storageFromFile", "(", "open", "(", "self", ".", ...
Open the connection to the database based on the configuration file.
[ "Open", "the", "connection", "to", "the", "database", "based", "on", "the", "configuration", "file", "." ]
train
https://github.com/Bystroushaak/zeo_connector/blob/93f86447204efc8e33d3112907cd221daf6bce3b/src/zeo_connector/zeo_conf_wrapper.py#L44-L54
calvinku96/labreporthelper
labreporthelper/plot.py
PlotSingle2D.do_plot_and_bestfit
def do_plot_and_bestfit(self): """ Create plot """ # Plot fmt = str(self.kwargs.get("fmt", "k.")) if "errors" in self.kwargs: errors = self.kwargs["errors"] if isinstance(errors, dict): self.subplot.errorbar(self.x, self.y, fmt=fmt,...
python
def do_plot_and_bestfit(self): """ Create plot """ # Plot fmt = str(self.kwargs.get("fmt", "k.")) if "errors" in self.kwargs: errors = self.kwargs["errors"] if isinstance(errors, dict): self.subplot.errorbar(self.x, self.y, fmt=fmt,...
[ "def", "do_plot_and_bestfit", "(", "self", ")", ":", "# Plot", "fmt", "=", "str", "(", "self", ".", "kwargs", ".", "get", "(", "\"fmt\"", ",", "\"k.\"", ")", ")", "if", "\"errors\"", "in", "self", ".", "kwargs", ":", "errors", "=", "self", ".", "kwar...
Create plot
[ "Create", "plot" ]
train
https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/plot.py#L110-L146
calvinku96/labreporthelper
labreporthelper/plot.py
PlotSingle2D.do_label
def do_label(self): """ Create label for x and y axis, title and suptitle """ outputdict = self.outputdict xlabel_options = self.kwargs.get("xlabel_options", {}) self.subplot.set_xlabel( self.kwargs.get("xlabel", "").format(**outputdict), **xlabel_...
python
def do_label(self): """ Create label for x and y axis, title and suptitle """ outputdict = self.outputdict xlabel_options = self.kwargs.get("xlabel_options", {}) self.subplot.set_xlabel( self.kwargs.get("xlabel", "").format(**outputdict), **xlabel_...
[ "def", "do_label", "(", "self", ")", ":", "outputdict", "=", "self", ".", "outputdict", "xlabel_options", "=", "self", ".", "kwargs", ".", "get", "(", "\"xlabel_options\"", ",", "{", "}", ")", "self", ".", "subplot", ".", "set_xlabel", "(", "self", ".", ...
Create label for x and y axis, title and suptitle
[ "Create", "label", "for", "x", "and", "y", "axis", "title", "and", "suptitle" ]
train
https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/plot.py#L148-L186
calvinku96/labreporthelper
labreporthelper/plot.py
PlotSingle2D.plot
def plot(self): """ Plot """ self.before_plot() self.do_plot_and_bestfit() self.after_plot() self.do_label() self.after_label() self.save() self.close() return self.outputdict
python
def plot(self): """ Plot """ self.before_plot() self.do_plot_and_bestfit() self.after_plot() self.do_label() self.after_label() self.save() self.close() return self.outputdict
[ "def", "plot", "(", "self", ")", ":", "self", ".", "before_plot", "(", ")", "self", ".", "do_plot_and_bestfit", "(", ")", "self", ".", "after_plot", "(", ")", "self", ".", "do_label", "(", ")", "self", ".", "after_label", "(", ")", "self", ".", "save...
Plot
[ "Plot" ]
train
https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/plot.py#L208-L219
questrail/arghelper
arghelper.py
extant_item
def extant_item(arg, arg_type): """Determine if parser argument is an existing file or directory. This technique comes from http://stackoverflow.com/a/11541450/95592 and from http://stackoverflow.com/a/11541495/95592 Args: arg: parser argument containing filename to be checked arg_type...
python
def extant_item(arg, arg_type): """Determine if parser argument is an existing file or directory. This technique comes from http://stackoverflow.com/a/11541450/95592 and from http://stackoverflow.com/a/11541495/95592 Args: arg: parser argument containing filename to be checked arg_type...
[ "def", "extant_item", "(", "arg", ",", "arg_type", ")", ":", "if", "arg_type", "==", "\"file\"", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "arg", ")", ":", "raise", "argparse", ".", "ArgumentError", "(", "None", ",", "\"The file {arg} does...
Determine if parser argument is an existing file or directory. This technique comes from http://stackoverflow.com/a/11541450/95592 and from http://stackoverflow.com/a/11541495/95592 Args: arg: parser argument containing filename to be checked arg_type: string of either "file" or "directory...
[ "Determine", "if", "parser", "argument", "is", "an", "existing", "file", "or", "directory", "." ]
train
https://github.com/questrail/arghelper/blob/833d7d25a1f3daba70f186057d3d39a040c56200/arghelper.py#L35-L66
questrail/arghelper
arghelper.py
parse_config_input_output
def parse_config_input_output(args=sys.argv): """Parse the args using the config_file, input_dir, output_dir pattern Args: args: sys.argv Returns: The populated namespace object from parser.parse_args(). Raises: TBD """ parser = argparse.ArgumentParser( descrip...
python
def parse_config_input_output(args=sys.argv): """Parse the args using the config_file, input_dir, output_dir pattern Args: args: sys.argv Returns: The populated namespace object from parser.parse_args(). Raises: TBD """ parser = argparse.ArgumentParser( descrip...
[ "def", "parse_config_input_output", "(", "args", "=", "sys", ".", "argv", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Process the input files using the given config'", ")", "parser", ".", "add_argument", "(", "'config_file'",...
Parse the args using the config_file, input_dir, output_dir pattern Args: args: sys.argv Returns: The populated namespace object from parser.parse_args(). Raises: TBD
[ "Parse", "the", "args", "using", "the", "config_file", "input_dir", "output_dir", "pattern" ]
train
https://github.com/questrail/arghelper/blob/833d7d25a1f3daba70f186057d3d39a040c56200/arghelper.py#L69-L95
questrail/arghelper
arghelper.py
parse_config
def parse_config(args=sys.argv): """Parse the args using the config_file pattern Args: args: sys.argv Returns: The populated namespace object from parser.parse_args(). Raises: TBD """ parser = argparse.ArgumentParser( description='Read in the config file') ...
python
def parse_config(args=sys.argv): """Parse the args using the config_file pattern Args: args: sys.argv Returns: The populated namespace object from parser.parse_args(). Raises: TBD """ parser = argparse.ArgumentParser( description='Read in the config file') ...
[ "def", "parse_config", "(", "args", "=", "sys", ".", "argv", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Read in the config file'", ")", "parser", ".", "add_argument", "(", "'config_file'", ",", "help", "=", "'Configu...
Parse the args using the config_file pattern Args: args: sys.argv Returns: The populated namespace object from parser.parse_args(). Raises: TBD
[ "Parse", "the", "args", "using", "the", "config_file", "pattern" ]
train
https://github.com/questrail/arghelper/blob/833d7d25a1f3daba70f186057d3d39a040c56200/arghelper.py#L98-L116
cfobel/clutter-webcam-viewer
clutter_webcam_viewer/svg.py
parse_args
def parse_args(args=None): """Parses arguments, returns (options, args).""" from argparse import ArgumentParser if args is None: args = sys.argv[1:] parser = ArgumentParser(description='Demonstrate drawing SVG on Clutter ' 'stage') parser.add_argument('svg_path'...
python
def parse_args(args=None): """Parses arguments, returns (options, args).""" from argparse import ArgumentParser if args is None: args = sys.argv[1:] parser = ArgumentParser(description='Demonstrate drawing SVG on Clutter ' 'stage') parser.add_argument('svg_path'...
[ "def", "parse_args", "(", "args", "=", "None", ")", ":", "from", "argparse", "import", "ArgumentParser", "if", "args", "is", "None", ":", "args", "=", "sys", ".", "argv", "[", "1", ":", "]", "parser", "=", "ArgumentParser", "(", "description", "=", "'D...
Parses arguments, returns (options, args).
[ "Parses", "arguments", "returns", "(", "options", "args", ")", "." ]
train
https://github.com/cfobel/clutter-webcam-viewer/blob/b227d2ae02d750194e65c13bcf178550755c3afc/clutter_webcam_viewer/svg.py#L148-L161
Julian/txmusicbrainz
txmusicbrainz/_entities.py
BoundEntityRetriever.lookup
def lookup(self, mbid, include=()): """ Lookup an entity directly from a specified :term:`MBID`\ . """ if include: for included in include: if included not in self.available_includes: raise ValueError( "{0!r} is no...
python
def lookup(self, mbid, include=()): """ Lookup an entity directly from a specified :term:`MBID`\ . """ if include: for included in include: if included not in self.available_includes: raise ValueError( "{0!r} is no...
[ "def", "lookup", "(", "self", ",", "mbid", ",", "include", "=", "(", ")", ")", ":", "if", "include", ":", "for", "included", "in", "include", ":", "if", "included", "not", "in", "self", ".", "available_includes", ":", "raise", "ValueError", "(", "\"{0!...
Lookup an entity directly from a specified :term:`MBID`\ .
[ "Lookup", "an", "entity", "directly", "from", "a", "specified", ":", "term", ":", "MBID", "\\", "." ]
train
https://github.com/Julian/txmusicbrainz/blob/0512acb53a253c2d569c47c474d575160e5ca0ea/txmusicbrainz/_entities.py#L19-L38
Julian/txmusicbrainz
txmusicbrainz/_entities.py
BoundEntityRetriever.search
def search(self, query): """ Perform a (Lucene) search of the entity. :argument str query: a properly escaped Lucene query """ return self.client.request( self.path + "?" + urlencode([("query", query)]), )
python
def search(self, query): """ Perform a (Lucene) search of the entity. :argument str query: a properly escaped Lucene query """ return self.client.request( self.path + "?" + urlencode([("query", query)]), )
[ "def", "search", "(", "self", ",", "query", ")", ":", "return", "self", ".", "client", ".", "request", "(", "self", ".", "path", "+", "\"?\"", "+", "urlencode", "(", "[", "(", "\"query\"", ",", "query", ")", "]", ")", ",", ")" ]
Perform a (Lucene) search of the entity. :argument str query: a properly escaped Lucene query
[ "Perform", "a", "(", "Lucene", ")", "search", "of", "the", "entity", "." ]
train
https://github.com/Julian/txmusicbrainz/blob/0512acb53a253c2d569c47c474d575160e5ca0ea/txmusicbrainz/_entities.py#L40-L50
davisd50/sparc.cache
sparc/cache/sql/sql.py
SqlObjectCacheArea.get
def get(self, CachableItem): """Returns current ICachedItem for ICachableItem Args: CachableItem: ICachableItem, used as a reference to find a cached version Returns: ICachedItem or None, if CachableItem has not been cached """ return self.session.\ ...
python
def get(self, CachableItem): """Returns current ICachedItem for ICachableItem Args: CachableItem: ICachableItem, used as a reference to find a cached version Returns: ICachedItem or None, if CachableItem has not been cached """ return self.session.\ ...
[ "def", "get", "(", "self", ",", "CachableItem", ")", ":", "return", "self", ".", "session", ".", "query", "(", "self", ".", "mapper", ".", "factory", "(", ")", ".", "__class__", ")", ".", "filter", "(", "self", ".", "mapper", ".", "factory", "(", "...
Returns current ICachedItem for ICachableItem Args: CachableItem: ICachableItem, used as a reference to find a cached version Returns: ICachedItem or None, if CachableItem has not been cached
[ "Returns", "current", "ICachedItem", "for", "ICachableItem", "Args", ":", "CachableItem", ":", "ICachableItem", "used", "as", "a", "reference", "to", "find", "a", "cached", "version", "Returns", ":", "ICachedItem", "or", "None", "if", "CachableItem", "has", "not...
train
https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/sql/sql.py#L124-L135
davisd50/sparc.cache
sparc/cache/sql/sql.py
SqlObjectCacheArea.cache
def cache(self, CachableItem): """Updates cache area with latest information """ _cachedItem = self.get(CachableItem) if not _cachedItem: _dirtyCachedItem = self.mapper.get(CachableItem) logger.debug("new cachable item added to sql cache area {id: %s, type: %s}", ...
python
def cache(self, CachableItem): """Updates cache area with latest information """ _cachedItem = self.get(CachableItem) if not _cachedItem: _dirtyCachedItem = self.mapper.get(CachableItem) logger.debug("new cachable item added to sql cache area {id: %s, type: %s}", ...
[ "def", "cache", "(", "self", ",", "CachableItem", ")", ":", "_cachedItem", "=", "self", ".", "get", "(", "CachableItem", ")", "if", "not", "_cachedItem", ":", "_dirtyCachedItem", "=", "self", ".", "mapper", ".", "get", "(", "CachableItem", ")", "logger", ...
Updates cache area with latest information
[ "Updates", "cache", "area", "with", "latest", "information" ]
train
https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/sql/sql.py#L153-L170
davisd50/sparc.cache
sparc/cache/sql/sql.py
SqlObjectCacheArea.import_source
def import_source(self, CachableSource): """Updates cache area and returns number of items updated with all available entries in ICachableSource""" _count = 0 for item in CachableSource.items(): if self.cache(item): _count += 1 return _count
python
def import_source(self, CachableSource): """Updates cache area and returns number of items updated with all available entries in ICachableSource""" _count = 0 for item in CachableSource.items(): if self.cache(item): _count += 1 return _count
[ "def", "import_source", "(", "self", ",", "CachableSource", ")", ":", "_count", "=", "0", "for", "item", "in", "CachableSource", ".", "items", "(", ")", ":", "if", "self", ".", "cache", "(", "item", ")", ":", "_count", "+=", "1", "return", "_count" ]
Updates cache area and returns number of items updated with all available entries in ICachableSource
[ "Updates", "cache", "area", "and", "returns", "number", "of", "items", "updated", "with", "all", "available", "entries", "in", "ICachableSource" ]
train
https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/sql/sql.py#L172-L178
davisd50/sparc.cache
sparc/cache/sql/sql.py
SqlObjectCacheArea.reset
def reset(self): """Deletes all entries in the cache area""" self.Base.metadata.drop_all(self.session.bind) self.initialize()
python
def reset(self): """Deletes all entries in the cache area""" self.Base.metadata.drop_all(self.session.bind) self.initialize()
[ "def", "reset", "(", "self", ")", ":", "self", ".", "Base", ".", "metadata", ".", "drop_all", "(", "self", ".", "session", ".", "bind", ")", "self", ".", "initialize", "(", ")" ]
Deletes all entries in the cache area
[ "Deletes", "all", "entries", "in", "the", "cache", "area" ]
train
https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/sql/sql.py#L186-L189
davisd50/sparc.cache
sparc/cache/sql/sql.py
SqlObjectCacheArea.initialize
def initialize(self): """Instantiates the cache area to be ready for updates""" self.Base.metadata.create_all(self.session.bind) logger.debug("initialized sqlalchemy orm tables")
python
def initialize(self): """Instantiates the cache area to be ready for updates""" self.Base.metadata.create_all(self.session.bind) logger.debug("initialized sqlalchemy orm tables")
[ "def", "initialize", "(", "self", ")", ":", "self", ".", "Base", ".", "metadata", ".", "create_all", "(", "self", ".", "session", ".", "bind", ")", "logger", ".", "debug", "(", "\"initialized sqlalchemy orm tables\"", ")" ]
Instantiates the cache area to be ready for updates
[ "Instantiates", "the", "cache", "area", "to", "be", "ready", "for", "updates" ]
train
https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/sql/sql.py#L191-L194
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
format_json
def format_json(item, **kwargs): """ formats a datatype object to a json value """ try: json.dumps(item.value) return item.value except TypeError: if 'time' in item.class_type.lower() \ or 'date' in item.class_type.lower(): return item.value.isoformat() ...
python
def format_json(item, **kwargs): """ formats a datatype object to a json value """ try: json.dumps(item.value) return item.value except TypeError: if 'time' in item.class_type.lower() \ or 'date' in item.class_type.lower(): return item.value.isoformat() ...
[ "def", "format_json", "(", "item", ",", "*", "*", "kwargs", ")", ":", "try", ":", "json", ".", "dumps", "(", "item", ".", "value", ")", "return", "item", ".", "value", "except", "TypeError", ":", "if", "'time'", "in", "item", ".", "class_type", ".", ...
formats a datatype object to a json value
[ "formats", "a", "datatype", "object", "to", "a", "json", "value" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L31-L40
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
format_sparql
def format_sparql(item, dt_format='turtle', **kwargs): """ Formats a datatype value to a SPARQL representation args: item: the datatype object dt_format: the return format ['turtle', 'uri'] """ try: rtn_val = json.dumps(item.value) rtn_val = item.value except: ...
python
def format_sparql(item, dt_format='turtle', **kwargs): """ Formats a datatype value to a SPARQL representation args: item: the datatype object dt_format: the return format ['turtle', 'uri'] """ try: rtn_val = json.dumps(item.value) rtn_val = item.value except: ...
[ "def", "format_sparql", "(", "item", ",", "dt_format", "=", "'turtle'", ",", "*", "*", "kwargs", ")", ":", "try", ":", "rtn_val", "=", "json", ".", "dumps", "(", "item", ".", "value", ")", "rtn_val", "=", "item", ".", "value", "except", ":", "if", ...
Formats a datatype value to a SPARQL representation args: item: the datatype object dt_format: the return format ['turtle', 'uri']
[ "Formats", "a", "datatype", "value", "to", "a", "SPARQL", "representation" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L42-L74
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
BaseRdfDataType._format
def _format(self, method="sparql", dt_format="turtle"): """ Rormats the value in various formats args: method: ['sparql', 'json', 'pyuri'] dt_format: ['turtle','uri'] used in conjuction with the 'sparql' method """ try: ...
python
def _format(self, method="sparql", dt_format="turtle"): """ Rormats the value in various formats args: method: ['sparql', 'json', 'pyuri'] dt_format: ['turtle','uri'] used in conjuction with the 'sparql' method """ try: ...
[ "def", "_format", "(", "self", ",", "method", "=", "\"sparql\"", ",", "dt_format", "=", "\"turtle\"", ")", ":", "try", ":", "return", "__FORMAT_OPTIONS__", "[", "method", "]", "(", "self", ",", "dt_format", "=", "dt_format", ")", "except", "KeyError", ":",...
Rormats the value in various formats args: method: ['sparql', 'json', 'pyuri'] dt_format: ['turtle','uri'] used in conjuction with the 'sparql' method
[ "Rormats", "the", "value", "in", "various", "formats" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L112-L127
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
RdfNsManager.bind
def bind(self, prefix, namespace, *args, **kwargs): """ Extends the function to add an attribute to the class for each added namespace to allow for use of dot notation. All prefixes are converted to lowercase Args: prefix: string of namespace name namespace: rdfl...
python
def bind(self, prefix, namespace, *args, **kwargs): """ Extends the function to add an attribute to the class for each added namespace to allow for use of dot notation. All prefixes are converted to lowercase Args: prefix: string of namespace name namespace: rdfl...
[ "def", "bind", "(", "self", ",", "prefix", ",", "namespace", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# RdfNamespace(prefix, namespace, **kwargs)", "setattr", "(", "self", ",", "prefix", ",", "RdfNamespace", "(", "prefix", ",", "namespace", ",",...
Extends the function to add an attribute to the class for each added namespace to allow for use of dot notation. All prefixes are converted to lowercase Args: prefix: string of namespace name namespace: rdflib.namespace instance kwargs: calc: whether...
[ "Extends", "the", "function", "to", "add", "an", "attribute", "to", "the", "class", "for", "each", "added", "namespace", "to", "allow", "for", "use", "of", "dot", "notation", ".", "All", "prefixes", "are", "converted", "to", "lowercase" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L459-L479
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
RdfNsManager.prefix
def prefix(self, format="sparql"): ''' Generates a string of the rdf namespaces listed used in the framework format: "sparql" or "turtle" ''' lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3])) lg.setLevel(self.log_level) _return_str = ""...
python
def prefix(self, format="sparql"): ''' Generates a string of the rdf namespaces listed used in the framework format: "sparql" or "turtle" ''' lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3])) lg.setLevel(self.log_level) _return_str = ""...
[ "def", "prefix", "(", "self", ",", "format", "=", "\"sparql\"", ")", ":", "lg", "=", "logging", ".", "getLogger", "(", "\"%s.%s\"", "%", "(", "self", ".", "ln", ",", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "3", "]", ")", ")", "lg...
Generates a string of the rdf namespaces listed used in the framework format: "sparql" or "turtle"
[ "Generates", "a", "string", "of", "the", "rdf", "namespaces", "listed", "used", "in", "the", "framework" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L481-L501
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
RdfNsManager.load
def load(self, filepath, file_encoding=None): """ Reads the the beginning of a turtle file and sets the prefix's used in that file and sets the prefix attribute Args: filepath: the path to the turtle file file_encoding: specify a specific encoding if necessary ""...
python
def load(self, filepath, file_encoding=None): """ Reads the the beginning of a turtle file and sets the prefix's used in that file and sets the prefix attribute Args: filepath: the path to the turtle file file_encoding: specify a specific encoding if necessary ""...
[ "def", "load", "(", "self", ",", "filepath", ",", "file_encoding", "=", "None", ")", ":", "with", "open", "(", "filepath", ",", "encoding", "=", "file_encoding", ")", "as", "inf", ":", "for", "line", "in", "inf", ":", "current_line", "=", "str", "(", ...
Reads the the beginning of a turtle file and sets the prefix's used in that file and sets the prefix attribute Args: filepath: the path to the turtle file file_encoding: specify a specific encoding if necessary
[ "Reads", "the", "the", "beginning", "of", "a", "turtle", "file", "and", "sets", "the", "prefix", "s", "used", "in", "that", "file", "and", "sets", "the", "prefix", "attribute" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L503-L518
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
RdfNsManager.dict_load
def dict_load(self, ns_dict): """ Reads a dictionary of namespaces and binds them to the manager Args: ns_dict: dictionary with the key as the prefix and the value as the uri """ for prefix, uri in ns_dict.items(): self.bind(prefix, uri, over...
python
def dict_load(self, ns_dict): """ Reads a dictionary of namespaces and binds them to the manager Args: ns_dict: dictionary with the key as the prefix and the value as the uri """ for prefix, uri in ns_dict.items(): self.bind(prefix, uri, over...
[ "def", "dict_load", "(", "self", ",", "ns_dict", ")", ":", "for", "prefix", ",", "uri", "in", "ns_dict", ".", "items", "(", ")", ":", "self", ".", "bind", "(", "prefix", ",", "uri", ",", "override", "=", "False", ",", "calc", "=", "False", ")", "...
Reads a dictionary of namespaces and binds them to the manager Args: ns_dict: dictionary with the key as the prefix and the value as the uri
[ "Reads", "a", "dictionary", "of", "namespaces", "and", "binds", "them", "to", "the", "manager" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L524-L533
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
RdfNsManager._add_ttl_ns
def _add_ttl_ns(self, line): """ takes one prefix line from the turtle file and binds the namespace to the class Args: line: the turtle prefix line string """ lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3])) lg.setLevel(self.log_level) ...
python
def _add_ttl_ns(self, line): """ takes one prefix line from the turtle file and binds the namespace to the class Args: line: the turtle prefix line string """ lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3])) lg.setLevel(self.log_level) ...
[ "def", "_add_ttl_ns", "(", "self", ",", "line", ")", ":", "lg", "=", "logging", ".", "getLogger", "(", "\"%s.%s\"", "%", "(", "self", ".", "ln", ",", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "3", "]", ")", ")", "lg", ".", "setLeve...
takes one prefix line from the turtle file and binds the namespace to the class Args: line: the turtle prefix line string
[ "takes", "one", "prefix", "line", "from", "the", "turtle", "file", "and", "binds", "the", "namespace", "to", "the", "class" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L535-L559
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
RdfNsManager.del_ns
def del_ns(self, namespace): """ will remove a namespace ref from the manager. either Arg is optional. args: namespace: prefix, string or Namespace() to remove """ # remove the item from the namespace dict namespace = str(namespace) attr_name = None ...
python
def del_ns(self, namespace): """ will remove a namespace ref from the manager. either Arg is optional. args: namespace: prefix, string or Namespace() to remove """ # remove the item from the namespace dict namespace = str(namespace) attr_name = None ...
[ "def", "del_ns", "(", "self", ",", "namespace", ")", ":", "# remove the item from the namespace dict", "namespace", "=", "str", "(", "namespace", ")", "attr_name", "=", "None", "if", "hasattr", "(", "self", ",", "namespace", ")", ":", "delattr", "(", "self", ...
will remove a namespace ref from the manager. either Arg is optional. args: namespace: prefix, string or Namespace() to remove
[ "will", "remove", "a", "namespace", "ref", "from", "the", "manager", ".", "either", "Arg", "is", "optional", "." ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L561-L572
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
RdfNsManager.uri
def uri(self, value, strip_iri=True): """ Converts py_uri or ttl uri to a http://... full uri format Args: value: the string to convert Returns: full uri of an abbreivated uri """ return self.convert_to_uri(value, strip_iri=strip_iri)
python
def uri(self, value, strip_iri=True): """ Converts py_uri or ttl uri to a http://... full uri format Args: value: the string to convert Returns: full uri of an abbreivated uri """ return self.convert_to_uri(value, strip_iri=strip_iri)
[ "def", "uri", "(", "self", ",", "value", ",", "strip_iri", "=", "True", ")", ":", "return", "self", ".", "convert_to_uri", "(", "value", ",", "strip_iri", "=", "strip_iri", ")" ]
Converts py_uri or ttl uri to a http://... full uri format Args: value: the string to convert Returns: full uri of an abbreivated uri
[ "Converts", "py_uri", "or", "ttl", "uri", "to", "a", "http", ":", "//", "...", "full", "uri", "format" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L596-L606
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
RdfNsManager.convert_to_uri
def convert_to_uri(self, value, strip_iri=True): ''' converts a prefixed rdf ns equivalent value to its uri form. If not found returns the value as is args: value: the URI/IRI to convert strip_iri: removes the < and > signs rdflib_uri: ret...
python
def convert_to_uri(self, value, strip_iri=True): ''' converts a prefixed rdf ns equivalent value to its uri form. If not found returns the value as is args: value: the URI/IRI to convert strip_iri: removes the < and > signs rdflib_uri: ret...
[ "def", "convert_to_uri", "(", "self", ",", "value", ",", "strip_iri", "=", "True", ")", ":", "parsed", "=", "self", ".", "parse_uri", "(", "str", "(", "value", ")", ")", "try", ":", "new_uri", "=", "\"%s%s\"", "%", "(", "self", ".", "ns_dict", "[", ...
converts a prefixed rdf ns equivalent value to its uri form. If not found returns the value as is args: value: the URI/IRI to convert strip_iri: removes the < and > signs rdflib_uri: returns an rdflib URIRef
[ "converts", "a", "prefixed", "rdf", "ns", "equivalent", "value", "to", "its", "uri", "form", ".", "If", "not", "found", "returns", "the", "value", "as", "is" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L608-L625
KnowledgeLinks/rdfframework
rdfframework/datatypes/namespaces.py
RdfNsManager.get_uri_parts
def get_uri_parts(self, value): """takes an value and returns a tuple of the parts args: value: a uri in any form pyuri, ttl or full IRI """ if value.startswith('pyuri_'): value = self.rpyhttp(value) parts = self.parse_uri(value) try: ...
python
def get_uri_parts(self, value): """takes an value and returns a tuple of the parts args: value: a uri in any form pyuri, ttl or full IRI """ if value.startswith('pyuri_'): value = self.rpyhttp(value) parts = self.parse_uri(value) try: ...
[ "def", "get_uri_parts", "(", "self", ",", "value", ")", ":", "if", "value", ".", "startswith", "(", "'pyuri_'", ")", ":", "value", "=", "self", ".", "rpyhttp", "(", "value", ")", "parts", "=", "self", ".", "parse_uri", "(", "value", ")", "try", ":", ...
takes an value and returns a tuple of the parts args: value: a uri in any form pyuri, ttl or full IRI
[ "takes", "an", "value", "and", "returns", "a", "tuple", "of", "the", "parts" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L627-L642