repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
eleme/meepo
meepo/apps/eventsourcing/prepare_commit.py
RedisPrepareCommit.prepare_info
def prepare_info(self, ts=None): """Return all session unique ids recorded in prepare phase. :param ts: timestamp, default to current timestamp :return: set of session unique ids """ sp_key = "%s:session_prepare" % self.namespace(ts or int(time.time())) return set(s(m) f...
python
def prepare_info(self, ts=None): """Return all session unique ids recorded in prepare phase. :param ts: timestamp, default to current timestamp :return: set of session unique ids """ sp_key = "%s:session_prepare" % self.namespace(ts or int(time.time())) return set(s(m) f...
[ "def", "prepare_info", "(", "self", ",", "ts", "=", "None", ")", ":", "sp_key", "=", "\"%s:session_prepare\"", "%", "self", ".", "namespace", "(", "ts", "or", "int", "(", "time", ".", "time", "(", ")", ")", ")", "return", "set", "(", "s", "(", "m",...
Return all session unique ids recorded in prepare phase. :param ts: timestamp, default to current timestamp :return: set of session unique ids
[ "Return", "all", "session", "unique", "ids", "recorded", "in", "prepare", "phase", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L181-L188
train
Return all session unique ids recorded in prepare phase.
eleme/meepo
meepo/apps/eventsourcing/prepare_commit.py
RedisPrepareCommit.clear
def clear(self, ts=None): """Clear all session in prepare phase. :param ts: timestamp used locate the namespace """ sp_key = "%s:session_prepare" % self.namespace(ts or int(time.time())) return self.r.delete(sp_key)
python
def clear(self, ts=None): """Clear all session in prepare phase. :param ts: timestamp used locate the namespace """ sp_key = "%s:session_prepare" % self.namespace(ts or int(time.time())) return self.r.delete(sp_key)
[ "def", "clear", "(", "self", ",", "ts", "=", "None", ")", ":", "sp_key", "=", "\"%s:session_prepare\"", "%", "self", ".", "namespace", "(", "ts", "or", "int", "(", "time", ".", "time", "(", ")", ")", ")", "return", "self", ".", "r", ".", "delete", ...
Clear all session in prepare phase. :param ts: timestamp used locate the namespace
[ "Clear", "all", "session", "in", "prepare", "phase", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L190-L196
train
Clear all session in prepare phase.
robinandeer/puzzle
puzzle/utils/get_file_info.py
get_file_type
def get_file_type(variant_source): """Check what kind of file variant source is Args: variant_source (str): Path to variant source Returns: file_type (str): 'vcf', 'gemini' or 'unknown' """ file_type = 'unknown' valid_vcf_suffixes = ('.vcf', '.vcf.gz...
python
def get_file_type(variant_source): """Check what kind of file variant source is Args: variant_source (str): Path to variant source Returns: file_type (str): 'vcf', 'gemini' or 'unknown' """ file_type = 'unknown' valid_vcf_suffixes = ('.vcf', '.vcf.gz...
[ "def", "get_file_type", "(", "variant_source", ")", ":", "file_type", "=", "'unknown'", "valid_vcf_suffixes", "=", "(", "'.vcf'", ",", "'.vcf.gz'", ")", "if", "variant_source", ":", "logger", ".", "debug", "(", "\"Check file type with file: {0}\"", ".", "format", ...
Check what kind of file variant source is Args: variant_source (str): Path to variant source Returns: file_type (str): 'vcf', 'gemini' or 'unknown'
[ "Check", "what", "kind", "of", "file", "variant", "source", "is", "Args", ":", "variant_source", "(", "str", ")", ":", "Path", "to", "variant", "source", "Returns", ":", "file_type", "(", "str", ")", ":", "vcf", "gemini", "or", "unknown" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/get_file_info.py#L11-L33
train
Check what kind of file is a variant source and return it
robinandeer/puzzle
puzzle/utils/get_file_info.py
get_variant_type
def get_variant_type(variant_source): """Try to find out what type of variants that exists in a variant source Args: variant_source (str): Path to variant source source_mode (str): 'vcf' or 'gemini' Returns: variant_type (str): 'sv' or 'snv' """ ...
python
def get_variant_type(variant_source): """Try to find out what type of variants that exists in a variant source Args: variant_source (str): Path to variant source source_mode (str): 'vcf' or 'gemini' Returns: variant_type (str): 'sv' or 'snv' """ ...
[ "def", "get_variant_type", "(", "variant_source", ")", ":", "file_type", "=", "get_file_type", "(", "variant_source", ")", "variant_type", "=", "'sv'", "if", "file_type", "==", "'vcf'", ":", "variants", "=", "VCF", "(", "variant_source", ")", "elif", "file_type"...
Try to find out what type of variants that exists in a variant source Args: variant_source (str): Path to variant source source_mode (str): 'vcf' or 'gemini' Returns: variant_type (str): 'sv' or 'snv'
[ "Try", "to", "find", "out", "what", "type", "of", "variants", "that", "exists", "in", "a", "variant", "source", "Args", ":", "variant_source", "(", "str", ")", ":", "Path", "to", "variant", "source", "source_mode", "(", "str", ")", ":", "vcf", "or", "g...
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/get_file_info.py#L35-L66
train
Try to find out what type of variants that exists in a variant source source_mode is vcf or gemini.
Shinichi-Nakagawa/pitchpx
pitchpx/baseball/retrosheet.py
RetroSheet.event_cd
def event_cd(cls, event_tx, ab_des): """ Event Code for Retrosheet :param event_tx: Event text :param ab_des: at bat description :return: event_cd(int) """ _event_tx = event_tx.lower() _ab_des = ab_des.lower() # Generic out(event_cd:2) if _...
python
def event_cd(cls, event_tx, ab_des): """ Event Code for Retrosheet :param event_tx: Event text :param ab_des: at bat description :return: event_cd(int) """ _event_tx = event_tx.lower() _ab_des = ab_des.lower() # Generic out(event_cd:2) if _...
[ "def", "event_cd", "(", "cls", ",", "event_tx", ",", "ab_des", ")", ":", "_event_tx", "=", "event_tx", ".", "lower", "(", ")", "_ab_des", "=", "ab_des", ".", "lower", "(", ")", "# Generic out(event_cd:2)", "if", "_event_tx", "in", "cls", ".", "EVENT_02_GEN...
Event Code for Retrosheet :param event_tx: Event text :param ab_des: at bat description :return: event_cd(int)
[ "Event", "Code", "for", "Retrosheet", ":", "param", "event_tx", ":", "Event", "text", ":", "param", "ab_des", ":", "at", "bat", "description", ":", "return", ":", "event_cd", "(", "int", ")" ]
5747402a0b3416f5e910b479e100df858f0b6440
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/baseball/retrosheet.py#L26-L92
train
Return the event code for the event_cd.
Shinichi-Nakagawa/pitchpx
pitchpx/baseball/retrosheet.py
RetroSheet.battedball_cd
def battedball_cd(cls, event_cd, event_tx, ab_des): """ Batted ball Code for Retrosheet :param event_cd: Event code :param event_tx: Event text :param ab_des: at bat description :return: battedball_cd(str) """ _event_tx = event_tx.lower() # Fly Out...
python
def battedball_cd(cls, event_cd, event_tx, ab_des): """ Batted ball Code for Retrosheet :param event_cd: Event code :param event_tx: Event text :param ab_des: at bat description :return: battedball_cd(str) """ _event_tx = event_tx.lower() # Fly Out...
[ "def", "battedball_cd", "(", "cls", ",", "event_cd", ",", "event_tx", ",", "ab_des", ")", ":", "_event_tx", "=", "event_tx", ".", "lower", "(", ")", "# Fly Out", "if", "_event_tx", "in", "cls", ".", "EVENT_02_GENERIC_OUT_FLYBALL", ":", "return", "'F'", "# Li...
Batted ball Code for Retrosheet :param event_cd: Event code :param event_tx: Event text :param ab_des: at bat description :return: battedball_cd(str)
[ "Batted", "ball", "Code", "for", "Retrosheet", ":", "param", "event_cd", ":", "Event", "code", ":", "param", "event_tx", ":", "Event", "text", ":", "param", "ab_des", ":", "at", "bat", "description", ":", "return", ":", "battedball_cd", "(", "str", ")" ]
5747402a0b3416f5e910b479e100df858f0b6440
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/baseball/retrosheet.py#L95-L124
train
Return the battedball code for Retrosheet event_cd event_tx ab_des.
Shinichi-Nakagawa/pitchpx
pitchpx/baseball/retrosheet.py
RetroSheet._battedball_cd
def _battedball_cd(cls, ab_des): """ Batted ball Code for at bat description :param ab_des: at bat description :return: battedball_cd(str) """ _ab_des = ab_des.lower() if ab_des.count("ground")>0: return 'G' elif _ab_des.count("lines")>0: ...
python
def _battedball_cd(cls, ab_des): """ Batted ball Code for at bat description :param ab_des: at bat description :return: battedball_cd(str) """ _ab_des = ab_des.lower() if ab_des.count("ground")>0: return 'G' elif _ab_des.count("lines")>0: ...
[ "def", "_battedball_cd", "(", "cls", ",", "ab_des", ")", ":", "_ab_des", "=", "ab_des", ".", "lower", "(", ")", "if", "ab_des", ".", "count", "(", "\"ground\"", ")", ">", "0", ":", "return", "'G'", "elif", "_ab_des", ".", "count", "(", "\"lines\"", "...
Batted ball Code for at bat description :param ab_des: at bat description :return: battedball_cd(str)
[ "Batted", "ball", "Code", "for", "at", "bat", "description", ":", "param", "ab_des", ":", "at", "bat", "description", ":", "return", ":", "battedball_cd", "(", "str", ")" ]
5747402a0b3416f5e910b479e100df858f0b6440
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/baseball/retrosheet.py#L127-L151
train
Return the Batted ball Code for at bat description.
Shinichi-Nakagawa/pitchpx
pitchpx/baseball/retrosheet.py
RetroSheet.ball_count
def ball_count(cls, ball_tally, strike_tally, pitch_res): """ Ball/Strike counter :param ball_tally: Ball telly :param strike_tally: Strike telly :param pitch_res: pitching result(Retrosheet format) :return: ball count, strike count """ b, s = ball_tally, ...
python
def ball_count(cls, ball_tally, strike_tally, pitch_res): """ Ball/Strike counter :param ball_tally: Ball telly :param strike_tally: Strike telly :param pitch_res: pitching result(Retrosheet format) :return: ball count, strike count """ b, s = ball_tally, ...
[ "def", "ball_count", "(", "cls", ",", "ball_tally", ",", "strike_tally", ",", "pitch_res", ")", ":", "b", ",", "s", "=", "ball_tally", ",", "strike_tally", "if", "pitch_res", "==", "\"B\"", ":", "if", "ball_tally", "<", "4", ":", "b", "+=", "1", "elif"...
Ball/Strike counter :param ball_tally: Ball telly :param strike_tally: Strike telly :param pitch_res: pitching result(Retrosheet format) :return: ball count, strike count
[ "Ball", "/", "Strike", "counter", ":", "param", "ball_tally", ":", "Ball", "telly", ":", "param", "strike_tally", ":", "Strike", "telly", ":", "param", "pitch_res", ":", "pitching", "result", "(", "Retrosheet", "format", ")", ":", "return", ":", "ball", "c...
5747402a0b3416f5e910b479e100df858f0b6440
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/baseball/retrosheet.py#L154-L172
train
Return the ball count and strike count for a given pitching result.
Shinichi-Nakagawa/pitchpx
pitchpx/baseball/retrosheet.py
RetroSheet.is_pa_terminal
def is_pa_terminal(cls, ball_tally, strike_tally, pitch_res, event_cd): """ Is PA terminal :param ball_tally: Ball telly :param strike_tally: Strike telly :param pitch_res: pitching result(Retrosheet format) :param event_cd: Event code :return: True or False ...
python
def is_pa_terminal(cls, ball_tally, strike_tally, pitch_res, event_cd): """ Is PA terminal :param ball_tally: Ball telly :param strike_tally: Strike telly :param pitch_res: pitching result(Retrosheet format) :param event_cd: Event code :return: True or False ...
[ "def", "is_pa_terminal", "(", "cls", ",", "ball_tally", ",", "strike_tally", ",", "pitch_res", ",", "event_cd", ")", ":", "# In Play", "if", "pitch_res", "==", "'X'", ":", "return", "True", "# Strike Out(Strike or Call)", "elif", "(", "pitch_res", "==", "'S'", ...
Is PA terminal :param ball_tally: Ball telly :param strike_tally: Strike telly :param pitch_res: pitching result(Retrosheet format) :param event_cd: Event code :return: True or False
[ "Is", "PA", "terminal", ":", "param", "ball_tally", ":", "Ball", "telly", ":", "param", "strike_tally", ":", "Strike", "telly", ":", "param", "pitch_res", ":", "pitching", "result", "(", "Retrosheet", "format", ")", ":", "param", "event_cd", ":", "Event", ...
5747402a0b3416f5e910b479e100df858f0b6440
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/baseball/retrosheet.py#L175-L193
train
Check if a set of attributes is a PA terminal.
robinandeer/puzzle
puzzle/cli/cases.py
cases
def cases(ctx, root): """ Show all cases in the database. If no database was found run puzzle init first. """ root = root or ctx.obj.get('root') or os.path.expanduser("~/.puzzle") if os.path.isfile(root): logger.error("'root' can't be a file") ctx.abort() logger.info("Root...
python
def cases(ctx, root): """ Show all cases in the database. If no database was found run puzzle init first. """ root = root or ctx.obj.get('root') or os.path.expanduser("~/.puzzle") if os.path.isfile(root): logger.error("'root' can't be a file") ctx.abort() logger.info("Root...
[ "def", "cases", "(", "ctx", ",", "root", ")", ":", "root", "=", "root", "or", "ctx", ".", "obj", ".", "get", "(", "'root'", ")", "or", "os", ".", "path", ".", "expanduser", "(", "\"~/.puzzle\"", ")", "if", "os", ".", "path", ".", "isfile", "(", ...
Show all cases in the database. If no database was found run puzzle init first.
[ "Show", "all", "cases", "in", "the", "database", "." ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/cli/cases.py#L16-L39
train
Show all cases in the database.
ellethee/argparseinator
argparseinator/__main__.py
copy_skeleton
def copy_skeleton( name, src, dest, renames=None, description=None, ignore=False, exclude_dirs=None, exclude_files=None): """Copy skeleton""" fmt = DevFormatter(name, dest, description=description) if os.path.exists(dest): if ignore is False: print("project already exists...
python
def copy_skeleton( name, src, dest, renames=None, description=None, ignore=False, exclude_dirs=None, exclude_files=None): """Copy skeleton""" fmt = DevFormatter(name, dest, description=description) if os.path.exists(dest): if ignore is False: print("project already exists...
[ "def", "copy_skeleton", "(", "name", ",", "src", ",", "dest", ",", "renames", "=", "None", ",", "description", "=", "None", ",", "ignore", "=", "False", ",", "exclude_dirs", "=", "None", ",", "exclude_files", "=", "None", ")", ":", "fmt", "=", "DevForm...
Copy skeleton
[ "Copy", "skeleton" ]
05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e
https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__main__.py#L51-L100
train
Copy skeleton from src to dest.
ellethee/argparseinator
argparseinator/__main__.py
init
def init(name, subnames, dest, skeleton, description, project_type, skip_core): """Creates a standalone, subprojects or submodules script sctrucure""" dest = dest or CUR_DIR skeleton = join(skeleton or SKEL_PATH, project_type) project = join(dest, name) script = join(project, name + '.py') core ...
python
def init(name, subnames, dest, skeleton, description, project_type, skip_core): """Creates a standalone, subprojects or submodules script sctrucure""" dest = dest or CUR_DIR skeleton = join(skeleton or SKEL_PATH, project_type) project = join(dest, name) script = join(project, name + '.py') core ...
[ "def", "init", "(", "name", ",", "subnames", ",", "dest", ",", "skeleton", ",", "description", ",", "project_type", ",", "skip_core", ")", ":", "dest", "=", "dest", "or", "CUR_DIR", "skeleton", "=", "join", "(", "skeleton", "or", "SKEL_PATH", ",", "proje...
Creates a standalone, subprojects or submodules script sctrucure
[ "Creates", "a", "standalone", "subprojects", "or", "submodules", "script", "sctrucure" ]
05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e
https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__main__.py#L115-L145
train
Creates a standalone subprojects or submodules script sctrucure
jwodder/javaproperties
javaproperties/propfile.py
PropertiesFile._check
def _check(self): """ Assert the internal consistency of the instance's data structures. This method is for debugging only. """ for k,ix in six.iteritems(self._indices): assert k is not None, 'null key' assert ix, 'Key does not map to any indices' ...
python
def _check(self): """ Assert the internal consistency of the instance's data structures. This method is for debugging only. """ for k,ix in six.iteritems(self._indices): assert k is not None, 'null key' assert ix, 'Key does not map to any indices' ...
[ "def", "_check", "(", "self", ")", ":", "for", "k", ",", "ix", "in", "six", ".", "iteritems", "(", "self", ".", "_indices", ")", ":", "assert", "k", "is", "not", "None", ",", "'null key'", "assert", "ix", ",", "'Key does not map to any indices'", "assert...
Assert the internal consistency of the instance's data structures. This method is for debugging only.
[ "Assert", "the", "internal", "consistency", "of", "the", "instance", "s", "data", "structures", ".", "This", "method", "is", "for", "debugging", "only", "." ]
8b48f040305217ebeb80c98c4354691bbb01429b
https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L64-L93
train
Checks that the internal consistency of the instance s data structures.
jwodder/javaproperties
javaproperties/propfile.py
PropertiesFile.load
def load(cls, fp): """ Parse the contents of the `~io.IOBase.readline`-supporting file-like object ``fp`` as a simple line-oriented ``.properties`` file and return a `PropertiesFile` instance. ``fp`` may be either a text or binary filehandle, with or without universal ne...
python
def load(cls, fp): """ Parse the contents of the `~io.IOBase.readline`-supporting file-like object ``fp`` as a simple line-oriented ``.properties`` file and return a `PropertiesFile` instance. ``fp`` may be either a text or binary filehandle, with or without universal ne...
[ "def", "load", "(", "cls", ",", "fp", ")", ":", "obj", "=", "cls", "(", ")", "for", "i", ",", "(", "k", ",", "v", ",", "src", ")", "in", "enumerate", "(", "parse", "(", "fp", ")", ")", ":", "if", "k", "is", "not", "None", ":", "obj", ".",...
Parse the contents of the `~io.IOBase.readline`-supporting file-like object ``fp`` as a simple line-oriented ``.properties`` file and return a `PropertiesFile` instance. ``fp`` may be either a text or binary filehandle, with or without universal newlines enabled. If it is a binary file...
[ "Parse", "the", "contents", "of", "the", "~io", ".", "IOBase", ".", "readline", "-", "supporting", "file", "-", "like", "object", "fp", "as", "a", "simple", "line", "-", "oriented", ".", "properties", "file", "and", "return", "a", "PropertiesFile", "instan...
8b48f040305217ebeb80c98c4354691bbb01429b
https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L170-L195
train
Loads the contents of the ~io. IOBase. readLine - supporting file - like objectfp as a simple line - oriented file - like object and returns a PropertiesFile instance.
jwodder/javaproperties
javaproperties/propfile.py
PropertiesFile.loads
def loads(cls, s): """ Parse the contents of the string ``s`` as a simple line-oriented ``.properties`` file and return a `PropertiesFile` instance. ``s`` may be either a text string or bytes string. If it is a bytes string, its contents are decoded as Latin-1. .. vers...
python
def loads(cls, s): """ Parse the contents of the string ``s`` as a simple line-oriented ``.properties`` file and return a `PropertiesFile` instance. ``s`` may be either a text string or bytes string. If it is a bytes string, its contents are decoded as Latin-1. .. vers...
[ "def", "loads", "(", "cls", ",", "s", ")", ":", "if", "isinstance", "(", "s", ",", "six", ".", "binary_type", ")", ":", "fp", "=", "six", ".", "BytesIO", "(", "s", ")", "else", ":", "fp", "=", "six", ".", "StringIO", "(", "s", ")", "return", ...
Parse the contents of the string ``s`` as a simple line-oriented ``.properties`` file and return a `PropertiesFile` instance. ``s`` may be either a text string or bytes string. If it is a bytes string, its contents are decoded as Latin-1. .. versionchanged:: 0.5.0 Invalid ...
[ "Parse", "the", "contents", "of", "the", "string", "s", "as", "a", "simple", "line", "-", "oriented", ".", "properties", "file", "and", "return", "a", "PropertiesFile", "instance", "." ]
8b48f040305217ebeb80c98c4354691bbb01429b
https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L198-L220
train
Parse the contents of the string s as a simple line - oriented . properties file and return a PropertiesFile instance.
jwodder/javaproperties
javaproperties/propfile.py
PropertiesFile.dump
def dump(self, fp, separator='='): """ Write the mapping to a file in simple line-oriented ``.properties`` format. If the instance was originally created from a file or string with `PropertiesFile.load()` or `PropertiesFile.loads()`, then the output will include the comm...
python
def dump(self, fp, separator='='): """ Write the mapping to a file in simple line-oriented ``.properties`` format. If the instance was originally created from a file or string with `PropertiesFile.load()` or `PropertiesFile.loads()`, then the output will include the comm...
[ "def", "dump", "(", "self", ",", "fp", ",", "separator", "=", "'='", ")", ":", "### TODO: Support setting the timestamp", "for", "line", "in", "six", ".", "itervalues", "(", "self", ".", "_lines", ")", ":", "if", "line", ".", "source", "is", "None", ":",...
Write the mapping to a file in simple line-oriented ``.properties`` format. If the instance was originally created from a file or string with `PropertiesFile.load()` or `PropertiesFile.loads()`, then the output will include the comments and whitespace from the original input, and ...
[ "Write", "the", "mapping", "to", "a", "file", "in", "simple", "line", "-", "oriented", ".", "properties", "format", "." ]
8b48f040305217ebeb80c98c4354691bbb01429b
https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L222-L256
train
Writes the mapping to a file - like object.
jwodder/javaproperties
javaproperties/propfile.py
PropertiesFile.dumps
def dumps(self, separator='='): """ Convert the mapping to a text string in simple line-oriented ``.properties`` format. If the instance was originally created from a file or string with `PropertiesFile.load()` or `PropertiesFile.loads()`, then the output will include th...
python
def dumps(self, separator='='): """ Convert the mapping to a text string in simple line-oriented ``.properties`` format. If the instance was originally created from a file or string with `PropertiesFile.load()` or `PropertiesFile.loads()`, then the output will include th...
[ "def", "dumps", "(", "self", ",", "separator", "=", "'='", ")", ":", "s", "=", "six", ".", "StringIO", "(", ")", "self", ".", "dump", "(", "s", ",", "separator", "=", "separator", ")", "return", "s", ".", "getvalue", "(", ")" ]
Convert the mapping to a text string in simple line-oriented ``.properties`` format. If the instance was originally created from a file or string with `PropertiesFile.load()` or `PropertiesFile.loads()`, then the output will include the comments and whitespace from the original input, a...
[ "Convert", "the", "mapping", "to", "a", "text", "string", "in", "simple", "line", "-", "oriented", ".", "properties", "format", "." ]
8b48f040305217ebeb80c98c4354691bbb01429b
https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L258-L287
train
Serializes the mapping to a text string in simple line - oriented format.
jwodder/javaproperties
javaproperties/propfile.py
PropertiesFile.copy
def copy(self): """ Create a copy of the mapping, including formatting information """ dup = type(self)() dup._indices = OrderedDict( (k, list(v)) for k,v in six.iteritems(self._indices) ) dup._lines = self._lines.copy() return dup
python
def copy(self): """ Create a copy of the mapping, including formatting information """ dup = type(self)() dup._indices = OrderedDict( (k, list(v)) for k,v in six.iteritems(self._indices) ) dup._lines = self._lines.copy() return dup
[ "def", "copy", "(", "self", ")", ":", "dup", "=", "type", "(", "self", ")", "(", ")", "dup", ".", "_indices", "=", "OrderedDict", "(", "(", "k", ",", "list", "(", "v", ")", ")", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "self"...
Create a copy of the mapping, including formatting information
[ "Create", "a", "copy", "of", "the", "mapping", "including", "formatting", "information" ]
8b48f040305217ebeb80c98c4354691bbb01429b
https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L289-L296
train
Create a copy of the mapping including formatting information
ldomic/lintools
lintools/analysis/maths_functions.py
prepare_normal_vectors
def prepare_normal_vectors(atomselection): """Create and normalize a vector across ring plane.""" ring_atomselection = [atomselection.coordinates()[a] for a in [0,2,4]] vect1 = self.vector(ring_atomselection[0],ring_atomselection[1]) vect2 = self.vector(ring_atomselection[2],ring_atomselection[0]) r...
python
def prepare_normal_vectors(atomselection): """Create and normalize a vector across ring plane.""" ring_atomselection = [atomselection.coordinates()[a] for a in [0,2,4]] vect1 = self.vector(ring_atomselection[0],ring_atomselection[1]) vect2 = self.vector(ring_atomselection[2],ring_atomselection[0]) r...
[ "def", "prepare_normal_vectors", "(", "atomselection", ")", ":", "ring_atomselection", "=", "[", "atomselection", ".", "coordinates", "(", ")", "[", "a", "]", "for", "a", "in", "[", "0", ",", "2", ",", "4", "]", "]", "vect1", "=", "self", ".", "vector"...
Create and normalize a vector across ring plane.
[ "Create", "and", "normalize", "a", "vector", "across", "ring", "plane", "." ]
d825a4a7b35f3f857d3b81b46c9aee72b0ec697a
https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/analysis/maths_functions.py#L3-L8
train
Create and normalize a vector across ring plane.
ldomic/lintools
lintools/analysis/maths_functions.py
vector
def vector(p1, p2): """Vector from p1 to p2. :param p1: coordinates of point p1 :param p2: coordinates of point p2 :returns : numpy array with vector coordinates """ return None if len(p1) != len(p2) else np.array([p2[i] - p1[i] for i in xrange(len(p1))])
python
def vector(p1, p2): """Vector from p1 to p2. :param p1: coordinates of point p1 :param p2: coordinates of point p2 :returns : numpy array with vector coordinates """ return None if len(p1) != len(p2) else np.array([p2[i] - p1[i] for i in xrange(len(p1))])
[ "def", "vector", "(", "p1", ",", "p2", ")", ":", "return", "None", "if", "len", "(", "p1", ")", "!=", "len", "(", "p2", ")", "else", "np", ".", "array", "(", "[", "p2", "[", "i", "]", "-", "p1", "[", "i", "]", "for", "i", "in", "xrange", ...
Vector from p1 to p2. :param p1: coordinates of point p1 :param p2: coordinates of point p2 :returns : numpy array with vector coordinates
[ "Vector", "from", "p1", "to", "p2", ".", ":", "param", "p1", ":", "coordinates", "of", "point", "p1", ":", "param", "p2", ":", "coordinates", "of", "point", "p2", ":", "returns", ":", "numpy", "array", "with", "vector", "coordinates" ]
d825a4a7b35f3f857d3b81b46c9aee72b0ec697a
https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/analysis/maths_functions.py#L19-L25
train
Vector from p1 to p2.
ldomic/lintools
lintools/analysis/maths_functions.py
projection
def projection(pnormal1, ppoint, tpoint): """Calculates the centroid from a 3D point cloud and returns the coordinates :param pnormal1: normal of plane :param ppoint: coordinates of point in the plane :param tpoint: coordinates of point to be projected :returns : coordinates of point orthogonally pr...
python
def projection(pnormal1, ppoint, tpoint): """Calculates the centroid from a 3D point cloud and returns the coordinates :param pnormal1: normal of plane :param ppoint: coordinates of point in the plane :param tpoint: coordinates of point to be projected :returns : coordinates of point orthogonally pr...
[ "def", "projection", "(", "pnormal1", ",", "ppoint", ",", "tpoint", ")", ":", "# Choose the plane normal pointing to the point to be projected", "pnormal2", "=", "[", "coo", "*", "(", "-", "1", ")", "for", "coo", "in", "pnormal1", "]", "d1", "=", "self", ".", ...
Calculates the centroid from a 3D point cloud and returns the coordinates :param pnormal1: normal of plane :param ppoint: coordinates of point in the plane :param tpoint: coordinates of point to be projected :returns : coordinates of point orthogonally projected on the plane
[ "Calculates", "the", "centroid", "from", "a", "3D", "point", "cloud", "and", "returns", "the", "coordinates", ":", "param", "pnormal1", ":", "normal", "of", "plane", ":", "param", "ppoint", ":", "coordinates", "of", "point", "in", "the", "plane", ":", "par...
d825a4a7b35f3f857d3b81b46c9aee72b0ec697a
https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/analysis/maths_functions.py#L40-L56
train
Calculates the centroid from a 3D point cloud and returns the coordinates of point orthogonally projected on the plane
rycus86/ghost-client
ghost_client/helpers.py
refresh_session_if_necessary
def refresh_session_if_necessary(f): """ Decorator to use on methods that are allowed to retry the request after reauthenticating the client. :param f: The original function :return: The decorated function """ @functools.wraps(f) def wrapped(self, *args, **kwargs): try: ...
python
def refresh_session_if_necessary(f): """ Decorator to use on methods that are allowed to retry the request after reauthenticating the client. :param f: The original function :return: The decorated function """ @functools.wraps(f) def wrapped(self, *args, **kwargs): try: ...
[ "def", "refresh_session_if_necessary", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapped", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "result", "=", "f", "(", "self", ",", "*", "...
Decorator to use on methods that are allowed to retry the request after reauthenticating the client. :param f: The original function :return: The decorated function
[ "Decorator", "to", "use", "on", "methods", "that", "are", "allowed", "to", "retry", "the", "request", "after", "reauthenticating", "the", "client", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/helpers.py#L4-L27
train
Decorator to use on methods that are allowed to retry the request after reauthenticating the client.
robinandeer/puzzle
puzzle/utils/puzzle_database.py
init_db
def init_db(db_path): """Build the sqlite database""" logger.info("Creating database") with closing(connect_database(db_path)) as db: with open(SCHEMA, 'r') as f: db.cursor().executescript(f.read()) db.commit() return
python
def init_db(db_path): """Build the sqlite database""" logger.info("Creating database") with closing(connect_database(db_path)) as db: with open(SCHEMA, 'r') as f: db.cursor().executescript(f.read()) db.commit() return
[ "def", "init_db", "(", "db_path", ")", ":", "logger", ".", "info", "(", "\"Creating database\"", ")", "with", "closing", "(", "connect_database", "(", "db_path", ")", ")", "as", "db", ":", "with", "open", "(", "SCHEMA", ",", "'r'", ")", "as", "f", ":",...
Build the sqlite database
[ "Build", "the", "sqlite", "database" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/puzzle_database.py#L15-L22
train
Build the sqlite database
inveniosoftware-contrib/json-merger
json_merger/merger.py
Merger.merge
def merge(self): """Populates result members. Performs the merge algorithm using the specified config and fills in the members that provide stats about the merging procedure. Attributes: merged_root: The result of the merge. aligned_root, aligned_head, aligned_...
python
def merge(self): """Populates result members. Performs the merge algorithm using the specified config and fills in the members that provide stats about the merging procedure. Attributes: merged_root: The result of the merge. aligned_root, aligned_head, aligned_...
[ "def", "merge", "(", "self", ")", ":", "self", ".", "merged_root", "=", "self", ".", "_recursive_merge", "(", "self", ".", "root", ",", "self", ".", "head", ",", "self", ".", "update", ")", "if", "self", ".", "conflicts", ":", "raise", "MergeError", ...
Populates result members. Performs the merge algorithm using the specified config and fills in the members that provide stats about the merging procedure. Attributes: merged_root: The result of the merge. aligned_root, aligned_head, aligned_update: Copies of root, head...
[ "Populates", "result", "members", "." ]
adc6d372da018427e1db7b92424d3471e01a4118
https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/merger.py#L135-L224
train
Populates the result of the merge with the current configuration.
robinandeer/puzzle
puzzle/utils/phenomizer.py
hpo_genes
def hpo_genes(phenotype_ids, username, password): """Return list of HGNC symbols matching HPO phenotype ids. Args: phenotype_ids (list): list of phenotype ids username (str): username to connect to phenomizer password (str): password to connect to phenomizer Returns: query_...
python
def hpo_genes(phenotype_ids, username, password): """Return list of HGNC symbols matching HPO phenotype ids. Args: phenotype_ids (list): list of phenotype ids username (str): username to connect to phenomizer password (str): password to connect to phenomizer Returns: query_...
[ "def", "hpo_genes", "(", "phenotype_ids", ",", "username", ",", "password", ")", ":", "if", "phenotype_ids", ":", "try", ":", "results", "=", "query_phenomizer", ".", "query", "(", "username", ",", "password", ",", "phenotype_ids", ")", "return", "[", "resul...
Return list of HGNC symbols matching HPO phenotype ids. Args: phenotype_ids (list): list of phenotype ids username (str): username to connect to phenomizer password (str): password to connect to phenomizer Returns: query_result: a list of dictionaries on the form { ...
[ "Return", "list", "of", "HGNC", "symbols", "matching", "HPO", "phenotype", "ids", "." ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/phenomizer.py#L5-L34
train
Return list of HGNC symbols matching HPO phenotype ids.
Colorless-Green-Ideas/MaterialDjango
materialdjango/forms.py
mangle_form
def mangle_form(form): "Utility to monkeypatch forms into paperinputs, untested" for field, widget in form.fields.iteritems(): if type(widget) is forms.widgets.TextInput: form.fields[field].widget = PaperTextInput() form.fields[field].label = '' if type(widget) is forms.w...
python
def mangle_form(form): "Utility to monkeypatch forms into paperinputs, untested" for field, widget in form.fields.iteritems(): if type(widget) is forms.widgets.TextInput: form.fields[field].widget = PaperTextInput() form.fields[field].label = '' if type(widget) is forms.w...
[ "def", "mangle_form", "(", "form", ")", ":", "for", "field", ",", "widget", "in", "form", ".", "fields", ".", "iteritems", "(", ")", ":", "if", "type", "(", "widget", ")", "is", "forms", ".", "widgets", ".", "TextInput", ":", "form", ".", "fields", ...
Utility to monkeypatch forms into paperinputs, untested
[ "Utility", "to", "monkeypatch", "forms", "into", "paperinputs", "untested" ]
e7a69e968965d25198d90318623a828cff67f5dc
https://github.com/Colorless-Green-Ideas/MaterialDjango/blob/e7a69e968965d25198d90318623a828cff67f5dc/materialdjango/forms.py#L14-L23
train
Utility to monkeypatch forms into paperinputs untested
eleme/meepo
meepo/apps/eventsourcing/event_store.py
RedisEventStore._keygen
def _keygen(self, event, ts=None): """Generate redis key for event at timestamp. :param event: event name :param ts: timestamp, default to current timestamp if left as None """ return "%s:%s" % (self.namespace(ts or time.time()), event)
python
def _keygen(self, event, ts=None): """Generate redis key for event at timestamp. :param event: event name :param ts: timestamp, default to current timestamp if left as None """ return "%s:%s" % (self.namespace(ts or time.time()), event)
[ "def", "_keygen", "(", "self", ",", "event", ",", "ts", "=", "None", ")", ":", "return", "\"%s:%s\"", "%", "(", "self", ".", "namespace", "(", "ts", "or", "time", ".", "time", "(", ")", ")", ",", "event", ")" ]
Generate redis key for event at timestamp. :param event: event name :param ts: timestamp, default to current timestamp if left as None
[ "Generate", "redis", "key", "for", "event", "at", "timestamp", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L140-L146
train
Generate redis key for event at timestamp.
eleme/meepo
meepo/apps/eventsourcing/event_store.py
RedisEventStore._zadd
def _zadd(self, key, pk, ts=None, ttl=None): """Redis lua func to add an event to the corresponding sorted set. :param key: the key to be stored in redis server :param pk: the primary key of event :param ts: timestamp of the event, default to redis_server's current timestamp ...
python
def _zadd(self, key, pk, ts=None, ttl=None): """Redis lua func to add an event to the corresponding sorted set. :param key: the key to be stored in redis server :param pk: the primary key of event :param ts: timestamp of the event, default to redis_server's current timestamp ...
[ "def", "_zadd", "(", "self", ",", "key", ",", "pk", ",", "ts", "=", "None", ",", "ttl", "=", "None", ")", ":", "return", "self", ".", "r", ".", "eval", "(", "self", ".", "LUA_ZADD", ",", "1", ",", "key", ",", "ts", "or", "self", ".", "_time",...
Redis lua func to add an event to the corresponding sorted set. :param key: the key to be stored in redis server :param pk: the primary key of event :param ts: timestamp of the event, default to redis_server's current timestamp :param ttl: the expiration time of event since the...
[ "Redis", "lua", "func", "to", "add", "an", "event", "to", "the", "corresponding", "sorted", "set", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L154-L163
train
Redis lua func to add an event to the corresponding sorted set.
eleme/meepo
meepo/apps/eventsourcing/event_store.py
RedisEventStore.add
def add(self, event, pk, ts=None, ttl=None): """Add an event to event store. All events were stored in a sorted set in redis with timestamp as rank score. :param event: the event to be added, format should be ``table_action`` :param pk: the primary key of event :param ...
python
def add(self, event, pk, ts=None, ttl=None): """Add an event to event store. All events were stored in a sorted set in redis with timestamp as rank score. :param event: the event to be added, format should be ``table_action`` :param pk: the primary key of event :param ...
[ "def", "add", "(", "self", ",", "event", ",", "pk", ",", "ts", "=", "None", ",", "ttl", "=", "None", ")", ":", "key", "=", "self", ".", "_keygen", "(", "event", ",", "ts", ")", "try", ":", "self", ".", "_zadd", "(", "key", ",", "pk", ",", "...
Add an event to event store. All events were stored in a sorted set in redis with timestamp as rank score. :param event: the event to be added, format should be ``table_action`` :param pk: the primary key of event :param ts: timestamp of the event, default to redis_server's ...
[ "Add", "an", "event", "to", "event", "store", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L165-L188
train
Add an event to the event store.
eleme/meepo
meepo/apps/eventsourcing/event_store.py
RedisEventStore.replay
def replay(self, event, ts=0, end_ts=None, with_ts=False): """Replay events based on timestamp. If you split namespace with ts, the replay will only return events within the same namespace. :param event: event name :param ts: replay events after ts, default from 0. :par...
python
def replay(self, event, ts=0, end_ts=None, with_ts=False): """Replay events based on timestamp. If you split namespace with ts, the replay will only return events within the same namespace. :param event: event name :param ts: replay events after ts, default from 0. :par...
[ "def", "replay", "(", "self", ",", "event", ",", "ts", "=", "0", ",", "end_ts", "=", "None", ",", "with_ts", "=", "False", ")", ":", "key", "=", "self", ".", "_keygen", "(", "event", ",", "ts", ")", "end_ts", "=", "end_ts", "if", "end_ts", "else"...
Replay events based on timestamp. If you split namespace with ts, the replay will only return events within the same namespace. :param event: event name :param ts: replay events after ts, default from 0. :param end_ts: replay events to ts, default to "+inf". :param with...
[ "Replay", "events", "based", "on", "timestamp", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L190-L210
train
Return the list of events that have a timestamp.
eleme/meepo
meepo/apps/eventsourcing/event_store.py
RedisEventStore.query
def query(self, event, pk, ts=None): """Query the last update timestamp of an event pk. You can pass a timestamp to only look for events later than that within the same namespace. :param event: the event name. :param pk: the pk value for query. :param ts: query event pk...
python
def query(self, event, pk, ts=None): """Query the last update timestamp of an event pk. You can pass a timestamp to only look for events later than that within the same namespace. :param event: the event name. :param pk: the pk value for query. :param ts: query event pk...
[ "def", "query", "(", "self", ",", "event", ",", "pk", ",", "ts", "=", "None", ")", ":", "key", "=", "self", ".", "_keygen", "(", "event", ",", "ts", ")", "pk_ts", "=", "self", ".", "r", ".", "zscore", "(", "key", ",", "pk", ")", "return", "in...
Query the last update timestamp of an event pk. You can pass a timestamp to only look for events later than that within the same namespace. :param event: the event name. :param pk: the pk value for query. :param ts: query event pk after ts, default to None which will query ...
[ "Query", "the", "last", "update", "timestamp", "of", "an", "event", "pk", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L212-L225
train
Query the last update timestamp of an event pk.
eleme/meepo
meepo/apps/eventsourcing/event_store.py
RedisEventStore.clear
def clear(self, event, ts=None): """Clear all stored record of event. :param event: event name to be cleared. :param ts: timestamp used locate the namespace """ return self.r.delete(self._keygen(event, ts))
python
def clear(self, event, ts=None): """Clear all stored record of event. :param event: event name to be cleared. :param ts: timestamp used locate the namespace """ return self.r.delete(self._keygen(event, ts))
[ "def", "clear", "(", "self", ",", "event", ",", "ts", "=", "None", ")", ":", "return", "self", ".", "r", ".", "delete", "(", "self", ".", "_keygen", "(", "event", ",", "ts", ")", ")" ]
Clear all stored record of event. :param event: event name to be cleared. :param ts: timestamp used locate the namespace
[ "Clear", "all", "stored", "record", "of", "event", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L227-L233
train
Clear all stored record of event.
alunduil/crumbs
crumbs/__init__.py
Parameters.add_configuration_file
def add_configuration_file(self, file_name): '''Register a file path from which to read parameter values. This method can be called multiple times to register multiple files for querying. Files are expected to be ``ini`` formatted. No assumptions should be made about the order that th...
python
def add_configuration_file(self, file_name): '''Register a file path from which to read parameter values. This method can be called multiple times to register multiple files for querying. Files are expected to be ``ini`` formatted. No assumptions should be made about the order that th...
[ "def", "add_configuration_file", "(", "self", ",", "file_name", ")", ":", "logger", ".", "info", "(", "'adding %s to configuration files'", ",", "file_name", ")", "if", "file_name", "not", "in", "self", ".", "configuration_files", "and", "self", ".", "_inotify", ...
Register a file path from which to read parameter values. This method can be called multiple times to register multiple files for querying. Files are expected to be ``ini`` formatted. No assumptions should be made about the order that the registered files are read and values defined i...
[ "Register", "a", "file", "path", "from", "which", "to", "read", "parameter", "values", "." ]
94b23f45db3054000d16968a44400780c6cff5ba
https://github.com/alunduil/crumbs/blob/94b23f45db3054000d16968a44400780c6cff5ba/crumbs/__init__.py#L328-L354
train
Add a configuration file to the dictionary of configuration files.
alunduil/crumbs
crumbs/__init__.py
Parameters.add_parameter
def add_parameter(self, **kwargs): '''Add the parameter to ``Parameters``. **Arguments** The arguments are lumped into two groups:``Parameters.add_parameter`` and ``argparse.ArgumentParser.add_argument``. Parameters that are only used by ``Parameters.add_parameter`` are remove...
python
def add_parameter(self, **kwargs): '''Add the parameter to ``Parameters``. **Arguments** The arguments are lumped into two groups:``Parameters.add_parameter`` and ``argparse.ArgumentParser.add_argument``. Parameters that are only used by ``Parameters.add_parameter`` are remove...
[ "def", "add_parameter", "(", "self", ",", "*", "*", "kwargs", ")", ":", "parameter_name", "=", "max", "(", "kwargs", "[", "'options'", "]", ",", "key", "=", "len", ")", ".", "lstrip", "(", "'-'", ")", "if", "'dest'", "in", "kwargs", ":", "parameter_n...
Add the parameter to ``Parameters``. **Arguments** The arguments are lumped into two groups:``Parameters.add_parameter`` and ``argparse.ArgumentParser.add_argument``. Parameters that are only used by ``Parameters.add_parameter`` are removed before ``kwargs`` is passed directly...
[ "Add", "the", "parameter", "to", "Parameters", "." ]
94b23f45db3054000d16968a44400780c6cff5ba
https://github.com/alunduil/crumbs/blob/94b23f45db3054000d16968a44400780c6cff5ba/crumbs/__init__.py#L356-L464
train
Add the parameter to the Parameters object.
alunduil/crumbs
crumbs/__init__.py
Parameters.parse
def parse(self, only_known = False): '''Ensure all sources are ready to be queried. Parses ``sys.argv`` with the contained ``argparse.ArgumentParser`` and sets ``parsed`` to True if ``only_known`` is False. Once ``parsed`` is set to True, it is inadvisable to add more parameters (cf. ...
python
def parse(self, only_known = False): '''Ensure all sources are ready to be queried. Parses ``sys.argv`` with the contained ``argparse.ArgumentParser`` and sets ``parsed`` to True if ``only_known`` is False. Once ``parsed`` is set to True, it is inadvisable to add more parameters (cf. ...
[ "def", "parse", "(", "self", ",", "only_known", "=", "False", ")", ":", "self", ".", "parsed", "=", "not", "only_known", "or", "self", ".", "parsed", "logger", ".", "info", "(", "'parsing parameters'", ")", "logger", ".", "debug", "(", "'sys.argv: %s'", ...
Ensure all sources are ready to be queried. Parses ``sys.argv`` with the contained ``argparse.ArgumentParser`` and sets ``parsed`` to True if ``only_known`` is False. Once ``parsed`` is set to True, it is inadvisable to add more parameters (cf. ``add_parameter``). Also, if ``parsed`` ...
[ "Ensure", "all", "sources", "are", "ready", "to", "be", "queried", "." ]
94b23f45db3054000d16968a44400780c6cff5ba
https://github.com/alunduil/crumbs/blob/94b23f45db3054000d16968a44400780c6cff5ba/crumbs/__init__.py#L466-L501
train
Parses sys. argv and sets self. parsed to True if only_known is False.
alunduil/crumbs
crumbs/__init__.py
Parameters.read_configuration_files
def read_configuration_files(self): '''Explicitly read the configuration files. Reads all configuration files in this Parameters object. Even if inotify is watching or a read has already occurred. .. note:: The order that the configuration files are read is not guaranteed....
python
def read_configuration_files(self): '''Explicitly read the configuration files. Reads all configuration files in this Parameters object. Even if inotify is watching or a read has already occurred. .. note:: The order that the configuration files are read is not guaranteed....
[ "def", "read_configuration_files", "(", "self", ")", ":", "for", "file_name", ",", "configuration_parser", "in", "self", ".", "configuration_files", ".", "items", "(", ")", ":", "if", "os", ".", "access", "(", "file_name", ",", "os", ".", "R_OK", ")", ":",...
Explicitly read the configuration files. Reads all configuration files in this Parameters object. Even if inotify is watching or a read has already occurred. .. note:: The order that the configuration files are read is not guaranteed.
[ "Explicitly", "read", "the", "configuration", "files", "." ]
94b23f45db3054000d16968a44400780c6cff5ba
https://github.com/alunduil/crumbs/blob/94b23f45db3054000d16968a44400780c6cff5ba/crumbs/__init__.py#L503-L520
train
Explicitly read the configuration files.
robinandeer/puzzle
puzzle/models/variant.py
Variant.nr_genes
def nr_genes(self): """Return the number of genes""" if self['genes']: nr_genes = len(self['genes']) else: nr_genes = len(self['gene_symbols']) return nr_genes
python
def nr_genes(self): """Return the number of genes""" if self['genes']: nr_genes = len(self['genes']) else: nr_genes = len(self['gene_symbols']) return nr_genes
[ "def", "nr_genes", "(", "self", ")", ":", "if", "self", "[", "'genes'", "]", ":", "nr_genes", "=", "len", "(", "self", "[", "'genes'", "]", ")", "else", ":", "nr_genes", "=", "len", "(", "self", "[", "'gene_symbols'", "]", ")", "return", "nr_genes" ]
Return the number of genes
[ "Return", "the", "number", "of", "genes" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L44-L50
train
Return the number of genes in the database
robinandeer/puzzle
puzzle/models/variant.py
Variant.display_name
def display_name(self): """Readable name for the variant.""" if self.is_snv: gene_ids = self.gene_symbols[:2] return ', '.join(gene_ids) else: return "{this.cytoband_start} ({this.sv_len})".format(this=self)
python
def display_name(self): """Readable name for the variant.""" if self.is_snv: gene_ids = self.gene_symbols[:2] return ', '.join(gene_ids) else: return "{this.cytoband_start} ({this.sv_len})".format(this=self)
[ "def", "display_name", "(", "self", ")", ":", "if", "self", ".", "is_snv", ":", "gene_ids", "=", "self", ".", "gene_symbols", "[", ":", "2", "]", "return", "', '", ".", "join", "(", "gene_ids", ")", "else", ":", "return", "\"{this.cytoband_start} ({this.sv...
Readable name for the variant.
[ "Readable", "name", "for", "the", "variant", "." ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L58-L64
train
Readable name for the variant.
robinandeer/puzzle
puzzle/models/variant.py
Variant.md5
def md5(self): """Return a md5 key string based on position, ref and alt""" return hashlib.md5('_'.join([self.CHROM, str(self.POS), self.REF, self.ALT])).hexdigest()
python
def md5(self): """Return a md5 key string based on position, ref and alt""" return hashlib.md5('_'.join([self.CHROM, str(self.POS), self.REF, self.ALT])).hexdigest()
[ "def", "md5", "(", "self", ")", ":", "return", "hashlib", ".", "md5", "(", "'_'", ".", "join", "(", "[", "self", ".", "CHROM", ",", "str", "(", "self", ".", "POS", ")", ",", "self", ".", "REF", ",", "self", ".", "ALT", "]", ")", ")", ".", "...
Return a md5 key string based on position, ref and alt
[ "Return", "a", "md5", "key", "string", "based", "on", "position", "ref", "and", "alt" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L67-L70
train
Return a md5 key string based on position ref and alt
robinandeer/puzzle
puzzle/models/variant.py
Variant.add_frequency
def add_frequency(self, name, value): """Add a frequency that will be displayed on the variant level Args: name (str): The name of the frequency field """ logger.debug("Adding frequency {0} with value {1} to variant {2}".format( name, value, self['variant...
python
def add_frequency(self, name, value): """Add a frequency that will be displayed on the variant level Args: name (str): The name of the frequency field """ logger.debug("Adding frequency {0} with value {1} to variant {2}".format( name, value, self['variant...
[ "def", "add_frequency", "(", "self", ",", "name", ",", "value", ")", ":", "logger", ".", "debug", "(", "\"Adding frequency {0} with value {1} to variant {2}\"", ".", "format", "(", "name", ",", "value", ",", "self", "[", "'variant_id'", "]", ")", ")", "self", ...
Add a frequency that will be displayed on the variant level Args: name (str): The name of the frequency field
[ "Add", "a", "frequency", "that", "will", "be", "displayed", "on", "the", "variant", "level" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L81-L89
train
Adds a frequency to the frequency field of the specified resource
robinandeer/puzzle
puzzle/models/variant.py
Variant.set_max_freq
def set_max_freq(self, max_freq=None): """Set the max frequency for the variant If max_freq use this, otherwise go through all frequencies and set the highest as self['max_freq'] Args: max_freq (float): The max frequency """ if max_freq: ...
python
def set_max_freq(self, max_freq=None): """Set the max frequency for the variant If max_freq use this, otherwise go through all frequencies and set the highest as self['max_freq'] Args: max_freq (float): The max frequency """ if max_freq: ...
[ "def", "set_max_freq", "(", "self", ",", "max_freq", "=", "None", ")", ":", "if", "max_freq", ":", "self", "[", "'max_freq'", "]", "=", "max_freq", "else", ":", "for", "frequency", "in", "self", "[", "'frequencies'", "]", ":", "if", "self", "[", "'max_...
Set the max frequency for the variant If max_freq use this, otherwise go through all frequencies and set the highest as self['max_freq'] Args: max_freq (float): The max frequency
[ "Set", "the", "max", "frequency", "for", "the", "variant" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L91-L109
train
Set the max frequency for the variant and the highest frequency for the variant. If max_freq is None go through all frequencies and set the highest frequency for the variant.
robinandeer/puzzle
puzzle/models/variant.py
Variant.add_severity
def add_severity(self, name, value): """Add a severity to the variant Args: name (str): The name of the severity value : The value of the severity """ logger.debug("Adding severity {0} with value {1} to variant {2}".format( name, value, se...
python
def add_severity(self, name, value): """Add a severity to the variant Args: name (str): The name of the severity value : The value of the severity """ logger.debug("Adding severity {0} with value {1} to variant {2}".format( name, value, se...
[ "def", "add_severity", "(", "self", ",", "name", ",", "value", ")", ":", "logger", ".", "debug", "(", "\"Adding severity {0} with value {1} to variant {2}\"", ".", "format", "(", "name", ",", "value", ",", "self", "[", "'variant_id'", "]", ")", ")", "self", ...
Add a severity to the variant Args: name (str): The name of the severity value : The value of the severity
[ "Add", "a", "severity", "to", "the", "variant" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L111-L120
train
Adds a severity to the variant
robinandeer/puzzle
puzzle/models/variant.py
Variant.add_individual
def add_individual(self, genotype): """Add the information for a individual This adds a genotype dict to variant['individuals'] Args: genotype (dict): A genotype dictionary """ logger.debug("Adding genotype {0} to variant {1}".format( genotyp...
python
def add_individual(self, genotype): """Add the information for a individual This adds a genotype dict to variant['individuals'] Args: genotype (dict): A genotype dictionary """ logger.debug("Adding genotype {0} to variant {1}".format( genotyp...
[ "def", "add_individual", "(", "self", ",", "genotype", ")", ":", "logger", ".", "debug", "(", "\"Adding genotype {0} to variant {1}\"", ".", "format", "(", "genotype", ",", "self", "[", "'variant_id'", "]", ")", ")", "self", "[", "'individuals'", "]", ".", "...
Add the information for a individual This adds a genotype dict to variant['individuals'] Args: genotype (dict): A genotype dictionary
[ "Add", "the", "information", "for", "a", "individual" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L122-L132
train
Add the information for a individual to the variant
robinandeer/puzzle
puzzle/models/variant.py
Variant.add_transcript
def add_transcript(self, transcript): """Add the information transcript This adds a transcript dict to variant['transcripts'] Args: transcript (dict): A transcript dictionary """ logger.debug("Adding transcript {0} to variant {1}".format( tra...
python
def add_transcript(self, transcript): """Add the information transcript This adds a transcript dict to variant['transcripts'] Args: transcript (dict): A transcript dictionary """ logger.debug("Adding transcript {0} to variant {1}".format( tra...
[ "def", "add_transcript", "(", "self", ",", "transcript", ")", ":", "logger", ".", "debug", "(", "\"Adding transcript {0} to variant {1}\"", ".", "format", "(", "transcript", ",", "self", "[", "'variant_id'", "]", ")", ")", "self", "[", "'transcripts'", "]", "....
Add the information transcript This adds a transcript dict to variant['transcripts'] Args: transcript (dict): A transcript dictionary
[ "Add", "the", "information", "transcript" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L134-L144
train
Add the information transcript to the variant s transcripts
robinandeer/puzzle
puzzle/models/variant.py
Variant.add_gene
def add_gene(self, gene): """Add the information of a gene This adds a gene dict to variant['genes'] Args: gene (dict): A gene dictionary """ logger.debug("Adding gene {0} to variant {1}".format( gene, self['variant_id'])) self['gene...
python
def add_gene(self, gene): """Add the information of a gene This adds a gene dict to variant['genes'] Args: gene (dict): A gene dictionary """ logger.debug("Adding gene {0} to variant {1}".format( gene, self['variant_id'])) self['gene...
[ "def", "add_gene", "(", "self", ",", "gene", ")", ":", "logger", ".", "debug", "(", "\"Adding gene {0} to variant {1}\"", ".", "format", "(", "gene", ",", "self", "[", "'variant_id'", "]", ")", ")", "self", "[", "'genes'", "]", ".", "append", "(", "gene"...
Add the information of a gene This adds a gene dict to variant['genes'] Args: gene (dict): A gene dictionary
[ "Add", "the", "information", "of", "a", "gene" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L146-L157
train
Add the information of a gene to the variant s genes list
robinandeer/puzzle
puzzle/models/variant.py
Variant.add_compound
def add_compound(self, compound): """Add the information of a compound variant This adds a compound dict to variant['compounds'] Args: compound (dict): A compound dictionary """ logger.debug("Adding compound {0} to variant {1}".format( compo...
python
def add_compound(self, compound): """Add the information of a compound variant This adds a compound dict to variant['compounds'] Args: compound (dict): A compound dictionary """ logger.debug("Adding compound {0} to variant {1}".format( compo...
[ "def", "add_compound", "(", "self", ",", "compound", ")", ":", "logger", ".", "debug", "(", "\"Adding compound {0} to variant {1}\"", ".", "format", "(", "compound", ",", "self", "[", "'variant_id'", "]", ")", ")", "self", "[", "'compounds'", "]", ".", "appe...
Add the information of a compound variant This adds a compound dict to variant['compounds'] Args: compound (dict): A compound dictionary
[ "Add", "the", "information", "of", "a", "compound", "variant" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L159-L170
train
Add the information of a compound to the variant
robinandeer/puzzle
puzzle/models/variant.py
Variant._set_variant_id
def _set_variant_id(self, variant_id=None): """Set the variant id for this variant""" if not variant_id: variant_id = '_'.join([ self.CHROM, str(self.POS), self.REF, self.ALT ]) logger.debug("Updating va...
python
def _set_variant_id(self, variant_id=None): """Set the variant id for this variant""" if not variant_id: variant_id = '_'.join([ self.CHROM, str(self.POS), self.REF, self.ALT ]) logger.debug("Updating va...
[ "def", "_set_variant_id", "(", "self", ",", "variant_id", "=", "None", ")", ":", "if", "not", "variant_id", ":", "variant_id", "=", "'_'", ".", "join", "(", "[", "self", ".", "CHROM", ",", "str", "(", "self", ".", "POS", ")", ",", "self", ".", "REF...
Set the variant id for this variant
[ "Set", "the", "variant", "id", "for", "this", "variant" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L181-L194
train
Set the variant id for this variant
inveniosoftware-contrib/json-merger
json_merger/stats.py
ListMatchStats.move_to_result
def move_to_result(self, lst_idx): """Moves element from lst available at lst_idx.""" self.in_result_idx.add(lst_idx) if lst_idx in self.not_in_result_root_match_idx: self.not_in_result_root_match_idx.remove(lst_idx)
python
def move_to_result(self, lst_idx): """Moves element from lst available at lst_idx.""" self.in_result_idx.add(lst_idx) if lst_idx in self.not_in_result_root_match_idx: self.not_in_result_root_match_idx.remove(lst_idx)
[ "def", "move_to_result", "(", "self", ",", "lst_idx", ")", ":", "self", ".", "in_result_idx", ".", "add", "(", "lst_idx", ")", "if", "lst_idx", "in", "self", ".", "not_in_result_root_match_idx", ":", "self", ".", "not_in_result_root_match_idx", ".", "remove", ...
Moves element from lst available at lst_idx.
[ "Moves", "element", "from", "lst", "available", "at", "lst_idx", "." ]
adc6d372da018427e1db7b92424d3471e01a4118
https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/stats.py#L72-L77
train
Moves element from lst available at lst_idx.
inveniosoftware-contrib/json-merger
json_merger/stats.py
ListMatchStats.add_root_match
def add_root_match(self, lst_idx, root_idx): """Adds a match for the elements avaialble at lst_idx and root_idx.""" self.root_matches[lst_idx] = root_idx if lst_idx in self.in_result_idx: return self.not_in_result_root_match_idx.add(lst_idx)
python
def add_root_match(self, lst_idx, root_idx): """Adds a match for the elements avaialble at lst_idx and root_idx.""" self.root_matches[lst_idx] = root_idx if lst_idx in self.in_result_idx: return self.not_in_result_root_match_idx.add(lst_idx)
[ "def", "add_root_match", "(", "self", ",", "lst_idx", ",", "root_idx", ")", ":", "self", ".", "root_matches", "[", "lst_idx", "]", "=", "root_idx", "if", "lst_idx", "in", "self", ".", "in_result_idx", ":", "return", "self", ".", "not_in_result_root_match_idx",...
Adds a match for the elements avaialble at lst_idx and root_idx.
[ "Adds", "a", "match", "for", "the", "elements", "avaialble", "at", "lst_idx", "and", "root_idx", "." ]
adc6d372da018427e1db7b92424d3471e01a4118
https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/stats.py#L79-L85
train
Adds a match for the elements avaialble at lst_idx and root_idx.
robinandeer/puzzle
puzzle/plugins/gemini/mixins/variant_extras/transcripts.py
TranscriptExtras._add_transcripts
def _add_transcripts(self, variant_obj, gemini_variant): """ Add all transcripts for a variant Go through all transcripts found for the variant Args: gemini_variant (GeminiQueryRow): The gemini variant Yields: transcript (puzzle.models.T...
python
def _add_transcripts(self, variant_obj, gemini_variant): """ Add all transcripts for a variant Go through all transcripts found for the variant Args: gemini_variant (GeminiQueryRow): The gemini variant Yields: transcript (puzzle.models.T...
[ "def", "_add_transcripts", "(", "self", ",", "variant_obj", ",", "gemini_variant", ")", ":", "query", "=", "\"SELECT * from variant_impacts WHERE variant_id = {0}\"", ".", "format", "(", "gemini_variant", "[", "'variant_id'", "]", ")", "gq", "=", "GeminiQuery", "(", ...
Add all transcripts for a variant Go through all transcripts found for the variant Args: gemini_variant (GeminiQueryRow): The gemini variant Yields: transcript (puzzle.models.Transcript)
[ "Add", "all", "transcripts", "for", "a", "variant" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant_extras/transcripts.py#L8-L39
train
Add all transcripts for a variant
eleme/meepo
meepo/pub/mysql.py
mysql_pub
def mysql_pub(mysql_dsn, tables=None, blocking=False, **kwargs): """MySQL row-based binlog events pub. **General Usage** Listen and pub all tables events:: mysql_pub(mysql_dsn) Listen and pub only some tables events:: mysql_pub(mysql_dsn, tables=["test"]) By default the ``mysql...
python
def mysql_pub(mysql_dsn, tables=None, blocking=False, **kwargs): """MySQL row-based binlog events pub. **General Usage** Listen and pub all tables events:: mysql_pub(mysql_dsn) Listen and pub only some tables events:: mysql_pub(mysql_dsn, tables=["test"]) By default the ``mysql...
[ "def", "mysql_pub", "(", "mysql_dsn", ",", "tables", "=", "None", ",", "blocking", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# parse mysql settings", "parsed", "=", "urlparse", "(", "mysql_dsn", ")", "mysql_settings", "=", "{", "\"host\"", ":", "pa...
MySQL row-based binlog events pub. **General Usage** Listen and pub all tables events:: mysql_pub(mysql_dsn) Listen and pub only some tables events:: mysql_pub(mysql_dsn, tables=["test"]) By default the ``mysql_pub`` will process and pub all existing row-based binlog (starting ...
[ "MySQL", "row", "-", "based", "binlog", "events", "pub", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/pub/mysql.py#L50-L180
train
MySQL row - based binlog events pub.
jwodder/javaproperties
javaproperties/propclass.py
Properties.propertyNames
def propertyNames(self): r""" Returns a generator of all distinct keys in the `Properties` object and its `defaults` (and its `defaults`\ ’s `defaults`, etc.) in unspecified order :rtype: generator of text strings """ for k in self.data: yield k ...
python
def propertyNames(self): r""" Returns a generator of all distinct keys in the `Properties` object and its `defaults` (and its `defaults`\ ’s `defaults`, etc.) in unspecified order :rtype: generator of text strings """ for k in self.data: yield k ...
[ "def", "propertyNames", "(", "self", ")", ":", "for", "k", "in", "self", ".", "data", ":", "yield", "k", "if", "self", ".", "defaults", "is", "not", "None", ":", "for", "k", "in", "self", ".", "defaults", ".", "propertyNames", "(", ")", ":", "if", ...
r""" Returns a generator of all distinct keys in the `Properties` object and its `defaults` (and its `defaults`\ ’s `defaults`, etc.) in unspecified order :rtype: generator of text strings
[ "r", "Returns", "a", "generator", "of", "all", "distinct", "keys", "in", "the", "Properties", "object", "and", "its", "defaults", "(", "and", "its", "defaults", "\\", "’s", "defaults", "etc", ".", ")", "in", "unspecified", "order" ]
8b48f040305217ebeb80c98c4354691bbb01429b
https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propclass.py#L136-L149
train
r Returns a generator of all distinct keys in the Properties object and s defaults and defaults in unspecified
jwodder/javaproperties
javaproperties/propclass.py
Properties.store
def store(self, out, comments=None): """ Write the `Properties` object's entries (in unspecified order) in ``.properties`` format to ``out``, including the current timestamp. :param out: A file-like object to write the properties to. It must have been opened as a text file ...
python
def store(self, out, comments=None): """ Write the `Properties` object's entries (in unspecified order) in ``.properties`` format to ``out``, including the current timestamp. :param out: A file-like object to write the properties to. It must have been opened as a text file ...
[ "def", "store", "(", "self", ",", "out", ",", "comments", "=", "None", ")", ":", "dump", "(", "self", ".", "data", ",", "out", ",", "comments", "=", "comments", ")" ]
Write the `Properties` object's entries (in unspecified order) in ``.properties`` format to ``out``, including the current timestamp. :param out: A file-like object to write the properties to. It must have been opened as a text file with a Latin-1-compatible encoding. :param commen...
[ "Write", "the", "Properties", "object", "s", "entries", "(", "in", "unspecified", "order", ")", "in", ".", "properties", "format", "to", "out", "including", "the", "current", "timestamp", "." ]
8b48f040305217ebeb80c98c4354691bbb01429b
https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propclass.py#L155-L167
train
Write the in - memory properties of the object to out.
jwodder/javaproperties
javaproperties/propclass.py
Properties.stringPropertyNames
def stringPropertyNames(self): r""" Returns a `set` of all keys in the `Properties` object and its `defaults` (and its `defaults`\ ’s `defaults`, etc.) :rtype: `set` of text strings """ names = set(self.data) if self.defaults is not None: names.update...
python
def stringPropertyNames(self): r""" Returns a `set` of all keys in the `Properties` object and its `defaults` (and its `defaults`\ ’s `defaults`, etc.) :rtype: `set` of text strings """ names = set(self.data) if self.defaults is not None: names.update...
[ "def", "stringPropertyNames", "(", "self", ")", ":", "names", "=", "set", "(", "self", ".", "data", ")", "if", "self", ".", "defaults", "is", "not", "None", ":", "names", ".", "update", "(", "self", ".", "defaults", ".", "stringPropertyNames", "(", ")"...
r""" Returns a `set` of all keys in the `Properties` object and its `defaults` (and its `defaults`\ ’s `defaults`, etc.) :rtype: `set` of text strings
[ "r", "Returns", "a", "set", "of", "all", "keys", "in", "the", "Properties", "object", "and", "its", "defaults", "(", "and", "its", "defaults", "\\", "’s", "defaults", "etc", ".", ")" ]
8b48f040305217ebeb80c98c4354691bbb01429b
https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propclass.py#L169-L179
train
r Returns a set of all keys in the Properties object and its defaults.
jwodder/javaproperties
javaproperties/propclass.py
Properties.storeToXML
def storeToXML(self, out, comment=None, encoding='UTF-8'): """ Write the `Properties` object's entries (in unspecified order) in XML properties format to ``out``. :param out: a file-like object to write the properties to :type out: binary file-like object :param comment:...
python
def storeToXML(self, out, comment=None, encoding='UTF-8'): """ Write the `Properties` object's entries (in unspecified order) in XML properties format to ``out``. :param out: a file-like object to write the properties to :type out: binary file-like object :param comment:...
[ "def", "storeToXML", "(", "self", ",", "out", ",", "comment", "=", "None", ",", "encoding", "=", "'UTF-8'", ")", ":", "dump_xml", "(", "self", ".", "data", ",", "out", ",", "comment", "=", "comment", ",", "encoding", "=", "encoding", ")" ]
Write the `Properties` object's entries (in unspecified order) in XML properties format to ``out``. :param out: a file-like object to write the properties to :type out: binary file-like object :param comment: if non-`None`, ``comment`` will be output as a ``<comment>`` eleme...
[ "Write", "the", "Properties", "object", "s", "entries", "(", "in", "unspecified", "order", ")", "in", "XML", "properties", "format", "to", "out", "." ]
8b48f040305217ebeb80c98c4354691bbb01429b
https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propclass.py#L206-L220
train
Write the properties object to out in XML format.
bazzite/django-knowledgebase
knowledgebase/article/search_indexes.py
ArticleIndex.index_queryset
def index_queryset(self, using=None): """Used when the entire index for model is updated.""" return self.get_model().objects.filter( modified__lte=datetime.datetime.now(), status=STATUS.published )
python
def index_queryset(self, using=None): """Used when the entire index for model is updated.""" return self.get_model().objects.filter( modified__lte=datetime.datetime.now(), status=STATUS.published )
[ "def", "index_queryset", "(", "self", ",", "using", "=", "None", ")", ":", "return", "self", ".", "get_model", "(", ")", ".", "objects", ".", "filter", "(", "modified__lte", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ",", "status", "=", ...
Used when the entire index for model is updated.
[ "Used", "when", "the", "entire", "index", "for", "model", "is", "updated", "." ]
457f4acf06fe895369bdb99d52af57e6e927e8f5
https://github.com/bazzite/django-knowledgebase/blob/457f4acf06fe895369bdb99d52af57e6e927e8f5/knowledgebase/article/search_indexes.py#L18-L23
train
Used when the entire index for model is updated.
ellethee/argparseinator
examples/greets/greets/__init__.py
cfg_factory
def cfg_factory(filename): """Config Factory""" try: # try to load config as yaml file. with open(filename, 'rb') as stream: return yaml.load(stream) except StandardError as error: # In case of error we use the **__argpi__** builtin to exit from # script _...
python
def cfg_factory(filename): """Config Factory""" try: # try to load config as yaml file. with open(filename, 'rb') as stream: return yaml.load(stream) except StandardError as error: # In case of error we use the **__argpi__** builtin to exit from # script _...
[ "def", "cfg_factory", "(", "filename", ")", ":", "try", ":", "# try to load config as yaml file.", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "stream", ":", "return", "yaml", ".", "load", "(", "stream", ")", "except", "StandardError", "as", "er...
Config Factory
[ "Config", "Factory" ]
05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e
https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/examples/greets/greets/__init__.py#L17-L26
train
Config Factory
ldomic/lintools
lintools/molecule.py
Molecule.load_molecule_in_rdkit_smiles
def load_molecule_in_rdkit_smiles(self, molSize,kekulize=True,bonds=[],bond_color=None,atom_color = {}, size= {} ): """ Loads mol file in rdkit without the hydrogens - they do not have to appear in the final figure. Once loaded, the molecule is converted to SMILES format which RDKit appears to ...
python
def load_molecule_in_rdkit_smiles(self, molSize,kekulize=True,bonds=[],bond_color=None,atom_color = {}, size= {} ): """ Loads mol file in rdkit without the hydrogens - they do not have to appear in the final figure. Once loaded, the molecule is converted to SMILES format which RDKit appears to ...
[ "def", "load_molecule_in_rdkit_smiles", "(", "self", ",", "molSize", ",", "kekulize", "=", "True", ",", "bonds", "=", "[", "]", ",", "bond_color", "=", "None", ",", "atom_color", "=", "{", "}", ",", "size", "=", "{", "}", ")", ":", "mol_in_rdkit", "=",...
Loads mol file in rdkit without the hydrogens - they do not have to appear in the final figure. Once loaded, the molecule is converted to SMILES format which RDKit appears to draw best - since we do not care about the actual coordinates of the original molecule, it is sufficient to have just 2D ...
[ "Loads", "mol", "file", "in", "rdkit", "without", "the", "hydrogens", "-", "they", "do", "not", "have", "to", "appear", "in", "the", "final", "figure", ".", "Once", "loaded", "the", "molecule", "is", "converted", "to", "SMILES", "format", "which", "RDKit",...
d825a4a7b35f3f857d3b81b46c9aee72b0ec697a
https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/molecule.py#L48-L94
train
Loads the molecule in rdkit with the given size and converts it to SMILES format.
ldomic/lintools
lintools/molecule.py
Molecule.convex_hull
def convex_hull(self): """ Draws a convex hull around ligand atoms and expands it, giving space to put diagramms on. This is done with the help of Shapely.geometry class. The initial convex hull the residue coordinates are inserted on, determines the order the coordinates are going to be...
python
def convex_hull(self): """ Draws a convex hull around ligand atoms and expands it, giving space to put diagramms on. This is done with the help of Shapely.geometry class. The initial convex hull the residue coordinates are inserted on, determines the order the coordinates are going to be...
[ "def", "convex_hull", "(", "self", ")", ":", "#Get coordinates of ligand atoms (needed to draw the convex hull around)", "self", ".", "ligand_atom_coords", "=", "[", "]", "ligand_atoms", "=", "[", "x", ".", "name", "for", "x", "in", "self", ".", "topology_data", "."...
Draws a convex hull around ligand atoms and expands it, giving space to put diagramms on. This is done with the help of Shapely.geometry class. The initial convex hull the residue coordinates are inserted on, determines the order the coordinates are going to be moved, i.e. if the residue 1 is on...
[ "Draws", "a", "convex", "hull", "around", "ligand", "atoms", "and", "expands", "it", "giving", "space", "to", "put", "diagramms", "on", ".", "This", "is", "done", "with", "the", "help", "of", "Shapely", ".", "geometry", "class", ".", "The", "initial", "c...
d825a4a7b35f3f857d3b81b46c9aee72b0ec697a
https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/molecule.py#L95-L157
train
Draw a convex hull around ligand atoms and expands it around the diagrams.
ldomic/lintools
lintools/molecule.py
Molecule.calc_2d_forces
def calc_2d_forces(self,x1,y1,x2,y2,width): """Calculate overlap in 2D space""" #calculate a if x1>x2: a = x1-x2 else: a = x2-x1 a_sq=a*a #calculate b if y1>y2: b = y1-y2 else: b = y2-y1 b_sq=b*b ...
python
def calc_2d_forces(self,x1,y1,x2,y2,width): """Calculate overlap in 2D space""" #calculate a if x1>x2: a = x1-x2 else: a = x2-x1 a_sq=a*a #calculate b if y1>y2: b = y1-y2 else: b = y2-y1 b_sq=b*b ...
[ "def", "calc_2d_forces", "(", "self", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ",", "width", ")", ":", "#calculate a", "if", "x1", ">", "x2", ":", "a", "=", "x1", "-", "x2", "else", ":", "a", "=", "x2", "-", "x1", "a_sq", "=", "a", "*", ...
Calculate overlap in 2D space
[ "Calculate", "overlap", "in", "2D", "space" ]
d825a4a7b35f3f857d3b81b46c9aee72b0ec697a
https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/molecule.py#L162-L189
train
Calculate the overlap in 2D space for a given set of points.
ldomic/lintools
lintools/molecule.py
Molecule.do_step
def do_step(self, values, xy_values,coeff, width): """Calculates forces between two diagrams and pushes them apart by tenth of width""" forces = {k:[] for k,i in enumerate(xy_values)} for (index1, value1), (index2,value2) in combinations(enumerate(xy_values),2): f = self.calc_2d_forc...
python
def do_step(self, values, xy_values,coeff, width): """Calculates forces between two diagrams and pushes them apart by tenth of width""" forces = {k:[] for k,i in enumerate(xy_values)} for (index1, value1), (index2,value2) in combinations(enumerate(xy_values),2): f = self.calc_2d_forc...
[ "def", "do_step", "(", "self", ",", "values", ",", "xy_values", ",", "coeff", ",", "width", ")", ":", "forces", "=", "{", "k", ":", "[", "]", "for", "k", ",", "i", "in", "enumerate", "(", "xy_values", ")", "}", "for", "(", "index1", ",", "value1"...
Calculates forces between two diagrams and pushes them apart by tenth of width
[ "Calculates", "forces", "between", "two", "diagrams", "and", "pushes", "them", "apart", "by", "tenth", "of", "width" ]
d825a4a7b35f3f857d3b81b46c9aee72b0ec697a
https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/molecule.py#L192-L217
train
Calculates forces between two diagrams and pushes them apart by tenth of width
ldomic/lintools
lintools/molecule.py
Molecule.make_new_projection_values
def make_new_projection_values(self,width=160): """Run do_step function until the diagramms have diverged from each other. Also determines how big the figure is going to be by calculating the borders from new residue coordinates. These are then added some buffer space. """ #Make...
python
def make_new_projection_values(self,width=160): """Run do_step function until the diagramms have diverged from each other. Also determines how big the figure is going to be by calculating the borders from new residue coordinates. These are then added some buffer space. """ #Make...
[ "def", "make_new_projection_values", "(", "self", ",", "width", "=", "160", ")", ":", "#Make gap between residues bigger if plots have a lot of rings - each ring after the 4th", "#give extra 12.5px space", "start", "=", "timer", "(", ")", "if", "self", ".", "topology_data", ...
Run do_step function until the diagramms have diverged from each other. Also determines how big the figure is going to be by calculating the borders from new residue coordinates. These are then added some buffer space.
[ "Run", "do_step", "function", "until", "the", "diagramms", "have", "diverged", "from", "each", "other", ".", "Also", "determines", "how", "big", "the", "figure", "is", "going", "to", "be", "by", "calculating", "the", "borders", "from", "new", "residue", "coo...
d825a4a7b35f3f857d3b81b46c9aee72b0ec697a
https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/molecule.py#L221-L277
train
Run do_step function until the diagramms have diverged from each other.
robinandeer/puzzle
puzzle/plugins/sql/mixins/variant.py
VariantMixin.variants
def variants(self, case_id, skip=0, count=1000, filters=None): """Fetch variants for a case.""" filters = filters or {} logger.debug("Fetching case with case_id: {0}".format(case_id)) case_obj = self.case(case_id) plugin, case_id = self.select_plugin(case_obj) self.filter...
python
def variants(self, case_id, skip=0, count=1000, filters=None): """Fetch variants for a case.""" filters = filters or {} logger.debug("Fetching case with case_id: {0}".format(case_id)) case_obj = self.case(case_id) plugin, case_id = self.select_plugin(case_obj) self.filter...
[ "def", "variants", "(", "self", ",", "case_id", ",", "skip", "=", "0", ",", "count", "=", "1000", ",", "filters", "=", "None", ")", ":", "filters", "=", "filters", "or", "{", "}", "logger", ".", "debug", "(", "\"Fetching case with case_id: {0}\"", ".", ...
Fetch variants for a case.
[ "Fetch", "variants", "for", "a", "case", "." ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/variant.py#L11-L29
train
Fetch variants for a case.
robinandeer/puzzle
puzzle/plugins/sql/mixins/variant.py
VariantMixin.variant
def variant(self, case_id, variant_id): """Fetch a single variant from variant source.""" case_obj = self.case(case_id) plugin, case_id = self.select_plugin(case_obj) variant = plugin.variant(case_id, variant_id) return variant
python
def variant(self, case_id, variant_id): """Fetch a single variant from variant source.""" case_obj = self.case(case_id) plugin, case_id = self.select_plugin(case_obj) variant = plugin.variant(case_id, variant_id) return variant
[ "def", "variant", "(", "self", ",", "case_id", ",", "variant_id", ")", ":", "case_obj", "=", "self", ".", "case", "(", "case_id", ")", "plugin", ",", "case_id", "=", "self", ".", "select_plugin", "(", "case_obj", ")", "variant", "=", "plugin", ".", "va...
Fetch a single variant from variant source.
[ "Fetch", "a", "single", "variant", "from", "variant", "source", "." ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/variant.py#L31-L36
train
Fetch a single variant from variant source.
eleme/meepo
meepo/apps/eventsourcing/sub.py
redis_es_sub
def redis_es_sub(session, tables, redis_dsn, strict=False, namespace=None, ttl=3600*24*3, socket_timeout=1): """Redis EventSourcing sub. This sub should be used together with sqlalchemy_es_pub, it will use RedisEventStore as events storage layer and use the prepare-commit pattern in :f...
python
def redis_es_sub(session, tables, redis_dsn, strict=False, namespace=None, ttl=3600*24*3, socket_timeout=1): """Redis EventSourcing sub. This sub should be used together with sqlalchemy_es_pub, it will use RedisEventStore as events storage layer and use the prepare-commit pattern in :f...
[ "def", "redis_es_sub", "(", "session", ",", "tables", ",", "redis_dsn", ",", "strict", "=", "False", ",", "namespace", "=", "None", ",", "ttl", "=", "3600", "*", "24", "*", "3", ",", "socket_timeout", "=", "1", ")", ":", "logger", "=", "logging", "."...
Redis EventSourcing sub. This sub should be used together with sqlalchemy_es_pub, it will use RedisEventStore as events storage layer and use the prepare-commit pattern in :func:`sqlalchemy_es_pub` to ensure 100% security on events recording. :param session: the sqlalchemy to bind the signal :...
[ "Redis", "EventSourcing", "sub", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/sub.py#L16-L71
train
Redis EventSourcing sub.
jalmeroth/pymusiccast
musiccast.py
setup_parser
def setup_parser(): """Setup an ArgumentParser.""" parser = argparse.ArgumentParser() parser.add_argument('-p', '--port', type=int, default=5005) parser.add_argument('-i', '--interval', type=int, default=480) parser.add_argument('host', type=str, help='hostname') return parser
python
def setup_parser(): """Setup an ArgumentParser.""" parser = argparse.ArgumentParser() parser.add_argument('-p', '--port', type=int, default=5005) parser.add_argument('-i', '--interval', type=int, default=480) parser.add_argument('host', type=str, help='hostname') return parser
[ "def", "setup_parser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'-p'", ",", "'--port'", ",", "type", "=", "int", ",", "default", "=", "5005", ")", "parser", ".", "add_argument", "(", ...
Setup an ArgumentParser.
[ "Setup", "an", "ArgumentParser", "." ]
616379ae22d6b518c61042d58be6d18a46242168
https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/musiccast.py#L13-L19
train
Setup an ArgumentParser.
jalmeroth/pymusiccast
musiccast.py
main
def main(): """Connect to a McDevice""" args = setup_parser().parse_args() host = getattr(args, "host") port = getattr(args, "port") ipv4 = socket.gethostbyname(host) interval = getattr(args, "interval") receiver = McDevice(ipv4, udp_port=port, mc_interval=interval) receiver.handle_stat...
python
def main(): """Connect to a McDevice""" args = setup_parser().parse_args() host = getattr(args, "host") port = getattr(args, "port") ipv4 = socket.gethostbyname(host) interval = getattr(args, "interval") receiver = McDevice(ipv4, udp_port=port, mc_interval=interval) receiver.handle_stat...
[ "def", "main", "(", ")", ":", "args", "=", "setup_parser", "(", ")", ".", "parse_args", "(", ")", "host", "=", "getattr", "(", "args", ",", "\"host\"", ")", "port", "=", "getattr", "(", "args", ",", "\"port\"", ")", "ipv4", "=", "socket", ".", "get...
Connect to a McDevice
[ "Connect", "to", "a", "McDevice" ]
616379ae22d6b518c61042d58be6d18a46242168
https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/musiccast.py#L22-L35
train
Connect to a McDevice
rycus86/ghost-client
ghost_client/api.py
Ghost.from_sqlite
def from_sqlite(cls, database_path, base_url, version='auto', client_id='ghost-admin'): """ Initialize a new Ghost API client, reading the client ID and secret from the SQlite database. :param database_path: The path to the database file. :param base_url: The base url of the ser...
python
def from_sqlite(cls, database_path, base_url, version='auto', client_id='ghost-admin'): """ Initialize a new Ghost API client, reading the client ID and secret from the SQlite database. :param database_path: The path to the database file. :param base_url: The base url of the ser...
[ "def", "from_sqlite", "(", "cls", ",", "database_path", ",", "base_url", ",", "version", "=", "'auto'", ",", "client_id", "=", "'ghost-admin'", ")", ":", "import", "os", "import", "sqlite3", "fd", "=", "os", ".", "open", "(", "database_path", ",", "os", ...
Initialize a new Ghost API client, reading the client ID and secret from the SQlite database. :param database_path: The path to the database file. :param base_url: The base url of the server :param version: The server version to use (default: `auto`) :param client_id: The client...
[ "Initialize", "a", "new", "Ghost", "API", "client", "reading", "the", "client", "ID", "and", "secret", "from", "the", "SQlite", "database", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L142-L180
train
Initialize a new Ghost API client instance from a SQLite database file.
rycus86/ghost-client
ghost_client/api.py
Ghost.version
def version(self): """ :return: The version of the server when initialized as 'auto', otherwise the version passed in at initialization """ if self._version != 'auto': return self._version if self._version == 'auto': try: data...
python
def version(self): """ :return: The version of the server when initialized as 'auto', otherwise the version passed in at initialization """ if self._version != 'auto': return self._version if self._version == 'auto': try: data...
[ "def", "version", "(", "self", ")", ":", "if", "self", ".", "_version", "!=", "'auto'", ":", "return", "self", ".", "_version", "if", "self", ".", "_version", "==", "'auto'", ":", "try", ":", "data", "=", "self", ".", "execute_get", "(", "'configuratio...
:return: The version of the server when initialized as 'auto', otherwise the version passed in at initialization
[ ":", "return", ":", "The", "version", "of", "the", "server", "when", "initialized", "as", "auto", "otherwise", "the", "version", "passed", "in", "at", "initialization" ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L183-L199
train
Returns the version of the server when initialized as auto otherwise the version passed in at initialization
rycus86/ghost-client
ghost_client/api.py
Ghost.login
def login(self, username, password): """ Authenticate with the server. :param username: The username of an existing user :param password: The password for the user :return: The authentication response from the REST endpoint """ data = self._authenticate( ...
python
def login(self, username, password): """ Authenticate with the server. :param username: The username of an existing user :param password: The password for the user :return: The authentication response from the REST endpoint """ data = self._authenticate( ...
[ "def", "login", "(", "self", ",", "username", ",", "password", ")", ":", "data", "=", "self", ".", "_authenticate", "(", "grant_type", "=", "'password'", ",", "username", "=", "username", ",", "password", "=", "password", ",", "client_id", "=", "self", "...
Authenticate with the server. :param username: The username of an existing user :param password: The password for the user :return: The authentication response from the REST endpoint
[ "Authenticate", "with", "the", "server", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L201-L221
train
Authenticate with the server.
rycus86/ghost-client
ghost_client/api.py
Ghost.refresh_session
def refresh_session(self): """ Re-authenticate using the refresh token if available. Otherwise log in using the username and password if it was used to authenticate initially. :return: The authentication response or `None` if not available """ if not self._refre...
python
def refresh_session(self): """ Re-authenticate using the refresh token if available. Otherwise log in using the username and password if it was used to authenticate initially. :return: The authentication response or `None` if not available """ if not self._refre...
[ "def", "refresh_session", "(", "self", ")", ":", "if", "not", "self", ".", "_refresh_token", ":", "if", "self", ".", "_username", "and", "self", ".", "_password", ":", "return", "self", ".", "login", "(", "self", ".", "_username", ",", "self", ".", "_p...
Re-authenticate using the refresh token if available. Otherwise log in using the username and password if it was used to authenticate initially. :return: The authentication response or `None` if not available
[ "Re", "-", "authenticate", "using", "the", "refresh", "token", "if", "available", ".", "Otherwise", "log", "in", "using", "the", "username", "and", "password", "if", "it", "was", "used", "to", "authenticate", "initially", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L223-L243
train
Re - authenticate using the refresh token if available.
rycus86/ghost-client
ghost_client/api.py
Ghost.revoke_access_token
def revoke_access_token(self): """ Revoke the access token currently in use. """ if not self._access_token: return self.execute_post('authentication/revoke', json=dict( token_type_hint='access_token', token=self._access_token )) ...
python
def revoke_access_token(self): """ Revoke the access token currently in use. """ if not self._access_token: return self.execute_post('authentication/revoke', json=dict( token_type_hint='access_token', token=self._access_token )) ...
[ "def", "revoke_access_token", "(", "self", ")", ":", "if", "not", "self", ".", "_access_token", ":", "return", "self", ".", "execute_post", "(", "'authentication/revoke'", ",", "json", "=", "dict", "(", "token_type_hint", "=", "'access_token'", ",", "token", "...
Revoke the access token currently in use.
[ "Revoke", "the", "access", "token", "currently", "in", "use", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L260-L273
train
Revoke the access token currently in use.
rycus86/ghost-client
ghost_client/api.py
Ghost.revoke_refresh_token
def revoke_refresh_token(self): """ Revoke the refresh token currently active. """ if not self._refresh_token: return self.execute_post('authentication/revoke', json=dict( token_type_hint='refresh_token', token=self._refresh_token )) ...
python
def revoke_refresh_token(self): """ Revoke the refresh token currently active. """ if not self._refresh_token: return self.execute_post('authentication/revoke', json=dict( token_type_hint='refresh_token', token=self._refresh_token )) ...
[ "def", "revoke_refresh_token", "(", "self", ")", ":", "if", "not", "self", ".", "_refresh_token", ":", "return", "self", ".", "execute_post", "(", "'authentication/revoke'", ",", "json", "=", "dict", "(", "token_type_hint", "=", "'refresh_token'", ",", "token", ...
Revoke the refresh token currently active.
[ "Revoke", "the", "refresh", "token", "currently", "active", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L275-L288
train
Revoke the refresh token currently active.
rycus86/ghost-client
ghost_client/api.py
Ghost.logout
def logout(self): """ Log out, revoking the access tokens and forgetting the login details if they were given. """ self.revoke_refresh_token() self.revoke_access_token() self._username, self._password = None, None
python
def logout(self): """ Log out, revoking the access tokens and forgetting the login details if they were given. """ self.revoke_refresh_token() self.revoke_access_token() self._username, self._password = None, None
[ "def", "logout", "(", "self", ")", ":", "self", ".", "revoke_refresh_token", "(", ")", "self", ".", "revoke_access_token", "(", ")", "self", ".", "_username", ",", "self", ".", "_password", "=", "None", ",", "None" ]
Log out, revoking the access tokens and forgetting the login details if they were given.
[ "Log", "out", "revoking", "the", "access", "tokens", "and", "forgetting", "the", "login", "details", "if", "they", "were", "given", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L290-L299
train
Log out and forgetting the login details.
rycus86/ghost-client
ghost_client/api.py
Ghost.upload
def upload(self, file_obj=None, file_path=None, name=None, data=None): """ Upload an image and return its path on the server. Either `file_obj` or `file_path` or `name` and `data` has to be specified. :param file_obj: A file object to upload :param file_path: A file path to uplo...
python
def upload(self, file_obj=None, file_path=None, name=None, data=None): """ Upload an image and return its path on the server. Either `file_obj` or `file_path` or `name` and `data` has to be specified. :param file_obj: A file object to upload :param file_path: A file path to uplo...
[ "def", "upload", "(", "self", ",", "file_obj", "=", "None", ",", "file_path", "=", "None", ",", "name", "=", "None", ",", "data", "=", "None", ")", ":", "close", "=", "False", "if", "file_obj", ":", "file_name", ",", "content", "=", "os", ".", "pat...
Upload an image and return its path on the server. Either `file_obj` or `file_path` or `name` and `data` has to be specified. :param file_obj: A file object to upload :param file_path: A file path to upload from :param name: A file name for uploading :param data: The file conten...
[ "Upload", "an", "image", "and", "return", "its", "path", "on", "the", "server", ".", "Either", "file_obj", "or", "file_path", "or", "name", "and", "data", "has", "to", "be", "specified", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L301-L343
train
Uploads an image to the server and returns its path on the server.
rycus86/ghost-client
ghost_client/api.py
Ghost.execute_get
def execute_get(self, resource, **kwargs): """ Execute an HTTP GET request against the API endpoints. This method is meant for internal use. :param resource: The last part of the URI :param kwargs: Additional query parameters (and optionally headers) :return: The HTTP re...
python
def execute_get(self, resource, **kwargs): """ Execute an HTTP GET request against the API endpoints. This method is meant for internal use. :param resource: The last part of the URI :param kwargs: Additional query parameters (and optionally headers) :return: The HTTP re...
[ "def", "execute_get", "(", "self", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "url", "=", "'%s/%s'", "%", "(", "self", ".", "base_url", ",", "resource", ")", "headers", "=", "kwargs", ".", "pop", "(", "'headers'", ",", "dict", "(", ")", ")...
Execute an HTTP GET request against the API endpoints. This method is meant for internal use. :param resource: The last part of the URI :param kwargs: Additional query parameters (and optionally headers) :return: The HTTP response as JSON or `GhostException` if unsuccessful
[ "Execute", "an", "HTTP", "GET", "request", "against", "the", "API", "endpoints", ".", "This", "method", "is", "meant", "for", "internal", "use", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L346-L389
train
Execute an HTTP GET request against the API endpoints.
rycus86/ghost-client
ghost_client/api.py
Ghost.execute_post
def execute_post(self, resource, **kwargs): """ Execute an HTTP POST request against the API endpoints. This method is meant for internal use. :param resource: The last part of the URI :param kwargs: Additional parameters for the HTTP call (`request` library) :return: Th...
python
def execute_post(self, resource, **kwargs): """ Execute an HTTP POST request against the API endpoints. This method is meant for internal use. :param resource: The last part of the URI :param kwargs: Additional parameters for the HTTP call (`request` library) :return: Th...
[ "def", "execute_post", "(", "self", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_request", "(", "resource", ",", "requests", ".", "post", ",", "*", "*", "kwargs", ")", ".", "json", "(", ")" ]
Execute an HTTP POST request against the API endpoints. This method is meant for internal use. :param resource: The last part of the URI :param kwargs: Additional parameters for the HTTP call (`request` library) :return: The HTTP response as JSON or `GhostException` if unsuccessful
[ "Execute", "an", "HTTP", "POST", "request", "against", "the", "API", "endpoints", ".", "This", "method", "is", "meant", "for", "internal", "use", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L391-L401
train
Execute an HTTP POST request against the API endpoints.
rycus86/ghost-client
ghost_client/api.py
Ghost.execute_put
def execute_put(self, resource, **kwargs): """ Execute an HTTP PUT request against the API endpoints. This method is meant for internal use. :param resource: The last part of the URI :param kwargs: Additional parameters for the HTTP call (`request` library) :return: The ...
python
def execute_put(self, resource, **kwargs): """ Execute an HTTP PUT request against the API endpoints. This method is meant for internal use. :param resource: The last part of the URI :param kwargs: Additional parameters for the HTTP call (`request` library) :return: The ...
[ "def", "execute_put", "(", "self", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_request", "(", "resource", ",", "requests", ".", "put", ",", "*", "*", "kwargs", ")", ".", "json", "(", ")" ]
Execute an HTTP PUT request against the API endpoints. This method is meant for internal use. :param resource: The last part of the URI :param kwargs: Additional parameters for the HTTP call (`request` library) :return: The HTTP response as JSON or `GhostException` if unsuccessful
[ "Execute", "an", "HTTP", "PUT", "request", "against", "the", "API", "endpoints", ".", "This", "method", "is", "meant", "for", "internal", "use", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L403-L413
train
Execute an HTTP PUT request against the API endpoints.
rycus86/ghost-client
ghost_client/api.py
Ghost.execute_delete
def execute_delete(self, resource, **kwargs): """ Execute an HTTP DELETE request against the API endpoints. This method is meant for internal use. Does not return anything but raises an exception when failed. :param resource: The last part of the URI :param kwargs: Addit...
python
def execute_delete(self, resource, **kwargs): """ Execute an HTTP DELETE request against the API endpoints. This method is meant for internal use. Does not return anything but raises an exception when failed. :param resource: The last part of the URI :param kwargs: Addit...
[ "def", "execute_delete", "(", "self", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_request", "(", "resource", ",", "requests", ".", "delete", ",", "*", "*", "kwargs", ")" ]
Execute an HTTP DELETE request against the API endpoints. This method is meant for internal use. Does not return anything but raises an exception when failed. :param resource: The last part of the URI :param kwargs: Additional parameters for the HTTP call (`request` library)
[ "Execute", "an", "HTTP", "DELETE", "request", "against", "the", "API", "endpoints", ".", "This", "method", "is", "meant", "for", "internal", "use", ".", "Does", "not", "return", "anything", "but", "raises", "an", "exception", "when", "failed", "." ]
863d332801d2c1b8e7ad4573c7b16db78a7f8c8d
https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L415-L425
train
Execute an HTTP DELETE request against the API endpoints.
Shinichi-Nakagawa/pitchpx
pitchpx/mlbam_util.py
MlbamUtil._get_content
def _get_content(cls, url, headers=HTTP_HEADERS): """ Get http content :param url: contents url :param headers: http header :return: BeautifulSoup object """ session = requests.Session() return session.get(url, headers=headers)
python
def _get_content(cls, url, headers=HTTP_HEADERS): """ Get http content :param url: contents url :param headers: http header :return: BeautifulSoup object """ session = requests.Session() return session.get(url, headers=headers)
[ "def", "_get_content", "(", "cls", ",", "url", ",", "headers", "=", "HTTP_HEADERS", ")", ":", "session", "=", "requests", ".", "Session", "(", ")", "return", "session", ".", "get", "(", "url", ",", "headers", "=", "headers", ")" ]
Get http content :param url: contents url :param headers: http header :return: BeautifulSoup object
[ "Get", "http", "content", ":", "param", "url", ":", "contents", "url", ":", "param", "headers", ":", "http", "header", ":", "return", ":", "BeautifulSoup", "object" ]
5747402a0b3416f5e910b479e100df858f0b6440
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/mlbam_util.py#L20-L28
train
Get http content
Shinichi-Nakagawa/pitchpx
pitchpx/mlbam_util.py
MlbamUtil.find_xml
def find_xml(cls, url, features): """ find xml :param url: contents url :param features: markup provider :param headers: http header :return: BeautifulSoup object """ req = cls._get_content(url) if req.status_code in range(200, 300): re...
python
def find_xml(cls, url, features): """ find xml :param url: contents url :param features: markup provider :param headers: http header :return: BeautifulSoup object """ req = cls._get_content(url) if req.status_code in range(200, 300): re...
[ "def", "find_xml", "(", "cls", ",", "url", ",", "features", ")", ":", "req", "=", "cls", ".", "_get_content", "(", "url", ")", "if", "req", ".", "status_code", "in", "range", "(", "200", ",", "300", ")", ":", "return", "BeautifulSoup", "(", "req", ...
find xml :param url: contents url :param features: markup provider :param headers: http header :return: BeautifulSoup object
[ "find", "xml", ":", "param", "url", ":", "contents", "url", ":", "param", "features", ":", "markup", "provider", ":", "param", "headers", ":", "http", "header", ":", "return", ":", "BeautifulSoup", "object" ]
5747402a0b3416f5e910b479e100df858f0b6440
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/mlbam_util.py#L31-L43
train
find xml
Shinichi-Nakagawa/pitchpx
pitchpx/mlbam_util.py
MlbamUtil.find_xml_all
def find_xml_all(cls, url, markup, tag, pattern): """ find xml(list) :param url: contents url :param markup: markup provider :param tag: find tag :param pattern: xml file pattern :return: BeautifulSoup object list """ body = cls.find_xml(url, marku...
python
def find_xml_all(cls, url, markup, tag, pattern): """ find xml(list) :param url: contents url :param markup: markup provider :param tag: find tag :param pattern: xml file pattern :return: BeautifulSoup object list """ body = cls.find_xml(url, marku...
[ "def", "find_xml_all", "(", "cls", ",", "url", ",", "markup", ",", "tag", ",", "pattern", ")", ":", "body", "=", "cls", ".", "find_xml", "(", "url", ",", "markup", ")", "return", "body", ".", "find_all", "(", "tag", ",", "href", "=", "re", ".", "...
find xml(list) :param url: contents url :param markup: markup provider :param tag: find tag :param pattern: xml file pattern :return: BeautifulSoup object list
[ "find", "xml", "(", "list", ")", ":", "param", "url", ":", "contents", "url", ":", "param", "markup", ":", "markup", "provider", ":", "param", "tag", ":", "find", "tag", ":", "param", "pattern", ":", "xml", "file", "pattern", ":", "return", ":", "Bea...
5747402a0b3416f5e910b479e100df858f0b6440
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/mlbam_util.py#L46-L56
train
find xml ( list
Shinichi-Nakagawa/pitchpx
pitchpx/mlbam_util.py
MlbamUtil.get_attribute
def get_attribute(cls, soup, key, unknown=None): """ Get attribute for Beautifulsoup object :param soup: Beautifulsoup object :param key: attribute key :param unknown: attribute key not exists value(default:None) :return: attribute value """ if key in soup...
python
def get_attribute(cls, soup, key, unknown=None): """ Get attribute for Beautifulsoup object :param soup: Beautifulsoup object :param key: attribute key :param unknown: attribute key not exists value(default:None) :return: attribute value """ if key in soup...
[ "def", "get_attribute", "(", "cls", ",", "soup", ",", "key", ",", "unknown", "=", "None", ")", ":", "if", "key", "in", "soup", ".", "attrs", ":", "return", "soup", ".", "get", "(", "key", ")", "return", "unknown" ]
Get attribute for Beautifulsoup object :param soup: Beautifulsoup object :param key: attribute key :param unknown: attribute key not exists value(default:None) :return: attribute value
[ "Get", "attribute", "for", "Beautifulsoup", "object", ":", "param", "soup", ":", "Beautifulsoup", "object", ":", "param", "key", ":", "attribute", "key", ":", "param", "unknown", ":", "attribute", "key", "not", "exists", "value", "(", "default", ":", "None",...
5747402a0b3416f5e910b479e100df858f0b6440
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/mlbam_util.py#L59-L69
train
Get attribute for Beautifulsoup object
Shinichi-Nakagawa/pitchpx
pitchpx/mlbam_util.py
MlbamUtil.get_attribute_stats
def get_attribute_stats(cls, soup, key, data_type=str, unknown=None): """ Get attribute for Beautifulsoup object :param soup: Beautifulsoup object :param key: attribute key :param data_type: Data type(int, float, etc...) :param unknown: attribute key not exists value(defa...
python
def get_attribute_stats(cls, soup, key, data_type=str, unknown=None): """ Get attribute for Beautifulsoup object :param soup: Beautifulsoup object :param key: attribute key :param data_type: Data type(int, float, etc...) :param unknown: attribute key not exists value(defa...
[ "def", "get_attribute_stats", "(", "cls", ",", "soup", ",", "key", ",", "data_type", "=", "str", ",", "unknown", "=", "None", ")", ":", "value", "=", "cls", ".", "get_attribute", "(", "soup", ",", "key", ",", "unknown", ")", "if", "value", "and", "va...
Get attribute for Beautifulsoup object :param soup: Beautifulsoup object :param key: attribute key :param data_type: Data type(int, float, etc...) :param unknown: attribute key not exists value(default:None) :return: (data_type)attribute value
[ "Get", "attribute", "for", "Beautifulsoup", "object", ":", "param", "soup", ":", "Beautifulsoup", "object", ":", "param", "key", ":", "attribute", "key", ":", "param", "data_type", ":", "Data", "type", "(", "int", "float", "etc", "...", ")", ":", "param", ...
5747402a0b3416f5e910b479e100df858f0b6440
https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/mlbam_util.py#L72-L85
train
Get attribute for Beautifulsoup object containing key and data type
inveniosoftware-contrib/json-merger
json_merger/contrib/inspirehep/author_util.py
token_distance
def token_distance(t1, t2, initial_match_penalization): """Calculates the edit distance between two tokens.""" if isinstance(t1, NameInitial) or isinstance(t2, NameInitial): if t1.token == t2.token: return 0 if t1 == t2: return initial_match_penalization return 1....
python
def token_distance(t1, t2, initial_match_penalization): """Calculates the edit distance between two tokens.""" if isinstance(t1, NameInitial) or isinstance(t2, NameInitial): if t1.token == t2.token: return 0 if t1 == t2: return initial_match_penalization return 1....
[ "def", "token_distance", "(", "t1", ",", "t2", ",", "initial_match_penalization", ")", ":", "if", "isinstance", "(", "t1", ",", "NameInitial", ")", "or", "isinstance", "(", "t2", ",", "NameInitial", ")", ":", "if", "t1", ".", "token", "==", "t2", ".", ...
Calculates the edit distance between two tokens.
[ "Calculates", "the", "edit", "distance", "between", "two", "tokens", "." ]
adc6d372da018427e1db7b92424d3471e01a4118
https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/contrib/inspirehep/author_util.py#L60-L68
train
Calculates the edit distance between two tokens.
inveniosoftware-contrib/json-merger
json_merger/contrib/inspirehep/author_util.py
simple_tokenize
def simple_tokenize(name): """Simple tokenizer function to be used with the normalizers.""" last_names, first_names = name.split(',') last_names = _RE_NAME_TOKEN_SEPARATOR.split(last_names) first_names = _RE_NAME_TOKEN_SEPARATOR.split(first_names) first_names = [NameToken(n) if len(n) > 1 else Name...
python
def simple_tokenize(name): """Simple tokenizer function to be used with the normalizers.""" last_names, first_names = name.split(',') last_names = _RE_NAME_TOKEN_SEPARATOR.split(last_names) first_names = _RE_NAME_TOKEN_SEPARATOR.split(first_names) first_names = [NameToken(n) if len(n) > 1 else Name...
[ "def", "simple_tokenize", "(", "name", ")", ":", "last_names", ",", "first_names", "=", "name", ".", "split", "(", "','", ")", "last_names", "=", "_RE_NAME_TOKEN_SEPARATOR", ".", "split", "(", "last_names", ")", "first_names", "=", "_RE_NAME_TOKEN_SEPARATOR", "....
Simple tokenizer function to be used with the normalizers.
[ "Simple", "tokenizer", "function", "to", "be", "used", "with", "the", "normalizers", "." ]
adc6d372da018427e1db7b92424d3471e01a4118
https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/contrib/inspirehep/author_util.py#L71-L82
train
Simple tokenizer function to be used with the normalizers.
ldomic/lintools
lintools/ligand_description.py
LigDescr.calculate_descriptors
def calculate_descriptors(self,mol): """Calculates descriptors such as logP, charges and MR and saves that in a dictionary.""" #make dictionary self.ligand_atoms = {index:{"name":x.name} for index,x in enumerate(self.topology_data.universe.ligand_noH.atoms)} #Calculate logP and MR contribs = self.calculate_l...
python
def calculate_descriptors(self,mol): """Calculates descriptors such as logP, charges and MR and saves that in a dictionary.""" #make dictionary self.ligand_atoms = {index:{"name":x.name} for index,x in enumerate(self.topology_data.universe.ligand_noH.atoms)} #Calculate logP and MR contribs = self.calculate_l...
[ "def", "calculate_descriptors", "(", "self", ",", "mol", ")", ":", "#make dictionary", "self", ".", "ligand_atoms", "=", "{", "index", ":", "{", "\"name\"", ":", "x", ".", "name", "}", "for", "index", ",", "x", "in", "enumerate", "(", "self", ".", "top...
Calculates descriptors such as logP, charges and MR and saves that in a dictionary.
[ "Calculates", "descriptors", "such", "as", "logP", "charges", "and", "MR", "and", "saves", "that", "in", "a", "dictionary", "." ]
d825a4a7b35f3f857d3b81b46c9aee72b0ec697a
https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/ligand_description.py#L23-L44
train
Calculates the descriptors of the ligands in a molecule and saves that in a dictionary.
ldomic/lintools
lintools/ligand_description.py
LigDescr.get_rotatable_bonds
def get_rotatable_bonds(self,mol): """Determines rotatable bonds in a ligand molecule Takes: * mol * - mol file in rdkit environment Output: * bonds * - tuples of atom ids """ RotatableBondSmarts = Chem.MolFromSmarts('[!$(*#*)&!D1]-&!@[!$(*#*)&!D1]') bonds = mol.GetSubstructMatches(RotatableBondSmarts...
python
def get_rotatable_bonds(self,mol): """Determines rotatable bonds in a ligand molecule Takes: * mol * - mol file in rdkit environment Output: * bonds * - tuples of atom ids """ RotatableBondSmarts = Chem.MolFromSmarts('[!$(*#*)&!D1]-&!@[!$(*#*)&!D1]') bonds = mol.GetSubstructMatches(RotatableBondSmarts...
[ "def", "get_rotatable_bonds", "(", "self", ",", "mol", ")", ":", "RotatableBondSmarts", "=", "Chem", ".", "MolFromSmarts", "(", "'[!$(*#*)&!D1]-&!@[!$(*#*)&!D1]'", ")", "bonds", "=", "mol", ".", "GetSubstructMatches", "(", "RotatableBondSmarts", ",", "uniquify", "="...
Determines rotatable bonds in a ligand molecule Takes: * mol * - mol file in rdkit environment Output: * bonds * - tuples of atom ids
[ "Determines", "rotatable", "bonds", "in", "a", "ligand", "molecule", "Takes", ":", "*", "mol", "*", "-", "mol", "file", "in", "rdkit", "environment", "Output", ":", "*", "bonds", "*", "-", "tuples", "of", "atom", "ids" ]
d825a4a7b35f3f857d3b81b46c9aee72b0ec697a
https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/ligand_description.py#L57-L66
train
Determines the rotatable bonds in a ligand molecule
ldomic/lintools
lintools/ligand_description.py
LigDescr.calculate_formal_charge
def calculate_formal_charge(self,mol): """Calculates formal charge for each atom. Takes: * mol * - mol file in rdkit environment Output: * formal_charges * - list of charges """ formal_charges = [] for atom in mol.GetAtoms(): formal_charges.append(atom.GetFormalCharge()) return formal_charges
python
def calculate_formal_charge(self,mol): """Calculates formal charge for each atom. Takes: * mol * - mol file in rdkit environment Output: * formal_charges * - list of charges """ formal_charges = [] for atom in mol.GetAtoms(): formal_charges.append(atom.GetFormalCharge()) return formal_charges
[ "def", "calculate_formal_charge", "(", "self", ",", "mol", ")", ":", "formal_charges", "=", "[", "]", "for", "atom", "in", "mol", ".", "GetAtoms", "(", ")", ":", "formal_charges", ".", "append", "(", "atom", ".", "GetFormalCharge", "(", ")", ")", "return...
Calculates formal charge for each atom. Takes: * mol * - mol file in rdkit environment Output: * formal_charges * - list of charges
[ "Calculates", "formal", "charge", "for", "each", "atom", ".", "Takes", ":", "*", "mol", "*", "-", "mol", "file", "in", "rdkit", "environment", "Output", ":", "*", "formal_charges", "*", "-", "list", "of", "charges" ]
d825a4a7b35f3f857d3b81b46c9aee72b0ec697a
https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/ligand_description.py#L71-L81
train
Calculates the formal charge for each atom in the molecule.
gusdan/geoindex
geoindex/geo_grid_index.py
GeoGridIndex.get_point_hash
def get_point_hash(self, point): """ return geohash for given point with self.precision :param point: GeoPoint instance :return: string """ return geohash.encode(point.latitude, point.longitude, self.precision)
python
def get_point_hash(self, point): """ return geohash for given point with self.precision :param point: GeoPoint instance :return: string """ return geohash.encode(point.latitude, point.longitude, self.precision)
[ "def", "get_point_hash", "(", "self", ",", "point", ")", ":", "return", "geohash", ".", "encode", "(", "point", ".", "latitude", ",", "point", ".", "longitude", ",", "self", ".", "precision", ")" ]
return geohash for given point with self.precision :param point: GeoPoint instance :return: string
[ "return", "geohash", "for", "given", "point", "with", "self", ".", "precision", ":", "param", "point", ":", "GeoPoint", "instance", ":", "return", ":", "string" ]
d1b3b5a52271200713a64041576caa1f2d588f55
https://github.com/gusdan/geoindex/blob/d1b3b5a52271200713a64041576caa1f2d588f55/geoindex/geo_grid_index.py#L31-L37
train
Returns geohash for given point with self. precision
gusdan/geoindex
geoindex/geo_grid_index.py
GeoGridIndex.add_point
def add_point(self, point): """ add point to index, point must be a GeoPoint instance :param point: :return: """ assert isinstance(point, GeoPoint), \ 'point should be GeoPoint instance' point_hash = self.get_point_hash(point) points = self.dat...
python
def add_point(self, point): """ add point to index, point must be a GeoPoint instance :param point: :return: """ assert isinstance(point, GeoPoint), \ 'point should be GeoPoint instance' point_hash = self.get_point_hash(point) points = self.dat...
[ "def", "add_point", "(", "self", ",", "point", ")", ":", "assert", "isinstance", "(", "point", ",", "GeoPoint", ")", ",", "'point should be GeoPoint instance'", "point_hash", "=", "self", ".", "get_point_hash", "(", "point", ")", "points", "=", "self", ".", ...
add point to index, point must be a GeoPoint instance :param point: :return:
[ "add", "point", "to", "index", "point", "must", "be", "a", "GeoPoint", "instance", ":", "param", "point", ":", ":", "return", ":" ]
d1b3b5a52271200713a64041576caa1f2d588f55
https://github.com/gusdan/geoindex/blob/d1b3b5a52271200713a64041576caa1f2d588f55/geoindex/geo_grid_index.py#L39-L49
train
add point to index
gusdan/geoindex
geoindex/geo_grid_index.py
GeoGridIndex.get_nearest_points_dirty
def get_nearest_points_dirty(self, center_point, radius, unit='km'): """ return approx list of point from circle with given center and radius it uses geohash and return with some error (see GEO_HASH_ERRORS) :param center_point: center of search circle :param radius: radius of sea...
python
def get_nearest_points_dirty(self, center_point, radius, unit='km'): """ return approx list of point from circle with given center and radius it uses geohash and return with some error (see GEO_HASH_ERRORS) :param center_point: center of search circle :param radius: radius of sea...
[ "def", "get_nearest_points_dirty", "(", "self", ",", "center_point", ",", "radius", ",", "unit", "=", "'km'", ")", ":", "if", "unit", "==", "'mi'", ":", "radius", "=", "utils", ".", "mi_to_km", "(", "radius", ")", "grid_size", "=", "GEO_HASH_GRID_SIZE", "[...
return approx list of point from circle with given center and radius it uses geohash and return with some error (see GEO_HASH_ERRORS) :param center_point: center of search circle :param radius: radius of search circle :return: list of GeoPoints from given area
[ "return", "approx", "list", "of", "point", "from", "circle", "with", "given", "center", "and", "radius", "it", "uses", "geohash", "and", "return", "with", "some", "error", "(", "see", "GEO_HASH_ERRORS", ")", ":", "param", "center_point", ":", "center", "of",...
d1b3b5a52271200713a64041576caa1f2d588f55
https://github.com/gusdan/geoindex/blob/d1b3b5a52271200713a64041576caa1f2d588f55/geoindex/geo_grid_index.py#L51-L75
train
get nearest points from circle with given center and radius
gusdan/geoindex
geoindex/geo_grid_index.py
GeoGridIndex.get_nearest_points
def get_nearest_points(self, center_point, radius, unit='km'): """ return list of geo points from circle with given center and radius :param center_point: GeoPoint with center of search circle :param radius: radius of search circle :return: generator with tuple with GeoPoints and...
python
def get_nearest_points(self, center_point, radius, unit='km'): """ return list of geo points from circle with given center and radius :param center_point: GeoPoint with center of search circle :param radius: radius of search circle :return: generator with tuple with GeoPoints and...
[ "def", "get_nearest_points", "(", "self", ",", "center_point", ",", "radius", ",", "unit", "=", "'km'", ")", ":", "assert", "isinstance", "(", "center_point", ",", "GeoPoint", ")", ",", "'point should be GeoPoint instance'", "for", "point", "in", "self", ".", ...
return list of geo points from circle with given center and radius :param center_point: GeoPoint with center of search circle :param radius: radius of search circle :return: generator with tuple with GeoPoints and distance
[ "return", "list", "of", "geo", "points", "from", "circle", "with", "given", "center", "and", "radius", ":", "param", "center_point", ":", "GeoPoint", "with", "center", "of", "search", "circle", ":", "param", "radius", ":", "radius", "of", "search", "circle",...
d1b3b5a52271200713a64041576caa1f2d588f55
https://github.com/gusdan/geoindex/blob/d1b3b5a52271200713a64041576caa1f2d588f55/geoindex/geo_grid_index.py#L77-L89
train
get nearest points from circle with given center and radius
robinandeer/puzzle
puzzle/plugins/vcf/mixins/variant_mixin.py
VariantMixin.variant
def variant(self, case_id, variant_id): """Return a specific variant. Args: case_id (str): Path to vcf file variant_id (str): A variant id Returns: variant (Variant): The variant object for the given id """ case_obj = self...
python
def variant(self, case_id, variant_id): """Return a specific variant. Args: case_id (str): Path to vcf file variant_id (str): A variant id Returns: variant (Variant): The variant object for the given id """ case_obj = self...
[ "def", "variant", "(", "self", ",", "case_id", ",", "variant_id", ")", ":", "case_obj", "=", "self", ".", "case", "(", "case_id", "=", "case_id", ")", "vcf_file_path", "=", "case_obj", ".", "variant_source", "self", ".", "head", "=", "get_header", "(", "...
Return a specific variant. Args: case_id (str): Path to vcf file variant_id (str): A variant id Returns: variant (Variant): The variant object for the given id
[ "Return", "a", "specific", "variant", "." ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_mixin.py#L22-L52
train
Return a specific variant.
robinandeer/puzzle
puzzle/plugins/vcf/mixins/variant_mixin.py
VariantMixin.variants
def variants(self, case_id, skip=0, count=1000, filters=None): """Return all variants in the VCF. This function will apply the given filter and return the 'count' first variants. If skip the first 'skip' variants will not be regarded. Args: case_id (str): Path to a ...
python
def variants(self, case_id, skip=0, count=1000, filters=None): """Return all variants in the VCF. This function will apply the given filter and return the 'count' first variants. If skip the first 'skip' variants will not be regarded. Args: case_id (str): Path to a ...
[ "def", "variants", "(", "self", ",", "case_id", ",", "skip", "=", "0", ",", "count", "=", "1000", ",", "filters", "=", "None", ")", ":", "filters", "=", "filters", "or", "{", "}", "case_obj", "=", "self", ".", "case", "(", "case_id", "=", "case_id"...
Return all variants in the VCF. This function will apply the given filter and return the 'count' first variants. If skip the first 'skip' variants will not be regarded. Args: case_id (str): Path to a vcf file (for this adapter) skip (int): Skip first variant...
[ "Return", "all", "variants", "in", "the", "VCF", "." ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_mixin.py#L54-L164
train
Return all variants in the VCF file.
robinandeer/puzzle
puzzle/plugins/vcf/mixins/variant_mixin.py
VariantMixin._get_filtered_variants
def _get_filtered_variants(self, vcf_file_path, filters={}): """Check if variants follows the filters This function will try to make filters faster for the vcf adapter Args: vcf_file_path(str): Path to vcf filters (dict): A dictionary with filters ...
python
def _get_filtered_variants(self, vcf_file_path, filters={}): """Check if variants follows the filters This function will try to make filters faster for the vcf adapter Args: vcf_file_path(str): Path to vcf filters (dict): A dictionary with filters ...
[ "def", "_get_filtered_variants", "(", "self", ",", "vcf_file_path", ",", "filters", "=", "{", "}", ")", ":", "genes", "=", "set", "(", ")", "consequences", "=", "set", "(", ")", "sv_types", "=", "set", "(", ")", "if", "filters", ".", "get", "(", "'ge...
Check if variants follows the filters This function will try to make filters faster for the vcf adapter Args: vcf_file_path(str): Path to vcf filters (dict): A dictionary with filters Yields: varian_line (str): A vcf variant line
[ "Check", "if", "variants", "follows", "the", "filters" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_mixin.py#L166-L231
train
Returns a generator that yields the variants that follow the filters
robinandeer/puzzle
puzzle/plugins/vcf/mixins/variant_mixin.py
VariantMixin._format_variants
def _format_variants(self, variant, index, case_obj, add_all_info=False): """Return a Variant object Format variant make a variant that includes enough information for the variant view. If add_all_info then all transcripts will be parsed Args: variant (cython2.Varia...
python
def _format_variants(self, variant, index, case_obj, add_all_info=False): """Return a Variant object Format variant make a variant that includes enough information for the variant view. If add_all_info then all transcripts will be parsed Args: variant (cython2.Varia...
[ "def", "_format_variants", "(", "self", ",", "variant", ",", "index", ",", "case_obj", ",", "add_all_info", "=", "False", ")", ":", "header_line", "=", "self", ".", "head", ".", "header", "# Get the individual ids for individuals in vcf file", "vcf_individuals", "="...
Return a Variant object Format variant make a variant that includes enough information for the variant view. If add_all_info then all transcripts will be parsed Args: variant (cython2.Variant): A variant object index (int): The index of the variant c...
[ "Return", "a", "Variant", "object" ]
9476f05b416d3a5135d25492cb31411fdf831c58
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_mixin.py#L233-L317
train
Format a single variant into a Variant object.
znerol/py-fnvhash
fnvhash/__init__.py
fnv
def fnv(data, hval_init, fnv_prime, fnv_size): """ Core FNV hash algorithm used in FNV0 and FNV1. """ assert isinstance(data, bytes) hval = hval_init for byte in data: hval = (hval * fnv_prime) % fnv_size hval = hval ^ _get_byte(byte) return hval
python
def fnv(data, hval_init, fnv_prime, fnv_size): """ Core FNV hash algorithm used in FNV0 and FNV1. """ assert isinstance(data, bytes) hval = hval_init for byte in data: hval = (hval * fnv_prime) % fnv_size hval = hval ^ _get_byte(byte) return hval
[ "def", "fnv", "(", "data", ",", "hval_init", ",", "fnv_prime", ",", "fnv_size", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "hval", "=", "hval_init", "for", "byte", "in", "data", ":", "hval", "=", "(", "hval", "*", "fnv_prime", ...
Core FNV hash algorithm used in FNV0 and FNV1.
[ "Core", "FNV", "hash", "algorithm", "used", "in", "FNV0", "and", "FNV1", "." ]
ea6d6993e1082dee2ca3b9aba7a7eb2b7ab6a52a
https://github.com/znerol/py-fnvhash/blob/ea6d6993e1082dee2ca3b9aba7a7eb2b7ab6a52a/fnvhash/__init__.py#L26-L36
train
Core FNV hash algorithm used in FNV0 and FNV1.
eleme/meepo
meepo/apps/eventsourcing/pub.py
sqlalchemy_es_pub.session_prepare
def session_prepare(self, session, _): """Send session_prepare signal in session "before_commit". The signal contains another event argument, which records whole info of what's changed in this session, so the signal receiver can receive and record the event. """ if not h...
python
def session_prepare(self, session, _): """Send session_prepare signal in session "before_commit". The signal contains another event argument, which records whole info of what's changed in this session, so the signal receiver can receive and record the event. """ if not h...
[ "def", "session_prepare", "(", "self", ",", "session", ",", "_", ")", ":", "if", "not", "hasattr", "(", "session", ",", "'meepo_unique_id'", ")", ":", "self", ".", "_session_init", "(", "session", ")", "evt", "=", "collections", ".", "defaultdict", "(", ...
Send session_prepare signal in session "before_commit". The signal contains another event argument, which records whole info of what's changed in this session, so the signal receiver can receive and record the event.
[ "Send", "session_prepare", "signal", "in", "session", "before_commit", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/pub.py#L75-L100
train
Send session_prepare signal in session before_commit.
eleme/meepo
meepo/apps/eventsourcing/pub.py
sqlalchemy_es_pub.session_commit
def session_commit(self, session): """Send session_commit signal in sqlalchemy ``before_commit``. This marks the success of session so the session may enter commit state. """ # this may happen when there's nothing to commit if not hasattr(session, 'meepo_unique_id'): ...
python
def session_commit(self, session): """Send session_commit signal in sqlalchemy ``before_commit``. This marks the success of session so the session may enter commit state. """ # this may happen when there's nothing to commit if not hasattr(session, 'meepo_unique_id'): ...
[ "def", "session_commit", "(", "self", ",", "session", ")", ":", "# this may happen when there's nothing to commit", "if", "not", "hasattr", "(", "session", ",", "'meepo_unique_id'", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"skipped - session_commit\"", ...
Send session_commit signal in sqlalchemy ``before_commit``. This marks the success of session so the session may enter commit state.
[ "Send", "session_commit", "signal", "in", "sqlalchemy", "before_commit", "." ]
8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/pub.py#L102-L117
train
Send session_commit signal in sqlalchemy before_commit.