repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
botstory/botstory
botstory/ast/story_context/reducers.py
scope_in
def scope_in(ctx): """ - build new scope on the top of stack - and current scope will wait for it result :param ctx: :return: """ logger.debug('# scope_in') logger.debug(ctx) ctx = ctx.clone() compiled_story = None if not ctx.is_empty_stack(): compiled_story = ctx.g...
python
def scope_in(ctx): """ - build new scope on the top of stack - and current scope will wait for it result :param ctx: :return: """ logger.debug('# scope_in') logger.debug(ctx) ctx = ctx.clone() compiled_story = None if not ctx.is_empty_stack(): compiled_story = ctx.g...
[ "def", "scope_in", "(", "ctx", ")", ":", "logger", ".", "debug", "(", "'# scope_in'", ")", "logger", ".", "debug", "(", "ctx", ")", "ctx", "=", "ctx", ".", "clone", "(", ")", "compiled_story", "=", "None", "if", "not", "ctx", ".", "is_empty_stack", "...
- build new scope on the top of stack - and current scope will wait for it result :param ctx: :return:
[ "-", "build", "new", "scope", "on", "the", "top", "of", "stack", "-", "and", "current", "scope", "will", "wait", "for", "it", "result" ]
9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3
https://github.com/botstory/botstory/blob/9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3/botstory/ast/story_context/reducers.py#L117-L158
train
55,700
MacHu-GWU/rolex-project
rolex/parse.py
Parser.str2date
def str2date(self, date_str): """ Parse date from string. If there's no template matches your string, Please go https://github.com/MacHu-GWU/rolex-project/issues submit your datetime string. I 'll update templates ASAP. This method is faster than :meth:`dateutil.parser....
python
def str2date(self, date_str): """ Parse date from string. If there's no template matches your string, Please go https://github.com/MacHu-GWU/rolex-project/issues submit your datetime string. I 'll update templates ASAP. This method is faster than :meth:`dateutil.parser....
[ "def", "str2date", "(", "self", ",", "date_str", ")", ":", "# try default date template", "try", ":", "a_datetime", "=", "datetime", ".", "strptime", "(", "date_str", ",", "self", ".", "_default_date_template", ")", "return", "a_datetime", ".", "date", "(", ")...
Parse date from string. If there's no template matches your string, Please go https://github.com/MacHu-GWU/rolex-project/issues submit your datetime string. I 'll update templates ASAP. This method is faster than :meth:`dateutil.parser.parse`. :param date_str: a string represe...
[ "Parse", "date", "from", "string", "." ]
a1111b410ed04b4b6eddd81df110fa2dacfa6537
https://github.com/MacHu-GWU/rolex-project/blob/a1111b410ed04b4b6eddd81df110fa2dacfa6537/rolex/parse.py#L129-L168
train
55,701
MacHu-GWU/rolex-project
rolex/parse.py
Parser._str2datetime
def _str2datetime(self, datetime_str): """ Parse datetime from string. If there's no template matches your string, Please go https://github.com/MacHu-GWU/rolex-project/issues submit your datetime string. I 'll update templates ASAP. This method is faster than :meth:`dat...
python
def _str2datetime(self, datetime_str): """ Parse datetime from string. If there's no template matches your string, Please go https://github.com/MacHu-GWU/rolex-project/issues submit your datetime string. I 'll update templates ASAP. This method is faster than :meth:`dat...
[ "def", "_str2datetime", "(", "self", ",", "datetime_str", ")", ":", "# try default datetime template", "try", ":", "a_datetime", "=", "datetime", ".", "strptime", "(", "datetime_str", ",", "self", ".", "_default_datetime_template", ")", "return", "a_datetime", "exce...
Parse datetime from string. If there's no template matches your string, Please go https://github.com/MacHu-GWU/rolex-project/issues submit your datetime string. I 'll update templates ASAP. This method is faster than :meth:`dateutil.parser.parse`. :param datetime_str: a string...
[ "Parse", "datetime", "from", "string", "." ]
a1111b410ed04b4b6eddd81df110fa2dacfa6537
https://github.com/MacHu-GWU/rolex-project/blob/a1111b410ed04b4b6eddd81df110fa2dacfa6537/rolex/parse.py#L170-L216
train
55,702
GeorgeArgyros/symautomata
symautomata/pythondfa.py
PythonDFA.define
def define(self): """If DFA is empty, create a sink state""" if len(self.states) == 0: for char in self.alphabet: self.add_arc(0, 0, char) self[0].final = False
python
def define(self): """If DFA is empty, create a sink state""" if len(self.states) == 0: for char in self.alphabet: self.add_arc(0, 0, char) self[0].final = False
[ "def", "define", "(", "self", ")", ":", "if", "len", "(", "self", ".", "states", ")", "==", "0", ":", "for", "char", "in", "self", ".", "alphabet", ":", "self", ".", "add_arc", "(", "0", ",", "0", ",", "char", ")", "self", "[", "0", "]", ".",...
If DFA is empty, create a sink state
[ "If", "DFA", "is", "empty", "create", "a", "sink", "state" ]
f5d66533573b27e155bec3f36b8c00b8e3937cb3
https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pythondfa.py#L160-L165
train
55,703
GeorgeArgyros/symautomata
symautomata/pythondfa.py
PythonDFA.add_state
def add_state(self): """Adds a new state""" sid = len(self.states) self.states.append(DFAState(sid)) return sid
python
def add_state(self): """Adds a new state""" sid = len(self.states) self.states.append(DFAState(sid)) return sid
[ "def", "add_state", "(", "self", ")", ":", "sid", "=", "len", "(", "self", ".", "states", ")", "self", ".", "states", ".", "append", "(", "DFAState", "(", "sid", ")", ")", "return", "sid" ]
Adds a new state
[ "Adds", "a", "new", "state" ]
f5d66533573b27e155bec3f36b8c00b8e3937cb3
https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pythondfa.py#L167-L171
train
55,704
GeorgeArgyros/symautomata
symautomata/pythondfa.py
PythonDFA._epsilon_closure
def _epsilon_closure(self, state): """ Returns the \epsilon-closure for the state given as input. """ closure = set([state.stateid]) stack = [state] while True: if not stack: break s = stack.pop() for arc in s: ...
python
def _epsilon_closure(self, state): """ Returns the \epsilon-closure for the state given as input. """ closure = set([state.stateid]) stack = [state] while True: if not stack: break s = stack.pop() for arc in s: ...
[ "def", "_epsilon_closure", "(", "self", ",", "state", ")", ":", "closure", "=", "set", "(", "[", "state", ".", "stateid", "]", ")", "stack", "=", "[", "state", "]", "while", "True", ":", "if", "not", "stack", ":", "break", "s", "=", "stack", ".", ...
Returns the \epsilon-closure for the state given as input.
[ "Returns", "the", "\\", "epsilon", "-", "closure", "for", "the", "state", "given", "as", "input", "." ]
f5d66533573b27e155bec3f36b8c00b8e3937cb3
https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pythondfa.py#L426-L442
train
55,705
GeorgeArgyros/symautomata
symautomata/pythondfa.py
PythonDFA.invert
def invert(self): """Inverts the DFA final states""" for state in self.states: if state.final: state.final = False else: state.final = True
python
def invert(self): """Inverts the DFA final states""" for state in self.states: if state.final: state.final = False else: state.final = True
[ "def", "invert", "(", "self", ")", ":", "for", "state", "in", "self", ".", "states", ":", "if", "state", ".", "final", ":", "state", ".", "final", "=", "False", "else", ":", "state", ".", "final", "=", "True" ]
Inverts the DFA final states
[ "Inverts", "the", "DFA", "final", "states" ]
f5d66533573b27e155bec3f36b8c00b8e3937cb3
https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pythondfa.py#L523-L529
train
55,706
Equitable/trump
trump/templating/converters.py
_ListConverter.as_list
def as_list(self): """ returns a list version of the object, based on it's attributes """ if hasattr(self, 'cust_list'): return self.cust_list if hasattr(self, 'attr_check'): self.attr_check() cls_bltns = set(dir(self.__class__)) r...
python
def as_list(self): """ returns a list version of the object, based on it's attributes """ if hasattr(self, 'cust_list'): return self.cust_list if hasattr(self, 'attr_check'): self.attr_check() cls_bltns = set(dir(self.__class__)) r...
[ "def", "as_list", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'cust_list'", ")", ":", "return", "self", ".", "cust_list", "if", "hasattr", "(", "self", ",", "'attr_check'", ")", ":", "self", ".", "attr_check", "(", ")", "cls_bltns", "=",...
returns a list version of the object, based on it's attributes
[ "returns", "a", "list", "version", "of", "the", "object", "based", "on", "it", "s", "attributes" ]
a2802692bc642fa32096374159eea7ceca2947b4
https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/templating/converters.py#L27-L37
train
55,707
Equitable/trump
trump/templating/converters.py
_DictConverter.as_dict
def as_dict(self): """ returns an dict version of the object, based on it's attributes """ if hasattr(self, 'cust_dict'): return self.cust_dict if hasattr(self, 'attr_check'): self.attr_check() cls_bltns = set(dir(self.__class__)) ...
python
def as_dict(self): """ returns an dict version of the object, based on it's attributes """ if hasattr(self, 'cust_dict'): return self.cust_dict if hasattr(self, 'attr_check'): self.attr_check() cls_bltns = set(dir(self.__class__)) ...
[ "def", "as_dict", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'cust_dict'", ")", ":", "return", "self", ".", "cust_dict", "if", "hasattr", "(", "self", ",", "'attr_check'", ")", ":", "self", ".", "attr_check", "(", ")", "cls_bltns", "=",...
returns an dict version of the object, based on it's attributes
[ "returns", "an", "dict", "version", "of", "the", "object", "based", "on", "it", "s", "attributes" ]
a2802692bc642fa32096374159eea7ceca2947b4
https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/templating/converters.py#L46-L55
train
55,708
Equitable/trump
trump/templating/converters.py
_OrderedDictConverter.as_odict
def as_odict(self): """ returns an odict version of the object, based on it's attributes """ if hasattr(self, 'cust_odict'): return self.cust_odict if hasattr(self, 'attr_check'): self.attr_check() odc = odict() for attr in self.at...
python
def as_odict(self): """ returns an odict version of the object, based on it's attributes """ if hasattr(self, 'cust_odict'): return self.cust_odict if hasattr(self, 'attr_check'): self.attr_check() odc = odict() for attr in self.at...
[ "def", "as_odict", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'cust_odict'", ")", ":", "return", "self", ".", "cust_odict", "if", "hasattr", "(", "self", ",", "'attr_check'", ")", ":", "self", ".", "attr_check", "(", ")", "odc", "=", ...
returns an odict version of the object, based on it's attributes
[ "returns", "an", "odict", "version", "of", "the", "object", "based", "on", "it", "s", "attributes" ]
a2802692bc642fa32096374159eea7ceca2947b4
https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/templating/converters.py#L68-L79
train
55,709
mnkhouri/news_scraper
news_scraper/scrape.py
fetch_and_parse
def fetch_and_parse(url, bodyLines): """Takes a url, and returns a dictionary of data with 'bodyLines' lines""" pageHtml = fetch_page(url) return parse(url, pageHtml, bodyLines)
python
def fetch_and_parse(url, bodyLines): """Takes a url, and returns a dictionary of data with 'bodyLines' lines""" pageHtml = fetch_page(url) return parse(url, pageHtml, bodyLines)
[ "def", "fetch_and_parse", "(", "url", ",", "bodyLines", ")", ":", "pageHtml", "=", "fetch_page", "(", "url", ")", "return", "parse", "(", "url", ",", "pageHtml", ",", "bodyLines", ")" ]
Takes a url, and returns a dictionary of data with 'bodyLines' lines
[ "Takes", "a", "url", "and", "returns", "a", "dictionary", "of", "data", "with", "bodyLines", "lines" ]
7fd3487c587281a4816f0761f0c4d2196ae05702
https://github.com/mnkhouri/news_scraper/blob/7fd3487c587281a4816f0761f0c4d2196ae05702/news_scraper/scrape.py#L68-L72
train
55,710
jlesquembre/termite
termite/utils.py
copy_rec
def copy_rec(source, dest): """Copy files between diferent directories. Copy one or more files to an existing directory. This function is recursive, if the source is a directory, all its subdirectories are created in the destination. Existing files in destination are overwrited without any warning....
python
def copy_rec(source, dest): """Copy files between diferent directories. Copy one or more files to an existing directory. This function is recursive, if the source is a directory, all its subdirectories are created in the destination. Existing files in destination are overwrited without any warning....
[ "def", "copy_rec", "(", "source", ",", "dest", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "source", ")", ":", "for", "child", "in", "os", ".", "listdir", "(", "source", ")", ":", "new_dest", "=", "os", ".", "path", ".", "join", "(", ...
Copy files between diferent directories. Copy one or more files to an existing directory. This function is recursive, if the source is a directory, all its subdirectories are created in the destination. Existing files in destination are overwrited without any warning. Args: source (str): F...
[ "Copy", "files", "between", "diferent", "directories", "." ]
fb77dcaa31872dc14dd3eeac694cd4c44aeee27b
https://github.com/jlesquembre/termite/blob/fb77dcaa31872dc14dd3eeac694cd4c44aeee27b/termite/utils.py#L31-L58
train
55,711
bitesofcode/projex
projex/xbuild/builder.py
Builder.build
def build(self): """ Builds this object into the desired output information. """ signed = bool(self.options() & Builder.Options.Signed) # remove previous build information buildpath = self.buildPath() if not buildpath: raise errors.InvalidBuildPath(bu...
python
def build(self): """ Builds this object into the desired output information. """ signed = bool(self.options() & Builder.Options.Signed) # remove previous build information buildpath = self.buildPath() if not buildpath: raise errors.InvalidBuildPath(bu...
[ "def", "build", "(", "self", ")", ":", "signed", "=", "bool", "(", "self", ".", "options", "(", ")", "&", "Builder", ".", "Options", ".", "Signed", ")", "# remove previous build information", "buildpath", "=", "self", ".", "buildPath", "(", ")", "if", "n...
Builds this object into the desired output information.
[ "Builds", "this", "object", "into", "the", "desired", "output", "information", "." ]
d31743ec456a41428709968ab11a2cf6c6c76247
https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/xbuild/builder.py#L185-L243
train
55,712
bitesofcode/projex
projex/xbuild/builder.py
Builder.generateRevision
def generateRevision(self): """ Generates the revision file for this builder. """ revpath = self.sourcePath() if not os.path.exists(revpath): return # determine the revision location revfile = os.path.join(revpath, self.revisionFilename()) mod...
python
def generateRevision(self): """ Generates the revision file for this builder. """ revpath = self.sourcePath() if not os.path.exists(revpath): return # determine the revision location revfile = os.path.join(revpath, self.revisionFilename()) mod...
[ "def", "generateRevision", "(", "self", ")", ":", "revpath", "=", "self", ".", "sourcePath", "(", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "revpath", ")", ":", "return", "# determine the revision location", "revfile", "=", "os", ".", "path"...
Generates the revision file for this builder.
[ "Generates", "the", "revision", "file", "for", "this", "builder", "." ]
d31743ec456a41428709968ab11a2cf6c6c76247
https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/xbuild/builder.py#L538-L578
train
55,713
bitesofcode/projex
projex/xbuild/builder.py
Builder.generateSetupFile
def generateSetupFile(self, outpath='.', egg=False): """ Generates the setup file for this builder. """ outpath = os.path.abspath(outpath) outfile = os.path.join(outpath, 'setup.py') opts = { 'name': self.name(), 'distname': self.distributionName(...
python
def generateSetupFile(self, outpath='.', egg=False): """ Generates the setup file for this builder. """ outpath = os.path.abspath(outpath) outfile = os.path.join(outpath, 'setup.py') opts = { 'name': self.name(), 'distname': self.distributionName(...
[ "def", "generateSetupFile", "(", "self", ",", "outpath", "=", "'.'", ",", "egg", "=", "False", ")", ":", "outpath", "=", "os", ".", "path", ".", "abspath", "(", "outpath", ")", "outfile", "=", "os", ".", "path", ".", "join", "(", "outpath", ",", "'...
Generates the setup file for this builder.
[ "Generates", "the", "setup", "file", "for", "this", "builder", "." ]
d31743ec456a41428709968ab11a2cf6c6c76247
https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/xbuild/builder.py#L709-L771
train
55,714
bitesofcode/projex
projex/xbuild/builder.py
Builder.generateZipFile
def generateZipFile(self, outpath='.'): """ Generates the zip file for this builder. """ fname = self.installName() + '.zip' outfile = os.path.abspath(os.path.join(outpath, fname)) # clears out the exiting archive if os.path.exists(outfile): try: ...
python
def generateZipFile(self, outpath='.'): """ Generates the zip file for this builder. """ fname = self.installName() + '.zip' outfile = os.path.abspath(os.path.join(outpath, fname)) # clears out the exiting archive if os.path.exists(outfile): try: ...
[ "def", "generateZipFile", "(", "self", ",", "outpath", "=", "'.'", ")", ":", "fname", "=", "self", ".", "installName", "(", ")", "+", "'.zip'", "outfile", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "outpath", ...
Generates the zip file for this builder.
[ "Generates", "the", "zip", "file", "for", "this", "builder", "." ]
d31743ec456a41428709968ab11a2cf6c6c76247
https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/xbuild/builder.py#L773-L819
train
55,715
e7dal/bubble3
_features_base/steps/behave_undefined_steps.py
step_undefined_step_snippets_should_exist_for_table
def step_undefined_step_snippets_should_exist_for_table(context): """ Checks if undefined-step snippets are provided. EXAMPLE: Then undefined-step snippets should exist for: | Step | | When an undefined step is used | | Then another undefined step is used | "...
python
def step_undefined_step_snippets_should_exist_for_table(context): """ Checks if undefined-step snippets are provided. EXAMPLE: Then undefined-step snippets should exist for: | Step | | When an undefined step is used | | Then another undefined step is used | "...
[ "def", "step_undefined_step_snippets_should_exist_for_table", "(", "context", ")", ":", "assert", "context", ".", "table", ",", "\"REQUIRES: table\"", "for", "row", "in", "context", ".", "table", ".", "rows", ":", "step", "=", "row", "[", "\"Step\"", "]", "step_...
Checks if undefined-step snippets are provided. EXAMPLE: Then undefined-step snippets should exist for: | Step | | When an undefined step is used | | Then another undefined step is used |
[ "Checks", "if", "undefined", "-", "step", "snippets", "are", "provided", "." ]
59c735281a95b44f6263a25f4d6ce24fca520082
https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/_features_base/steps/behave_undefined_steps.py#L71-L84
train
55,716
e7dal/bubble3
_features_base/steps/behave_undefined_steps.py
step_undefined_step_snippets_should_not_exist_for_table
def step_undefined_step_snippets_should_not_exist_for_table(context): """ Checks if undefined-step snippets are not provided. EXAMPLE: Then undefined-step snippets should not exist for: | Step | | When an known step is used | | Then another known step is used | ...
python
def step_undefined_step_snippets_should_not_exist_for_table(context): """ Checks if undefined-step snippets are not provided. EXAMPLE: Then undefined-step snippets should not exist for: | Step | | When an known step is used | | Then another known step is used | ...
[ "def", "step_undefined_step_snippets_should_not_exist_for_table", "(", "context", ")", ":", "assert", "context", ".", "table", ",", "\"REQUIRES: table\"", "for", "row", "in", "context", ".", "table", ".", "rows", ":", "step", "=", "row", "[", "\"Step\"", "]", "s...
Checks if undefined-step snippets are not provided. EXAMPLE: Then undefined-step snippets should not exist for: | Step | | When an known step is used | | Then another known step is used |
[ "Checks", "if", "undefined", "-", "step", "snippets", "are", "not", "provided", "." ]
59c735281a95b44f6263a25f4d6ce24fca520082
https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/_features_base/steps/behave_undefined_steps.py#L88-L101
train
55,717
andy9775/pyevent
pyevent/pyevent.py
mixin
def mixin (cls): """ A decorator which adds event methods to a class giving it the ability to bind to and trigger events :param cls: the class to add the event logic to :type cls: class :return: the modified class :rtype: class """ cls._events = {} cls.bind = Pyevent.bind.__func...
python
def mixin (cls): """ A decorator which adds event methods to a class giving it the ability to bind to and trigger events :param cls: the class to add the event logic to :type cls: class :return: the modified class :rtype: class """ cls._events = {} cls.bind = Pyevent.bind.__func...
[ "def", "mixin", "(", "cls", ")", ":", "cls", ".", "_events", "=", "{", "}", "cls", ".", "bind", "=", "Pyevent", ".", "bind", ".", "__func__", "cls", ".", "unbind", "=", "Pyevent", ".", "unbind", ".", "__func__", "cls", ".", "trigger", "=", "Pyevent...
A decorator which adds event methods to a class giving it the ability to bind to and trigger events :param cls: the class to add the event logic to :type cls: class :return: the modified class :rtype: class
[ "A", "decorator", "which", "adds", "event", "methods", "to", "a", "class", "giving", "it", "the", "ability", "to", "bind", "to", "and", "trigger", "events" ]
8ed4a4246e7af53e37114e1eeddcd9960285e1d6
https://github.com/andy9775/pyevent/blob/8ed4a4246e7af53e37114e1eeddcd9960285e1d6/pyevent/pyevent.py#L60-L74
train
55,718
Equitable/trump
trump/options.py
_read_options
def _read_options(paths,fname_def=None): """Builds a configuration reader function""" def reader_func(fname=fname_def, sect=None, sett=None, default=None): """Reads the configuration for trump""" cur_dir = os.path.dirname(os.path.realpath(__file__)) config_dir = os.path.join(cur_d...
python
def _read_options(paths,fname_def=None): """Builds a configuration reader function""" def reader_func(fname=fname_def, sect=None, sett=None, default=None): """Reads the configuration for trump""" cur_dir = os.path.dirname(os.path.realpath(__file__)) config_dir = os.path.join(cur_d...
[ "def", "_read_options", "(", "paths", ",", "fname_def", "=", "None", ")", ":", "def", "reader_func", "(", "fname", "=", "fname_def", ",", "sect", "=", "None", ",", "sett", "=", "None", ",", "default", "=", "None", ")", ":", "\"\"\"Reads the configuration f...
Builds a configuration reader function
[ "Builds", "a", "configuration", "reader", "function" ]
a2802692bc642fa32096374159eea7ceca2947b4
https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/options.py#L27-L92
train
55,719
hollenstein/maspy
maspy/sil.py
returnLabelState
def returnLabelState(peptide, labelDescriptor, labelSymbols=None, labelAminoacids=None): """Calculates the label state of a given peptide for the label setup described in labelDescriptor :param peptide: peptide which label state should be calcualted :param labelDescriptor: :class:`...
python
def returnLabelState(peptide, labelDescriptor, labelSymbols=None, labelAminoacids=None): """Calculates the label state of a given peptide for the label setup described in labelDescriptor :param peptide: peptide which label state should be calcualted :param labelDescriptor: :class:`...
[ "def", "returnLabelState", "(", "peptide", ",", "labelDescriptor", ",", "labelSymbols", "=", "None", ",", "labelAminoacids", "=", "None", ")", ":", "if", "labelSymbols", "is", "None", ":", "labelSymbols", "=", "modSymbolsFromLabelInfo", "(", "labelDescriptor", ")"...
Calculates the label state of a given peptide for the label setup described in labelDescriptor :param peptide: peptide which label state should be calcualted :param labelDescriptor: :class:`LabelDescriptor`, describes the label setup of an experiment. :param labelSymbols: modifications that sho...
[ "Calculates", "the", "label", "state", "of", "a", "given", "peptide", "for", "the", "label", "setup", "described", "in", "labelDescriptor" ]
f15fcfd24df306d8420540460d902aa3073ec133
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/sil.py#L159-L232
train
55,720
hollenstein/maspy
maspy/sil.py
modSymbolsFromLabelInfo
def modSymbolsFromLabelInfo(labelDescriptor): """Returns a set of all modiciation symbols which were used in the labelDescriptor :param labelDescriptor: :class:`LabelDescriptor` describes the label setup of an experiment :returns: #TODO: docstring """ modSymbols = set() for labelSt...
python
def modSymbolsFromLabelInfo(labelDescriptor): """Returns a set of all modiciation symbols which were used in the labelDescriptor :param labelDescriptor: :class:`LabelDescriptor` describes the label setup of an experiment :returns: #TODO: docstring """ modSymbols = set() for labelSt...
[ "def", "modSymbolsFromLabelInfo", "(", "labelDescriptor", ")", ":", "modSymbols", "=", "set", "(", ")", "for", "labelStateEntry", "in", "viewvalues", "(", "labelDescriptor", ".", "labels", ")", ":", "for", "labelPositionEntry", "in", "viewvalues", "(", "labelState...
Returns a set of all modiciation symbols which were used in the labelDescriptor :param labelDescriptor: :class:`LabelDescriptor` describes the label setup of an experiment :returns: #TODO: docstring
[ "Returns", "a", "set", "of", "all", "modiciation", "symbols", "which", "were", "used", "in", "the", "labelDescriptor" ]
f15fcfd24df306d8420540460d902aa3073ec133
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/sil.py#L235-L250
train
55,721
hollenstein/maspy
maspy/sil.py
modAminoacidsFromLabelInfo
def modAminoacidsFromLabelInfo(labelDescriptor): """Returns a set of all amino acids and termini which can bear a label, as described in "labelDescriptor". :param labelDescriptor: :class:`LabelDescriptor` describes the label setup of an experiment :returns: #TODO: docstring """ modAmin...
python
def modAminoacidsFromLabelInfo(labelDescriptor): """Returns a set of all amino acids and termini which can bear a label, as described in "labelDescriptor". :param labelDescriptor: :class:`LabelDescriptor` describes the label setup of an experiment :returns: #TODO: docstring """ modAmin...
[ "def", "modAminoacidsFromLabelInfo", "(", "labelDescriptor", ")", ":", "modAminoacids", "=", "set", "(", ")", "for", "labelStateEntry", "in", "viewvalues", "(", "labelDescriptor", ".", "labels", ")", ":", "for", "labelPositionEntry", "in", "viewkeys", "(", "labelS...
Returns a set of all amino acids and termini which can bear a label, as described in "labelDescriptor". :param labelDescriptor: :class:`LabelDescriptor` describes the label setup of an experiment :returns: #TODO: docstring
[ "Returns", "a", "set", "of", "all", "amino", "acids", "and", "termini", "which", "can", "bear", "a", "label", "as", "described", "in", "labelDescriptor", "." ]
f15fcfd24df306d8420540460d902aa3073ec133
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/sil.py#L253-L268
train
55,722
hollenstein/maspy
maspy/sil.py
expectedLabelPosition
def expectedLabelPosition(peptide, labelStateInfo, sequence=None, modPositions=None): """Returns a modification description of a certain label state of a peptide. :param peptide: Peptide sequence used to calculat the expected label state modifications :param labelStateInfo...
python
def expectedLabelPosition(peptide, labelStateInfo, sequence=None, modPositions=None): """Returns a modification description of a certain label state of a peptide. :param peptide: Peptide sequence used to calculat the expected label state modifications :param labelStateInfo...
[ "def", "expectedLabelPosition", "(", "peptide", ",", "labelStateInfo", ",", "sequence", "=", "None", ",", "modPositions", "=", "None", ")", ":", "if", "modPositions", "is", "None", ":", "modPositions", "=", "maspy", ".", "peptidemethods", ".", "returnModPosition...
Returns a modification description of a certain label state of a peptide. :param peptide: Peptide sequence used to calculat the expected label state modifications :param labelStateInfo: An entry of :attr:`LabelDescriptor.labels` that describes a label state :param sequence: unmodified amino...
[ "Returns", "a", "modification", "description", "of", "a", "certain", "label", "state", "of", "a", "peptide", "." ]
f15fcfd24df306d8420540460d902aa3073ec133
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/sil.py#L271-L327
train
55,723
hollenstein/maspy
maspy/sil.py
LabelDescriptor.addLabel
def addLabel(self, aminoAcidLabels, excludingModifications=None): """Adds a new labelstate. :param aminoAcidsLabels: Describes which amino acids can bear which labels. Possible keys are the amino acids in one letter code and 'nTerm', 'cTerm'. Possible values are the modification...
python
def addLabel(self, aminoAcidLabels, excludingModifications=None): """Adds a new labelstate. :param aminoAcidsLabels: Describes which amino acids can bear which labels. Possible keys are the amino acids in one letter code and 'nTerm', 'cTerm'. Possible values are the modification...
[ "def", "addLabel", "(", "self", ",", "aminoAcidLabels", ",", "excludingModifications", "=", "None", ")", ":", "if", "excludingModifications", "is", "not", "None", ":", "self", ".", "excludingModifictions", "=", "True", "labelEntry", "=", "{", "'aminoAcidLabels'", ...
Adds a new labelstate. :param aminoAcidsLabels: Describes which amino acids can bear which labels. Possible keys are the amino acids in one letter code and 'nTerm', 'cTerm'. Possible values are the modifications ids from :attr:`maspy.constants.aaModMass` as strings or a list...
[ "Adds", "a", "new", "labelstate", "." ]
f15fcfd24df306d8420540460d902aa3073ec133
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/sil.py#L61-L88
train
55,724
e7dal/bubble3
bubble3/util/generators.py
get_gen_slice
def get_gen_slice(ctx=Bubble(), iterable=[], amount=-1, index=-1): """very crude way of slicing a generator""" ctx.gbc.say('get_gen_slice', stuff=iterable, verbosity=10) i = -1 # TODO # i = 0 #NATURAL INDEX, this will break all features with exports and -p if amount > 0: if index < 0: ...
python
def get_gen_slice(ctx=Bubble(), iterable=[], amount=-1, index=-1): """very crude way of slicing a generator""" ctx.gbc.say('get_gen_slice', stuff=iterable, verbosity=10) i = -1 # TODO # i = 0 #NATURAL INDEX, this will break all features with exports and -p if amount > 0: if index < 0: ...
[ "def", "get_gen_slice", "(", "ctx", "=", "Bubble", "(", ")", ",", "iterable", "=", "[", "]", ",", "amount", "=", "-", "1", ",", "index", "=", "-", "1", ")", ":", "ctx", ".", "gbc", ".", "say", "(", "'get_gen_slice'", ",", "stuff", "=", "iterable"...
very crude way of slicing a generator
[ "very", "crude", "way", "of", "slicing", "a", "generator" ]
59c735281a95b44f6263a25f4d6ce24fca520082
https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/bubble3/util/generators.py#L35-L78
train
55,725
sparknetworks/pgpm
pgpm/lib/deploy.py
DeploymentManager._get_scripts
def _get_scripts(self, scripts_path_rel, files_deployment, script_type, project_path): """ Gets scripts from specified folders """ scripts_dict = {} if scripts_path_rel: self._logger.debug('Getting scripts with {0} definitions'.format(script_type)) scrip...
python
def _get_scripts(self, scripts_path_rel, files_deployment, script_type, project_path): """ Gets scripts from specified folders """ scripts_dict = {} if scripts_path_rel: self._logger.debug('Getting scripts with {0} definitions'.format(script_type)) scrip...
[ "def", "_get_scripts", "(", "self", ",", "scripts_path_rel", ",", "files_deployment", ",", "script_type", ",", "project_path", ")", ":", "scripts_dict", "=", "{", "}", "if", "scripts_path_rel", ":", "self", ".", "_logger", ".", "debug", "(", "'Getting scripts wi...
Gets scripts from specified folders
[ "Gets", "scripts", "from", "specified", "folders" ]
1a060df46a886095181f692ea870a73a32510a2e
https://github.com/sparknetworks/pgpm/blob/1a060df46a886095181f692ea870a73a32510a2e/pgpm/lib/deploy.py#L467-L483
train
55,726
sparknetworks/pgpm
pgpm/lib/deploy.py
DeploymentManager._resolve_dependencies
def _resolve_dependencies(self, cur, dependencies): """ Function checks if dependant packages are installed in DB """ list_of_deps_ids = [] _list_of_deps_unresolved = [] _is_deps_resolved = True for k, v in dependencies.items(): pgpm.lib.utils.db.SqlSc...
python
def _resolve_dependencies(self, cur, dependencies): """ Function checks if dependant packages are installed in DB """ list_of_deps_ids = [] _list_of_deps_unresolved = [] _is_deps_resolved = True for k, v in dependencies.items(): pgpm.lib.utils.db.SqlSc...
[ "def", "_resolve_dependencies", "(", "self", ",", "cur", ",", "dependencies", ")", ":", "list_of_deps_ids", "=", "[", "]", "_list_of_deps_unresolved", "=", "[", "]", "_is_deps_resolved", "=", "True", "for", "k", ",", "v", "in", "dependencies", ".", "items", ...
Function checks if dependant packages are installed in DB
[ "Function", "checks", "if", "dependant", "packages", "are", "installed", "in", "DB" ]
1a060df46a886095181f692ea870a73a32510a2e
https://github.com/sparknetworks/pgpm/blob/1a060df46a886095181f692ea870a73a32510a2e/pgpm/lib/deploy.py#L485-L505
train
55,727
sparknetworks/pgpm
pgpm/lib/deploy.py
DeploymentManager._reorder_types
def _reorder_types(self, types_script): """ Takes type scripts and reorders them to avoid Type doesn't exist exception """ self._logger.debug('Running types definitions scripts') self._logger.debug('Reordering types definitions scripts to avoid "type does not exist" exceptions') ...
python
def _reorder_types(self, types_script): """ Takes type scripts and reorders them to avoid Type doesn't exist exception """ self._logger.debug('Running types definitions scripts') self._logger.debug('Reordering types definitions scripts to avoid "type does not exist" exceptions') ...
[ "def", "_reorder_types", "(", "self", ",", "types_script", ")", ":", "self", ".", "_logger", ".", "debug", "(", "'Running types definitions scripts'", ")", "self", ".", "_logger", ".", "debug", "(", "'Reordering types definitions scripts to avoid \"type does not exist\" e...
Takes type scripts and reorders them to avoid Type doesn't exist exception
[ "Takes", "type", "scripts", "and", "reorders", "them", "to", "avoid", "Type", "doesn", "t", "exist", "exception" ]
1a060df46a886095181f692ea870a73a32510a2e
https://github.com/sparknetworks/pgpm/blob/1a060df46a886095181f692ea870a73a32510a2e/pgpm/lib/deploy.py#L507-L568
train
55,728
codeforamerica/epa_python
scrape_definitions.py
Scraper.find_table_links
def find_table_links(self): """ When given a url, this function will find all the available table names for that EPA dataset. """ html = urlopen(self.model_url).read() doc = lh.fromstring(html) href_list = [area.attrib['href'] for area in doc.cssselect('map area')...
python
def find_table_links(self): """ When given a url, this function will find all the available table names for that EPA dataset. """ html = urlopen(self.model_url).read() doc = lh.fromstring(html) href_list = [area.attrib['href'] for area in doc.cssselect('map area')...
[ "def", "find_table_links", "(", "self", ")", ":", "html", "=", "urlopen", "(", "self", ".", "model_url", ")", ".", "read", "(", ")", "doc", "=", "lh", ".", "fromstring", "(", "html", ")", "href_list", "=", "[", "area", ".", "attrib", "[", "'href'", ...
When given a url, this function will find all the available table names for that EPA dataset.
[ "When", "given", "a", "url", "this", "function", "will", "find", "all", "the", "available", "table", "names", "for", "that", "EPA", "dataset", "." ]
62a53da62936bea8daa487a01a52b973e9062b2c
https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/scrape_definitions.py#L37-L46
train
55,729
codeforamerica/epa_python
scrape_definitions.py
Scraper.find_definition_urls
def find_definition_urls(self, set_of_links): """Find the available definition URLs for the columns in a table.""" definition_dict = {} re_link_name = re.compile('.*p_table_name=(\w+)&p_topic.*') for link in set_of_links: if link.startswith('http://'): table_d...
python
def find_definition_urls(self, set_of_links): """Find the available definition URLs for the columns in a table.""" definition_dict = {} re_link_name = re.compile('.*p_table_name=(\w+)&p_topic.*') for link in set_of_links: if link.startswith('http://'): table_d...
[ "def", "find_definition_urls", "(", "self", ",", "set_of_links", ")", ":", "definition_dict", "=", "{", "}", "re_link_name", "=", "re", ".", "compile", "(", "'.*p_table_name=(\\w+)&p_topic.*'", ")", "for", "link", "in", "set_of_links", ":", "if", "link", ".", ...
Find the available definition URLs for the columns in a table.
[ "Find", "the", "available", "definition", "URLs", "for", "the", "columns", "in", "a", "table", "." ]
62a53da62936bea8daa487a01a52b973e9062b2c
https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/scrape_definitions.py#L69-L84
train
55,730
codeforamerica/epa_python
scrape_definitions.py
Scraper.create_agency
def create_agency(self): """Create an agency text file of definitions.""" agency = self.agency links = self.find_table_links() definition_dict = self.find_definition_urls(links) with open(agency + '.txt', 'w') as f: f.write(str(definition_dict))
python
def create_agency(self): """Create an agency text file of definitions.""" agency = self.agency links = self.find_table_links() definition_dict = self.find_definition_urls(links) with open(agency + '.txt', 'w') as f: f.write(str(definition_dict))
[ "def", "create_agency", "(", "self", ")", ":", "agency", "=", "self", ".", "agency", "links", "=", "self", ".", "find_table_links", "(", ")", "definition_dict", "=", "self", ".", "find_definition_urls", "(", "links", ")", "with", "open", "(", "agency", "+"...
Create an agency text file of definitions.
[ "Create", "an", "agency", "text", "file", "of", "definitions", "." ]
62a53da62936bea8daa487a01a52b973e9062b2c
https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/scrape_definitions.py#L86-L92
train
55,731
codeforamerica/epa_python
scrape_definitions.py
Scraper.loop_through_agency
def loop_through_agency(self): """Loop through an agency to grab the definitions for its tables.""" agency = self.agency with open(agency + '.txt') as f: data = eval(f.read()) for table in data: for column in data[table]: value_link = data[table][c...
python
def loop_through_agency(self): """Loop through an agency to grab the definitions for its tables.""" agency = self.agency with open(agency + '.txt') as f: data = eval(f.read()) for table in data: for column in data[table]: value_link = data[table][c...
[ "def", "loop_through_agency", "(", "self", ")", ":", "agency", "=", "self", ".", "agency", "with", "open", "(", "agency", "+", "'.txt'", ")", "as", "f", ":", "data", "=", "eval", "(", "f", ".", "read", "(", ")", ")", "for", "table", "in", "data", ...
Loop through an agency to grab the definitions for its tables.
[ "Loop", "through", "an", "agency", "to", "grab", "the", "definitions", "for", "its", "tables", "." ]
62a53da62936bea8daa487a01a52b973e9062b2c
https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/scrape_definitions.py#L94-L105
train
55,732
codeforamerica/epa_python
scrape_definitions.py
Scraper.grab_definition
def grab_definition(self, url): """ Grab the column definition of a table from the EPA using a combination of regular expressions and lxml. """ re_description = re.compile('Description:(.+?\\n)') re_table_name = re.compile("(\w+ Table.+)") if url.startswith('//'):...
python
def grab_definition(self, url): """ Grab the column definition of a table from the EPA using a combination of regular expressions and lxml. """ re_description = re.compile('Description:(.+?\\n)') re_table_name = re.compile("(\w+ Table.+)") if url.startswith('//'):...
[ "def", "grab_definition", "(", "self", ",", "url", ")", ":", "re_description", "=", "re", ".", "compile", "(", "'Description:(.+?\\\\n)'", ")", "re_table_name", "=", "re", ".", "compile", "(", "\"(\\w+ Table.+)\"", ")", "if", "url", ".", "startswith", "(", "...
Grab the column definition of a table from the EPA using a combination of regular expressions and lxml.
[ "Grab", "the", "column", "definition", "of", "a", "table", "from", "the", "EPA", "using", "a", "combination", "of", "regular", "expressions", "and", "lxml", "." ]
62a53da62936bea8daa487a01a52b973e9062b2c
https://github.com/codeforamerica/epa_python/blob/62a53da62936bea8daa487a01a52b973e9062b2c/scrape_definitions.py#L107-L129
train
55,733
nicferrier/md
src/mdlib/cli.py
main
def main(*argv, filesystem=None, do_exit=True, stdout=None, stderr=None): """Main method for the cli. We allow the filesystem to be overridden for test purposes.""" try: mdcli = MdCLI() mdcli.filesystem = filesystem mdcli.stdout = stdout or ...
python
def main(*argv, filesystem=None, do_exit=True, stdout=None, stderr=None): """Main method for the cli. We allow the filesystem to be overridden for test purposes.""" try: mdcli = MdCLI() mdcli.filesystem = filesystem mdcli.stdout = stdout or ...
[ "def", "main", "(", "*", "argv", ",", "filesystem", "=", "None", ",", "do_exit", "=", "True", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ")", ":", "try", ":", "mdcli", "=", "MdCLI", "(", ")", "mdcli", ".", "filesystem", "=", "filesyste...
Main method for the cli. We allow the filesystem to be overridden for test purposes.
[ "Main", "method", "for", "the", "cli", "." ]
302ca8882dae060fb15bd5ae470d8e661fb67ec4
https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/cli.py#L361-L380
train
55,734
nicferrier/md
src/mdlib/cli.py
MdCLI.get_optparser
def get_optparser(self): """Override to allow specification of the maildir""" p = Cmdln.get_optparser(self) p.add_option( "-M", "--maildir", action="store", dest="maildir" ) p.add_option( "-V", "--verbose...
python
def get_optparser(self): """Override to allow specification of the maildir""" p = Cmdln.get_optparser(self) p.add_option( "-M", "--maildir", action="store", dest="maildir" ) p.add_option( "-V", "--verbose...
[ "def", "get_optparser", "(", "self", ")", ":", "p", "=", "Cmdln", ".", "get_optparser", "(", "self", ")", "p", ".", "add_option", "(", "\"-M\"", ",", "\"--maildir\"", ",", "action", "=", "\"store\"", ",", "dest", "=", "\"maildir\"", ")", "p", ".", "add...
Override to allow specification of the maildir
[ "Override", "to", "allow", "specification", "of", "the", "maildir" ]
302ca8882dae060fb15bd5ae470d8e661fb67ec4
https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/cli.py#L62-L77
train
55,735
stephrdev/django-tapeforms
tapeforms/templatetags/tapeforms.py
form
def form(context, form, **kwargs): """ The `form` template tag will render a tape-form enabled form using the template provided by `get_layout_template` method of the form using the context generated by `get_layout_context` method of the form. Usage:: {% load tapeforms %} {% form m...
python
def form(context, form, **kwargs): """ The `form` template tag will render a tape-form enabled form using the template provided by `get_layout_template` method of the form using the context generated by `get_layout_context` method of the form. Usage:: {% load tapeforms %} {% form m...
[ "def", "form", "(", "context", ",", "form", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "form", ",", "(", "forms", ".", "BaseForm", ",", "TapeformFieldset", ")", ")", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "'P...
The `form` template tag will render a tape-form enabled form using the template provided by `get_layout_template` method of the form using the context generated by `get_layout_context` method of the form. Usage:: {% load tapeforms %} {% form my_form %} You can override the used layout...
[ "The", "form", "template", "tag", "will", "render", "a", "tape", "-", "form", "enabled", "form", "using", "the", "template", "provided", "by", "get_layout_template", "method", "of", "the", "form", "using", "the", "context", "generated", "by", "get_layout_context...
255602de43777141f18afaf30669d7bdd4f7c323
https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/templatetags/tapeforms.py#L11-L39
train
55,736
stephrdev/django-tapeforms
tapeforms/templatetags/tapeforms.py
formfield
def formfield(context, bound_field, **kwargs): """ The `formfield` template tag will render a form field of a tape-form enabled form using the template provided by `get_field_template` method of the form together with the context generated by `get_field_context` method of the form. Usage:: ...
python
def formfield(context, bound_field, **kwargs): """ The `formfield` template tag will render a form field of a tape-form enabled form using the template provided by `get_field_template` method of the form together with the context generated by `get_field_context` method of the form. Usage:: ...
[ "def", "formfield", "(", "context", ",", "bound_field", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "bound_field", ",", "forms", ".", "BoundField", ")", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "'Provided field should b...
The `formfield` template tag will render a form field of a tape-form enabled form using the template provided by `get_field_template` method of the form together with the context generated by `get_field_context` method of the form. Usage:: {% load tapeforms %} {% formfield my_form.my_field...
[ "The", "formfield", "template", "tag", "will", "render", "a", "form", "field", "of", "a", "tape", "-", "form", "enabled", "form", "using", "the", "template", "provided", "by", "get_field_template", "method", "of", "the", "form", "together", "with", "the", "c...
255602de43777141f18afaf30669d7bdd4f7c323
https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/templatetags/tapeforms.py#L43-L71
train
55,737
BrianHicks/emit
emit/router/core.py
Router.wrap_as_node
def wrap_as_node(self, func): 'wrap a function as a node' name = self.get_name(func) @wraps(func) def wrapped(*args, **kwargs): 'wrapped version of func' message = self.get_message_from_call(*args, **kwargs) self.logger.info('calling "%s" with %r', na...
python
def wrap_as_node(self, func): 'wrap a function as a node' name = self.get_name(func) @wraps(func) def wrapped(*args, **kwargs): 'wrapped version of func' message = self.get_message_from_call(*args, **kwargs) self.logger.info('calling "%s" with %r', na...
[ "def", "wrap_as_node", "(", "self", ",", "func", ")", ":", "name", "=", "self", ".", "get_name", "(", "func", ")", "@", "wraps", "(", "func", ")", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "'wrapped version of func'", "me...
wrap a function as a node
[ "wrap", "a", "function", "as", "a", "node" ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L61-L105
train
55,738
BrianHicks/emit
emit/router/core.py
Router.node
def node(self, fields, subscribe_to=None, entry_point=False, ignore=None, **wrapper_options): '''\ Decorate a function to make it a node. .. note:: decorating as a node changes the function signature. Nodes should accept a single argument, which will be a ...
python
def node(self, fields, subscribe_to=None, entry_point=False, ignore=None, **wrapper_options): '''\ Decorate a function to make it a node. .. note:: decorating as a node changes the function signature. Nodes should accept a single argument, which will be a ...
[ "def", "node", "(", "self", ",", "fields", ",", "subscribe_to", "=", "None", ",", "entry_point", "=", "False", ",", "ignore", "=", "None", ",", "*", "*", "wrapper_options", ")", ":", "def", "outer", "(", "func", ")", ":", "'outer level function'", "# cre...
\ Decorate a function to make it a node. .. note:: decorating as a node changes the function signature. Nodes should accept a single argument, which will be a :py:class:`emit.message.Message`. Nodes can be called directly by providing a dictionary argument or...
[ "\\", "Decorate", "a", "function", "to", "make", "it", "a", "node", "." ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L107-L159
train
55,739
BrianHicks/emit
emit/router/core.py
Router.resolve_node_modules
def resolve_node_modules(self): 'import the modules specified in init' if not self.resolved_node_modules: try: self.resolved_node_modules = [ importlib.import_module(mod, self.node_package) for mod in self.node_modules ]...
python
def resolve_node_modules(self): 'import the modules specified in init' if not self.resolved_node_modules: try: self.resolved_node_modules = [ importlib.import_module(mod, self.node_package) for mod in self.node_modules ]...
[ "def", "resolve_node_modules", "(", "self", ")", ":", "if", "not", "self", ".", "resolved_node_modules", ":", "try", ":", "self", ".", "resolved_node_modules", "=", "[", "importlib", ".", "import_module", "(", "mod", ",", "self", ".", "node_package", ")", "f...
import the modules specified in init
[ "import", "the", "modules", "specified", "in", "init" ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L161-L173
train
55,740
BrianHicks/emit
emit/router/core.py
Router.get_message_from_call
def get_message_from_call(self, *args, **kwargs): '''\ Get message object from a call. :raises: :py:exc:`TypeError` (if the format is not what we expect) This is where arguments to nodes are turned into Messages. Arguments are parsed in the following order: - A single...
python
def get_message_from_call(self, *args, **kwargs): '''\ Get message object from a call. :raises: :py:exc:`TypeError` (if the format is not what we expect) This is where arguments to nodes are turned into Messages. Arguments are parsed in the following order: - A single...
[ "def", "get_message_from_call", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", "==", "1", "and", "isinstance", "(", "args", "[", "0", "]", ",", "dict", ")", ":", "# then it's a message", "self", ".", ...
\ Get message object from a call. :raises: :py:exc:`TypeError` (if the format is not what we expect) This is where arguments to nodes are turned into Messages. Arguments are parsed in the following order: - A single positional argument (a :py:class:`dict`) - No posit...
[ "\\", "Get", "message", "object", "from", "a", "call", "." ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L175-L203
train
55,741
BrianHicks/emit
emit/router/core.py
Router.register
def register(self, name, func, fields, subscribe_to, entry_point, ignore): ''' Register a named function in the graph :param name: name to register :type name: :py:class:`str` :param func: function to remember and call :type func: callable ``fields``, ``subscrib...
python
def register(self, name, func, fields, subscribe_to, entry_point, ignore): ''' Register a named function in the graph :param name: name to register :type name: :py:class:`str` :param func: function to remember and call :type func: callable ``fields``, ``subscrib...
[ "def", "register", "(", "self", ",", "name", ",", "func", ",", "fields", ",", "subscribe_to", ",", "entry_point", ",", "ignore", ")", ":", "self", ".", "fields", "[", "name", "]", "=", "fields", "self", ".", "functions", "[", "name", "]", "=", "func"...
Register a named function in the graph :param name: name to register :type name: :py:class:`str` :param func: function to remember and call :type func: callable ``fields``, ``subscribe_to`` and ``entry_point`` are the same as in :py:meth:`Router.node`.
[ "Register", "a", "named", "function", "in", "the", "graph" ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L205-L228
train
55,742
BrianHicks/emit
emit/router/core.py
Router.add_entry_point
def add_entry_point(self, destination): '''\ Add an entry point :param destination: node to route to initially :type destination: str ''' self.routes.setdefault('__entry_point', set()).add(destination) return self.routes['__entry_point']
python
def add_entry_point(self, destination): '''\ Add an entry point :param destination: node to route to initially :type destination: str ''' self.routes.setdefault('__entry_point', set()).add(destination) return self.routes['__entry_point']
[ "def", "add_entry_point", "(", "self", ",", "destination", ")", ":", "self", ".", "routes", ".", "setdefault", "(", "'__entry_point'", ",", "set", "(", ")", ")", ".", "add", "(", "destination", ")", "return", "self", ".", "routes", "[", "'__entry_point'", ...
\ Add an entry point :param destination: node to route to initially :type destination: str
[ "\\", "Add", "an", "entry", "point" ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L230-L238
train
55,743
BrianHicks/emit
emit/router/core.py
Router.register_route
def register_route(self, origins, destination): ''' Add routes to the routing dictionary :param origins: a number of origins to register :type origins: :py:class:`str` or iterable of :py:class:`str` or None :param destination: where the origins should point to :type dest...
python
def register_route(self, origins, destination): ''' Add routes to the routing dictionary :param origins: a number of origins to register :type origins: :py:class:`str` or iterable of :py:class:`str` or None :param destination: where the origins should point to :type dest...
[ "def", "register_route", "(", "self", ",", "origins", ",", "destination", ")", ":", "self", ".", "names", ".", "add", "(", "destination", ")", "self", ".", "logger", ".", "debug", "(", "'added \"%s\" to names'", ",", "destination", ")", "origins", "=", "or...
Add routes to the routing dictionary :param origins: a number of origins to register :type origins: :py:class:`str` or iterable of :py:class:`str` or None :param destination: where the origins should point to :type destination: :py:class:`str` Routing dictionary takes the follo...
[ "Add", "routes", "to", "the", "routing", "dictionary" ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L240-L265
train
55,744
BrianHicks/emit
emit/router/core.py
Router.register_ignore
def register_ignore(self, origins, destination): ''' Add routes to the ignore dictionary :param origins: a number of origins to register :type origins: :py:class:`str` or iterable of :py:class:`str` :param destination: where the origins should point to :type destination:...
python
def register_ignore(self, origins, destination): ''' Add routes to the ignore dictionary :param origins: a number of origins to register :type origins: :py:class:`str` or iterable of :py:class:`str` :param destination: where the origins should point to :type destination:...
[ "def", "register_ignore", "(", "self", ",", "origins", ",", "destination", ")", ":", "if", "not", "isinstance", "(", "origins", ",", "list", ")", ":", "origins", "=", "[", "origins", "]", "self", ".", "ignore_regexes", ".", "setdefault", "(", "destination"...
Add routes to the ignore dictionary :param origins: a number of origins to register :type origins: :py:class:`str` or iterable of :py:class:`str` :param destination: where the origins should point to :type destination: :py:class:`str` Ignore dictionary takes the following form:...
[ "Add", "routes", "to", "the", "ignore", "dictionary" ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L267-L288
train
55,745
BrianHicks/emit
emit/router/core.py
Router.regenerate_routes
def regenerate_routes(self): 'regenerate the routes after a new route is added' for destination, origins in self.regexes.items(): # we want only the names that match the destination regexes. resolved = [ name for name in self.names if name is not d...
python
def regenerate_routes(self): 'regenerate the routes after a new route is added' for destination, origins in self.regexes.items(): # we want only the names that match the destination regexes. resolved = [ name for name in self.names if name is not d...
[ "def", "regenerate_routes", "(", "self", ")", ":", "for", "destination", ",", "origins", "in", "self", ".", "regexes", ".", "items", "(", ")", ":", "# we want only the names that match the destination regexes.", "resolved", "=", "[", "name", "for", "name", "in", ...
regenerate the routes after a new route is added
[ "regenerate", "the", "routes", "after", "a", "new", "route", "is", "added" ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L290-L317
train
55,746
BrianHicks/emit
emit/router/core.py
Router.route
def route(self, origin, message): '''\ Using the routing dictionary, dispatch a message to all subscribers :param origin: name of the origin node :type origin: :py:class:`str` :param message: message to dispatch :type message: :py:class:`emit.message.Message` or subclass...
python
def route(self, origin, message): '''\ Using the routing dictionary, dispatch a message to all subscribers :param origin: name of the origin node :type origin: :py:class:`str` :param message: message to dispatch :type message: :py:class:`emit.message.Message` or subclass...
[ "def", "route", "(", "self", ",", "origin", ",", "message", ")", ":", "# side-effect: we have to know all the routes before we can route. But", "# we can't resolve them while the object is initializing, so we have to", "# do it just in time to route.", "self", ".", "resolve_node_module...
\ Using the routing dictionary, dispatch a message to all subscribers :param origin: name of the origin node :type origin: :py:class:`str` :param message: message to dispatch :type message: :py:class:`emit.message.Message` or subclass
[ "\\", "Using", "the", "routing", "dictionary", "dispatch", "a", "message", "to", "all", "subscribers" ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L327-L348
train
55,747
BrianHicks/emit
emit/router/core.py
Router.dispatch
def dispatch(self, origin, destination, message): '''\ dispatch a message to a named function :param destination: destination to dispatch to :type destination: :py:class:`str` :param message: message to dispatch :type message: :py:class:`emit.message.Message` or subclass...
python
def dispatch(self, origin, destination, message): '''\ dispatch a message to a named function :param destination: destination to dispatch to :type destination: :py:class:`str` :param message: message to dispatch :type message: :py:class:`emit.message.Message` or subclass...
[ "def", "dispatch", "(", "self", ",", "origin", ",", "destination", ",", "message", ")", ":", "func", "=", "self", ".", "functions", "[", "destination", "]", "self", ".", "logger", ".", "debug", "(", "'calling %r directly'", ",", "func", ")", "return", "f...
\ dispatch a message to a named function :param destination: destination to dispatch to :type destination: :py:class:`str` :param message: message to dispatch :type message: :py:class:`emit.message.Message` or subclass
[ "\\", "dispatch", "a", "message", "to", "a", "named", "function" ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L350-L361
train
55,748
BrianHicks/emit
emit/router/core.py
Router.wrap_result
def wrap_result(self, name, result): ''' Wrap a result from a function with it's stated fields :param name: fields to look up :type name: :py:class:`str` :param result: return value from function. Will be converted to tuple. :type result: anything :raises: :py:e...
python
def wrap_result(self, name, result): ''' Wrap a result from a function with it's stated fields :param name: fields to look up :type name: :py:class:`str` :param result: return value from function. Will be converted to tuple. :type result: anything :raises: :py:e...
[ "def", "wrap_result", "(", "self", ",", "name", ",", "result", ")", ":", "if", "not", "isinstance", "(", "result", ",", "tuple", ")", ":", "result", "=", "tuple", "(", "[", "result", "]", ")", "try", ":", "return", "dict", "(", "zip", "(", "self", ...
Wrap a result from a function with it's stated fields :param name: fields to look up :type name: :py:class:`str` :param result: return value from function. Will be converted to tuple. :type result: anything :raises: :py:exc:`ValueError` if name has no associated fields ...
[ "Wrap", "a", "result", "from", "a", "function", "with", "it", "s", "stated", "fields" ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L363-L384
train
55,749
BrianHicks/emit
emit/router/core.py
Router.get_name
def get_name(self, func): ''' Get the name to reference a function by :param func: function to get the name of :type func: callable ''' if hasattr(func, 'name'): return func.name return '%s.%s' % ( func.__module__, func.__name...
python
def get_name(self, func): ''' Get the name to reference a function by :param func: function to get the name of :type func: callable ''' if hasattr(func, 'name'): return func.name return '%s.%s' % ( func.__module__, func.__name...
[ "def", "get_name", "(", "self", ",", "func", ")", ":", "if", "hasattr", "(", "func", ",", "'name'", ")", ":", "return", "func", ".", "name", "return", "'%s.%s'", "%", "(", "func", ".", "__module__", ",", "func", ".", "__name__", ")" ]
Get the name to reference a function by :param func: function to get the name of :type func: callable
[ "Get", "the", "name", "to", "reference", "a", "function", "by" ]
19a86c2392b136c9e857000798ccaa525aa0ed84
https://github.com/BrianHicks/emit/blob/19a86c2392b136c9e857000798ccaa525aa0ed84/emit/router/core.py#L386-L399
train
55,750
GeorgeArgyros/symautomata
symautomata/pdadiff.py
main
def main(): """ Testing function for PDA - DFA Diff Operation """ if len(argv) < 2: print 'Usage: ' print ' Get A String %s CFG_fileA FST_fileB' % argv[0] return alphabet = createalphabet() cfgtopda = CfgPDA(alphabet) print '* Parsing Grammar:',...
python
def main(): """ Testing function for PDA - DFA Diff Operation """ if len(argv) < 2: print 'Usage: ' print ' Get A String %s CFG_fileA FST_fileB' % argv[0] return alphabet = createalphabet() cfgtopda = CfgPDA(alphabet) print '* Parsing Grammar:',...
[ "def", "main", "(", ")", ":", "if", "len", "(", "argv", ")", "<", "2", ":", "print", "'Usage: '", "print", "' Get A String %s CFG_fileA FST_fileB'", "%", "argv", "[", "0", "]", "return", "alphabet", "=", "createalphabet", "(", ")", "cfgtop...
Testing function for PDA - DFA Diff Operation
[ "Testing", "function", "for", "PDA", "-", "DFA", "Diff", "Operation" ]
f5d66533573b27e155bec3f36b8c00b8e3937cb3
https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pdadiff.py#L259-L289
train
55,751
GeorgeArgyros/symautomata
symautomata/pdadiff.py
PdaDiff._intesect
def _intesect(self): """The intesection of a PDA and a DFA""" p1automaton = self.mma p2automaton = self.mmb p3automaton = PDA(self.alphabet) self._break_terms() p1counter = 0 p3counter = 0 p2states = list(p2automaton.states) print 'PDA States: ' + ...
python
def _intesect(self): """The intesection of a PDA and a DFA""" p1automaton = self.mma p2automaton = self.mmb p3automaton = PDA(self.alphabet) self._break_terms() p1counter = 0 p3counter = 0 p2states = list(p2automaton.states) print 'PDA States: ' + ...
[ "def", "_intesect", "(", "self", ")", ":", "p1automaton", "=", "self", ".", "mma", "p2automaton", "=", "self", ".", "mmb", "p3automaton", "=", "PDA", "(", "self", ".", "alphabet", ")", "self", ".", "_break_terms", "(", ")", "p1counter", "=", "0", "p3co...
The intesection of a PDA and a DFA
[ "The", "intesection", "of", "a", "PDA", "and", "a", "DFA" ]
f5d66533573b27e155bec3f36b8c00b8e3937cb3
https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pdadiff.py#L86-L164
train
55,752
GeorgeArgyros/symautomata
symautomata/pdadiff.py
PdaDiff.diff
def diff(self): """The Difference between a PDA and a DFA""" self.mmb.complement(self.alphabet) self.mmb.minimize() print 'start intersection' self.mmc = self._intesect() print 'end intersection' return self.mmc
python
def diff(self): """The Difference between a PDA and a DFA""" self.mmb.complement(self.alphabet) self.mmb.minimize() print 'start intersection' self.mmc = self._intesect() print 'end intersection' return self.mmc
[ "def", "diff", "(", "self", ")", ":", "self", ".", "mmb", ".", "complement", "(", "self", ".", "alphabet", ")", "self", ".", "mmb", ".", "minimize", "(", ")", "print", "'start intersection'", "self", ".", "mmc", "=", "self", ".", "_intesect", "(", ")...
The Difference between a PDA and a DFA
[ "The", "Difference", "between", "a", "PDA", "and", "a", "DFA" ]
f5d66533573b27e155bec3f36b8c00b8e3937cb3
https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pdadiff.py#L166-L173
train
55,753
FreekingDean/insteon-hub
insteon/insteon.py
Insteon.refresh_devices
def refresh_devices(self): '''Queries hub for list of devices, and creates new device objects''' try: response = self.api.get("/api/v2/devices", {'properties':'all'}) for device_data in response['DeviceList']: self.devices.append(Device(device_data, self)) ...
python
def refresh_devices(self): '''Queries hub for list of devices, and creates new device objects''' try: response = self.api.get("/api/v2/devices", {'properties':'all'}) for device_data in response['DeviceList']: self.devices.append(Device(device_data, self)) ...
[ "def", "refresh_devices", "(", "self", ")", ":", "try", ":", "response", "=", "self", ".", "api", ".", "get", "(", "\"/api/v2/devices\"", ",", "{", "'properties'", ":", "'all'", "}", ")", "for", "device_data", "in", "response", "[", "'DeviceList'", "]", ...
Queries hub for list of devices, and creates new device objects
[ "Queries", "hub", "for", "list", "of", "devices", "and", "creates", "new", "device", "objects" ]
afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e
https://github.com/FreekingDean/insteon-hub/blob/afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e/insteon/insteon.py#L34-L43
train
55,754
FreekingDean/insteon-hub
insteon/insteon.py
DeviceP.refresh_details
def refresh_details(self): '''Query hub and refresh all details of a device, but NOT status, includes grouplist not present in refresh_all_devices''' try: return self.api_iface._api_get("/api/v2/devices/" + str(self.device_id)) except APIError as e: print(...
python
def refresh_details(self): '''Query hub and refresh all details of a device, but NOT status, includes grouplist not present in refresh_all_devices''' try: return self.api_iface._api_get("/api/v2/devices/" + str(self.device_id)) except APIError as e: print(...
[ "def", "refresh_details", "(", "self", ")", ":", "try", ":", "return", "self", ".", "api_iface", ".", "_api_get", "(", "\"/api/v2/devices/\"", "+", "str", "(", "self", ".", "device_id", ")", ")", "except", "APIError", "as", "e", ":", "print", "(", "\"API...
Query hub and refresh all details of a device, but NOT status, includes grouplist not present in refresh_all_devices
[ "Query", "hub", "and", "refresh", "all", "details", "of", "a", "device", "but", "NOT", "status", "includes", "grouplist", "not", "present", "in", "refresh_all_devices" ]
afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e
https://github.com/FreekingDean/insteon-hub/blob/afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e/insteon/insteon.py#L50-L59
train
55,755
FreekingDean/insteon-hub
insteon/insteon.py
DeviceP.send_command
def send_command(self, command): '''Send a command to a device''' data = {"command": command, "device_id": self.device_id} try: response = self.api_iface._api_post("/api/v2/commands", data) return Command(response, self) except APIError as e: print("AP...
python
def send_command(self, command): '''Send a command to a device''' data = {"command": command, "device_id": self.device_id} try: response = self.api_iface._api_post("/api/v2/commands", data) return Command(response, self) except APIError as e: print("AP...
[ "def", "send_command", "(", "self", ",", "command", ")", ":", "data", "=", "{", "\"command\"", ":", "command", ",", "\"device_id\"", ":", "self", ".", "device_id", "}", "try", ":", "response", "=", "self", ".", "api_iface", ".", "_api_post", "(", "\"/api...
Send a command to a device
[ "Send", "a", "command", "to", "a", "device" ]
afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e
https://github.com/FreekingDean/insteon-hub/blob/afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e/insteon/insteon.py#L61-L70
train
55,756
FreekingDean/insteon-hub
insteon/insteon.py
DeviceP._update_details
def _update_details(self,data): '''Intakes dict of details, and sets necessary properties in device''' # DeviceName, IconID, HouseID, DeviceID always present self.device_id = data['DeviceID'] self.device_name = data['DeviceName'] self.properties = data
python
def _update_details(self,data): '''Intakes dict of details, and sets necessary properties in device''' # DeviceName, IconID, HouseID, DeviceID always present self.device_id = data['DeviceID'] self.device_name = data['DeviceName'] self.properties = data
[ "def", "_update_details", "(", "self", ",", "data", ")", ":", "# DeviceName, IconID, HouseID, DeviceID always present", "self", ".", "device_id", "=", "data", "[", "'DeviceID'", "]", "self", ".", "device_name", "=", "data", "[", "'DeviceName'", "]", "self", ".", ...
Intakes dict of details, and sets necessary properties in device
[ "Intakes", "dict", "of", "details", "and", "sets", "necessary", "properties", "in", "device" ]
afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e
https://github.com/FreekingDean/insteon-hub/blob/afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e/insteon/insteon.py#L72-L78
train
55,757
FreekingDean/insteon-hub
insteon/insteon.py
Command._update_details
def _update_details(self,data): '''Intakes dict of details, and sets necessary properties in command''' for api_name in self._properties: if api_name in data: setattr(self, "_" + api_name, data[api_name]) else: # Only set to blank if not in...
python
def _update_details(self,data): '''Intakes dict of details, and sets necessary properties in command''' for api_name in self._properties: if api_name in data: setattr(self, "_" + api_name, data[api_name]) else: # Only set to blank if not in...
[ "def", "_update_details", "(", "self", ",", "data", ")", ":", "for", "api_name", "in", "self", ".", "_properties", ":", "if", "api_name", "in", "data", ":", "setattr", "(", "self", ",", "\"_\"", "+", "api_name", ",", "data", "[", "api_name", "]", ")", ...
Intakes dict of details, and sets necessary properties in command
[ "Intakes", "dict", "of", "details", "and", "sets", "necessary", "properties", "in", "command" ]
afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e
https://github.com/FreekingDean/insteon-hub/blob/afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e/insteon/insteon.py#L89-L100
train
55,758
FreekingDean/insteon-hub
insteon/insteon.py
Command.query_status
def query_status(self): '''Query the hub for the status of this command''' try: data = self.api_iface._api_get(self.link) self._update_details(data) except APIError as e: print("API error: ") for key,value in e.data.iteritems: print...
python
def query_status(self): '''Query the hub for the status of this command''' try: data = self.api_iface._api_get(self.link) self._update_details(data) except APIError as e: print("API error: ") for key,value in e.data.iteritems: print...
[ "def", "query_status", "(", "self", ")", ":", "try", ":", "data", "=", "self", ".", "api_iface", ".", "_api_get", "(", "self", ".", "link", ")", "self", ".", "_update_details", "(", "data", ")", "except", "APIError", "as", "e", ":", "print", "(", "\"...
Query the hub for the status of this command
[ "Query", "the", "hub", "for", "the", "status", "of", "this", "command" ]
afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e
https://github.com/FreekingDean/insteon-hub/blob/afd60d0a7fa74752f29d63c9bb6ccccd46d7aa3e/insteon/insteon.py#L102-L110
train
55,759
jingming/spotify
spotify/v1/album/__init__.py
AlbumContext.tracks
def tracks(self): """ Tracks list context :return: Tracks list context """ if self._tracks is None: self._tracks = TrackList(self.version, self.id) return self._tracks
python
def tracks(self): """ Tracks list context :return: Tracks list context """ if self._tracks is None: self._tracks = TrackList(self.version, self.id) return self._tracks
[ "def", "tracks", "(", "self", ")", ":", "if", "self", ".", "_tracks", "is", "None", ":", "self", ".", "_tracks", "=", "TrackList", "(", "self", ".", "version", ",", "self", ".", "id", ")", "return", "self", ".", "_tracks" ]
Tracks list context :return: Tracks list context
[ "Tracks", "list", "context" ]
d92c71073b2515f3c850604114133a7d2022d1a4
https://github.com/jingming/spotify/blob/d92c71073b2515f3c850604114133a7d2022d1a4/spotify/v1/album/__init__.py#L24-L33
train
55,760
what-studio/smartformat
smartformat/smart.py
extension
def extension(names): """Makes a function to be an extension.""" for name in names: if not NAME_PATTERN.match(name): raise ValueError('invalid extension name: %s' % name) def decorator(f, names=names): return Extension(f, names=names) return decorator
python
def extension(names): """Makes a function to be an extension.""" for name in names: if not NAME_PATTERN.match(name): raise ValueError('invalid extension name: %s' % name) def decorator(f, names=names): return Extension(f, names=names) return decorator
[ "def", "extension", "(", "names", ")", ":", "for", "name", "in", "names", ":", "if", "not", "NAME_PATTERN", ".", "match", "(", "name", ")", ":", "raise", "ValueError", "(", "'invalid extension name: %s'", "%", "name", ")", "def", "decorator", "(", "f", "...
Makes a function to be an extension.
[ "Makes", "a", "function", "to", "be", "an", "extension", "." ]
5731203cbf29617ab8d42542f9dac03d5e34b217
https://github.com/what-studio/smartformat/blob/5731203cbf29617ab8d42542f9dac03d5e34b217/smartformat/smart.py#L190-L197
train
55,761
what-studio/smartformat
smartformat/smart.py
SmartFormatter.register
def register(self, extensions): """Registers extensions.""" for ext in reversed(extensions): for name in ext.names: try: self._extensions[name].appendleft(ext) except KeyError: self._extensions[name] = deque([ext])
python
def register(self, extensions): """Registers extensions.""" for ext in reversed(extensions): for name in ext.names: try: self._extensions[name].appendleft(ext) except KeyError: self._extensions[name] = deque([ext])
[ "def", "register", "(", "self", ",", "extensions", ")", ":", "for", "ext", "in", "reversed", "(", "extensions", ")", ":", "for", "name", "in", "ext", ".", "names", ":", "try", ":", "self", ".", "_extensions", "[", "name", "]", ".", "appendleft", "(",...
Registers extensions.
[ "Registers", "extensions", "." ]
5731203cbf29617ab8d42542f9dac03d5e34b217
https://github.com/what-studio/smartformat/blob/5731203cbf29617ab8d42542f9dac03d5e34b217/smartformat/smart.py#L75-L82
train
55,762
what-studio/smartformat
smartformat/smart.py
SmartFormatter.eval_extensions
def eval_extensions(self, value, name, option, format): """Evaluates extensions in the registry. If some extension handles the format string, it returns a string. Otherwise, returns ``None``. """ try: exts = self._extensions[name] except KeyError: raise ...
python
def eval_extensions(self, value, name, option, format): """Evaluates extensions in the registry. If some extension handles the format string, it returns a string. Otherwise, returns ``None``. """ try: exts = self._extensions[name] except KeyError: raise ...
[ "def", "eval_extensions", "(", "self", ",", "value", ",", "name", ",", "option", ",", "format", ")", ":", "try", ":", "exts", "=", "self", ".", "_extensions", "[", "name", "]", "except", "KeyError", ":", "raise", "ValueError", "(", "'no suitable extension:...
Evaluates extensions in the registry. If some extension handles the format string, it returns a string. Otherwise, returns ``None``.
[ "Evaluates", "extensions", "in", "the", "registry", ".", "If", "some", "extension", "handles", "the", "format", "string", "it", "returns", "a", "string", ".", "Otherwise", "returns", "None", "." ]
5731203cbf29617ab8d42542f9dac03d5e34b217
https://github.com/what-studio/smartformat/blob/5731203cbf29617ab8d42542f9dac03d5e34b217/smartformat/smart.py#L95-L106
train
55,763
davgeo/clear
clear/tvfile.py
TVFile.GetShowDetails
def GetShowDetails(self): """ Extract show name, season number and episode number from file name. Supports formats S<NUM>E<NUM> or <NUM>x<NUM> for season and episode numbers where letters are case insensitive and number can be one or more digits. It expects season number to be unique however it can...
python
def GetShowDetails(self): """ Extract show name, season number and episode number from file name. Supports formats S<NUM>E<NUM> or <NUM>x<NUM> for season and episode numbers where letters are case insensitive and number can be one or more digits. It expects season number to be unique however it can...
[ "def", "GetShowDetails", "(", "self", ")", ":", "fileName", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "self", ".", "fileInfo", ".", "origPath", ")", ")", "[", "0", "]", "# Episode Number", "episodeNumSubstring...
Extract show name, season number and episode number from file name. Supports formats S<NUM>E<NUM> or <NUM>x<NUM> for season and episode numbers where letters are case insensitive and number can be one or more digits. It expects season number to be unique however it can handle either single or multipart...
[ "Extract", "show", "name", "season", "number", "and", "episode", "number", "from", "file", "name", "." ]
5ec85d27efd28afddfcd4c3f44df17f0115a77aa
https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/tvfile.py#L170-L255
train
55,764
davgeo/clear
clear/tvfile.py
TVFile.GenerateNewFilePath
def GenerateNewFilePath(self, fileDir = None): """ Create new file path. If a fileDir is provided it will be used otherwise the original file path is used. Updates file info object with new path. Parameters ---------- fileDir : string [optional : default = None] Optional file director...
python
def GenerateNewFilePath(self, fileDir = None): """ Create new file path. If a fileDir is provided it will be used otherwise the original file path is used. Updates file info object with new path. Parameters ---------- fileDir : string [optional : default = None] Optional file director...
[ "def", "GenerateNewFilePath", "(", "self", ",", "fileDir", "=", "None", ")", ":", "newFileName", "=", "self", ".", "GenerateNewFileName", "(", ")", "if", "newFileName", "is", "not", "None", ":", "if", "fileDir", "is", "None", ":", "fileDir", "=", "os", "...
Create new file path. If a fileDir is provided it will be used otherwise the original file path is used. Updates file info object with new path. Parameters ---------- fileDir : string [optional : default = None] Optional file directory
[ "Create", "new", "file", "path", ".", "If", "a", "fileDir", "is", "provided", "it", "will", "be", "used", "otherwise", "the", "original", "file", "path", "is", "used", ".", "Updates", "file", "info", "object", "with", "new", "path", "." ]
5ec85d27efd28afddfcd4c3f44df17f0115a77aa
https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/tvfile.py#L286-L300
train
55,765
davgeo/clear
clear/tvfile.py
TVFile.Print
def Print(self): """ Print contents of showInfo and FileInfo object """ goodlogging.Log.Info("TVFILE", "TV File details are:") goodlogging.Log.IncreaseIndent() goodlogging.Log.Info("TVFILE", "Original File Path = {0}".format(self.fileInfo.origPath)) if self.showInfo.showName is not None: ...
python
def Print(self): """ Print contents of showInfo and FileInfo object """ goodlogging.Log.Info("TVFILE", "TV File details are:") goodlogging.Log.IncreaseIndent() goodlogging.Log.Info("TVFILE", "Original File Path = {0}".format(self.fileInfo.origPath)) if self.showInfo.showName is not None: ...
[ "def", "Print", "(", "self", ")", ":", "goodlogging", ".", "Log", ".", "Info", "(", "\"TVFILE\"", ",", "\"TV File details are:\"", ")", "goodlogging", ".", "Log", ".", "IncreaseIndent", "(", ")", "goodlogging", ".", "Log", ".", "Info", "(", "\"TVFILE\"", "...
Print contents of showInfo and FileInfo object
[ "Print", "contents", "of", "showInfo", "and", "FileInfo", "object" ]
5ec85d27efd28afddfcd4c3f44df17f0115a77aa
https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/tvfile.py#L305-L320
train
55,766
sporsh/carnifex
carnifex/ssh/process.py
connectProcess
def connectProcess(connection, processProtocol, commandLine='', env={}, usePTY=None, childFDs=None, *args, **kwargs): """Opens a SSHSession channel and connects a ProcessProtocol to it @param connection: the SSH Connection to open the session channel on @param processProtocol: the Proces...
python
def connectProcess(connection, processProtocol, commandLine='', env={}, usePTY=None, childFDs=None, *args, **kwargs): """Opens a SSHSession channel and connects a ProcessProtocol to it @param connection: the SSH Connection to open the session channel on @param processProtocol: the Proces...
[ "def", "connectProcess", "(", "connection", ",", "processProtocol", ",", "commandLine", "=", "''", ",", "env", "=", "{", "}", ",", "usePTY", "=", "None", ",", "childFDs", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "processOpenDef...
Opens a SSHSession channel and connects a ProcessProtocol to it @param connection: the SSH Connection to open the session channel on @param processProtocol: the ProcessProtocol instance to connect to the process @param commandLine: the command line to execute the process @param env: optional environmen...
[ "Opens", "a", "SSHSession", "channel", "and", "connects", "a", "ProcessProtocol", "to", "it" ]
82dd3bd2bc134dfb69a78f43171e227f2127060b
https://github.com/sporsh/carnifex/blob/82dd3bd2bc134dfb69a78f43171e227f2127060b/carnifex/ssh/process.py#L16-L34
train
55,767
pauleveritt/kaybee
kaybee/plugins/events.py
EventAction.call_builder_init
def call_builder_init(cls, kb_app, sphinx_app: Sphinx): """ On builder init event, commit registry and do callbacks """ # Find and commit docs project plugins conf_dir = sphinx_app.confdir plugins_dir = sphinx_app.config.kaybee_settings.plugins_dir full_plugins_dir = os.path.joi...
python
def call_builder_init(cls, kb_app, sphinx_app: Sphinx): """ On builder init event, commit registry and do callbacks """ # Find and commit docs project plugins conf_dir = sphinx_app.confdir plugins_dir = sphinx_app.config.kaybee_settings.plugins_dir full_plugins_dir = os.path.joi...
[ "def", "call_builder_init", "(", "cls", ",", "kb_app", ",", "sphinx_app", ":", "Sphinx", ")", ":", "# Find and commit docs project plugins", "conf_dir", "=", "sphinx_app", ".", "confdir", "plugins_dir", "=", "sphinx_app", ".", "config", ".", "kaybee_settings", ".", ...
On builder init event, commit registry and do callbacks
[ "On", "builder", "init", "event", "commit", "registry", "and", "do", "callbacks" ]
a00a718aaaa23b2d12db30dfacb6b2b6ec84459c
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/events.py#L86-L103
train
55,768
pauleveritt/kaybee
kaybee/plugins/events.py
EventAction.call_purge_doc
def call_purge_doc(cls, kb_app, sphinx_app: Sphinx, sphinx_env: BuildEnvironment, docname: str): """ On env-purge-doc, do callbacks """ for callback in EventAction.get_callbacks(kb_app, SphinxEvent.EPD): callback(kb_app, sphinx_app, sphinx_env, ...
python
def call_purge_doc(cls, kb_app, sphinx_app: Sphinx, sphinx_env: BuildEnvironment, docname: str): """ On env-purge-doc, do callbacks """ for callback in EventAction.get_callbacks(kb_app, SphinxEvent.EPD): callback(kb_app, sphinx_app, sphinx_env, ...
[ "def", "call_purge_doc", "(", "cls", ",", "kb_app", ",", "sphinx_app", ":", "Sphinx", ",", "sphinx_env", ":", "BuildEnvironment", ",", "docname", ":", "str", ")", ":", "for", "callback", "in", "EventAction", ".", "get_callbacks", "(", "kb_app", ",", "SphinxE...
On env-purge-doc, do callbacks
[ "On", "env", "-", "purge", "-", "doc", "do", "callbacks" ]
a00a718aaaa23b2d12db30dfacb6b2b6ec84459c
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/events.py#L106-L112
train
55,769
pauleveritt/kaybee
kaybee/plugins/events.py
EventAction.call_env_before_read_docs
def call_env_before_read_docs(cls, kb_app, sphinx_app: Sphinx, sphinx_env: BuildEnvironment, docnames: List[str]): """ On env-read-docs, do callbacks""" for callback in EventAction.get_callbacks(kb_app, ...
python
def call_env_before_read_docs(cls, kb_app, sphinx_app: Sphinx, sphinx_env: BuildEnvironment, docnames: List[str]): """ On env-read-docs, do callbacks""" for callback in EventAction.get_callbacks(kb_app, ...
[ "def", "call_env_before_read_docs", "(", "cls", ",", "kb_app", ",", "sphinx_app", ":", "Sphinx", ",", "sphinx_env", ":", "BuildEnvironment", ",", "docnames", ":", "List", "[", "str", "]", ")", ":", "for", "callback", "in", "EventAction", ".", "get_callbacks", ...
On env-read-docs, do callbacks
[ "On", "env", "-", "read", "-", "docs", "do", "callbacks" ]
a00a718aaaa23b2d12db30dfacb6b2b6ec84459c
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/events.py#L115-L122
train
55,770
pauleveritt/kaybee
kaybee/plugins/events.py
EventAction.call_env_doctree_read
def call_env_doctree_read(cls, kb_app, sphinx_app: Sphinx, doctree: doctree): """ On doctree-read, do callbacks""" for callback in EventAction.get_callbacks(kb_app, SphinxEvent.DREAD): callback(kb_app, sphinx_ap...
python
def call_env_doctree_read(cls, kb_app, sphinx_app: Sphinx, doctree: doctree): """ On doctree-read, do callbacks""" for callback in EventAction.get_callbacks(kb_app, SphinxEvent.DREAD): callback(kb_app, sphinx_ap...
[ "def", "call_env_doctree_read", "(", "cls", ",", "kb_app", ",", "sphinx_app", ":", "Sphinx", ",", "doctree", ":", "doctree", ")", ":", "for", "callback", "in", "EventAction", ".", "get_callbacks", "(", "kb_app", ",", "SphinxEvent", ".", "DREAD", ")", ":", ...
On doctree-read, do callbacks
[ "On", "doctree", "-", "read", "do", "callbacks" ]
a00a718aaaa23b2d12db30dfacb6b2b6ec84459c
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/events.py#L125-L131
train
55,771
pauleveritt/kaybee
kaybee/plugins/events.py
EventAction.call_env_updated
def call_env_updated(cls, kb_app, sphinx_app: Sphinx, sphinx_env: BuildEnvironment): """ On the env-updated event, do callbacks """ for callback in EventAction.get_callbacks(kb_app, SphinxEvent.EU): callback(kb_app, sphinx_app, sphinx_env)
python
def call_env_updated(cls, kb_app, sphinx_app: Sphinx, sphinx_env: BuildEnvironment): """ On the env-updated event, do callbacks """ for callback in EventAction.get_callbacks(kb_app, SphinxEvent.EU): callback(kb_app, sphinx_app, sphinx_env)
[ "def", "call_env_updated", "(", "cls", ",", "kb_app", ",", "sphinx_app", ":", "Sphinx", ",", "sphinx_env", ":", "BuildEnvironment", ")", ":", "for", "callback", "in", "EventAction", ".", "get_callbacks", "(", "kb_app", ",", "SphinxEvent", ".", "EU", ")", ":"...
On the env-updated event, do callbacks
[ "On", "the", "env", "-", "updated", "event", "do", "callbacks" ]
a00a718aaaa23b2d12db30dfacb6b2b6ec84459c
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/events.py#L144-L150
train
55,772
pauleveritt/kaybee
kaybee/plugins/events.py
EventAction.call_html_collect_pages
def call_html_collect_pages(cls, kb_app, sphinx_app: Sphinx): """ On html-collect-pages, do callbacks""" EventAction.get_callbacks(kb_app, SphinxEvent.HCP) for callback in EventAction.get_callbacks(kb_app, Sphin...
python
def call_html_collect_pages(cls, kb_app, sphinx_app: Sphinx): """ On html-collect-pages, do callbacks""" EventAction.get_callbacks(kb_app, SphinxEvent.HCP) for callback in EventAction.get_callbacks(kb_app, Sphin...
[ "def", "call_html_collect_pages", "(", "cls", ",", "kb_app", ",", "sphinx_app", ":", "Sphinx", ")", ":", "EventAction", ".", "get_callbacks", "(", "kb_app", ",", "SphinxEvent", ".", "HCP", ")", "for", "callback", "in", "EventAction", ".", "get_callbacks", "(",...
On html-collect-pages, do callbacks
[ "On", "html", "-", "collect", "-", "pages", "do", "callbacks" ]
a00a718aaaa23b2d12db30dfacb6b2b6ec84459c
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/events.py#L153-L160
train
55,773
pauleveritt/kaybee
kaybee/plugins/events.py
EventAction.call_env_check_consistency
def call_env_check_consistency(cls, kb_app, builder: StandaloneHTMLBuilder, sphinx_env: BuildEnvironment): """ On env-check-consistency, do callbacks""" for callback in EventAction.get_callbacks(kb_app, SphinxEvent.ECC...
python
def call_env_check_consistency(cls, kb_app, builder: StandaloneHTMLBuilder, sphinx_env: BuildEnvironment): """ On env-check-consistency, do callbacks""" for callback in EventAction.get_callbacks(kb_app, SphinxEvent.ECC...
[ "def", "call_env_check_consistency", "(", "cls", ",", "kb_app", ",", "builder", ":", "StandaloneHTMLBuilder", ",", "sphinx_env", ":", "BuildEnvironment", ")", ":", "for", "callback", "in", "EventAction", ".", "get_callbacks", "(", "kb_app", ",", "SphinxEvent", "."...
On env-check-consistency, do callbacks
[ "On", "env", "-", "check", "-", "consistency", "do", "callbacks" ]
a00a718aaaa23b2d12db30dfacb6b2b6ec84459c
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/events.py#L163-L169
train
55,774
stephrdev/django-tapeforms
tapeforms/mixins.py
TapeformLayoutMixin.get_layout_template
def get_layout_template(self, template_name=None): """ Returns the layout template to use when rendering the form to HTML. Preference of template selection: 1. Provided method argument `template_name` 2. Form class property `layout_template` 3. Globally defined default ...
python
def get_layout_template(self, template_name=None): """ Returns the layout template to use when rendering the form to HTML. Preference of template selection: 1. Provided method argument `template_name` 2. Form class property `layout_template` 3. Globally defined default ...
[ "def", "get_layout_template", "(", "self", ",", "template_name", "=", "None", ")", ":", "if", "template_name", ":", "return", "template_name", "if", "self", ".", "layout_template", ":", "return", "self", ".", "layout_template", "return", "defaults", ".", "LAYOUT...
Returns the layout template to use when rendering the form to HTML. Preference of template selection: 1. Provided method argument `template_name` 2. Form class property `layout_template` 3. Globally defined default template from `defaults.LAYOUT_DEFAULT_TEMPLATE` :param templa...
[ "Returns", "the", "layout", "template", "to", "use", "when", "rendering", "the", "form", "to", "HTML", "." ]
255602de43777141f18afaf30669d7bdd4f7c323
https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/mixins.py#L18-L37
train
55,775
stephrdev/django-tapeforms
tapeforms/mixins.py
TapeformLayoutMixin.get_layout_context
def get_layout_context(self): """ Returns the context which is used when rendering the form to HTML. The generated template context will contain the following variables: * form: `Form` instance * errors: `ErrorList` instance with non field errors and hidden field errors ...
python
def get_layout_context(self): """ Returns the context which is used when rendering the form to HTML. The generated template context will contain the following variables: * form: `Form` instance * errors: `ErrorList` instance with non field errors and hidden field errors ...
[ "def", "get_layout_context", "(", "self", ")", ":", "errors", "=", "self", ".", "non_field_errors", "(", ")", "for", "field", "in", "self", ".", "hidden_fields", "(", ")", ":", "errors", ".", "extend", "(", "field", ".", "errors", ")", "return", "{", "...
Returns the context which is used when rendering the form to HTML. The generated template context will contain the following variables: * form: `Form` instance * errors: `ErrorList` instance with non field errors and hidden field errors * hidden_fields: All hidden fields to render. ...
[ "Returns", "the", "context", "which", "is", "used", "when", "rendering", "the", "form", "to", "HTML", "." ]
255602de43777141f18afaf30669d7bdd4f7c323
https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/mixins.py#L39-L61
train
55,776
stephrdev/django-tapeforms
tapeforms/mixins.py
TapeformMixin.get_field_template
def get_field_template(self, bound_field, template_name=None): """ Returns the field template to use when rendering a form field to HTML. Preference of template selection: 1. Provided method argument `template_name` 2. Template from `field_template_overrides` selected by field ...
python
def get_field_template(self, bound_field, template_name=None): """ Returns the field template to use when rendering a form field to HTML. Preference of template selection: 1. Provided method argument `template_name` 2. Template from `field_template_overrides` selected by field ...
[ "def", "get_field_template", "(", "self", ",", "bound_field", ",", "template_name", "=", "None", ")", ":", "if", "template_name", ":", "return", "template_name", "templates", "=", "self", ".", "field_template_overrides", "or", "{", "}", "template_name", "=", "te...
Returns the field template to use when rendering a form field to HTML. Preference of template selection: 1. Provided method argument `template_name` 2. Template from `field_template_overrides` selected by field name 3. Template from `field_template_overrides` selected by field class ...
[ "Returns", "the", "field", "template", "to", "use", "when", "rendering", "a", "form", "field", "to", "HTML", "." ]
255602de43777141f18afaf30669d7bdd4f7c323
https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/mixins.py#L129-L161
train
55,777
stephrdev/django-tapeforms
tapeforms/mixins.py
TapeformMixin.get_field_label_css_class
def get_field_label_css_class(self, bound_field): """ Returns the optional label CSS class to use when rendering a field template. By default, returns the Form class property `field_label_css_class`. If the field has errors and the Form class property `field_label_invalid_css_class` ...
python
def get_field_label_css_class(self, bound_field): """ Returns the optional label CSS class to use when rendering a field template. By default, returns the Form class property `field_label_css_class`. If the field has errors and the Form class property `field_label_invalid_css_class` ...
[ "def", "get_field_label_css_class", "(", "self", ",", "bound_field", ")", ":", "class_name", "=", "self", ".", "field_label_css_class", "if", "bound_field", ".", "errors", "and", "self", ".", "field_label_invalid_css_class", ":", "class_name", "=", "join_css_class", ...
Returns the optional label CSS class to use when rendering a field template. By default, returns the Form class property `field_label_css_class`. If the field has errors and the Form class property `field_label_invalid_css_class` is defined, its value is appended to the CSS class. :par...
[ "Returns", "the", "optional", "label", "CSS", "class", "to", "use", "when", "rendering", "a", "field", "template", "." ]
255602de43777141f18afaf30669d7bdd4f7c323
https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/mixins.py#L174-L191
train
55,778
stephrdev/django-tapeforms
tapeforms/mixins.py
TapeformMixin.get_field_context
def get_field_context(self, bound_field): """ Returns the context which is used when rendering a form field to HTML. The generated template context will contain the following variables: * form: `Form` instance * field: `BoundField` instance of the field * field_id: Fiel...
python
def get_field_context(self, bound_field): """ Returns the context which is used when rendering a form field to HTML. The generated template context will contain the following variables: * form: `Form` instance * field: `BoundField` instance of the field * field_id: Fiel...
[ "def", "get_field_context", "(", "self", ",", "bound_field", ")", ":", "widget", "=", "bound_field", ".", "field", ".", "widget", "widget_class_name", "=", "widget", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", "# Check if we have an overwritten id i...
Returns the context which is used when rendering a form field to HTML. The generated template context will contain the following variables: * form: `Form` instance * field: `BoundField` instance of the field * field_id: Field ID to use in `<label for="..">` * field_name: Name o...
[ "Returns", "the", "context", "which", "is", "used", "when", "rendering", "a", "form", "field", "to", "HTML", "." ]
255602de43777141f18afaf30669d7bdd4f7c323
https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/mixins.py#L193-L237
train
55,779
stephrdev/django-tapeforms
tapeforms/mixins.py
TapeformMixin.apply_widget_template
def apply_widget_template(self, field_name): """ Applies widget template overrides if available. The method uses the `get_widget_template` method to determine if the widget template should be exchanged. If a template is available, the template_name property of the widget instanc...
python
def apply_widget_template(self, field_name): """ Applies widget template overrides if available. The method uses the `get_widget_template` method to determine if the widget template should be exchanged. If a template is available, the template_name property of the widget instanc...
[ "def", "apply_widget_template", "(", "self", ",", "field_name", ")", ":", "field", "=", "self", ".", "fields", "[", "field_name", "]", "template_name", "=", "self", ".", "get_widget_template", "(", "field_name", ",", "field", ")", "if", "template_name", ":", ...
Applies widget template overrides if available. The method uses the `get_widget_template` method to determine if the widget template should be exchanged. If a template is available, the template_name property of the widget instance is updated. :param field_name: A field name of the for...
[ "Applies", "widget", "template", "overrides", "if", "available", "." ]
255602de43777141f18afaf30669d7bdd4f7c323
https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/mixins.py#L257-L271
train
55,780
stephrdev/django-tapeforms
tapeforms/mixins.py
TapeformMixin.get_widget_template
def get_widget_template(self, field_name, field): """ Returns the optional widget template to use when rendering the widget for a form field. Preference of template selection: 1. Template from `widget_template_overrides` selected by field name 2. Template from `w...
python
def get_widget_template(self, field_name, field): """ Returns the optional widget template to use when rendering the widget for a form field. Preference of template selection: 1. Template from `widget_template_overrides` selected by field name 2. Template from `w...
[ "def", "get_widget_template", "(", "self", ",", "field_name", ",", "field", ")", ":", "templates", "=", "self", ".", "widget_template_overrides", "or", "{", "}", "template_name", "=", "templates", ".", "get", "(", "field_name", ",", "None", ")", "if", "templ...
Returns the optional widget template to use when rendering the widget for a form field. Preference of template selection: 1. Template from `widget_template_overrides` selected by field name 2. Template from `widget_template_overrides` selected by widget class By default...
[ "Returns", "the", "optional", "widget", "template", "to", "use", "when", "rendering", "the", "widget", "for", "a", "form", "field", "." ]
255602de43777141f18afaf30669d7bdd4f7c323
https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/mixins.py#L273-L298
train
55,781
stephrdev/django-tapeforms
tapeforms/mixins.py
TapeformMixin.apply_widget_css_class
def apply_widget_css_class(self, field_name): """ Applies CSS classes to widgets if available. The method uses the `get_widget_css_class` method to determine if the widget CSS class should be changed. If a CSS class is returned, it is appended to the current value of the class p...
python
def apply_widget_css_class(self, field_name): """ Applies CSS classes to widgets if available. The method uses the `get_widget_css_class` method to determine if the widget CSS class should be changed. If a CSS class is returned, it is appended to the current value of the class p...
[ "def", "apply_widget_css_class", "(", "self", ",", "field_name", ")", ":", "field", "=", "self", ".", "fields", "[", "field_name", "]", "class_name", "=", "self", ".", "get_widget_css_class", "(", "field_name", ",", "field", ")", "if", "class_name", ":", "fi...
Applies CSS classes to widgets if available. The method uses the `get_widget_css_class` method to determine if the widget CSS class should be changed. If a CSS class is returned, it is appended to the current value of the class property of the widget instance. :param field_name: A fiel...
[ "Applies", "CSS", "classes", "to", "widgets", "if", "available", "." ]
255602de43777141f18afaf30669d7bdd4f7c323
https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/mixins.py#L300-L315
train
55,782
stephrdev/django-tapeforms
tapeforms/mixins.py
TapeformMixin.apply_widget_invalid_options
def apply_widget_invalid_options(self, field_name): """ Applies additional widget options for an invalid field. This method is called when there is some error on a field to apply additional options on its widget. It does the following: * Sets the aria-invalid property of the wi...
python
def apply_widget_invalid_options(self, field_name): """ Applies additional widget options for an invalid field. This method is called when there is some error on a field to apply additional options on its widget. It does the following: * Sets the aria-invalid property of the wi...
[ "def", "apply_widget_invalid_options", "(", "self", ",", "field_name", ")", ":", "field", "=", "self", ".", "fields", "[", "field_name", "]", "class_name", "=", "self", ".", "get_widget_invalid_css_class", "(", "field_name", ",", "field", ")", "if", "class_name"...
Applies additional widget options for an invalid field. This method is called when there is some error on a field to apply additional options on its widget. It does the following: * Sets the aria-invalid property of the widget for accessibility. * Adds an invalid CSS class, which is de...
[ "Applies", "additional", "widget", "options", "for", "an", "invalid", "field", "." ]
255602de43777141f18afaf30669d7bdd4f7c323
https://github.com/stephrdev/django-tapeforms/blob/255602de43777141f18afaf30669d7bdd4f7c323/tapeforms/mixins.py#L330-L351
train
55,783
Equitable/trump
trump/converting/objects.py
FXConverter.use_quandl_data
def use_quandl_data(self, authtoken): """ Use quandl data to build conversion table """ dfs = {} st = self.start.strftime("%Y-%m-%d") at = authtoken for pair in self.pairs: symbol = "".join(pair) qsym = "CURRFX/{}".format(symbol) ...
python
def use_quandl_data(self, authtoken): """ Use quandl data to build conversion table """ dfs = {} st = self.start.strftime("%Y-%m-%d") at = authtoken for pair in self.pairs: symbol = "".join(pair) qsym = "CURRFX/{}".format(symbol) ...
[ "def", "use_quandl_data", "(", "self", ",", "authtoken", ")", ":", "dfs", "=", "{", "}", "st", "=", "self", ".", "start", ".", "strftime", "(", "\"%Y-%m-%d\"", ")", "at", "=", "authtoken", "for", "pair", "in", "self", ".", "pairs", ":", "symbol", "="...
Use quandl data to build conversion table
[ "Use", "quandl", "data", "to", "build", "conversion", "table" ]
a2802692bc642fa32096374159eea7ceca2947b4
https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/converting/objects.py#L51-L63
train
55,784
Equitable/trump
trump/converting/objects.py
FXConverter.build_conversion_table
def build_conversion_table(self, dataframes): """ Build conversion table from a dictionary of dataframes """ self.data = pd.DataFrame(dataframes) tmp_pairs = [s.split("/") for s in self.data.columns] self.data.columns = pd.MultiIndex.from_tuples(tmp_pairs)
python
def build_conversion_table(self, dataframes): """ Build conversion table from a dictionary of dataframes """ self.data = pd.DataFrame(dataframes) tmp_pairs = [s.split("/") for s in self.data.columns] self.data.columns = pd.MultiIndex.from_tuples(tmp_pairs)
[ "def", "build_conversion_table", "(", "self", ",", "dataframes", ")", ":", "self", ".", "data", "=", "pd", ".", "DataFrame", "(", "dataframes", ")", "tmp_pairs", "=", "[", "s", ".", "split", "(", "\"/\"", ")", "for", "s", "in", "self", ".", "data", "...
Build conversion table from a dictionary of dataframes
[ "Build", "conversion", "table", "from", "a", "dictionary", "of", "dataframes" ]
a2802692bc642fa32096374159eea7ceca2947b4
https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/converting/objects.py#L78-L84
train
55,785
invinst/ResponseBot
responsebot/models.py
TweetFilter.match_tweet
def match_tweet(self, tweet, user_stream): """ Check if a tweet matches the defined criteria :param tweet: The tweet in question :type tweet: :class:`~responsebot.models.Tweet` :return: True if matched, False otherwise """ if user_stream: if len(self....
python
def match_tweet(self, tweet, user_stream): """ Check if a tweet matches the defined criteria :param tweet: The tweet in question :type tweet: :class:`~responsebot.models.Tweet` :return: True if matched, False otherwise """ if user_stream: if len(self....
[ "def", "match_tweet", "(", "self", ",", "tweet", ",", "user_stream", ")", ":", "if", "user_stream", ":", "if", "len", "(", "self", ".", "track", ")", ">", "0", ":", "return", "self", ".", "is_tweet_match_track", "(", "tweet", ")", "return", "True", "re...
Check if a tweet matches the defined criteria :param tweet: The tweet in question :type tweet: :class:`~responsebot.models.Tweet` :return: True if matched, False otherwise
[ "Check", "if", "a", "tweet", "matches", "the", "defined", "criteria" ]
a6b1a431a343007f7ae55a193e432a61af22253f
https://github.com/invinst/ResponseBot/blob/a6b1a431a343007f7ae55a193e432a61af22253f/responsebot/models.py#L81-L95
train
55,786
bitesofcode/projex
projex/notify.py
connectMSExchange
def connectMSExchange(server): """ Creates a connection for the inputted server to a Microsoft Exchange server. :param server | <smtplib.SMTP> :usage |>>> import smtplib |>>> import projex.notify |>>> smtp = smtplib.SMTP('mail.server.com') ...
python
def connectMSExchange(server): """ Creates a connection for the inputted server to a Microsoft Exchange server. :param server | <smtplib.SMTP> :usage |>>> import smtplib |>>> import projex.notify |>>> smtp = smtplib.SMTP('mail.server.com') ...
[ "def", "connectMSExchange", "(", "server", ")", ":", "if", "not", "sspi", ":", "return", "False", ",", "'No sspi module found.'", "# send the SMTP EHLO command", "code", ",", "response", "=", "server", ".", "ehlo", "(", ")", "if", "code", "!=", "SMTP_EHLO_OKAY",...
Creates a connection for the inputted server to a Microsoft Exchange server. :param server | <smtplib.SMTP> :usage |>>> import smtplib |>>> import projex.notify |>>> smtp = smtplib.SMTP('mail.server.com') |>>> projex.notify.connectMSExchange(smtp) ...
[ "Creates", "a", "connection", "for", "the", "inputted", "server", "to", "a", "Microsoft", "Exchange", "server", "." ]
d31743ec456a41428709968ab11a2cf6c6c76247
https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/notify.py#L51-L100
train
55,787
pauleveritt/kaybee
kaybee/plugins/articles/base_toctree.py
BaseToctree.set_entries
def set_entries(self, entries: List[Tuple[str, str]], titles, resources): """ Provide the template the data for the toc entries """ self.entries = [] for flag, pagename in entries: title = titles[pagename].children[0] resource = resources.get(pagename, None) ...
python
def set_entries(self, entries: List[Tuple[str, str]], titles, resources): """ Provide the template the data for the toc entries """ self.entries = [] for flag, pagename in entries: title = titles[pagename].children[0] resource = resources.get(pagename, None) ...
[ "def", "set_entries", "(", "self", ",", "entries", ":", "List", "[", "Tuple", "[", "str", ",", "str", "]", "]", ",", "titles", ",", "resources", ")", ":", "self", ".", "entries", "=", "[", "]", "for", "flag", ",", "pagename", "in", "entries", ":", ...
Provide the template the data for the toc entries
[ "Provide", "the", "template", "the", "data", "for", "the", "toc", "entries" ]
a00a718aaaa23b2d12db30dfacb6b2b6ec84459c
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/articles/base_toctree.py#L29-L46
train
55,788
pauleveritt/kaybee
kaybee/plugins/articles/base_toctree.py
BaseToctree.render
def render(self, builder, context, sphinx_app: Sphinx): """ Given a Sphinx builder and context with site in it, generate HTML """ context['sphinx_app'] = sphinx_app context['toctree'] = self html = builder.templates.render(self.template + '.html', context) return html
python
def render(self, builder, context, sphinx_app: Sphinx): """ Given a Sphinx builder and context with site in it, generate HTML """ context['sphinx_app'] = sphinx_app context['toctree'] = self html = builder.templates.render(self.template + '.html', context) return html
[ "def", "render", "(", "self", ",", "builder", ",", "context", ",", "sphinx_app", ":", "Sphinx", ")", ":", "context", "[", "'sphinx_app'", "]", "=", "sphinx_app", "context", "[", "'toctree'", "]", "=", "self", "html", "=", "builder", ".", "templates", "."...
Given a Sphinx builder and context with site in it, generate HTML
[ "Given", "a", "Sphinx", "builder", "and", "context", "with", "site", "in", "it", "generate", "HTML" ]
a00a718aaaa23b2d12db30dfacb6b2b6ec84459c
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/articles/base_toctree.py#L63-L71
train
55,789
jingming/spotify
spotify/auth/util.py
parse_code
def parse_code(url): """ Parse the code parameter from the a URL :param str url: URL to parse :return: code query parameter :rtype: str """ result = urlparse(url) query = parse_qs(result.query) return query['code']
python
def parse_code(url): """ Parse the code parameter from the a URL :param str url: URL to parse :return: code query parameter :rtype: str """ result = urlparse(url) query = parse_qs(result.query) return query['code']
[ "def", "parse_code", "(", "url", ")", ":", "result", "=", "urlparse", "(", "url", ")", "query", "=", "parse_qs", "(", "result", ".", "query", ")", "return", "query", "[", "'code'", "]" ]
Parse the code parameter from the a URL :param str url: URL to parse :return: code query parameter :rtype: str
[ "Parse", "the", "code", "parameter", "from", "the", "a", "URL" ]
d92c71073b2515f3c850604114133a7d2022d1a4
https://github.com/jingming/spotify/blob/d92c71073b2515f3c850604114133a7d2022d1a4/spotify/auth/util.py#L6-L16
train
55,790
jingming/spotify
spotify/auth/util.py
user_token
def user_token(scopes, client_id=None, client_secret=None, redirect_uri=None): """ Generate a user access token :param List[str] scopes: Scopes to get :param str client_id: Spotify Client ID :param str client_secret: Spotify Client secret :param str redirect_uri: Spotify redirect URI :retur...
python
def user_token(scopes, client_id=None, client_secret=None, redirect_uri=None): """ Generate a user access token :param List[str] scopes: Scopes to get :param str client_id: Spotify Client ID :param str client_secret: Spotify Client secret :param str redirect_uri: Spotify redirect URI :retur...
[ "def", "user_token", "(", "scopes", ",", "client_id", "=", "None", ",", "client_secret", "=", "None", ",", "redirect_uri", "=", "None", ")", ":", "webbrowser", ".", "open_new", "(", "authorize_url", "(", "client_id", "=", "client_id", ",", "redirect_uri", "=...
Generate a user access token :param List[str] scopes: Scopes to get :param str client_id: Spotify Client ID :param str client_secret: Spotify Client secret :param str redirect_uri: Spotify redirect URI :return: Generated access token :rtype: User
[ "Generate", "a", "user", "access", "token" ]
d92c71073b2515f3c850604114133a7d2022d1a4
https://github.com/jingming/spotify/blob/d92c71073b2515f3c850604114133a7d2022d1a4/spotify/auth/util.py#L19-L32
train
55,791
standage/tag
tag/index.py
Index.consume_file
def consume_file(self, infile): """Load the specified GFF3 file into memory.""" reader = tag.reader.GFF3Reader(infilename=infile) self.consume(reader)
python
def consume_file(self, infile): """Load the specified GFF3 file into memory.""" reader = tag.reader.GFF3Reader(infilename=infile) self.consume(reader)
[ "def", "consume_file", "(", "self", ",", "infile", ")", ":", "reader", "=", "tag", ".", "reader", ".", "GFF3Reader", "(", "infilename", "=", "infile", ")", "self", ".", "consume", "(", "reader", ")" ]
Load the specified GFF3 file into memory.
[ "Load", "the", "specified", "GFF3", "file", "into", "memory", "." ]
94686adf57115cea1c5235e99299e691f80ba10b
https://github.com/standage/tag/blob/94686adf57115cea1c5235e99299e691f80ba10b/tag/index.py#L55-L58
train
55,792
standage/tag
tag/index.py
Index.consume
def consume(self, entrystream): """ Load a stream of entries into memory. Only Feature objects and sequence-region directives are loaded, all other entries are discarded. """ for entry in entrystream: if isinstance(entry, tag.directive.Directive) and \ ...
python
def consume(self, entrystream): """ Load a stream of entries into memory. Only Feature objects and sequence-region directives are loaded, all other entries are discarded. """ for entry in entrystream: if isinstance(entry, tag.directive.Directive) and \ ...
[ "def", "consume", "(", "self", ",", "entrystream", ")", ":", "for", "entry", "in", "entrystream", ":", "if", "isinstance", "(", "entry", ",", "tag", ".", "directive", ".", "Directive", ")", "and", "entry", ".", "type", "==", "'sequence-region'", ":", "se...
Load a stream of entries into memory. Only Feature objects and sequence-region directives are loaded, all other entries are discarded.
[ "Load", "a", "stream", "of", "entries", "into", "memory", "." ]
94686adf57115cea1c5235e99299e691f80ba10b
https://github.com/standage/tag/blob/94686adf57115cea1c5235e99299e691f80ba10b/tag/index.py#L81-L93
train
55,793
standage/tag
tag/index.py
Index.query
def query(self, seqid, start, end, strict=True): """ Query the index for features in the specified range. :param seqid: ID of the sequence to query :param start: start of the query interval :param end: end of the query interval :param strict: indicates whether query is s...
python
def query(self, seqid, start, end, strict=True): """ Query the index for features in the specified range. :param seqid: ID of the sequence to query :param start: start of the query interval :param end: end of the query interval :param strict: indicates whether query is s...
[ "def", "query", "(", "self", ",", "seqid", ",", "start", ",", "end", ",", "strict", "=", "True", ")", ":", "return", "sorted", "(", "[", "intvl", ".", "data", "for", "intvl", "in", "self", "[", "seqid", "]", ".", "search", "(", "start", ",", "end...
Query the index for features in the specified range. :param seqid: ID of the sequence to query :param start: start of the query interval :param end: end of the query interval :param strict: indicates whether query is strict containment or overlap (:code:`True` and...
[ "Query", "the", "index", "for", "features", "in", "the", "specified", "range", "." ]
94686adf57115cea1c5235e99299e691f80ba10b
https://github.com/standage/tag/blob/94686adf57115cea1c5235e99299e691f80ba10b/tag/index.py#L110-L122
train
55,794
e7dal/bubble3
bubble3/commands/cmd_functions.py
cli
def cli(ctx, stage): """Show the functions that are available, bubble system and custom.""" if not ctx.bubble: ctx.say_yellow( 'There is no bubble present, will not show any transformer functions') raise click.Abort() rule_functions = get_registered_rule_functions() ctx.gbc.s...
python
def cli(ctx, stage): """Show the functions that are available, bubble system and custom.""" if not ctx.bubble: ctx.say_yellow( 'There is no bubble present, will not show any transformer functions') raise click.Abort() rule_functions = get_registered_rule_functions() ctx.gbc.s...
[ "def", "cli", "(", "ctx", ",", "stage", ")", ":", "if", "not", "ctx", ".", "bubble", ":", "ctx", ".", "say_yellow", "(", "'There is no bubble present, will not show any transformer functions'", ")", "raise", "click", ".", "Abort", "(", ")", "rule_functions", "="...
Show the functions that are available, bubble system and custom.
[ "Show", "the", "functions", "that", "are", "available", "bubble", "system", "and", "custom", "." ]
59c735281a95b44f6263a25f4d6ce24fca520082
https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/bubble3/commands/cmd_functions.py#L17-L33
train
55,795
MacHu-GWU/rolex-project
rolex/util.py
to_utc
def to_utc(a_datetime, keep_utc_tzinfo=False): """ Convert a time awared datetime to utc datetime. :param a_datetime: a timezone awared datetime. (If not, then just returns) :param keep_utc_tzinfo: whether to retain the utc time zone information. **中文文档** 将一个带时区的时间转化成UTC时间。而对于UTC时间而言, 有没有时区信息...
python
def to_utc(a_datetime, keep_utc_tzinfo=False): """ Convert a time awared datetime to utc datetime. :param a_datetime: a timezone awared datetime. (If not, then just returns) :param keep_utc_tzinfo: whether to retain the utc time zone information. **中文文档** 将一个带时区的时间转化成UTC时间。而对于UTC时间而言, 有没有时区信息...
[ "def", "to_utc", "(", "a_datetime", ",", "keep_utc_tzinfo", "=", "False", ")", ":", "if", "a_datetime", ".", "tzinfo", ":", "utc_datetime", "=", "a_datetime", ".", "astimezone", "(", "utc", ")", "# convert to utc time", "if", "keep_utc_tzinfo", "is", "False", ...
Convert a time awared datetime to utc datetime. :param a_datetime: a timezone awared datetime. (If not, then just returns) :param keep_utc_tzinfo: whether to retain the utc time zone information. **中文文档** 将一个带时区的时间转化成UTC时间。而对于UTC时间而言, 有没有时区信息都无所谓了。
[ "Convert", "a", "time", "awared", "datetime", "to", "utc", "datetime", "." ]
a1111b410ed04b4b6eddd81df110fa2dacfa6537
https://github.com/MacHu-GWU/rolex-project/blob/a1111b410ed04b4b6eddd81df110fa2dacfa6537/rolex/util.py#L74-L91
train
55,796
MacHu-GWU/rolex-project
rolex/util.py
utc_to_tz
def utc_to_tz(utc_datetime, tzinfo, keep_tzinfo=False): """ Convert a UTC datetime to a time awared local time :param utc_datetime: :param tzinfo: :param keep_tzinfo: """ tz_awared_datetime = utc_datetime.replace(tzinfo=utc).astimezone(tzinfo) if keep_tzinfo is False: tz_awared_...
python
def utc_to_tz(utc_datetime, tzinfo, keep_tzinfo=False): """ Convert a UTC datetime to a time awared local time :param utc_datetime: :param tzinfo: :param keep_tzinfo: """ tz_awared_datetime = utc_datetime.replace(tzinfo=utc).astimezone(tzinfo) if keep_tzinfo is False: tz_awared_...
[ "def", "utc_to_tz", "(", "utc_datetime", ",", "tzinfo", ",", "keep_tzinfo", "=", "False", ")", ":", "tz_awared_datetime", "=", "utc_datetime", ".", "replace", "(", "tzinfo", "=", "utc", ")", ".", "astimezone", "(", "tzinfo", ")", "if", "keep_tzinfo", "is", ...
Convert a UTC datetime to a time awared local time :param utc_datetime: :param tzinfo: :param keep_tzinfo:
[ "Convert", "a", "UTC", "datetime", "to", "a", "time", "awared", "local", "time" ]
a1111b410ed04b4b6eddd81df110fa2dacfa6537
https://github.com/MacHu-GWU/rolex-project/blob/a1111b410ed04b4b6eddd81df110fa2dacfa6537/rolex/util.py#L94-L105
train
55,797
MacHu-GWU/crawlib-project
crawlib/helper.py
repr_data_size
def repr_data_size(size_in_bytes, precision=2): # pragma: no cover """Return human readable string represent of a file size. Doesn"t support size greater than 1EB. For example: - 100 bytes => 100 B - 100,000 bytes => 97.66 KB - 100,000,000 bytes => 95.37 MB - 100,000,000,000 bytes => 93.1...
python
def repr_data_size(size_in_bytes, precision=2): # pragma: no cover """Return human readable string represent of a file size. Doesn"t support size greater than 1EB. For example: - 100 bytes => 100 B - 100,000 bytes => 97.66 KB - 100,000,000 bytes => 95.37 MB - 100,000,000,000 bytes => 93.1...
[ "def", "repr_data_size", "(", "size_in_bytes", ",", "precision", "=", "2", ")", ":", "# pragma: no cover", "if", "size_in_bytes", "<", "1024", ":", "return", "\"%s B\"", "%", "size_in_bytes", "magnitude_of_data", "=", "[", "\"B\"", ",", "\"KB\"", ",", "\"MB\"", ...
Return human readable string represent of a file size. Doesn"t support size greater than 1EB. For example: - 100 bytes => 100 B - 100,000 bytes => 97.66 KB - 100,000,000 bytes => 95.37 MB - 100,000,000,000 bytes => 93.13 GB - 100,000,000,000,000 bytes => 90.95 TB - 100,000,000,000,000,...
[ "Return", "human", "readable", "string", "represent", "of", "a", "file", "size", ".", "Doesn", "t", "support", "size", "greater", "than", "1EB", "." ]
241516f2a7a0a32c692f7af35a1f44064e8ce1ab
https://github.com/MacHu-GWU/crawlib-project/blob/241516f2a7a0a32c692f7af35a1f44064e8ce1ab/crawlib/helper.py#L5-L42
train
55,798
pauleveritt/kaybee
kaybee/plugins/articles/handlers.py
render_toctrees
def render_toctrees(kb_app: kb, sphinx_app: Sphinx, doctree: doctree, fromdocname: str): """ Look in doctrees for toctree and replace with custom render """ # Only do any of this if toctree support is turned on in KaybeeSettings. # By default, this is off. settings: KaybeeSettings =...
python
def render_toctrees(kb_app: kb, sphinx_app: Sphinx, doctree: doctree, fromdocname: str): """ Look in doctrees for toctree and replace with custom render """ # Only do any of this if toctree support is turned on in KaybeeSettings. # By default, this is off. settings: KaybeeSettings =...
[ "def", "render_toctrees", "(", "kb_app", ":", "kb", ",", "sphinx_app", ":", "Sphinx", ",", "doctree", ":", "doctree", ",", "fromdocname", ":", "str", ")", ":", "# Only do any of this if toctree support is turned on in KaybeeSettings.", "# By default, this is off.", "setti...
Look in doctrees for toctree and replace with custom render
[ "Look", "in", "doctrees", "for", "toctree", "and", "replace", "with", "custom", "render" ]
a00a718aaaa23b2d12db30dfacb6b2b6ec84459c
https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/articles/handlers.py#L48-L85
train
55,799