repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
metacloud/gilt
gilt/config.py
config
def config(filename): """ Construct `Config` object and return a list. :parse filename: A string containing the path to YAML file. :return: list """ Config = collections.namedtuple('Config', [ 'git', 'lock_file', 'version', 'name', 'src', 'dst', ...
python
def config(filename): """ Construct `Config` object and return a list. :parse filename: A string containing the path to YAML file. :return: list """ Config = collections.namedtuple('Config', [ 'git', 'lock_file', 'version', 'name', 'src', 'dst', ...
[ "def", "config", "(", "filename", ")", ":", "Config", "=", "collections", ".", "namedtuple", "(", "'Config'", ",", "[", "'git'", ",", "'lock_file'", ",", "'version'", ",", "'name'", ",", "'src'", ",", "'dst'", ",", "'files'", ",", "'post_commands'", ",", ...
Construct `Config` object and return a list. :parse filename: A string containing the path to YAML file. :return: list
[ "Construct", "Config", "object", "and", "return", "a", "list", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/config.py#L41-L59
train
metacloud/gilt
gilt/config.py
_get_files_config
def _get_files_config(src_dir, files_list): """ Construct `FileConfig` object and return a list. :param src_dir: A string containing the source directory. :param files_list: A list of dicts containing the src/dst mapping of files to overlay. :return: list """ FilesConfig = collections....
python
def _get_files_config(src_dir, files_list): """ Construct `FileConfig` object and return a list. :param src_dir: A string containing the source directory. :param files_list: A list of dicts containing the src/dst mapping of files to overlay. :return: list """ FilesConfig = collections....
[ "def", "_get_files_config", "(", "src_dir", ",", "files_list", ")", ":", "FilesConfig", "=", "collections", ".", "namedtuple", "(", "'FilesConfig'", ",", "[", "'src'", ",", "'dst'", ",", "'post_commands'", "]", ")", "return", "[", "FilesConfig", "(", "*", "*...
Construct `FileConfig` object and return a list. :param src_dir: A string containing the source directory. :param files_list: A list of dicts containing the src/dst mapping of files to overlay. :return: list
[ "Construct", "FileConfig", "object", "and", "return", "a", "list", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/config.py#L62-L76
train
metacloud/gilt
gilt/config.py
_get_config
def _get_config(filename): """ Parse the provided YAML file and return a dict. :parse filename: A string containing the path to YAML file. :return: dict """ i = interpolation.Interpolator(interpolation.TemplateWithDefaults, os.environ) with open(filename,...
python
def _get_config(filename): """ Parse the provided YAML file and return a dict. :parse filename: A string containing the path to YAML file. :return: dict """ i = interpolation.Interpolator(interpolation.TemplateWithDefaults, os.environ) with open(filename,...
[ "def", "_get_config", "(", "filename", ")", ":", "i", "=", "interpolation", ".", "Interpolator", "(", "interpolation", ".", "TemplateWithDefaults", ",", "os", ".", "environ", ")", "with", "open", "(", "filename", ",", "'r'", ")", "as", "stream", ":", "try"...
Parse the provided YAML file and return a dict. :parse filename: A string containing the path to YAML file. :return: dict
[ "Parse", "the", "provided", "YAML", "file", "and", "return", "a", "dict", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/config.py#L126-L142
train
metacloud/gilt
gilt/config.py
_get_dst_dir
def _get_dst_dir(dst_dir): """ Prefix the provided string with working directory and return a str. :param dst_dir: A string to be prefixed with the working dir. :return: str """ wd = os.getcwd() _makedirs(dst_dir) return os.path.join(wd, dst_dir)
python
def _get_dst_dir(dst_dir): """ Prefix the provided string with working directory and return a str. :param dst_dir: A string to be prefixed with the working dir. :return: str """ wd = os.getcwd() _makedirs(dst_dir) return os.path.join(wd, dst_dir)
[ "def", "_get_dst_dir", "(", "dst_dir", ")", ":", "wd", "=", "os", ".", "getcwd", "(", ")", "_makedirs", "(", "dst_dir", ")", "return", "os", ".", "path", ".", "join", "(", "wd", ",", "dst_dir", ")" ]
Prefix the provided string with working directory and return a str. :param dst_dir: A string to be prefixed with the working dir. :return: str
[ "Prefix", "the", "provided", "string", "with", "working", "directory", "and", "return", "a", "str", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/config.py#L145-L156
train
metacloud/gilt
gilt/config.py
_makedirs
def _makedirs(path): """ Create a base directory of the provided path and return None. :param path: A string containing a path to be deconstructed and basedir created. :return: None """ dirname, _ = os.path.split(path) try: os.makedirs(dirname) except OSError as exc: ...
python
def _makedirs(path): """ Create a base directory of the provided path and return None. :param path: A string containing a path to be deconstructed and basedir created. :return: None """ dirname, _ = os.path.split(path) try: os.makedirs(dirname) except OSError as exc: ...
[ "def", "_makedirs", "(", "path", ")", ":", "dirname", ",", "_", "=", "os", ".", "path", ".", "split", "(", "path", ")", "try", ":", "os", ".", "makedirs", "(", "dirname", ")", "except", "OSError", "as", "exc", ":", "if", "exc", ".", "errno", "=="...
Create a base directory of the provided path and return None. :param path: A string containing a path to be deconstructed and basedir created. :return: None
[ "Create", "a", "base", "directory", "of", "the", "provided", "path", "and", "return", "None", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/config.py#L193-L208
train
metacloud/gilt
gilt/shell.py
main
def main(ctx, config, debug): # pragma: no cover """ gilt - A GIT layering tool. """ ctx.obj = {} ctx.obj['args'] = {} ctx.obj['args']['debug'] = debug ctx.obj['args']['config'] = config
python
def main(ctx, config, debug): # pragma: no cover """ gilt - A GIT layering tool. """ ctx.obj = {} ctx.obj['args'] = {} ctx.obj['args']['debug'] = debug ctx.obj['args']['config'] = config
[ "def", "main", "(", "ctx", ",", "config", ",", "debug", ")", ":", "# pragma: no cover", "ctx", ".", "obj", "=", "{", "}", "ctx", ".", "obj", "[", "'args'", "]", "=", "{", "}", "ctx", ".", "obj", "[", "'args'", "]", "[", "'debug'", "]", "=", "de...
gilt - A GIT layering tool.
[ "gilt", "-", "A", "GIT", "layering", "tool", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/shell.py#L50-L55
train
metacloud/gilt
gilt/shell.py
overlay
def overlay(ctx): # pragma: no cover """ Install gilt dependencies """ args = ctx.obj.get('args') filename = args.get('config') debug = args.get('debug') _setup(filename) for c in config.config(filename): with fasteners.InterProcessLock(c.lock_file): util.print_info('{}:'.f...
python
def overlay(ctx): # pragma: no cover """ Install gilt dependencies """ args = ctx.obj.get('args') filename = args.get('config') debug = args.get('debug') _setup(filename) for c in config.config(filename): with fasteners.InterProcessLock(c.lock_file): util.print_info('{}:'.f...
[ "def", "overlay", "(", "ctx", ")", ":", "# pragma: no cover", "args", "=", "ctx", ".", "obj", ".", "get", "(", "'args'", ")", "filename", "=", "args", ".", "get", "(", "'config'", ")", "debug", "=", "args", ".", "get", "(", "'debug'", ")", "_setup", ...
Install gilt dependencies
[ "Install", "gilt", "dependencies" ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/shell.py#L60-L87
train
metacloud/gilt
gilt/git.py
clone
def clone(name, repository, destination, debug=False): """ Clone the specified repository into a temporary directory and return None. :param name: A string containing the name of the repository being cloned. :param repository: A string containing the repository to clone. :param destination: A strin...
python
def clone(name, repository, destination, debug=False): """ Clone the specified repository into a temporary directory and return None. :param name: A string containing the name of the repository being cloned. :param repository: A string containing the repository to clone. :param destination: A strin...
[ "def", "clone", "(", "name", ",", "repository", ",", "destination", ",", "debug", "=", "False", ")", ":", "msg", "=", "' - cloning {} to {}'", ".", "format", "(", "name", ",", "destination", ")", "util", ".", "print_info", "(", "msg", ")", "cmd", "=", ...
Clone the specified repository into a temporary directory and return None. :param name: A string containing the name of the repository being cloned. :param repository: A string containing the repository to clone. :param destination: A string containing the directory to clone the repository into. :...
[ "Clone", "the", "specified", "repository", "into", "a", "temporary", "directory", "and", "return", "None", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/git.py#L32-L46
train
metacloud/gilt
gilt/git.py
_get_version
def _get_version(version, debug=False): """ Handle switching to the specified version and return None. 1. Fetch the origin. 2. Checkout the specified version. 3. Clean the repository before we begin. 4. Pull the origin when a branch; _not_ a commit id. :param version: A string containing t...
python
def _get_version(version, debug=False): """ Handle switching to the specified version and return None. 1. Fetch the origin. 2. Checkout the specified version. 3. Clean the repository before we begin. 4. Pull the origin when a branch; _not_ a commit id. :param version: A string containing t...
[ "def", "_get_version", "(", "version", ",", "debug", "=", "False", ")", ":", "if", "not", "any", "(", "(", "_has_branch", "(", "version", ",", "debug", ")", ",", "_has_tag", "(", "version", ",", "debug", ")", ",", "_has_commit", "(", "version", ",", ...
Handle switching to the specified version and return None. 1. Fetch the origin. 2. Checkout the specified version. 3. Clean the repository before we begin. 4. Pull the origin when a branch; _not_ a commit id. :param version: A string containing the branch/tag/sha to be exported. :param debug: ...
[ "Handle", "switching", "to", "the", "specified", "version", "and", "return", "None", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/git.py#L109-L133
train
metacloud/gilt
gilt/git.py
_has_commit
def _has_commit(version, debug=False): """ Determine a version is a local git commit sha or not. :param version: A string containing the branch/tag/sha to be determined. :param debug: An optional bool to toggle debug output. :return: bool """ if _has_tag(version, debug) or _has_branch(versi...
python
def _has_commit(version, debug=False): """ Determine a version is a local git commit sha or not. :param version: A string containing the branch/tag/sha to be determined. :param debug: An optional bool to toggle debug output. :return: bool """ if _has_tag(version, debug) or _has_branch(versi...
[ "def", "_has_commit", "(", "version", ",", "debug", "=", "False", ")", ":", "if", "_has_tag", "(", "version", ",", "debug", ")", "or", "_has_branch", "(", "version", ",", "debug", ")", ":", "return", "False", "cmd", "=", "sh", ".", "git", ".", "bake"...
Determine a version is a local git commit sha or not. :param version: A string containing the branch/tag/sha to be determined. :param debug: An optional bool to toggle debug output. :return: bool
[ "Determine", "a", "version", "is", "a", "local", "git", "commit", "sha", "or", "not", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/git.py#L136-L151
train
metacloud/gilt
gilt/git.py
_has_tag
def _has_tag(version, debug=False): """ Determine a version is a local git tag name or not. :param version: A string containing the branch/tag/sha to be determined. :param debug: An optional bool to toggle debug output. :return: bool """ cmd = sh.git.bake('show-ref', '--verify', '--quiet', ...
python
def _has_tag(version, debug=False): """ Determine a version is a local git tag name or not. :param version: A string containing the branch/tag/sha to be determined. :param debug: An optional bool to toggle debug output. :return: bool """ cmd = sh.git.bake('show-ref', '--verify', '--quiet', ...
[ "def", "_has_tag", "(", "version", ",", "debug", "=", "False", ")", ":", "cmd", "=", "sh", ".", "git", ".", "bake", "(", "'show-ref'", ",", "'--verify'", ",", "'--quiet'", ",", "\"refs/tags/{}\"", ".", "format", "(", "version", ")", ")", "try", ":", ...
Determine a version is a local git tag name or not. :param version: A string containing the branch/tag/sha to be determined. :param debug: An optional bool to toggle debug output. :return: bool
[ "Determine", "a", "version", "is", "a", "local", "git", "tag", "name", "or", "not", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/git.py#L154-L168
train
metacloud/gilt
gilt/util.py
run_command
def run_command(cmd, debug=False): """ Execute the given command and return None. :param cmd: A `sh.Command` object to execute. :param debug: An optional bool to toggle debug output. :return: None """ if debug: msg = ' PWD: {}'.format(os.getcwd()) print_warn(msg) ms...
python
def run_command(cmd, debug=False): """ Execute the given command and return None. :param cmd: A `sh.Command` object to execute. :param debug: An optional bool to toggle debug output. :return: None """ if debug: msg = ' PWD: {}'.format(os.getcwd()) print_warn(msg) ms...
[ "def", "run_command", "(", "cmd", ",", "debug", "=", "False", ")", ":", "if", "debug", ":", "msg", "=", "' PWD: {}'", ".", "format", "(", "os", ".", "getcwd", "(", ")", ")", "print_warn", "(", "msg", ")", "msg", "=", "' COMMAND: {}'", ".", "format"...
Execute the given command and return None. :param cmd: A `sh.Command` object to execute. :param debug: An optional bool to toggle debug output. :return: None
[ "Execute", "the", "given", "command", "and", "return", "None", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/util.py#L46-L59
train
metacloud/gilt
gilt/util.py
build_sh_cmd
def build_sh_cmd(cmd, cwd=None): """Build a `sh.Command` from a string. :param cmd: String with the command to convert. :param cwd: Optional path to use as working directory. :return: `sh.Command` """ args = cmd.split() return getattr(sh, args[0]).bake(_cwd=cwd, *args[1:])
python
def build_sh_cmd(cmd, cwd=None): """Build a `sh.Command` from a string. :param cmd: String with the command to convert. :param cwd: Optional path to use as working directory. :return: `sh.Command` """ args = cmd.split() return getattr(sh, args[0]).bake(_cwd=cwd, *args[1:])
[ "def", "build_sh_cmd", "(", "cmd", ",", "cwd", "=", "None", ")", ":", "args", "=", "cmd", ".", "split", "(", ")", "return", "getattr", "(", "sh", ",", "args", "[", "0", "]", ")", ".", "bake", "(", "_cwd", "=", "cwd", ",", "*", "args", "[", "1...
Build a `sh.Command` from a string. :param cmd: String with the command to convert. :param cwd: Optional path to use as working directory. :return: `sh.Command`
[ "Build", "a", "sh", ".", "Command", "from", "a", "string", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/util.py#L62-L70
train
metacloud/gilt
gilt/util.py
copy
def copy(src, dst): """ Handle the copying of a file or directory. The destination basedir _must_ exist. :param src: A string containing the path of the source to copy. If the source ends with a '/', will become a recursive directory copy of source. :param dst: A string containing the path t...
python
def copy(src, dst): """ Handle the copying of a file or directory. The destination basedir _must_ exist. :param src: A string containing the path of the source to copy. If the source ends with a '/', will become a recursive directory copy of source. :param dst: A string containing the path t...
[ "def", "copy", "(", "src", ",", "dst", ")", ":", "try", ":", "shutil", ".", "copytree", "(", "src", ",", "dst", ")", "except", "OSError", "as", "exc", ":", "if", "exc", ".", "errno", "==", "errno", ".", "ENOTDIR", ":", "shutil", ".", "copy", "(",...
Handle the copying of a file or directory. The destination basedir _must_ exist. :param src: A string containing the path of the source to copy. If the source ends with a '/', will become a recursive directory copy of source. :param dst: A string containing the path to the destination. If the ...
[ "Handle", "the", "copying", "of", "a", "file", "or", "directory", "." ]
234eec23fe2f8144369d0ec3b35ad2fef508b8d1
https://github.com/metacloud/gilt/blob/234eec23fe2f8144369d0ec3b35ad2fef508b8d1/gilt/util.py#L83-L101
train
yhat/db.py
db/table.py
Table.to_dict
def to_dict(self): """Serialize representation of the table for local caching.""" return {'schema': self.schema, 'name': self.name, 'columns': [col.to_dict() for col in self._columns], 'foreign_keys': self.foreign_keys.to_dict(), 'ref_keys': self.ref_keys.to_dict()}
python
def to_dict(self): """Serialize representation of the table for local caching.""" return {'schema': self.schema, 'name': self.name, 'columns': [col.to_dict() for col in self._columns], 'foreign_keys': self.foreign_keys.to_dict(), 'ref_keys': self.ref_keys.to_dict()}
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "'schema'", ":", "self", ".", "schema", ",", "'name'", ":", "self", ".", "name", ",", "'columns'", ":", "[", "col", ".", "to_dict", "(", ")", "for", "col", "in", "self", ".", "_columns", "]", ...
Serialize representation of the table for local caching.
[ "Serialize", "representation", "of", "the", "table", "for", "local", "caching", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/table.py#L348-L351
train
yhat/db.py
db/db.py
list_profiles
def list_profiles(): """ Lists all of the database profiles available Examples -------- No doctest, covered by unittest list_profiles() {'demo': {u'dbname': None, u'dbtype': u'sqlite', u'filename': u'/Users/glamp/repos/yhat/opensource/db.py/db/data/chinook.sqlite', u'host...
python
def list_profiles(): """ Lists all of the database profiles available Examples -------- No doctest, covered by unittest list_profiles() {'demo': {u'dbname': None, u'dbtype': u'sqlite', u'filename': u'/Users/glamp/repos/yhat/opensource/db.py/db/data/chinook.sqlite', u'host...
[ "def", "list_profiles", "(", ")", ":", "profiles", "=", "{", "}", "user", "=", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", "for", "f", "in", "os", ".", "listdir", "(", "user", ")", ":", "if", "f", ".", "startswith", "(", "\".db.py_\"",...
Lists all of the database profiles available Examples -------- No doctest, covered by unittest list_profiles() {'demo': {u'dbname': None, u'dbtype': u'sqlite', u'filename': u'/Users/glamp/repos/yhat/opensource/db.py/db/data/chinook.sqlite', u'hostname': u'localhost', u'pass...
[ "Lists", "all", "of", "the", "database", "profiles", "available" ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L1059-L1094
train
yhat/db.py
db/db.py
remove_profile
def remove_profile(name, s3=False): """ Removes a profile from your config """ user = os.path.expanduser("~") if s3: f = os.path.join(user, S3_PROFILE_ID + name) else: f = os.path.join(user, DBPY_PROFILE_ID + name) try: try: open(f) except: ...
python
def remove_profile(name, s3=False): """ Removes a profile from your config """ user = os.path.expanduser("~") if s3: f = os.path.join(user, S3_PROFILE_ID + name) else: f = os.path.join(user, DBPY_PROFILE_ID + name) try: try: open(f) except: ...
[ "def", "remove_profile", "(", "name", ",", "s3", "=", "False", ")", ":", "user", "=", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", "if", "s3", ":", "f", "=", "os", ".", "path", ".", "join", "(", "user", ",", "S3_PROFILE_ID", "+", "nam...
Removes a profile from your config
[ "Removes", "a", "profile", "from", "your", "config" ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L1097-L1114
train
yhat/db.py
db/db.py
DB.tables
def tables(self): """A lazy loaded reference to the table metadata for the DB.""" if len(self._tables) == 0: self.refresh_schema(self._exclude_system_tables, self._use_cache) return self._tables
python
def tables(self): """A lazy loaded reference to the table metadata for the DB.""" if len(self._tables) == 0: self.refresh_schema(self._exclude_system_tables, self._use_cache) return self._tables
[ "def", "tables", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_tables", ")", "==", "0", ":", "self", ".", "refresh_schema", "(", "self", ".", "_exclude_system_tables", ",", "self", ".", "_use_cache", ")", "return", "self", ".", "_tables" ]
A lazy loaded reference to the table metadata for the DB.
[ "A", "lazy", "loaded", "reference", "to", "the", "table", "metadata", "for", "the", "DB", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L262-L266
train
yhat/db.py
db/db.py
DB.save_credentials
def save_credentials(self, profile="default"): """ Save your database credentials so you don't have to save them in script. Parameters ---------- profile: str (optional) identifier/name for your database (i.e. "dw", "prod") from db import DB import p...
python
def save_credentials(self, profile="default"): """ Save your database credentials so you don't have to save them in script. Parameters ---------- profile: str (optional) identifier/name for your database (i.e. "dw", "prod") from db import DB import p...
[ "def", "save_credentials", "(", "self", ",", "profile", "=", "\"default\"", ")", ":", "f", "=", "profile_path", "(", "DBPY_PROFILE_ID", ",", "profile", ")", "dump_to_json", "(", "f", ",", "self", ".", "credentials", ")" ]
Save your database credentials so you don't have to save them in script. Parameters ---------- profile: str (optional) identifier/name for your database (i.e. "dw", "prod") from db import DB import pymysql db = DB(username="hank", password="foo", hostname="p...
[ "Save", "your", "database", "credentials", "so", "you", "don", "t", "have", "to", "save", "them", "in", "script", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L307-L329
train
yhat/db.py
db/db.py
DB.save_metadata
def save_metadata(self, profile="default"): """Save the database credentials, plus the database properties to your db.py profile.""" if len(self.tables) > 0: f = profile_path(DBPY_PROFILE_ID, profile) dump_to_json(f, self.to_dict())
python
def save_metadata(self, profile="default"): """Save the database credentials, plus the database properties to your db.py profile.""" if len(self.tables) > 0: f = profile_path(DBPY_PROFILE_ID, profile) dump_to_json(f, self.to_dict())
[ "def", "save_metadata", "(", "self", ",", "profile", "=", "\"default\"", ")", ":", "if", "len", "(", "self", ".", "tables", ")", ">", "0", ":", "f", "=", "profile_path", "(", "DBPY_PROFILE_ID", ",", "profile", ")", "dump_to_json", "(", "f", ",", "self"...
Save the database credentials, plus the database properties to your db.py profile.
[ "Save", "the", "database", "credentials", "plus", "the", "database", "properties", "to", "your", "db", ".", "py", "profile", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L338-L342
train
yhat/db.py
db/db.py
DB.credentials
def credentials(self): """Dict representation of all credentials for the database.""" if self.filename: db_filename = os.path.join(os.getcwd(), self.filename) else: db_filename = None return { "username": self.username, "password": self.pa...
python
def credentials(self): """Dict representation of all credentials for the database.""" if self.filename: db_filename = os.path.join(os.getcwd(), self.filename) else: db_filename = None return { "username": self.username, "password": self.pa...
[ "def", "credentials", "(", "self", ")", ":", "if", "self", ".", "filename", ":", "db_filename", "=", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "self", ".", "filename", ")", "else", ":", "db_filename", "=", "None", "re...
Dict representation of all credentials for the database.
[ "Dict", "representation", "of", "all", "credentials", "for", "the", "database", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L345-L363
train
yhat/db.py
db/db.py
DB.find_table
def find_table(self, search): """ Aggresively search through your database's schema for a table. Parameters ----------- search: str glob pattern for what you're looking for Examples ---------- >>> from db import DemoDB >>> db = DemoDB(...
python
def find_table(self, search): """ Aggresively search through your database's schema for a table. Parameters ----------- search: str glob pattern for what you're looking for Examples ---------- >>> from db import DemoDB >>> db = DemoDB(...
[ "def", "find_table", "(", "self", ",", "search", ")", ":", "tables", "=", "[", "]", "for", "table", "in", "self", ".", "tables", ":", "if", "glob", ".", "fnmatch", ".", "fnmatch", "(", "table", ".", "name", ",", "search", ")", ":", "tables", ".", ...
Aggresively search through your database's schema for a table. Parameters ----------- search: str glob pattern for what you're looking for Examples ---------- >>> from db import DemoDB >>> db = DemoDB() >>> db.find_table("A*") +-------...
[ "Aggresively", "search", "through", "your", "database", "s", "schema", "for", "a", "table", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L365-L394
train
yhat/db.py
db/db.py
DB.find_column
def find_column(self, search, data_type=None): """ Aggresively search through your database's schema for a column. Parameters ----------- search: str glob pattern for what you're looking for data_type: str, list (optional) specify which data type(s)...
python
def find_column(self, search, data_type=None): """ Aggresively search through your database's schema for a column. Parameters ----------- search: str glob pattern for what you're looking for data_type: str, list (optional) specify which data type(s)...
[ "def", "find_column", "(", "self", ",", "search", ",", "data_type", "=", "None", ")", ":", "if", "isinstance", "(", "data_type", ",", "str", ")", ":", "data_type", "=", "[", "data_type", "]", "cols", "=", "[", "]", "for", "table", "in", "self", ".", ...
Aggresively search through your database's schema for a column. Parameters ----------- search: str glob pattern for what you're looking for data_type: str, list (optional) specify which data type(s) you want to return Examples ---------- >>...
[ "Aggresively", "search", "through", "your", "database", "s", "schema", "for", "a", "column", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L396-L508
train
yhat/db.py
db/db.py
DB.query
def query(self, q, data=None, union=True, limit=None): """ Query your database with a raw string. Parameters ---------- q: str Query string to execute data: list, dict Optional argument for handlebars-queries. Data will be passed to the ...
python
def query(self, q, data=None, union=True, limit=None): """ Query your database with a raw string. Parameters ---------- q: str Query string to execute data: list, dict Optional argument for handlebars-queries. Data will be passed to the ...
[ "def", "query", "(", "self", ",", "q", ",", "data", "=", "None", ",", "union", "=", "True", ",", "limit", "=", "None", ")", ":", "if", "data", ":", "q", "=", "self", ".", "_apply_handlebars", "(", "q", ",", "data", ",", "union", ")", "if", "lim...
Query your database with a raw string. Parameters ---------- q: str Query string to execute data: list, dict Optional argument for handlebars-queries. Data will be passed to the template and rendered using handlebars. union: bool W...
[ "Query", "your", "database", "with", "a", "raw", "string", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L541-L702
train
yhat/db.py
db/db.py
DB.query_from_file
def query_from_file(self, filename, data=None, union=True, limit=None): """ Query your database from a file. Parameters ---------- filename: str A SQL script data: list, dict Optional argument for handlebars-queries. Data will be passed to the ...
python
def query_from_file(self, filename, data=None, union=True, limit=None): """ Query your database from a file. Parameters ---------- filename: str A SQL script data: list, dict Optional argument for handlebars-queries. Data will be passed to the ...
[ "def", "query_from_file", "(", "self", ",", "filename", ",", "data", "=", "None", ",", "union", "=", "True", ",", "limit", "=", "None", ")", ":", "with", "open", "(", "filename", ")", "as", "fp", ":", "q", "=", "fp", ".", "read", "(", ")", "retur...
Query your database from a file. Parameters ---------- filename: str A SQL script data: list, dict Optional argument for handlebars-queries. Data will be passed to the template and rendered using handlebars. union: bool Whether or ...
[ "Query", "your", "database", "from", "a", "file", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L704-L771
train
yhat/db.py
db/db.py
DB.refresh_schema
def refresh_schema(self, exclude_system_tables=True, use_cache=False): """ Pulls your database's schema again and looks for any new tables and columns. """ col_meta, table_meta = self._get_db_metadata(exclude_system_tables, use_cache) tables = self._gen_tables_from_col_t...
python
def refresh_schema(self, exclude_system_tables=True, use_cache=False): """ Pulls your database's schema again and looks for any new tables and columns. """ col_meta, table_meta = self._get_db_metadata(exclude_system_tables, use_cache) tables = self._gen_tables_from_col_t...
[ "def", "refresh_schema", "(", "self", ",", "exclude_system_tables", "=", "True", ",", "use_cache", "=", "False", ")", ":", "col_meta", ",", "table_meta", "=", "self", ".", "_get_db_metadata", "(", "exclude_system_tables", ",", "use_cache", ")", "tables", "=", ...
Pulls your database's schema again and looks for any new tables and columns.
[ "Pulls", "your", "database", "s", "schema", "again", "and", "looks", "for", "any", "new", "tables", "and", "columns", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L809-L854
train
yhat/db.py
db/db.py
DB.to_dict
def to_dict(self): """Dict representation of the database as credentials plus tables dict representation.""" db_dict = self.credentials db_dict.update(self.tables.to_dict()) return db_dict
python
def to_dict(self): """Dict representation of the database as credentials plus tables dict representation.""" db_dict = self.credentials db_dict.update(self.tables.to_dict()) return db_dict
[ "def", "to_dict", "(", "self", ")", ":", "db_dict", "=", "self", ".", "credentials", "db_dict", ".", "update", "(", "self", ".", "tables", ".", "to_dict", "(", ")", ")", "return", "db_dict" ]
Dict representation of the database as credentials plus tables dict representation.
[ "Dict", "representation", "of", "the", "database", "as", "credentials", "plus", "tables", "dict", "representation", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/db.py#L1052-L1056
train
yhat/db.py
db/utils.py
profile_path
def profile_path(profile_id, profile): """Create full path to given provide for the current user.""" user = os.path.expanduser("~") return os.path.join(user, profile_id + profile)
python
def profile_path(profile_id, profile): """Create full path to given provide for the current user.""" user = os.path.expanduser("~") return os.path.join(user, profile_id + profile)
[ "def", "profile_path", "(", "profile_id", ",", "profile", ")", ":", "user", "=", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", "return", "os", ".", "path", ".", "join", "(", "user", ",", "profile_id", "+", "profile", ")" ]
Create full path to given provide for the current user.
[ "Create", "full", "path", "to", "given", "provide", "for", "the", "current", "user", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/utils.py#L5-L8
train
yhat/db.py
db/utils.py
load_from_json
def load_from_json(file_path): """Load the stored data from json, and return as a dict.""" if os.path.exists(file_path): raw_data = open(file_path, 'rb').read() return json.loads(base64.decodestring(raw_data).decode('utf-8'))
python
def load_from_json(file_path): """Load the stored data from json, and return as a dict.""" if os.path.exists(file_path): raw_data = open(file_path, 'rb').read() return json.loads(base64.decodestring(raw_data).decode('utf-8'))
[ "def", "load_from_json", "(", "file_path", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "file_path", ")", ":", "raw_data", "=", "open", "(", "file_path", ",", "'rb'", ")", ".", "read", "(", ")", "return", "json", ".", "loads", "(", "base64"...
Load the stored data from json, and return as a dict.
[ "Load", "the", "stored", "data", "from", "json", "and", "return", "as", "a", "dict", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/utils.py#L13-L17
train
yhat/db.py
db/s3.py
S3.save_credentials
def save_credentials(self, profile): """ Saves credentials to a dotfile so you can open them grab them later. Parameters ---------- profile: str name for your profile (i.e. "dev", "prod") """ filename = profile_path(S3_PROFILE_ID, profile) cre...
python
def save_credentials(self, profile): """ Saves credentials to a dotfile so you can open them grab them later. Parameters ---------- profile: str name for your profile (i.e. "dev", "prod") """ filename = profile_path(S3_PROFILE_ID, profile) cre...
[ "def", "save_credentials", "(", "self", ",", "profile", ")", ":", "filename", "=", "profile_path", "(", "S3_PROFILE_ID", ",", "profile", ")", "creds", "=", "{", "\"access_key\"", ":", "self", ".", "access_key", ",", "\"secret_key\"", ":", "self", ".", "secre...
Saves credentials to a dotfile so you can open them grab them later. Parameters ---------- profile: str name for your profile (i.e. "dev", "prod")
[ "Saves", "credentials", "to", "a", "dotfile", "so", "you", "can", "open", "them", "grab", "them", "later", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/s3.py#L16-L30
train
yhat/db.py
db/column.py
Column.to_dict
def to_dict(self): """ Serialize representation of the column for local caching. """ return {'schema': self.schema, 'table': self.table, 'name': self.name, 'type': self.type}
python
def to_dict(self): """ Serialize representation of the column for local caching. """ return {'schema': self.schema, 'table': self.table, 'name': self.name, 'type': self.type}
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "'schema'", ":", "self", ".", "schema", ",", "'table'", ":", "self", ".", "table", ",", "'name'", ":", "self", ".", "name", ",", "'type'", ":", "self", ".", "type", "}" ]
Serialize representation of the column for local caching.
[ "Serialize", "representation", "of", "the", "column", "for", "local", "caching", "." ]
df2dbb8ef947c2d4253d31f29eb58c4084daffc5
https://github.com/yhat/db.py/blob/df2dbb8ef947c2d4253d31f29eb58c4084daffc5/db/column.py#L192-L196
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.rate_limit
def rate_limit(self, rate_limit): """ Turn on or off rate limiting """ self._rate_limit = bool(rate_limit) self._rate_limit_last_call = None self.clear_memoized()
python
def rate_limit(self, rate_limit): """ Turn on or off rate limiting """ self._rate_limit = bool(rate_limit) self._rate_limit_last_call = None self.clear_memoized()
[ "def", "rate_limit", "(", "self", ",", "rate_limit", ")", ":", "self", ".", "_rate_limit", "=", "bool", "(", "rate_limit", ")", "self", ".", "_rate_limit_last_call", "=", "None", "self", ".", "clear_memoized", "(", ")" ]
Turn on or off rate limiting
[ "Turn", "on", "or", "off", "rate", "limiting" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L136-L140
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.language
def language(self, lang): """ Set the language to use; attempts to change the API URL """ lang = lang.lower() if self._lang == lang: return url = self._api_url tmp = url.replace("/{0}.".format(self._lang), "/{0}.".format(lang)) self._api_url = tmp se...
python
def language(self, lang): """ Set the language to use; attempts to change the API URL """ lang = lang.lower() if self._lang == lang: return url = self._api_url tmp = url.replace("/{0}.".format(self._lang), "/{0}.".format(lang)) self._api_url = tmp se...
[ "def", "language", "(", "self", ",", "lang", ")", ":", "lang", "=", "lang", ".", "lower", "(", ")", "if", "self", ".", "_lang", "==", "lang", ":", "return", "url", "=", "self", ".", "_api_url", "tmp", "=", "url", ".", "replace", "(", "\"/{0}.\"", ...
Set the language to use; attempts to change the API URL
[ "Set", "the", "language", "to", "use", ";", "attempts", "to", "change", "the", "API", "URL" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L197-L208
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.refresh_interval
def refresh_interval(self, refresh_interval): """ Set the new cache refresh interval """ if isinstance(refresh_interval, int) and refresh_interval > 0: self._refresh_interval = refresh_interval else: self._refresh_interval = None
python
def refresh_interval(self, refresh_interval): """ Set the new cache refresh interval """ if isinstance(refresh_interval, int) and refresh_interval > 0: self._refresh_interval = refresh_interval else: self._refresh_interval = None
[ "def", "refresh_interval", "(", "self", ",", "refresh_interval", ")", ":", "if", "isinstance", "(", "refresh_interval", ",", "int", ")", "and", "refresh_interval", ">", "0", ":", "self", ".", "_refresh_interval", "=", "refresh_interval", "else", ":", "self", "...
Set the new cache refresh interval
[ "Set", "the", "new", "cache", "refresh", "interval" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L262-L267
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.login
def login(self, username, password, strict=True): """ Login as specified user Args: username (str): The username to log in with password (str): The password for the user strict (bool): `True` to thow an error on failure Returns: ...
python
def login(self, username, password, strict=True): """ Login as specified user Args: username (str): The username to log in with password (str): The password for the user strict (bool): `True` to thow an error on failure Returns: ...
[ "def", "login", "(", "self", ",", "username", ",", "password", ",", "strict", "=", "True", ")", ":", "# get login token", "params", "=", "{", "\"action\"", ":", "\"query\"", ",", "\"meta\"", ":", "\"tokens\"", ",", "\"type\"", ":", "\"login\"", ",", "\"for...
Login as specified user Args: username (str): The username to log in with password (str): The password for the user strict (bool): `True` to thow an error on failure Returns: bool: `True` if successfully logged in; `False` otherwis...
[ "Login", "as", "specified", "user" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L269-L314
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.set_api_url
def set_api_url(self, api_url="https://{lang}.wikipedia.org/w/api.php", lang="en"): """ Set the API URL and language Args: api_url (str): API URL to use lang (str): Language of the API URL Raises: :py:func:`mediawiki.exceptions.MediaWikiAP...
python
def set_api_url(self, api_url="https://{lang}.wikipedia.org/w/api.php", lang="en"): """ Set the API URL and language Args: api_url (str): API URL to use lang (str): Language of the API URL Raises: :py:func:`mediawiki.exceptions.MediaWikiAP...
[ "def", "set_api_url", "(", "self", ",", "api_url", "=", "\"https://{lang}.wikipedia.org/w/api.php\"", ",", "lang", "=", "\"en\"", ")", ":", "old_api_url", "=", "self", ".", "_api_url", "old_lang", "=", "self", ".", "_lang", "self", ".", "_lang", "=", "lang", ...
Set the API URL and language Args: api_url (str): API URL to use lang (str): Language of the API URL Raises: :py:func:`mediawiki.exceptions.MediaWikiAPIURLError`: if the \ url is not a valid MediaWiki site
[ "Set", "the", "API", "URL", "and", "language" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L317-L338
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki._reset_session
def _reset_session(self): """ Set session information """ headers = {"User-Agent": self._user_agent} self._session = requests.Session() self._session.headers.update(headers) self._is_logged_in = False
python
def _reset_session(self): """ Set session information """ headers = {"User-Agent": self._user_agent} self._session = requests.Session() self._session.headers.update(headers) self._is_logged_in = False
[ "def", "_reset_session", "(", "self", ")", ":", "headers", "=", "{", "\"User-Agent\"", ":", "self", ".", "_user_agent", "}", "self", ".", "_session", "=", "requests", ".", "Session", "(", ")", "self", ".", "_session", ".", "headers", ".", "update", "(", ...
Set session information
[ "Set", "session", "information" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L340-L345
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.random
def random(self, pages=1): """ Request a random page title or list of random titles Args: pages (int): Number of random pages to return Returns: list or int: A list of random page titles or a random page \ title if pages = 1 "...
python
def random(self, pages=1): """ Request a random page title or list of random titles Args: pages (int): Number of random pages to return Returns: list or int: A list of random page titles or a random page \ title if pages = 1 "...
[ "def", "random", "(", "self", ",", "pages", "=", "1", ")", ":", "if", "pages", "is", "None", "or", "pages", "<", "1", ":", "raise", "ValueError", "(", "\"Number of pages must be greater than 0\"", ")", "query_params", "=", "{", "\"list\"", ":", "\"random\"",...
Request a random page title or list of random titles Args: pages (int): Number of random pages to return Returns: list or int: A list of random page titles or a random page \ title if pages = 1
[ "Request", "a", "random", "page", "title", "or", "list", "of", "random", "titles" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L371-L389
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.search
def search(self, query, results=10, suggestion=False): """ Search for similar titles Args: query (str): Page title results (int): Number of pages to return suggestion (bool): Use suggestion Returns: tuple or list: tuple (li...
python
def search(self, query, results=10, suggestion=False): """ Search for similar titles Args: query (str): Page title results (int): Number of pages to return suggestion (bool): Use suggestion Returns: tuple or list: tuple (li...
[ "def", "search", "(", "self", ",", "query", ",", "results", "=", "10", ",", "suggestion", "=", "False", ")", ":", "self", ".", "_check_query", "(", "query", ",", "\"Query must be specified\"", ")", "search_params", "=", "{", "\"list\"", ":", "\"search\"", ...
Search for similar titles Args: query (str): Page title results (int): Number of pages to return suggestion (bool): Use suggestion Returns: tuple or list: tuple (list results, suggestion) if \ suggest...
[ "Search", "for", "similar", "titles" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L392-L426
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.suggest
def suggest(self, query): """ Gather suggestions based on the provided title or None if no suggestions found Args: query (str): Page title Returns: String or None: Suggested page title or **None** if no \ sugges...
python
def suggest(self, query): """ Gather suggestions based on the provided title or None if no suggestions found Args: query (str): Page title Returns: String or None: Suggested page title or **None** if no \ sugges...
[ "def", "suggest", "(", "self", ",", "query", ")", ":", "res", ",", "suggest", "=", "self", ".", "search", "(", "query", ",", "results", "=", "1", ",", "suggestion", "=", "True", ")", "try", ":", "title", "=", "suggest", "or", "res", "[", "0", "]"...
Gather suggestions based on the provided title or None if no suggestions found Args: query (str): Page title Returns: String or None: Suggested page title or **None** if no \ suggestion found
[ "Gather", "suggestions", "based", "on", "the", "provided", "title", "or", "None", "if", "no", "suggestions", "found" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L429-L443
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.geosearch
def geosearch( self, latitude=None, longitude=None, radius=1000, title=None, auto_suggest=True, results=10, ): """ Search for pages that relate to the provided geocoords or near the page Args: latitude (Decimal ...
python
def geosearch( self, latitude=None, longitude=None, radius=1000, title=None, auto_suggest=True, results=10, ): """ Search for pages that relate to the provided geocoords or near the page Args: latitude (Decimal ...
[ "def", "geosearch", "(", "self", ",", "latitude", "=", "None", ",", "longitude", "=", "None", ",", "radius", "=", "1000", ",", "title", "=", "None", ",", "auto_suggest", "=", "True", ",", "results", "=", "10", ",", ")", ":", "def", "test_lat_long", "...
Search for pages that relate to the provided geocoords or near the page Args: latitude (Decimal or None): Latitude geocoord; must be \ coercable to decimal longitude (Decimal or None): Longitude geocoord; must be \ ...
[ "Search", "for", "pages", "that", "relate", "to", "the", "provided", "geocoords", "or", "near", "the", "page" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L446-L505
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.opensearch
def opensearch(self, query, results=10, redirect=True): """ Execute a MediaWiki opensearch request, similar to search box suggestions and conforming to the OpenSearch specification Args: query (str): Title to search for results (int): Number of pages with...
python
def opensearch(self, query, results=10, redirect=True): """ Execute a MediaWiki opensearch request, similar to search box suggestions and conforming to the OpenSearch specification Args: query (str): Title to search for results (int): Number of pages with...
[ "def", "opensearch", "(", "self", ",", "query", ",", "results", "=", "10", ",", "redirect", "=", "True", ")", ":", "self", ".", "_check_query", "(", "query", ",", "\"Query must be specified\"", ")", "query_params", "=", "{", "\"action\"", ":", "\"opensearch\...
Execute a MediaWiki opensearch request, similar to search box suggestions and conforming to the OpenSearch specification Args: query (str): Title to search for results (int): Number of pages within the radius to return redirect (bool): If **False*...
[ "Execute", "a", "MediaWiki", "opensearch", "request", "similar", "to", "search", "box", "suggestions", "and", "conforming", "to", "the", "OpenSearch", "specification" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L508-L540
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.prefixsearch
def prefixsearch(self, prefix, results=10): """ Perform a prefix search using the provided prefix string Args: prefix (str): Prefix string to use for search results (int): Number of pages with the prefix to return Returns: list: List of pa...
python
def prefixsearch(self, prefix, results=10): """ Perform a prefix search using the provided prefix string Args: prefix (str): Prefix string to use for search results (int): Number of pages with the prefix to return Returns: list: List of pa...
[ "def", "prefixsearch", "(", "self", ",", "prefix", ",", "results", "=", "10", ")", ":", "self", ".", "_check_query", "(", "prefix", ",", "\"Prefix must be specified\"", ")", "query_params", "=", "{", "\"list\"", ":", "\"prefixsearch\"", ",", "\"pssearch\"", ":...
Perform a prefix search using the provided prefix string Args: prefix (str): Prefix string to use for search results (int): Number of pages with the prefix to return Returns: list: List of page titles Note: **Per the do...
[ "Perform", "a", "prefix", "search", "using", "the", "provided", "prefix", "string" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L543-L572
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.summary
def summary(self, title, sentences=0, chars=0, auto_suggest=True, redirect=True): """ Get the summary for the title in question Args: title (str): Page title to summarize sentences (int): Number of sentences to return in summary chars (int): Number of...
python
def summary(self, title, sentences=0, chars=0, auto_suggest=True, redirect=True): """ Get the summary for the title in question Args: title (str): Page title to summarize sentences (int): Number of sentences to return in summary chars (int): Number of...
[ "def", "summary", "(", "self", ",", "title", ",", "sentences", "=", "0", ",", "chars", "=", "0", ",", "auto_suggest", "=", "True", ",", "redirect", "=", "True", ")", ":", "page_info", "=", "self", ".", "page", "(", "title", ",", "auto_suggest", "=", ...
Get the summary for the title in question Args: title (str): Page title to summarize sentences (int): Number of sentences to return in summary chars (int): Number of characters to return in summary auto_suggest (bool): Run auto-suggest on titl...
[ "Get", "the", "summary", "for", "the", "title", "in", "question" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L575-L591
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.categorytree
def categorytree(self, category, depth=5): """ Generate the Category Tree for the given categories Args: category(str or list of strings): Category name(s) depth(int): Depth to traverse the tree Returns: dict: Category tree structure ...
python
def categorytree(self, category, depth=5): """ Generate the Category Tree for the given categories Args: category(str or list of strings): Category name(s) depth(int): Depth to traverse the tree Returns: dict: Category tree structure ...
[ "def", "categorytree", "(", "self", ",", "category", ",", "depth", "=", "5", ")", ":", "def", "__cat_tree_rec", "(", "cat", ",", "depth", ",", "tree", ",", "level", ",", "categories", ",", "links", ")", ":", "\"\"\" recursive function to build out the tree \"\...
Generate the Category Tree for the given categories Args: category(str or list of strings): Category name(s) depth(int): Depth to traverse the tree Returns: dict: Category tree structure Note: Set depth to **None** to g...
[ "Generate", "the", "Category", "Tree", "for", "the", "given", "categories" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L662-L770
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.page
def page( self, title=None, pageid=None, auto_suggest=True, redirect=True, preload=False ): """ Get MediaWiki page based on the provided title or pageid Args: title (str): Page title pageid (int): MediaWiki page identifier auto-suggest (bo...
python
def page( self, title=None, pageid=None, auto_suggest=True, redirect=True, preload=False ): """ Get MediaWiki page based on the provided title or pageid Args: title (str): Page title pageid (int): MediaWiki page identifier auto-suggest (bo...
[ "def", "page", "(", "self", ",", "title", "=", "None", ",", "pageid", "=", "None", ",", "auto_suggest", "=", "True", ",", "redirect", "=", "True", ",", "preload", "=", "False", ")", ":", "if", "(", "title", "is", "None", "or", "title", ".", "strip"...
Get MediaWiki page based on the provided title or pageid Args: title (str): Page title pageid (int): MediaWiki page identifier auto-suggest (bool): **True:** Allow page title auto-suggest redirect (bool): **True:** Follow page redirects ...
[ "Get", "MediaWiki", "page", "based", "on", "the", "provided", "title", "or", "pageid" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L772-L802
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki.wiki_request
def wiki_request(self, params): """ Make a request to the MediaWiki API using the given search parameters Args: params (dict): Request parameters Returns: A parsed dict of the JSON response Note: Useful when wanting...
python
def wiki_request(self, params): """ Make a request to the MediaWiki API using the given search parameters Args: params (dict): Request parameters Returns: A parsed dict of the JSON response Note: Useful when wanting...
[ "def", "wiki_request", "(", "self", ",", "params", ")", ":", "params", "[", "\"format\"", "]", "=", "\"json\"", "if", "\"action\"", "not", "in", "params", ":", "params", "[", "\"action\"", "]", "=", "\"query\"", "limit", "=", "self", ".", "_rate_limit", ...
Make a request to the MediaWiki API using the given search parameters Args: params (dict): Request parameters Returns: A parsed dict of the JSON response Note: Useful when wanting to query the MediaWiki site for some \ ...
[ "Make", "a", "request", "to", "the", "MediaWiki", "API", "using", "the", "given", "search", "parameters" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L804-L832
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki._get_site_info
def _get_site_info(self): """ Parse out the Wikimedia site information including API Version and Extensions """ response = self.wiki_request( {"meta": "siteinfo", "siprop": "extensions|general"} ) # parse what we need out here! query = response.get("query", N...
python
def _get_site_info(self): """ Parse out the Wikimedia site information including API Version and Extensions """ response = self.wiki_request( {"meta": "siteinfo", "siprop": "extensions|general"} ) # parse what we need out here! query = response.get("query", N...
[ "def", "_get_site_info", "(", "self", ")", ":", "response", "=", "self", ".", "wiki_request", "(", "{", "\"meta\"", ":", "\"siteinfo\"", ",", "\"siprop\"", ":", "\"extensions|general\"", "}", ")", "# parse what we need out here!", "query", "=", "response", ".", ...
Parse out the Wikimedia site information including API Version and Extensions
[ "Parse", "out", "the", "Wikimedia", "site", "information", "including", "API", "Version", "and", "Extensions" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L835-L869
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki._check_error_response
def _check_error_response(response, query): """ check for default error messages and throw correct exception """ if "error" in response: http_error = ["HTTP request timed out.", "Pool queue is full"] geo_error = [ "Page coordinates unknown.", "One ...
python
def _check_error_response(response, query): """ check for default error messages and throw correct exception """ if "error" in response: http_error = ["HTTP request timed out.", "Pool queue is full"] geo_error = [ "Page coordinates unknown.", "One ...
[ "def", "_check_error_response", "(", "response", ",", "query", ")", ":", "if", "\"error\"", "in", "response", ":", "http_error", "=", "[", "\"HTTP request timed out.\"", ",", "\"Pool queue is full\"", "]", "geo_error", "=", "[", "\"Page coordinates unknown.\"", ",", ...
check for default error messages and throw correct exception
[ "check", "for", "default", "error", "messages", "and", "throw", "correct", "exception" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L874-L889
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki._get_response
def _get_response(self, params): """ wrap the call to the requests package """ return self._session.get( self._api_url, params=params, timeout=self._timeout ).json(encoding="utf8")
python
def _get_response(self, params): """ wrap the call to the requests package """ return self._session.get( self._api_url, params=params, timeout=self._timeout ).json(encoding="utf8")
[ "def", "_get_response", "(", "self", ",", "params", ")", ":", "return", "self", ".", "_session", ".", "get", "(", "self", ".", "_api_url", ",", "params", "=", "params", ",", "timeout", "=", "self", ".", "_timeout", ")", ".", "json", "(", "encoding", ...
wrap the call to the requests package
[ "wrap", "the", "call", "to", "the", "requests", "package" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L897-L901
train
barrust/mediawiki
mediawiki/mediawiki.py
MediaWiki._post_response
def _post_response(self, params): """ wrap a post call to the requests package """ return self._session.post( self._api_url, data=params, timeout=self._timeout ).json(encoding="utf8")
python
def _post_response(self, params): """ wrap a post call to the requests package """ return self._session.post( self._api_url, data=params, timeout=self._timeout ).json(encoding="utf8")
[ "def", "_post_response", "(", "self", ",", "params", ")", ":", "return", "self", ".", "_session", ".", "post", "(", "self", ".", "_api_url", ",", "data", "=", "params", ",", "timeout", "=", "self", ".", "_timeout", ")", ".", "json", "(", "encoding", ...
wrap a post call to the requests package
[ "wrap", "a", "post", "call", "to", "the", "requests", "package" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L903-L907
train
barrust/mediawiki
mediawiki/utilities.py
parse_all_arguments
def parse_all_arguments(func): """ determine all positional and named arguments as a dict """ args = dict() if sys.version_info < (3, 0): func_args = inspect.getargspec(func) if func_args.defaults is not None: val = len(func_args.defaults) for i, itm in enumerate(func...
python
def parse_all_arguments(func): """ determine all positional and named arguments as a dict """ args = dict() if sys.version_info < (3, 0): func_args = inspect.getargspec(func) if func_args.defaults is not None: val = len(func_args.defaults) for i, itm in enumerate(func...
[ "def", "parse_all_arguments", "(", "func", ")", ":", "args", "=", "dict", "(", ")", "if", "sys", ".", "version_info", "<", "(", "3", ",", "0", ")", ":", "func_args", "=", "inspect", ".", "getargspec", "(", "func", ")", "if", "func_args", ".", "defaul...
determine all positional and named arguments as a dict
[ "determine", "all", "positional", "and", "named", "arguments", "as", "a", "dict" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/utilities.py#L11-L26
train
barrust/mediawiki
mediawiki/utilities.py
str_or_unicode
def str_or_unicode(text): """ handle python 3 unicode and python 2.7 byte strings """ encoding = sys.stdout.encoding if sys.version_info > (3, 0): return text.encode(encoding).decode(encoding) return text.encode(encoding)
python
def str_or_unicode(text): """ handle python 3 unicode and python 2.7 byte strings """ encoding = sys.stdout.encoding if sys.version_info > (3, 0): return text.encode(encoding).decode(encoding) return text.encode(encoding)
[ "def", "str_or_unicode", "(", "text", ")", ":", "encoding", "=", "sys", ".", "stdout", ".", "encoding", "if", "sys", ".", "version_info", ">", "(", "3", ",", "0", ")", ":", "return", "text", ".", "encode", "(", "encoding", ")", ".", "decode", "(", ...
handle python 3 unicode and python 2.7 byte strings
[ "handle", "python", "3", "unicode", "and", "python", "2", ".", "7", "byte", "strings" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/utilities.py#L78-L83
train
barrust/mediawiki
mediawiki/utilities.py
is_relative_url
def is_relative_url(url): """ simple method to determine if a url is relative or absolute """ if url.startswith("#"): return None if url.find("://") > 0 or url.startswith("//"): # either 'http(s)://...' or '//cdn...' and therefore absolute return False return True
python
def is_relative_url(url): """ simple method to determine if a url is relative or absolute """ if url.startswith("#"): return None if url.find("://") > 0 or url.startswith("//"): # either 'http(s)://...' or '//cdn...' and therefore absolute return False return True
[ "def", "is_relative_url", "(", "url", ")", ":", "if", "url", ".", "startswith", "(", "\"#\"", ")", ":", "return", "None", "if", "url", ".", "find", "(", "\"://\"", ")", ">", "0", "or", "url", ".", "startswith", "(", "\"//\"", ")", ":", "# either 'htt...
simple method to determine if a url is relative or absolute
[ "simple", "method", "to", "determine", "if", "a", "url", "is", "relative", "or", "absolute" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/utilities.py#L86-L93
train
barrust/mediawiki
setup.py
read_file
def read_file(filepath): """ read the file """ with io.open(filepath, "r") as filepointer: res = filepointer.read() return res
python
def read_file(filepath): """ read the file """ with io.open(filepath, "r") as filepointer: res = filepointer.read() return res
[ "def", "read_file", "(", "filepath", ")", ":", "with", "io", ".", "open", "(", "filepath", ",", "\"r\"", ")", "as", "filepointer", ":", "res", "=", "filepointer", ".", "read", "(", ")", "return", "res" ]
read the file
[ "read", "the", "file" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/setup.py#L14-L18
train
barrust/mediawiki
mediawiki/mediawikipage.py
MediaWikiPage._pull_content_revision_parent
def _pull_content_revision_parent(self): """ combine the pulling of these three properties """ if self._revision_id is None: query_params = { "prop": "extracts|revisions", "explaintext": "", "rvprop": "ids", } query_par...
python
def _pull_content_revision_parent(self): """ combine the pulling of these three properties """ if self._revision_id is None: query_params = { "prop": "extracts|revisions", "explaintext": "", "rvprop": "ids", } query_par...
[ "def", "_pull_content_revision_parent", "(", "self", ")", ":", "if", "self", ".", "_revision_id", "is", "None", ":", "query_params", "=", "{", "\"prop\"", ":", "\"extracts|revisions\"", ",", "\"explaintext\"", ":", "\"\"", ",", "\"rvprop\"", ":", "\"ids\"", ",",...
combine the pulling of these three properties
[ "combine", "the", "pulling", "of", "these", "three", "properties" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawikipage.py#L127-L142
train
barrust/mediawiki
mediawiki/mediawikipage.py
MediaWikiPage.section
def section(self, section_title): """ Plain text section content Args: section_title (str): Name of the section to pull Returns: str: The content of the section Note: Returns **None** if section title is not found; only text \ ...
python
def section(self, section_title): """ Plain text section content Args: section_title (str): Name of the section to pull Returns: str: The content of the section Note: Returns **None** if section title is not found; only text \ ...
[ "def", "section", "(", "self", ",", "section_title", ")", ":", "section", "=", "\"== {0} ==\"", ".", "format", "(", "section_title", ")", "try", ":", "content", "=", "self", ".", "content", "index", "=", "content", ".", "index", "(", "section", ")", "+",...
Plain text section content Args: section_title (str): Name of the section to pull Returns: str: The content of the section Note: Returns **None** if section title is not found; only text \ between title and next section...
[ "Plain", "text", "section", "content" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawikipage.py#L412-L447
train
barrust/mediawiki
mediawiki/mediawikipage.py
MediaWikiPage.parse_section_links
def parse_section_links(self, section_title): """ Parse all links within a section Args: section_title (str): Name of the section to pull Returns: list: List of (title, url) tuples Note: Returns **None** if section title is not...
python
def parse_section_links(self, section_title): """ Parse all links within a section Args: section_title (str): Name of the section to pull Returns: list: List of (title, url) tuples Note: Returns **None** if section title is not...
[ "def", "parse_section_links", "(", "self", ",", "section_title", ")", ":", "soup", "=", "BeautifulSoup", "(", "self", ".", "html", ",", "\"html.parser\"", ")", "headlines", "=", "soup", ".", "find_all", "(", "\"span\"", ",", "{", "\"class\"", ":", "\"mw-head...
Parse all links within a section Args: section_title (str): Name of the section to pull Returns: list: List of (title, url) tuples Note: Returns **None** if section title is not found Note: Side effect is to...
[ "Parse", "all", "links", "within", "a", "section" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawikipage.py#L449-L475
train
barrust/mediawiki
mediawiki/mediawikipage.py
MediaWikiPage.__load
def __load(self, redirect=True, preload=False): """ load the basic page information """ query_params = { "prop": "info|pageprops", "inprop": "url", "ppprop": "disambiguation", "redirects": "", } query_params.update(self.__title_query_param(...
python
def __load(self, redirect=True, preload=False): """ load the basic page information """ query_params = { "prop": "info|pageprops", "inprop": "url", "ppprop": "disambiguation", "redirects": "", } query_params.update(self.__title_query_param(...
[ "def", "__load", "(", "self", ",", "redirect", "=", "True", ",", "preload", "=", "False", ")", ":", "query_params", "=", "{", "\"prop\"", ":", "\"info|pageprops\"", ",", "\"inprop\"", ":", "\"url\"", ",", "\"ppprop\"", ":", "\"disambiguation\"", ",", "\"redi...
load the basic page information
[ "load", "the", "basic", "page", "information" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawikipage.py#L478-L507
train
barrust/mediawiki
mediawiki/mediawikipage.py
MediaWikiPage._raise_page_error
def _raise_page_error(self): """ raise the correct type of page error """ if hasattr(self, "title"): raise PageError(title=self.title) else: raise PageError(pageid=self.pageid)
python
def _raise_page_error(self): """ raise the correct type of page error """ if hasattr(self, "title"): raise PageError(title=self.title) else: raise PageError(pageid=self.pageid)
[ "def", "_raise_page_error", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "\"title\"", ")", ":", "raise", "PageError", "(", "title", "=", "self", ".", "title", ")", "else", ":", "raise", "PageError", "(", "pageid", "=", "self", ".", "pageid...
raise the correct type of page error
[ "raise", "the", "correct", "type", "of", "page", "error" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawikipage.py#L509-L514
train
barrust/mediawiki
mediawiki/mediawikipage.py
MediaWikiPage._raise_disambiguation_error
def _raise_disambiguation_error(self, page, pageid): """ parse and throw a disambiguation error """ query_params = { "prop": "revisions", "rvprop": "content", "rvparse": "", "rvlimit": 1, } query_params.update(self.__title_query_param()) ...
python
def _raise_disambiguation_error(self, page, pageid): """ parse and throw a disambiguation error """ query_params = { "prop": "revisions", "rvprop": "content", "rvparse": "", "rvlimit": 1, } query_params.update(self.__title_query_param()) ...
[ "def", "_raise_disambiguation_error", "(", "self", ",", "page", ",", "pageid", ")", ":", "query_params", "=", "{", "\"prop\"", ":", "\"revisions\"", ",", "\"rvprop\"", ":", "\"content\"", ",", "\"rvparse\"", ":", "\"\"", ",", "\"rvlimit\"", ":", "1", ",", "}...
parse and throw a disambiguation error
[ "parse", "and", "throw", "a", "disambiguation", "error" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawikipage.py#L516-L550
train
barrust/mediawiki
mediawiki/mediawikipage.py
MediaWikiPage._parse_section_links
def _parse_section_links(self, id_tag): """ given a section id, parse the links in the unordered list """ soup = BeautifulSoup(self.html, "html.parser") info = soup.find("span", {"id": id_tag}) all_links = list() if info is None: return all_links for node in...
python
def _parse_section_links(self, id_tag): """ given a section id, parse the links in the unordered list """ soup = BeautifulSoup(self.html, "html.parser") info = soup.find("span", {"id": id_tag}) all_links = list() if info is None: return all_links for node in...
[ "def", "_parse_section_links", "(", "self", ",", "id_tag", ")", ":", "soup", "=", "BeautifulSoup", "(", "self", ".", "html", ",", "\"html.parser\"", ")", "info", "=", "soup", ".", "find", "(", "\"span\"", ",", "{", "\"id\"", ":", "id_tag", "}", ")", "a...
given a section id, parse the links in the unordered list
[ "given", "a", "section", "id", "parse", "the", "links", "in", "the", "unordered", "list" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawikipage.py#L613-L639
train
barrust/mediawiki
mediawiki/mediawikipage.py
MediaWikiPage._parse_sections
def _parse_sections(self): """ parse sections and TOC """ def _list_to_dict(_dict, path, sec): tmp = _dict for elm in path[:-1]: tmp = tmp[elm] tmp[sec] = OrderedDict() self._sections = list() section_regexp = r"\n==* .* ==*\n" # '==...
python
def _parse_sections(self): """ parse sections and TOC """ def _list_to_dict(_dict, path, sec): tmp = _dict for elm in path[:-1]: tmp = tmp[elm] tmp[sec] = OrderedDict() self._sections = list() section_regexp = r"\n==* .* ==*\n" # '==...
[ "def", "_parse_sections", "(", "self", ")", ":", "def", "_list_to_dict", "(", "_dict", ",", "path", ",", "sec", ")", ":", "tmp", "=", "_dict", "for", "elm", "in", "path", "[", ":", "-", "1", "]", ":", "tmp", "=", "tmp", "[", "elm", "]", "tmp", ...
parse sections and TOC
[ "parse", "sections", "and", "TOC" ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawikipage.py#L654-L699
train
barrust/mediawiki
mediawiki/mediawikipage.py
MediaWikiPage.__pull_combined_properties
def __pull_combined_properties(self): """ something here... """ query_params = { "titles": self.title, "prop": "extracts|redirects|links|coordinates|categories|extlinks", "continue": dict(), # summary "explaintext": "", "exintro": ...
python
def __pull_combined_properties(self): """ something here... """ query_params = { "titles": self.title, "prop": "extracts|redirects|links|coordinates|categories|extlinks", "continue": dict(), # summary "explaintext": "", "exintro": ...
[ "def", "__pull_combined_properties", "(", "self", ")", ":", "query_params", "=", "{", "\"titles\"", ":", "self", ".", "title", ",", "\"prop\"", ":", "\"extracts|redirects|links|coordinates|categories|extlinks\"", ",", "\"continue\"", ":", "dict", "(", ")", ",", "# s...
something here...
[ "something", "here", "..." ]
292e0be6c752409062dceed325d74839caf16a9b
https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawikipage.py#L707-L803
train
domwillcode/yale-smart-alarm-client
yalesmartalarmclient/client.py
YaleSmartAlarmClient.is_armed
def is_armed(self): """Return True or False if the system is armed in any way""" alarm_code = self.get_armed_status() if alarm_code == YALE_STATE_ARM_FULL: return True if alarm_code == YALE_STATE_ARM_PARTIAL: return True return False
python
def is_armed(self): """Return True or False if the system is armed in any way""" alarm_code = self.get_armed_status() if alarm_code == YALE_STATE_ARM_FULL: return True if alarm_code == YALE_STATE_ARM_PARTIAL: return True return False
[ "def", "is_armed", "(", "self", ")", ":", "alarm_code", "=", "self", ".", "get_armed_status", "(", ")", "if", "alarm_code", "==", "YALE_STATE_ARM_FULL", ":", "return", "True", "if", "alarm_code", "==", "YALE_STATE_ARM_PARTIAL", ":", "return", "True", "return", ...
Return True or False if the system is armed in any way
[ "Return", "True", "or", "False", "if", "the", "system", "is", "armed", "in", "any", "way" ]
a33b6db31440b8611c63081e231597bf0629e098
https://github.com/domwillcode/yale-smart-alarm-client/blob/a33b6db31440b8611c63081e231597bf0629e098/yalesmartalarmclient/client.py#L110-L120
train
springload/draftjs_exporter
example.py
linkify
def linkify(props): """ Wrap plain URLs with link tags. """ match = props['match'] protocol = match.group(1) url = match.group(2) href = protocol + url if props['block']['type'] == BLOCK_TYPES.CODE: return href link_props = { 'href': href, } if href.startsw...
python
def linkify(props): """ Wrap plain URLs with link tags. """ match = props['match'] protocol = match.group(1) url = match.group(2) href = protocol + url if props['block']['type'] == BLOCK_TYPES.CODE: return href link_props = { 'href': href, } if href.startsw...
[ "def", "linkify", "(", "props", ")", ":", "match", "=", "props", "[", "'match'", "]", "protocol", "=", "match", ".", "group", "(", "1", ")", "url", "=", "match", ".", "group", "(", "2", ")", "href", "=", "protocol", "+", "url", "if", "props", "["...
Wrap plain URLs with link tags.
[ "Wrap", "plain", "URLs", "with", "link", "tags", "." ]
1e391a46f162740f90511cde1ef615858e8de5cb
https://github.com/springload/draftjs_exporter/blob/1e391a46f162740f90511cde1ef615858e8de5cb/example.py#L85-L104
train
springload/draftjs_exporter
draftjs_exporter/options.py
Options.for_kind
def for_kind(kind_map, type_, fallback_key): """ Create an Options object from any mapping. """ if type_ not in kind_map: if fallback_key not in kind_map: raise ConfigException('"%s" is not in the config and has no fallback' % type_) config = kind...
python
def for_kind(kind_map, type_, fallback_key): """ Create an Options object from any mapping. """ if type_ not in kind_map: if fallback_key not in kind_map: raise ConfigException('"%s" is not in the config and has no fallback' % type_) config = kind...
[ "def", "for_kind", "(", "kind_map", ",", "type_", ",", "fallback_key", ")", ":", "if", "type_", "not", "in", "kind_map", ":", "if", "fallback_key", "not", "in", "kind_map", ":", "raise", "ConfigException", "(", "'\"%s\" is not in the config and has no fallback'", ...
Create an Options object from any mapping.
[ "Create", "an", "Options", "object", "from", "any", "mapping", "." ]
1e391a46f162740f90511cde1ef615858e8de5cb
https://github.com/springload/draftjs_exporter/blob/1e391a46f162740f90511cde1ef615858e8de5cb/draftjs_exporter/options.py#L31-L51
train
springload/draftjs_exporter
draftjs_exporter/html.py
HTML.render
def render(self, content_state=None): """ Starts the export process on a given piece of content state. """ if content_state is None: content_state = {} blocks = content_state.get('blocks', []) wrapper_state = WrapperState(self.block_map, blocks) docum...
python
def render(self, content_state=None): """ Starts the export process on a given piece of content state. """ if content_state is None: content_state = {} blocks = content_state.get('blocks', []) wrapper_state = WrapperState(self.block_map, blocks) docum...
[ "def", "render", "(", "self", ",", "content_state", "=", "None", ")", ":", "if", "content_state", "is", "None", ":", "content_state", "=", "{", "}", "blocks", "=", "content_state", ".", "get", "(", "'blocks'", ",", "[", "]", ")", "wrapper_state", "=", ...
Starts the export process on a given piece of content state.
[ "Starts", "the", "export", "process", "on", "a", "given", "piece", "of", "content", "state", "." ]
1e391a46f162740f90511cde1ef615858e8de5cb
https://github.com/springload/draftjs_exporter/blob/1e391a46f162740f90511cde1ef615858e8de5cb/draftjs_exporter/html.py#L31-L59
train
springload/draftjs_exporter
draftjs_exporter/html.py
HTML.build_command_groups
def build_command_groups(self, block): """ Creates block modification commands, grouped by start index, with the text to apply them on. """ text = block['text'] commands = sorted(self.build_commands(block)) grouped = groupby(commands, Command.key) listed ...
python
def build_command_groups(self, block): """ Creates block modification commands, grouped by start index, with the text to apply them on. """ text = block['text'] commands = sorted(self.build_commands(block)) grouped = groupby(commands, Command.key) listed ...
[ "def", "build_command_groups", "(", "self", ",", "block", ")", ":", "text", "=", "block", "[", "'text'", "]", "commands", "=", "sorted", "(", "self", ".", "build_commands", "(", "block", ")", ")", "grouped", "=", "groupby", "(", "commands", ",", "Command...
Creates block modification commands, grouped by start index, with the text to apply them on.
[ "Creates", "block", "modification", "commands", "grouped", "by", "start", "index", "with", "the", "text", "to", "apply", "them", "on", "." ]
1e391a46f162740f90511cde1ef615858e8de5cb
https://github.com/springload/draftjs_exporter/blob/1e391a46f162740f90511cde1ef615858e8de5cb/draftjs_exporter/html.py#L95-L116
train
springload/draftjs_exporter
draftjs_exporter/html.py
HTML.build_commands
def build_commands(self, block): """ Build all of the manipulation commands for a given block. - One pair to set the text. - Multiple pairs for styles. - Multiple pairs for entities. """ text_commands = Command.start_stop('text', 0, len(block['text'])) sty...
python
def build_commands(self, block): """ Build all of the manipulation commands for a given block. - One pair to set the text. - Multiple pairs for styles. - Multiple pairs for entities. """ text_commands = Command.start_stop('text', 0, len(block['text'])) sty...
[ "def", "build_commands", "(", "self", ",", "block", ")", ":", "text_commands", "=", "Command", ".", "start_stop", "(", "'text'", ",", "0", ",", "len", "(", "block", "[", "'text'", "]", ")", ")", "style_commands", "=", "self", ".", "build_style_commands", ...
Build all of the manipulation commands for a given block. - One pair to set the text. - Multiple pairs for styles. - Multiple pairs for entities.
[ "Build", "all", "of", "the", "manipulation", "commands", "for", "a", "given", "block", ".", "-", "One", "pair", "to", "set", "the", "text", ".", "-", "Multiple", "pairs", "for", "styles", ".", "-", "Multiple", "pairs", "for", "entities", "." ]
1e391a46f162740f90511cde1ef615858e8de5cb
https://github.com/springload/draftjs_exporter/blob/1e391a46f162740f90511cde1ef615858e8de5cb/draftjs_exporter/html.py#L118-L129
train
sloria/doitlive
doitlive/cli.py
run
def run( commands, shell=None, prompt_template="default", speed=1, quiet=False, test_mode=False, commentecho=False, ): """Main function for "magic-running" a list of commands.""" if not quiet: secho("We'll do it live!", fg="red", bold=True) secho( "STARTIN...
python
def run( commands, shell=None, prompt_template="default", speed=1, quiet=False, test_mode=False, commentecho=False, ): """Main function for "magic-running" a list of commands.""" if not quiet: secho("We'll do it live!", fg="red", bold=True) secho( "STARTIN...
[ "def", "run", "(", "commands", ",", "shell", "=", "None", ",", "prompt_template", "=", "\"default\"", ",", "speed", "=", "1", ",", "quiet", "=", "False", ",", "test_mode", "=", "False", ",", "commentecho", "=", "False", ",", ")", ":", "if", "not", "q...
Main function for "magic-running" a list of commands.
[ "Main", "function", "for", "magic", "-", "running", "a", "list", "of", "commands", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/cli.py#L146-L251
train
sloria/doitlive
doitlive/cli.py
play
def play(quiet, session_file, shell, speed, prompt, commentecho): """Play a session file.""" run( session_file.readlines(), shell=shell, speed=speed, quiet=quiet, test_mode=TESTING, prompt_template=prompt, commentecho=commentecho, )
python
def play(quiet, session_file, shell, speed, prompt, commentecho): """Play a session file.""" run( session_file.readlines(), shell=shell, speed=speed, quiet=quiet, test_mode=TESTING, prompt_template=prompt, commentecho=commentecho, )
[ "def", "play", "(", "quiet", ",", "session_file", ",", "shell", ",", "speed", ",", "prompt", ",", "commentecho", ")", ":", "run", "(", "session_file", ".", "readlines", "(", ")", ",", "shell", "=", "shell", ",", "speed", "=", "speed", ",", "quiet", "...
Play a session file.
[ "Play", "a", "session", "file", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/cli.py#L419-L429
train
sloria/doitlive
doitlive/cli.py
demo
def demo(quiet, shell, speed, prompt, commentecho): """Run a demo doitlive session.""" run( DEMO, shell=shell, speed=speed, test_mode=TESTING, prompt_template=prompt, quiet=quiet, commentecho=commentecho, )
python
def demo(quiet, shell, speed, prompt, commentecho): """Run a demo doitlive session.""" run( DEMO, shell=shell, speed=speed, test_mode=TESTING, prompt_template=prompt, quiet=quiet, commentecho=commentecho, )
[ "def", "demo", "(", "quiet", ",", "shell", ",", "speed", ",", "prompt", ",", "commentecho", ")", ":", "run", "(", "DEMO", ",", "shell", "=", "shell", ",", "speed", "=", "speed", ",", "test_mode", "=", "TESTING", ",", "prompt_template", "=", "prompt", ...
Run a demo doitlive session.
[ "Run", "a", "demo", "doitlive", "session", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/cli.py#L442-L452
train
sloria/doitlive
doitlive/styling.py
echo
def echo( message=None, file=None, nl=True, err=False, color=None, carriage_return=False ): """ Patched click echo function. """ message = message or "" if carriage_return and nl: click_echo(message + "\r\n", file, False, err, color) elif carriage_return and not nl: click_ech...
python
def echo( message=None, file=None, nl=True, err=False, color=None, carriage_return=False ): """ Patched click echo function. """ message = message or "" if carriage_return and nl: click_echo(message + "\r\n", file, False, err, color) elif carriage_return and not nl: click_ech...
[ "def", "echo", "(", "message", "=", "None", ",", "file", "=", "None", ",", "nl", "=", "True", ",", "err", "=", "False", ",", "color", "=", "None", ",", "carriage_return", "=", "False", ")", ":", "message", "=", "message", "or", "\"\"", "if", "carri...
Patched click echo function.
[ "Patched", "click", "echo", "function", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/styling.py#L201-L213
train
sloria/doitlive
doitlive/keyboard.py
magictype
def magictype(text, prompt_template="default", speed=1): """Echo each character in ``text`` as keyboard characters are pressed. Characters are echo'd ``speed`` characters at a time. """ echo_prompt(prompt_template) cursor_position = 0 return_to_regular_type = False with raw_mode(): w...
python
def magictype(text, prompt_template="default", speed=1): """Echo each character in ``text`` as keyboard characters are pressed. Characters are echo'd ``speed`` characters at a time. """ echo_prompt(prompt_template) cursor_position = 0 return_to_regular_type = False with raw_mode(): w...
[ "def", "magictype", "(", "text", ",", "prompt_template", "=", "\"default\"", ",", "speed", "=", "1", ")", ":", "echo_prompt", "(", "prompt_template", ")", "cursor_position", "=", "0", "return_to_regular_type", "=", "False", "with", "raw_mode", "(", ")", ":", ...
Echo each character in ``text`` as keyboard characters are pressed. Characters are echo'd ``speed`` characters at a time.
[ "Echo", "each", "character", "in", "text", "as", "keyboard", "characters", "are", "pressed", ".", "Characters", "are", "echo", "d", "speed", "characters", "at", "a", "time", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/keyboard.py#L36-L75
train
sloria/doitlive
doitlive/keyboard.py
regulartype
def regulartype(prompt_template="default"): """Echo each character typed. Unlike magictype, this echos the characters the user is pressing. Returns: command_string | The command to be passed to the shell to run. This is | typed by the user. """ echo_prompt(prompt_templ...
python
def regulartype(prompt_template="default"): """Echo each character typed. Unlike magictype, this echos the characters the user is pressing. Returns: command_string | The command to be passed to the shell to run. This is | typed by the user. """ echo_prompt(prompt_templ...
[ "def", "regulartype", "(", "prompt_template", "=", "\"default\"", ")", ":", "echo_prompt", "(", "prompt_template", ")", "command_string", "=", "\"\"", "cursor_position", "=", "0", "with", "raw_mode", "(", ")", ":", "while", "True", ":", "in_char", "=", "getcha...
Echo each character typed. Unlike magictype, this echos the characters the user is pressing. Returns: command_string | The command to be passed to the shell to run. This is | typed by the user.
[ "Echo", "each", "character", "typed", ".", "Unlike", "magictype", "this", "echos", "the", "characters", "the", "user", "is", "pressing", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/keyboard.py#L134-L171
train
sloria/doitlive
doitlive/keyboard.py
regularrun
def regularrun( shell, prompt_template="default", aliases=None, envvars=None, extra_commands=None, speed=1, test_mode=False, commentecho=False, ): """Allow user to run their own live commands until CTRL-Z is pressed again. """ loop_again = True command_string = regulartyp...
python
def regularrun( shell, prompt_template="default", aliases=None, envvars=None, extra_commands=None, speed=1, test_mode=False, commentecho=False, ): """Allow user to run their own live commands until CTRL-Z is pressed again. """ loop_again = True command_string = regulartyp...
[ "def", "regularrun", "(", "shell", ",", "prompt_template", "=", "\"default\"", ",", "aliases", "=", "None", ",", "envvars", "=", "None", ",", "extra_commands", "=", "None", ",", "speed", "=", "1", ",", "test_mode", "=", "False", ",", "commentecho", "=", ...
Allow user to run their own live commands until CTRL-Z is pressed again.
[ "Allow", "user", "to", "run", "their", "own", "live", "commands", "until", "CTRL", "-", "Z", "is", "pressed", "again", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/keyboard.py#L174-L199
train
sloria/doitlive
doitlive/keyboard.py
magicrun
def magicrun( text, shell, prompt_template="default", aliases=None, envvars=None, extra_commands=None, speed=1, test_mode=False, commentecho=False, ): """Echo out each character in ``text`` as keyboard characters are pressed, wait for a RETURN keypress, then run the ``text`` ...
python
def magicrun( text, shell, prompt_template="default", aliases=None, envvars=None, extra_commands=None, speed=1, test_mode=False, commentecho=False, ): """Echo out each character in ``text`` as keyboard characters are pressed, wait for a RETURN keypress, then run the ``text`` ...
[ "def", "magicrun", "(", "text", ",", "shell", ",", "prompt_template", "=", "\"default\"", ",", "aliases", "=", "None", ",", "envvars", "=", "None", ",", "extra_commands", "=", "None", ",", "speed", "=", "1", ",", "test_mode", "=", "False", ",", "commente...
Echo out each character in ``text`` as keyboard characters are pressed, wait for a RETURN keypress, then run the ``text`` in a shell context.
[ "Echo", "out", "each", "character", "in", "text", "as", "keyboard", "characters", "are", "pressed", "wait", "for", "a", "RETURN", "keypress", "then", "run", "the", "text", "in", "a", "shell", "context", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/keyboard.py#L202-L227
train
sloria/doitlive
doitlive/python_consoles.py
PythonPlayerConsole.run_commands
def run_commands(self): """Automatically type and execute all commands.""" more = 0 prompt = sys.ps1 for command in self.commands: try: prompt = sys.ps2 if more else sys.ps1 try: magictype(command, prompt_template=prompt, sp...
python
def run_commands(self): """Automatically type and execute all commands.""" more = 0 prompt = sys.ps1 for command in self.commands: try: prompt = sys.ps2 if more else sys.ps1 try: magictype(command, prompt_template=prompt, sp...
[ "def", "run_commands", "(", "self", ")", ":", "more", "=", "0", "prompt", "=", "sys", ".", "ps1", "for", "command", "in", "self", ".", "commands", ":", "try", ":", "prompt", "=", "sys", ".", "ps2", "if", "more", "else", "sys", ".", "ps1", "try", ...
Automatically type and execute all commands.
[ "Automatically", "type", "and", "execute", "all", "commands", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/python_consoles.py#L20-L42
train
sloria/doitlive
doitlive/python_consoles.py
PythonPlayerConsole.interact
def interact(self, banner=None): """Run an interactive session.""" try: sys.ps1 except AttributeError: sys.ps1 = ">>>" try: sys.ps2 except AttributeError: sys.ps2 = "... " cprt = ( 'Type "help", "copyright", "cre...
python
def interact(self, banner=None): """Run an interactive session.""" try: sys.ps1 except AttributeError: sys.ps1 = ">>>" try: sys.ps2 except AttributeError: sys.ps2 = "... " cprt = ( 'Type "help", "copyright", "cre...
[ "def", "interact", "(", "self", ",", "banner", "=", "None", ")", ":", "try", ":", "sys", ".", "ps1", "except", "AttributeError", ":", "sys", ".", "ps1", "=", "\">>>\"", "try", ":", "sys", ".", "ps2", "except", "AttributeError", ":", "sys", ".", "ps2"...
Run an interactive session.
[ "Run", "an", "interactive", "session", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/python_consoles.py#L44-L61
train
sloria/doitlive
doitlive/ipython_consoles.py
start_ipython_player
def start_ipython_player(commands, speed=1): """Starts a new magic IPython shell.""" PlayerTerminalIPythonApp.commands = commands PlayerTerminalIPythonApp.speed = speed PlayerTerminalIPythonApp.launch_instance()
python
def start_ipython_player(commands, speed=1): """Starts a new magic IPython shell.""" PlayerTerminalIPythonApp.commands = commands PlayerTerminalIPythonApp.speed = speed PlayerTerminalIPythonApp.launch_instance()
[ "def", "start_ipython_player", "(", "commands", ",", "speed", "=", "1", ")", ":", "PlayerTerminalIPythonApp", ".", "commands", "=", "commands", "PlayerTerminalIPythonApp", ".", "speed", "=", "speed", "PlayerTerminalIPythonApp", ".", "launch_instance", "(", ")" ]
Starts a new magic IPython shell.
[ "Starts", "a", "new", "magic", "IPython", "shell", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/ipython_consoles.py#L168-L172
train
sloria/doitlive
doitlive/ipython_consoles.py
PlayerTerminalInteractiveShell.on_feed_key
def on_feed_key(self, key_press): """Handles the magictyping when a key is pressed""" if key_press.key in {Keys.Escape, Keys.ControlC}: echo(carriage_return=True) raise Abort() if key_press.key == Keys.Backspace: if self.current_command_pos > 0: ...
python
def on_feed_key(self, key_press): """Handles the magictyping when a key is pressed""" if key_press.key in {Keys.Escape, Keys.ControlC}: echo(carriage_return=True) raise Abort() if key_press.key == Keys.Backspace: if self.current_command_pos > 0: ...
[ "def", "on_feed_key", "(", "self", ",", "key_press", ")", ":", "if", "key_press", ".", "key", "in", "{", "Keys", ".", "Escape", ",", "Keys", ".", "ControlC", "}", ":", "echo", "(", "carriage_return", "=", "True", ")", "raise", "Abort", "(", ")", "if"...
Handles the magictyping when a key is pressed
[ "Handles", "the", "magictyping", "when", "a", "key", "is", "pressed" ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/ipython_consoles.py#L61-L86
train
sloria/doitlive
doitlive/ipython_consoles.py
PlayerTerminalIPythonApp.init_shell
def init_shell(self): """initialize the InteractiveShell instance""" self.shell = PlayerTerminalInteractiveShell.instance( commands=self.commands, speed=self.speed, parent=self, display_banner=False, profile_dir=self.profile_dir, ip...
python
def init_shell(self): """initialize the InteractiveShell instance""" self.shell = PlayerTerminalInteractiveShell.instance( commands=self.commands, speed=self.speed, parent=self, display_banner=False, profile_dir=self.profile_dir, ip...
[ "def", "init_shell", "(", "self", ")", ":", "self", ".", "shell", "=", "PlayerTerminalInteractiveShell", ".", "instance", "(", "commands", "=", "self", ".", "commands", ",", "speed", "=", "self", ".", "speed", ",", "parent", "=", "self", ",", "display_bann...
initialize the InteractiveShell instance
[ "initialize", "the", "InteractiveShell", "instance" ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/ipython_consoles.py#L154-L165
train
sloria/doitlive
doitlive/termutils.py
raw_mode
def raw_mode(): """ Enables terminal raw mode during the context. Note: Currently noop for Windows systems. Usage: :: with raw_mode(): do_some_stuff() """ if WIN: # No implementation for windows yet. yield # needed for the empty context manager to work ...
python
def raw_mode(): """ Enables terminal raw mode during the context. Note: Currently noop for Windows systems. Usage: :: with raw_mode(): do_some_stuff() """ if WIN: # No implementation for windows yet. yield # needed for the empty context manager to work ...
[ "def", "raw_mode", "(", ")", ":", "if", "WIN", ":", "# No implementation for windows yet.", "yield", "# needed for the empty context manager to work", "else", ":", "# imports are placed here because this will fail under Windows", "import", "tty", "import", "termios", "if", "no...
Enables terminal raw mode during the context. Note: Currently noop for Windows systems. Usage: :: with raw_mode(): do_some_stuff()
[ "Enables", "terminal", "raw", "mode", "during", "the", "context", "." ]
baf43f8ad3f2e4593fe21f6af42aedd34ef1efee
https://github.com/sloria/doitlive/blob/baf43f8ad3f2e4593fe21f6af42aedd34ef1efee/doitlive/termutils.py#L13-L54
train
skorokithakis/shortuuid
shortuuid/main.py
int_to_string
def int_to_string(number, alphabet, padding=None): """ Convert a number to a string, using the given alphabet. The output has the most significant digit first. """ output = "" alpha_len = len(alphabet) while number: number, digit = divmod(number, alpha_len) output += alphabet...
python
def int_to_string(number, alphabet, padding=None): """ Convert a number to a string, using the given alphabet. The output has the most significant digit first. """ output = "" alpha_len = len(alphabet) while number: number, digit = divmod(number, alpha_len) output += alphabet...
[ "def", "int_to_string", "(", "number", ",", "alphabet", ",", "padding", "=", "None", ")", ":", "output", "=", "\"\"", "alpha_len", "=", "len", "(", "alphabet", ")", "while", "number", ":", "number", ",", "digit", "=", "divmod", "(", "number", ",", "alp...
Convert a number to a string, using the given alphabet. The output has the most significant digit first.
[ "Convert", "a", "number", "to", "a", "string", "using", "the", "given", "alphabet", ".", "The", "output", "has", "the", "most", "significant", "digit", "first", "." ]
4da632a986c3a43f75c7df64f27a90bbf7ff8039
https://github.com/skorokithakis/shortuuid/blob/4da632a986c3a43f75c7df64f27a90bbf7ff8039/shortuuid/main.py#L9-L22
train
skorokithakis/shortuuid
shortuuid/main.py
string_to_int
def string_to_int(string, alphabet): """ Convert a string to a number, using the given alphabet. The input is assumed to have the most significant digit first. """ number = 0 alpha_len = len(alphabet) for char in string: number = number * alpha_len + alphabet.index(char) return n...
python
def string_to_int(string, alphabet): """ Convert a string to a number, using the given alphabet. The input is assumed to have the most significant digit first. """ number = 0 alpha_len = len(alphabet) for char in string: number = number * alpha_len + alphabet.index(char) return n...
[ "def", "string_to_int", "(", "string", ",", "alphabet", ")", ":", "number", "=", "0", "alpha_len", "=", "len", "(", "alphabet", ")", "for", "char", "in", "string", ":", "number", "=", "number", "*", "alpha_len", "+", "alphabet", ".", "index", "(", "cha...
Convert a string to a number, using the given alphabet. The input is assumed to have the most significant digit first.
[ "Convert", "a", "string", "to", "a", "number", "using", "the", "given", "alphabet", ".", "The", "input", "is", "assumed", "to", "have", "the", "most", "significant", "digit", "first", "." ]
4da632a986c3a43f75c7df64f27a90bbf7ff8039
https://github.com/skorokithakis/shortuuid/blob/4da632a986c3a43f75c7df64f27a90bbf7ff8039/shortuuid/main.py#L25-L34
train
skorokithakis/shortuuid
shortuuid/main.py
ShortUUID.decode
def decode(self, string, legacy=False): """ Decode a string according to the current alphabet into a UUID Raises ValueError when encountering illegal characters or a too-long string. If string too short, fills leftmost (MSB) bits with 0. Pass `legacy=True` if your UUID ...
python
def decode(self, string, legacy=False): """ Decode a string according to the current alphabet into a UUID Raises ValueError when encountering illegal characters or a too-long string. If string too short, fills leftmost (MSB) bits with 0. Pass `legacy=True` if your UUID ...
[ "def", "decode", "(", "self", ",", "string", ",", "legacy", "=", "False", ")", ":", "if", "legacy", ":", "string", "=", "string", "[", ":", ":", "-", "1", "]", "return", "_uu", ".", "UUID", "(", "int", "=", "string_to_int", "(", "string", ",", "s...
Decode a string according to the current alphabet into a UUID Raises ValueError when encountering illegal characters or a too-long string. If string too short, fills leftmost (MSB) bits with 0. Pass `legacy=True` if your UUID was encoded with a ShortUUID version prior to 0.6.0.
[ "Decode", "a", "string", "according", "to", "the", "current", "alphabet", "into", "a", "UUID", "Raises", "ValueError", "when", "encountering", "illegal", "characters", "or", "a", "too", "-", "long", "string", "." ]
4da632a986c3a43f75c7df64f27a90bbf7ff8039
https://github.com/skorokithakis/shortuuid/blob/4da632a986c3a43f75c7df64f27a90bbf7ff8039/shortuuid/main.py#L62-L75
train
skorokithakis/shortuuid
shortuuid/main.py
ShortUUID.set_alphabet
def set_alphabet(self, alphabet): """Set the alphabet to be used for new UUIDs.""" # Turn the alphabet into a set and sort it to prevent duplicates # and ensure reproducibility. new_alphabet = list(sorted(set(alphabet))) if len(new_alphabet) > 1: self._alphabet = new...
python
def set_alphabet(self, alphabet): """Set the alphabet to be used for new UUIDs.""" # Turn the alphabet into a set and sort it to prevent duplicates # and ensure reproducibility. new_alphabet = list(sorted(set(alphabet))) if len(new_alphabet) > 1: self._alphabet = new...
[ "def", "set_alphabet", "(", "self", ",", "alphabet", ")", ":", "# Turn the alphabet into a set and sort it to prevent duplicates", "# and ensure reproducibility.", "new_alphabet", "=", "list", "(", "sorted", "(", "set", "(", "alphabet", ")", ")", ")", "if", "len", "("...
Set the alphabet to be used for new UUIDs.
[ "Set", "the", "alphabet", "to", "be", "used", "for", "new", "UUIDs", "." ]
4da632a986c3a43f75c7df64f27a90bbf7ff8039
https://github.com/skorokithakis/shortuuid/blob/4da632a986c3a43f75c7df64f27a90bbf7ff8039/shortuuid/main.py#L111-L121
train
skorokithakis/shortuuid
shortuuid/main.py
ShortUUID.encoded_length
def encoded_length(self, num_bytes=16): """ Returns the string length of the shortened UUID. """ factor = math.log(256) / math.log(self._alpha_len) return int(math.ceil(factor * num_bytes))
python
def encoded_length(self, num_bytes=16): """ Returns the string length of the shortened UUID. """ factor = math.log(256) / math.log(self._alpha_len) return int(math.ceil(factor * num_bytes))
[ "def", "encoded_length", "(", "self", ",", "num_bytes", "=", "16", ")", ":", "factor", "=", "math", ".", "log", "(", "256", ")", "/", "math", ".", "log", "(", "self", ".", "_alpha_len", ")", "return", "int", "(", "math", ".", "ceil", "(", "factor",...
Returns the string length of the shortened UUID.
[ "Returns", "the", "string", "length", "of", "the", "shortened", "UUID", "." ]
4da632a986c3a43f75c7df64f27a90bbf7ff8039
https://github.com/skorokithakis/shortuuid/blob/4da632a986c3a43f75c7df64f27a90bbf7ff8039/shortuuid/main.py#L123-L128
train
quarkslab/arybo
arybo/lib/exprs_asm.py
asm_module
def asm_module(exprs, dst_reg, sym_to_reg, triple_or_target=None): ''' Generate an LLVM module for a list of expressions Arguments: * See :meth:`arybo.lib.exprs_asm.asm_binary` for a description of the list of arguments Output: * An LLVM module with one function named "__arybo", containing...
python
def asm_module(exprs, dst_reg, sym_to_reg, triple_or_target=None): ''' Generate an LLVM module for a list of expressions Arguments: * See :meth:`arybo.lib.exprs_asm.asm_binary` for a description of the list of arguments Output: * An LLVM module with one function named "__arybo", containing...
[ "def", "asm_module", "(", "exprs", ",", "dst_reg", ",", "sym_to_reg", ",", "triple_or_target", "=", "None", ")", ":", "if", "not", "llvmlite_available", ":", "raise", "RuntimeError", "(", "\"llvmlite module unavailable! can't assemble...\"", ")", "target", "=", "llv...
Generate an LLVM module for a list of expressions Arguments: * See :meth:`arybo.lib.exprs_asm.asm_binary` for a description of the list of arguments Output: * An LLVM module with one function named "__arybo", containing the translated expression. See :meth:`arybo.lib.exprs_asm.asm_bin...
[ "Generate", "an", "LLVM", "module", "for", "a", "list", "of", "expressions" ]
04fad817090b3b9f2328a5e984457aba6024e971
https://github.com/quarkslab/arybo/blob/04fad817090b3b9f2328a5e984457aba6024e971/arybo/lib/exprs_asm.py#L225-L261
train
quarkslab/arybo
arybo/lib/exprs_asm.py
asm_binary
def asm_binary(exprs, dst_reg, sym_to_reg, triple_or_target=None): ''' Compile and assemble an expression for a given architecture. Arguments: * *exprs*: list of expressions to convert. This can represent a graph of expressions. * *dst_reg*: final register on which to store the result o...
python
def asm_binary(exprs, dst_reg, sym_to_reg, triple_or_target=None): ''' Compile and assemble an expression for a given architecture. Arguments: * *exprs*: list of expressions to convert. This can represent a graph of expressions. * *dst_reg*: final register on which to store the result o...
[ "def", "asm_binary", "(", "exprs", ",", "dst_reg", ",", "sym_to_reg", ",", "triple_or_target", "=", "None", ")", ":", "if", "not", "llvmlite_available", ":", "raise", "RuntimeError", "(", "\"llvmlite module unavailable! can't assemble...\"", ")", "target", "=", "llv...
Compile and assemble an expression for a given architecture. Arguments: * *exprs*: list of expressions to convert. This can represent a graph of expressions. * *dst_reg*: final register on which to store the result of the last expression. This is represented by a tuple ("reg_name", reg_...
[ "Compile", "and", "assemble", "an", "expression", "for", "a", "given", "architecture", "." ]
04fad817090b3b9f2328a5e984457aba6024e971
https://github.com/quarkslab/arybo/blob/04fad817090b3b9f2328a5e984457aba6024e971/arybo/lib/exprs_asm.py#L263-L314
train
quarkslab/arybo
arybo/lib/mba_if.py
expr_contains
def expr_contains(e, o): ''' Returns true if o is in e ''' if o == e: return True if e.has_args(): for a in e.args(): if expr_contains(a, o): return True return False
python
def expr_contains(e, o): ''' Returns true if o is in e ''' if o == e: return True if e.has_args(): for a in e.args(): if expr_contains(a, o): return True return False
[ "def", "expr_contains", "(", "e", ",", "o", ")", ":", "if", "o", "==", "e", ":", "return", "True", "if", "e", ".", "has_args", "(", ")", ":", "for", "a", "in", "e", ".", "args", "(", ")", ":", "if", "expr_contains", "(", "a", ",", "o", ")", ...
Returns true if o is in e
[ "Returns", "true", "if", "o", "is", "in", "e" ]
04fad817090b3b9f2328a5e984457aba6024e971
https://github.com/quarkslab/arybo/blob/04fad817090b3b9f2328a5e984457aba6024e971/arybo/lib/mba_if.py#L36-L44
train
quarkslab/arybo
arybo/lib/mba_if.py
MBAVariable.zext
def zext(self, n): ''' Zero-extend the variable to n bits. n bits must be stricly larger than the actual number of bits, or a ValueError is thrown ''' if n <= self.nbits: raise ValueError("n must be > %d bits" % self.nbits) mba_ret = self.__new_mba(...
python
def zext(self, n): ''' Zero-extend the variable to n bits. n bits must be stricly larger than the actual number of bits, or a ValueError is thrown ''' if n <= self.nbits: raise ValueError("n must be > %d bits" % self.nbits) mba_ret = self.__new_mba(...
[ "def", "zext", "(", "self", ",", "n", ")", ":", "if", "n", "<=", "self", ".", "nbits", ":", "raise", "ValueError", "(", "\"n must be > %d bits\"", "%", "self", ".", "nbits", ")", "mba_ret", "=", "self", ".", "__new_mba", "(", "n", ")", "ret", "=", ...
Zero-extend the variable to n bits. n bits must be stricly larger than the actual number of bits, or a ValueError is thrown
[ "Zero", "-", "extend", "the", "variable", "to", "n", "bits", ".", "n", "bits", "must", "be", "stricly", "larger", "than", "the", "actual", "number", "of", "bits", "or", "a", "ValueError", "is", "thrown" ]
04fad817090b3b9f2328a5e984457aba6024e971
https://github.com/quarkslab/arybo/blob/04fad817090b3b9f2328a5e984457aba6024e971/arybo/lib/mba_if.py#L255-L269
train
quarkslab/arybo
arybo/lib/mba_if.py
MBAVariable.sext
def sext(self, n): ''' Sign-extend the variable to n bits. n bits must be stricly larger than the actual number of bits, or a ValueError is thrown ''' if n <= self.nbits: raise ValueError("n must be > %d bits" % self.nbits) mba_ret = self.__new_mba(...
python
def sext(self, n): ''' Sign-extend the variable to n bits. n bits must be stricly larger than the actual number of bits, or a ValueError is thrown ''' if n <= self.nbits: raise ValueError("n must be > %d bits" % self.nbits) mba_ret = self.__new_mba(...
[ "def", "sext", "(", "self", ",", "n", ")", ":", "if", "n", "<=", "self", ".", "nbits", ":", "raise", "ValueError", "(", "\"n must be > %d bits\"", "%", "self", ".", "nbits", ")", "mba_ret", "=", "self", ".", "__new_mba", "(", "n", ")", "ret", "=", ...
Sign-extend the variable to n bits. n bits must be stricly larger than the actual number of bits, or a ValueError is thrown
[ "Sign", "-", "extend", "the", "variable", "to", "n", "bits", ".", "n", "bits", "must", "be", "stricly", "larger", "than", "the", "actual", "number", "of", "bits", "or", "a", "ValueError", "is", "thrown" ]
04fad817090b3b9f2328a5e984457aba6024e971
https://github.com/quarkslab/arybo/blob/04fad817090b3b9f2328a5e984457aba6024e971/arybo/lib/mba_if.py#L271-L288
train
quarkslab/arybo
arybo/lib/mba_if.py
MBAVariable.evaluate
def evaluate(self, values): ''' Evaluates the expression to an integer values is a dictionnary that associates n-bit variables to integer values. Every symbolic variables used in the expression must be represented. For instance, let x and y 4-bit variables, and e = x+y: ...
python
def evaluate(self, values): ''' Evaluates the expression to an integer values is a dictionnary that associates n-bit variables to integer values. Every symbolic variables used in the expression must be represented. For instance, let x and y 4-bit variables, and e = x+y: ...
[ "def", "evaluate", "(", "self", ",", "values", ")", ":", "ret", "=", "self", ".", "mba", ".", "evaluate", "(", "self", ".", "vec", ",", "values", ")", "if", "isinstance", "(", "ret", ",", "six", ".", "integer_types", ")", ":", "return", "ret", "ret...
Evaluates the expression to an integer values is a dictionnary that associates n-bit variables to integer values. Every symbolic variables used in the expression must be represented. For instance, let x and y 4-bit variables, and e = x+y: >>> mba = MBA(4) >>> x = mba....
[ "Evaluates", "the", "expression", "to", "an", "integer" ]
04fad817090b3b9f2328a5e984457aba6024e971
https://github.com/quarkslab/arybo/blob/04fad817090b3b9f2328a5e984457aba6024e971/arybo/lib/mba_if.py#L290-L315
train
quarkslab/arybo
arybo/lib/mba_if.py
MBAVariable.vectorial_decomp
def vectorial_decomp(self, symbols): ''' Compute the vectorial decomposition of the expression according to the given symbols. symbols is a list that represents the input of the resulting application. They are considerated as a flatten vector of bits. Args: symbols: TODO ...
python
def vectorial_decomp(self, symbols): ''' Compute the vectorial decomposition of the expression according to the given symbols. symbols is a list that represents the input of the resulting application. They are considerated as a flatten vector of bits. Args: symbols: TODO ...
[ "def", "vectorial_decomp", "(", "self", ",", "symbols", ")", ":", "try", ":", "symbols", "=", "[", "s", ".", "vec", "for", "s", "in", "symbols", "]", "N", "=", "sum", "(", "map", "(", "lambda", "s", ":", "len", "(", "s", ")", ",", "symbols", ")...
Compute the vectorial decomposition of the expression according to the given symbols. symbols is a list that represents the input of the resulting application. They are considerated as a flatten vector of bits. Args: symbols: TODO Returns: An :class:`pytanque.A...
[ "Compute", "the", "vectorial", "decomposition", "of", "the", "expression", "according", "to", "the", "given", "symbols", "." ]
04fad817090b3b9f2328a5e984457aba6024e971
https://github.com/quarkslab/arybo/blob/04fad817090b3b9f2328a5e984457aba6024e971/arybo/lib/mba_if.py#L338-L386
train
quarkslab/arybo
arybo/lib/mba_if.py
MBA.var
def var(self, name): ''' Get an n-bit named symbolic variable Returns: An :class:`MBAVariable` object representing a symbolic variable Example: >>> mba.var('x') Vec([ x0, x1, x2, x3 ]) ''' ...
python
def var(self, name): ''' Get an n-bit named symbolic variable Returns: An :class:`MBAVariable` object representing a symbolic variable Example: >>> mba.var('x') Vec([ x0, x1, x2, x3 ]) ''' ...
[ "def", "var", "(", "self", ",", "name", ")", ":", "ret", "=", "self", ".", "from_vec", "(", "self", ".", "var_symbols", "(", "name", ")", ")", "ret", ".", "name", "=", "name", "return", "ret" ]
Get an n-bit named symbolic variable Returns: An :class:`MBAVariable` object representing a symbolic variable Example: >>> mba.var('x') Vec([ x0, x1, x2, x3 ])
[ "Get", "an", "n", "-", "bit", "named", "symbolic", "variable" ]
04fad817090b3b9f2328a5e984457aba6024e971
https://github.com/quarkslab/arybo/blob/04fad817090b3b9f2328a5e984457aba6024e971/arybo/lib/mba_if.py#L408-L426
train
quarkslab/arybo
arybo/lib/mba_if.py
MBA.permut2expr
def permut2expr(self, P): ''' Convert a substitution table into an arybo application Args: P: list of integers. The list must not contain more than 2**nbits elements. Returns: A tuple containing an :class:`MBAVariable` object with the result and the symbolic...
python
def permut2expr(self, P): ''' Convert a substitution table into an arybo application Args: P: list of integers. The list must not contain more than 2**nbits elements. Returns: A tuple containing an :class:`MBAVariable` object with the result and the symbolic...
[ "def", "permut2expr", "(", "self", ",", "P", ")", ":", "if", "len", "(", "P", ")", ">", "(", "1", "<<", "self", ".", "nbits", ")", ":", "raise", "ValueError", "(", "\"P must not contain more than %d elements\"", "%", "(", "1", "<<", "self", ".", "nbits...
Convert a substitution table into an arybo application Args: P: list of integers. The list must not contain more than 2**nbits elements. Returns: A tuple containing an :class:`MBAVariable` object with the result and the symbolic input variable used in this object. A...
[ "Convert", "a", "substitution", "table", "into", "an", "arybo", "application" ]
04fad817090b3b9f2328a5e984457aba6024e971
https://github.com/quarkslab/arybo/blob/04fad817090b3b9f2328a5e984457aba6024e971/arybo/lib/mba_if.py#L444-L483
train
requests/requests-ntlm
requests_ntlm/requests_ntlm.py
HttpNtlmAuth.response_hook
def response_hook(self, r, **kwargs): """The actual hook handler.""" if r.status_code == 401: # Handle server auth. www_authenticate = r.headers.get('www-authenticate', '').lower() auth_type = _auth_type_from_header(www_authenticate) if auth_type is not N...
python
def response_hook(self, r, **kwargs): """The actual hook handler.""" if r.status_code == 401: # Handle server auth. www_authenticate = r.headers.get('www-authenticate', '').lower() auth_type = _auth_type_from_header(www_authenticate) if auth_type is not N...
[ "def", "response_hook", "(", "self", ",", "r", ",", "*", "*", "kwargs", ")", ":", "if", "r", ".", "status_code", "==", "401", ":", "# Handle server auth.", "www_authenticate", "=", "r", ".", "headers", ".", "get", "(", "'www-authenticate'", ",", "''", ")...
The actual hook handler.
[ "The", "actual", "hook", "handler", "." ]
f71fee60aa64c17941114d4eae40aed670a77afd
https://github.com/requests/requests-ntlm/blob/f71fee60aa64c17941114d4eae40aed670a77afd/requests_ntlm/requests_ntlm.py#L138-L168
train
esafak/mca
src/mca.py
dummy
def dummy(DF, cols=None): """Dummy code select columns of a DataFrame.""" dummies = (get_dummies(DF[col]) for col in (DF.columns if cols is None else cols)) return concat(dummies, axis=1, keys=DF.columns)
python
def dummy(DF, cols=None): """Dummy code select columns of a DataFrame.""" dummies = (get_dummies(DF[col]) for col in (DF.columns if cols is None else cols)) return concat(dummies, axis=1, keys=DF.columns)
[ "def", "dummy", "(", "DF", ",", "cols", "=", "None", ")", ":", "dummies", "=", "(", "get_dummies", "(", "DF", "[", "col", "]", ")", "for", "col", "in", "(", "DF", ".", "columns", "if", "cols", "is", "None", "else", "cols", ")", ")", "return", "...
Dummy code select columns of a DataFrame.
[ "Dummy", "code", "select", "columns", "of", "a", "DataFrame", "." ]
f2b79ecbf37629902ccdbad2e1a556977c53d370
https://github.com/esafak/mca/blob/f2b79ecbf37629902ccdbad2e1a556977c53d370/src/mca.py#L30-L34
train