repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
secynic/ipwhois
ipwhois/whois.py
Whois.get_nets_lacnic
def get_nets_lacnic(self, response): """ The function for parsing network blocks from LACNIC whois data. Args: response (:obj:`str`): The response from the LACNIC whois server. Returns: list of dict: Mapping of networks with start and end positions. ...
python
def get_nets_lacnic(self, response): """ The function for parsing network blocks from LACNIC whois data. Args: response (:obj:`str`): The response from the LACNIC whois server. Returns: list of dict: Mapping of networks with start and end positions. ...
[ "def", "get_nets_lacnic", "(", "self", ",", "response", ")", ":", "nets", "=", "[", "]", "# Iterate through all of the networks found, storing the CIDR value", "# and the start and end positions.", "for", "match", "in", "re", ".", "finditer", "(", "r'^(inetnum|inet6num|rout...
The function for parsing network blocks from LACNIC whois data. Args: response (:obj:`str`): The response from the LACNIC whois server. Returns: list of dict: Mapping of networks with start and end positions. :: [{ 'cidr' (str) ...
[ "The", "function", "for", "parsing", "network", "blocks", "from", "LACNIC", "whois", "data", "." ]
train
https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/whois.py#L428-L496
secynic/ipwhois
ipwhois/whois.py
Whois._get_nets_lacnic
def _get_nets_lacnic(self, *args, **kwargs): """ Deprecated. This will be removed in a future release. """ from warnings import warn warn('Whois._get_nets_lacnic() has been deprecated and will be ' 'removed. You should now use Whois.get_nets_lacnic().') retu...
python
def _get_nets_lacnic(self, *args, **kwargs): """ Deprecated. This will be removed in a future release. """ from warnings import warn warn('Whois._get_nets_lacnic() has been deprecated and will be ' 'removed. You should now use Whois.get_nets_lacnic().') retu...
[ "def", "_get_nets_lacnic", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "warnings", "import", "warn", "warn", "(", "'Whois._get_nets_lacnic() has been deprecated and will be '", "'removed. You should now use Whois.get_nets_lacnic().'", ")", "r...
Deprecated. This will be removed in a future release.
[ "Deprecated", ".", "This", "will", "be", "removed", "in", "a", "future", "release", "." ]
train
https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/whois.py#L498-L506
secynic/ipwhois
ipwhois/whois.py
Whois.get_nets_other
def get_nets_other(self, response): """ The function for parsing network blocks from generic whois data. Args: response (:obj:`str`): The response from the whois/rwhois server. Returns: list of dict: Mapping of networks with start and end positions. ...
python
def get_nets_other(self, response): """ The function for parsing network blocks from generic whois data. Args: response (:obj:`str`): The response from the whois/rwhois server. Returns: list of dict: Mapping of networks with start and end positions. ...
[ "def", "get_nets_other", "(", "self", ",", "response", ")", ":", "nets", "=", "[", "]", "# Iterate through all of the networks found, storing the CIDR value", "# and the start and end positions.", "for", "match", "in", "re", ".", "finditer", "(", "r'^(inetnum|inet6num|route...
The function for parsing network blocks from generic whois data. Args: response (:obj:`str`): The response from the whois/rwhois server. Returns: list of dict: Mapping of networks with start and end positions. :: [{ 'cidr' (str)...
[ "The", "function", "for", "parsing", "network", "blocks", "from", "generic", "whois", "data", "." ]
train
https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/whois.py#L508-L578
secynic/ipwhois
ipwhois/whois.py
Whois._get_nets_other
def _get_nets_other(self, *args, **kwargs): """ Deprecated. This will be removed in a future release. """ from warnings import warn warn('Whois._get_nets_other() has been deprecated and will be ' 'removed. You should now use Whois.get_nets_other().') return ...
python
def _get_nets_other(self, *args, **kwargs): """ Deprecated. This will be removed in a future release. """ from warnings import warn warn('Whois._get_nets_other() has been deprecated and will be ' 'removed. You should now use Whois.get_nets_other().') return ...
[ "def", "_get_nets_other", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "warnings", "import", "warn", "warn", "(", "'Whois._get_nets_other() has been deprecated and will be '", "'removed. You should now use Whois.get_nets_other().'", ")", "retu...
Deprecated. This will be removed in a future release.
[ "Deprecated", ".", "This", "will", "be", "removed", "in", "a", "future", "release", "." ]
train
https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/whois.py#L580-L588
secynic/ipwhois
ipwhois/whois.py
Whois.lookup
def lookup(self, inc_raw=False, retry_count=3, response=None, get_referral=False, extra_blacklist=None, ignore_referral_errors=False, asn_data=None, field_list=None, is_offline=False): """ The function for retrieving and parsing whois information for an IP ...
python
def lookup(self, inc_raw=False, retry_count=3, response=None, get_referral=False, extra_blacklist=None, ignore_referral_errors=False, asn_data=None, field_list=None, is_offline=False): """ The function for retrieving and parsing whois information for an IP ...
[ "def", "lookup", "(", "self", ",", "inc_raw", "=", "False", ",", "retry_count", "=", "3", ",", "response", "=", "None", ",", "get_referral", "=", "False", ",", "extra_blacklist", "=", "None", ",", "ignore_referral_errors", "=", "False", ",", "asn_data", "=...
The function for retrieving and parsing whois information for an IP address via port 43/tcp (WHOIS). Args: inc_raw (:obj:`bool`, optional): Whether to include the raw results in the returned dictionary. Defaults to False. retry_count (:obj:`int`): The number of t...
[ "The", "function", "for", "retrieving", "and", "parsing", "whois", "information", "for", "an", "IP", "address", "via", "port", "43", "/", "tcp", "(", "WHOIS", ")", "." ]
train
https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/whois.py#L590-L809
secynic/ipwhois
ipwhois/ipwhois.py
IPWhois.lookup_whois
def lookup_whois(self, inc_raw=False, retry_count=3, get_referral=False, extra_blacklist=None, ignore_referral_errors=False, field_list=None, asn_alts=None, extra_org_map=None, inc_nir=True, nir_field_list=None, asn_methods=None, get_as...
python
def lookup_whois(self, inc_raw=False, retry_count=3, get_referral=False, extra_blacklist=None, ignore_referral_errors=False, field_list=None, asn_alts=None, extra_org_map=None, inc_nir=True, nir_field_list=None, asn_methods=None, get_as...
[ "def", "lookup_whois", "(", "self", ",", "inc_raw", "=", "False", ",", "retry_count", "=", "3", ",", "get_referral", "=", "False", ",", "extra_blacklist", "=", "None", ",", "ignore_referral_errors", "=", "False", ",", "field_list", "=", "None", ",", "asn_alt...
The function for retrieving and parsing whois information for an IP address via port 43 (WHOIS). Args: inc_raw (:obj:`bool`): Whether to include the raw whois results in the returned dictionary. Defaults to False. retry_count (:obj:`int`): The number of times to ...
[ "The", "function", "for", "retrieving", "and", "parsing", "whois", "information", "for", "an", "IP", "address", "via", "port", "43", "(", "WHOIS", ")", "." ]
train
https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/ipwhois.py#L72-L205
secynic/ipwhois
ipwhois/ipwhois.py
IPWhois.lookup_rdap
def lookup_rdap(self, inc_raw=False, retry_count=3, depth=0, excluded_entities=None, bootstrap=False, rate_limit_timeout=120, asn_alts=None, extra_org_map=None, inc_nir=True, nir_field_list=None, asn_methods=None, get_asn_description=True):...
python
def lookup_rdap(self, inc_raw=False, retry_count=3, depth=0, excluded_entities=None, bootstrap=False, rate_limit_timeout=120, asn_alts=None, extra_org_map=None, inc_nir=True, nir_field_list=None, asn_methods=None, get_asn_description=True):...
[ "def", "lookup_rdap", "(", "self", ",", "inc_raw", "=", "False", ",", "retry_count", "=", "3", ",", "depth", "=", "0", ",", "excluded_entities", "=", "None", ",", "bootstrap", "=", "False", ",", "rate_limit_timeout", "=", "120", ",", "asn_alts", "=", "No...
The function for retrieving and parsing whois information for an IP address via HTTP (RDAP). **This is now the recommended method, as RDAP contains much better information to parse.** Args: inc_raw (:obj:`bool`): Whether to include the raw whois results in t...
[ "The", "function", "for", "retrieving", "and", "parsing", "whois", "information", "for", "an", "IP", "address", "via", "HTTP", "(", "RDAP", ")", "." ]
train
https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/ipwhois.py#L207-L346
klen/marshmallow-peewee
marshmallow_peewee/fields.py
Timestamp._serialize
def _serialize(self, value, attr, obj, **kwargs): """Serialize given datetime to timestamp.""" if value is None: return None return int(datetime_to_timestamp(value))
python
def _serialize(self, value, attr, obj, **kwargs): """Serialize given datetime to timestamp.""" if value is None: return None return int(datetime_to_timestamp(value))
[ "def", "_serialize", "(", "self", ",", "value", ",", "attr", ",", "obj", ",", "*", "*", "kwargs", ")", ":", "if", "value", "is", "None", ":", "return", "None", "return", "int", "(", "datetime_to_timestamp", "(", "value", ")", ")" ]
Serialize given datetime to timestamp.
[ "Serialize", "given", "datetime", "to", "timestamp", "." ]
train
https://github.com/klen/marshmallow-peewee/blob/a5985daa4072605882a9c7c41d74881631943953/marshmallow_peewee/fields.py#L18-L23
klen/marshmallow-peewee
marshmallow_peewee/fields.py
MSTimestamp._serialize
def _serialize(self, value, *args, **kwargs): """Serialize given datetime to timestamp.""" if value is not None: value = super(MSTimestamp, self)._serialize(value, *args) * 1e3 return value
python
def _serialize(self, value, *args, **kwargs): """Serialize given datetime to timestamp.""" if value is not None: value = super(MSTimestamp, self)._serialize(value, *args) * 1e3 return value
[ "def", "_serialize", "(", "self", ",", "value", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "value", "is", "not", "None", ":", "value", "=", "super", "(", "MSTimestamp", ",", "self", ")", ".", "_serialize", "(", "value", ",", "*", ...
Serialize given datetime to timestamp.
[ "Serialize", "given", "datetime", "to", "timestamp", "." ]
train
https://github.com/klen/marshmallow-peewee/blob/a5985daa4072605882a9c7c41d74881631943953/marshmallow_peewee/fields.py#L37-L41
klen/marshmallow-peewee
marshmallow_peewee/convert.py
ModelConverter.convert_default
def convert_default(self, field, **params): """Return raw field.""" for klass, ma_field in self.TYPE_MAPPING: if isinstance(field, klass): return ma_field(**params) return fields.Raw(**params)
python
def convert_default(self, field, **params): """Return raw field.""" for klass, ma_field in self.TYPE_MAPPING: if isinstance(field, klass): return ma_field(**params) return fields.Raw(**params)
[ "def", "convert_default", "(", "self", ",", "field", ",", "*", "*", "params", ")", ":", "for", "klass", ",", "ma_field", "in", "self", ".", "TYPE_MAPPING", ":", "if", "isinstance", "(", "field", ",", "klass", ")", ":", "return", "ma_field", "(", "*", ...
Return raw field.
[ "Return", "raw", "field", "." ]
train
https://github.com/klen/marshmallow-peewee/blob/a5985daa4072605882a9c7c41d74881631943953/marshmallow_peewee/convert.py#L78-L83
klen/marshmallow-peewee
marshmallow_peewee/schema.py
ModelSchema.make_instance
def make_instance(self, data): """Build object from data.""" if not self.opts.model: return data if self.instance is not None: for key, value in data.items(): setattr(self.instance, key, value) return self.instance return self.opts.mo...
python
def make_instance(self, data): """Build object from data.""" if not self.opts.model: return data if self.instance is not None: for key, value in data.items(): setattr(self.instance, key, value) return self.instance return self.opts.mo...
[ "def", "make_instance", "(", "self", ",", "data", ")", ":", "if", "not", "self", ".", "opts", ".", "model", ":", "return", "data", "if", "self", ".", "instance", "is", "not", "None", ":", "for", "key", ",", "value", "in", "data", ".", "items", "(",...
Build object from data.
[ "Build", "object", "from", "data", "." ]
train
https://github.com/klen/marshmallow-peewee/blob/a5985daa4072605882a9c7c41d74881631943953/marshmallow_peewee/schema.py#L68-L78
tyarkoni/pliers
pliers/extractors/text.py
ComplexTextExtractor._extract
def _extract(self, stim): ''' Returns all words. ''' props = [(e.text, e.onset, e.duration) for e in stim.elements] vals, onsets, durations = map(list, zip(*props)) return ExtractorResult(vals, stim, self, ['word'], onsets, durations)
python
def _extract(self, stim): ''' Returns all words. ''' props = [(e.text, e.onset, e.duration) for e in stim.elements] vals, onsets, durations = map(list, zip(*props)) return ExtractorResult(vals, stim, self, ['word'], onsets, durations)
[ "def", "_extract", "(", "self", ",", "stim", ")", ":", "props", "=", "[", "(", "e", ".", "text", ",", "e", ".", "onset", ",", "e", ".", "duration", ")", "for", "e", "in", "stim", ".", "elements", "]", "vals", ",", "onsets", ",", "durations", "=...
Returns all words.
[ "Returns", "all", "words", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/extractors/text.py#L44-L48
tyarkoni/pliers
pliers/stimuli/base.py
load_stims
def load_stims(source, dtype=None, fail_silently=False): """ Load one or more stimuli directly from file, inferring/extracting metadata as needed. Args: source (str or list): The location to load the stim(s) from. Can be the path to a directory, to a single file, or a list of filenames....
python
def load_stims(source, dtype=None, fail_silently=False): """ Load one or more stimuli directly from file, inferring/extracting metadata as needed. Args: source (str or list): The location to load the stim(s) from. Can be the path to a directory, to a single file, or a list of filenames....
[ "def", "load_stims", "(", "source", ",", "dtype", "=", "None", ",", "fail_silently", "=", "False", ")", ":", "from", ".", "video", "import", "VideoStim", ",", "ImageStim", "from", ".", "audio", "import", "AudioStim", "from", ".", "text", "import", "TextSti...
Load one or more stimuli directly from file, inferring/extracting metadata as needed. Args: source (str or list): The location to load the stim(s) from. Can be the path to a directory, to a single file, or a list of filenames. dtype (str): The type of stim to load. If dtype is None,...
[ "Load", "one", "or", "more", "stimuli", "directly", "from", "file", "inferring", "/", "extracting", "metadata", "as", "needed", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/stimuli/base.py#L98-L168
tyarkoni/pliers
pliers/stimuli/base.py
Stim.get_filename
def get_filename(self): ''' Return the source filename of the current Stim. ''' if self.filename is None or not os.path.exists(self.filename): tf = tempfile.mktemp() + self._default_file_extension self.save(tf) yield tf os.remove(tf) else: ...
python
def get_filename(self): ''' Return the source filename of the current Stim. ''' if self.filename is None or not os.path.exists(self.filename): tf = tempfile.mktemp() + self._default_file_extension self.save(tf) yield tf os.remove(tf) else: ...
[ "def", "get_filename", "(", "self", ")", ":", "if", "self", ".", "filename", "is", "None", "or", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "filename", ")", ":", "tf", "=", "tempfile", ".", "mktemp", "(", ")", "+", "self", ".", "_...
Return the source filename of the current Stim.
[ "Return", "the", "source", "filename", "of", "the", "current", "Stim", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/stimuli/base.py#L55-L63
tyarkoni/pliers
pliers/extractors/base.py
merge_results
def merge_results(results, format='wide', timing=True, metadata=True, extractor_names=True, object_id=True, aggfunc=None, invalid_results='ignore', **to_df_kwargs): ''' Merges a list of ExtractorResults instances and returns a pandas DF. Args: results (list, tuple): ...
python
def merge_results(results, format='wide', timing=True, metadata=True, extractor_names=True, object_id=True, aggfunc=None, invalid_results='ignore', **to_df_kwargs): ''' Merges a list of ExtractorResults instances and returns a pandas DF. Args: results (list, tuple): ...
[ "def", "merge_results", "(", "results", ",", "format", "=", "'wide'", ",", "timing", "=", "True", ",", "metadata", "=", "True", ",", "extractor_names", "=", "True", ",", "object_id", "=", "True", ",", "aggfunc", "=", "None", ",", "invalid_results", "=", ...
Merges a list of ExtractorResults instances and returns a pandas DF. Args: results (list, tuple): A list of ExtractorResult instances to merge. format (str): Format to return the data in. Can be either 'wide' or 'long'. In the wide case, every extracted feature is a column, ...
[ "Merges", "a", "list", "of", "ExtractorResults", "instances", "and", "returns", "a", "pandas", "DF", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/extractors/base.py#L195-L332
tyarkoni/pliers
pliers/extractors/base.py
ExtractorResult.to_df
def to_df(self, timing=True, metadata=False, format='wide', extractor_name=False, object_id=True, **to_df_kwargs): ''' Convert current instance to a pandas DatasFrame. Args: timing (bool): If True, adds columns for event onset and duration. Note that these colu...
python
def to_df(self, timing=True, metadata=False, format='wide', extractor_name=False, object_id=True, **to_df_kwargs): ''' Convert current instance to a pandas DatasFrame. Args: timing (bool): If True, adds columns for event onset and duration. Note that these colu...
[ "def", "to_df", "(", "self", ",", "timing", "=", "True", ",", "metadata", "=", "False", ",", "format", "=", "'wide'", ",", "extractor_name", "=", "False", ",", "object_id", "=", "True", ",", "*", "*", "to_df_kwargs", ")", ":", "# Ideally, Extractors should...
Convert current instance to a pandas DatasFrame. Args: timing (bool): If True, adds columns for event onset and duration. Note that these columns will be added even if there are no valid values in the current object (NaNs will be inserted). If 'auto',...
[ "Convert", "current", "instance", "to", "a", "pandas", "DatasFrame", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/extractors/base.py#L77-L183
tyarkoni/pliers
pliers/stimuli/compound.py
CompoundStim.get_stim
def get_stim(self, type_, return_all=False): ''' Returns component elements of the specified type. Args: type_ (str or Stim class): the desired Stim subclass to return. return_all (bool): when True, returns all elements that matched the specified type as a list. ...
python
def get_stim(self, type_, return_all=False): ''' Returns component elements of the specified type. Args: type_ (str or Stim class): the desired Stim subclass to return. return_all (bool): when True, returns all elements that matched the specified type as a list. ...
[ "def", "get_stim", "(", "self", ",", "type_", ",", "return_all", "=", "False", ")", ":", "if", "isinstance", "(", "type_", ",", "string_types", ")", ":", "type_", "=", "_get_stim_class", "(", "type_", ")", "matches", "=", "[", "]", "for", "s", "in", ...
Returns component elements of the specified type. Args: type_ (str or Stim class): the desired Stim subclass to return. return_all (bool): when True, returns all elements that matched the specified type as a list. When False (default), returns only the fi...
[ "Returns", "component", "elements", "of", "the", "specified", "type", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/stimuli/compound.py#L57-L81
tyarkoni/pliers
pliers/stimuli/compound.py
CompoundStim.has_types
def has_types(self, types, all_=True): ''' Check whether the current component list matches all Stim types in the types argument. Args: types (Stim, list): a Stim class or iterable of Stim classes. all_ (bool): if True, all input types must match; if False, at ...
python
def has_types(self, types, all_=True): ''' Check whether the current component list matches all Stim types in the types argument. Args: types (Stim, list): a Stim class or iterable of Stim classes. all_ (bool): if True, all input types must match; if False, at ...
[ "def", "has_types", "(", "self", ",", "types", ",", "all_", "=", "True", ")", ":", "func", "=", "all", "if", "all_", "else", "any", "return", "func", "(", "[", "self", ".", "get_stim", "(", "t", ")", "for", "t", "in", "listify", "(", "types", ")"...
Check whether the current component list matches all Stim types in the types argument. Args: types (Stim, list): a Stim class or iterable of Stim classes. all_ (bool): if True, all input types must match; if False, at least one input type must match. Ret...
[ "Check", "whether", "the", "current", "component", "list", "matches", "all", "Stim", "types", "in", "the", "types", "argument", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/stimuli/compound.py#L87-L101
tyarkoni/pliers
pliers/transformers/base.py
get_transformer
def get_transformer(name, base=None, *args, **kwargs): ''' Scans list of currently available Transformer classes and returns an instantiation of the first one whose name perfectly matches (case-insensitive). Args: name (str): The name of the transformer to retrieve. Case-insensitive; ...
python
def get_transformer(name, base=None, *args, **kwargs): ''' Scans list of currently available Transformer classes and returns an instantiation of the first one whose name perfectly matches (case-insensitive). Args: name (str): The name of the transformer to retrieve. Case-insensitive; ...
[ "def", "get_transformer", "(", "name", ",", "base", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "name", "=", "name", ".", "lower", "(", ")", "# Default to searching all kinds of Transformers", "if", "base", "is", "None", ":", "base", ...
Scans list of currently available Transformer classes and returns an instantiation of the first one whose name perfectly matches (case-insensitive). Args: name (str): The name of the transformer to retrieve. Case-insensitive; e.g., 'stftextractor' or 'CornerDetectionExtractor'. ...
[ "Scans", "list", "of", "currently", "available", "Transformer", "classes", "and", "returns", "an", "instantiation", "of", "the", "first", "one", "whose", "name", "perfectly", "matches", "(", "case", "-", "insensitive", ")", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/transformers/base.py#L286-L317
tyarkoni/pliers
pliers/transformers/base.py
Transformer.transform
def transform(self, stims, validation='strict', *args, **kwargs): ''' Executes the transformation on the passed stim(s). Args: stims (str, Stim, list): One or more stimuli to process. Must be one of: - A string giving the path to a file that can be read ...
python
def transform(self, stims, validation='strict', *args, **kwargs): ''' Executes the transformation on the passed stim(s). Args: stims (str, Stim, list): One or more stimuli to process. Must be one of: - A string giving the path to a file that can be read ...
[ "def", "transform", "(", "self", ",", "stims", ",", "validation", "=", "'strict'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "stims", ",", "string_types", ")", ":", "stims", "=", "load_stims", "(", "stims", ")", "#...
Executes the transformation on the passed stim(s). Args: stims (str, Stim, list): One or more stimuli to process. Must be one of: - A string giving the path to a file that can be read in as a Stim (e.g., a .txt file, .jpg image, etc.) ...
[ "Executes", "the", "transformation", "on", "the", "passed", "stim", "(", "s", ")", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/transformers/base.py#L65-L134
tyarkoni/pliers
pliers/stimuli/audio.py
AudioStim.get_sampling_rate
def get_sampling_rate(filename): ''' Use moviepy/FFMPEG to get the sampling rate ''' infos = ffmpeg_parse_infos(filename) fps = infos.get('audio_fps', 44100) if fps == 'unknown': fps = 44100 return fps
python
def get_sampling_rate(filename): ''' Use moviepy/FFMPEG to get the sampling rate ''' infos = ffmpeg_parse_infos(filename) fps = infos.get('audio_fps', 44100) if fps == 'unknown': fps = 44100 return fps
[ "def", "get_sampling_rate", "(", "filename", ")", ":", "infos", "=", "ffmpeg_parse_infos", "(", "filename", ")", "fps", "=", "infos", ".", "get", "(", "'audio_fps'", ",", "44100", ")", "if", "fps", "==", "'unknown'", ":", "fps", "=", "44100", "return", "...
Use moviepy/FFMPEG to get the sampling rate
[ "Use", "moviepy", "/", "FFMPEG", "to", "get", "the", "sampling", "rate" ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/stimuli/audio.py#L60-L66
tyarkoni/pliers
pliers/stimuli/audio.py
AudioStim.save
def save(self, path): ''' Save clip data to file. Args: path (str): Filename to save audio data to. ''' self.clip.write_audiofile(path, fps=self.sampling_rate)
python
def save(self, path): ''' Save clip data to file. Args: path (str): Filename to save audio data to. ''' self.clip.write_audiofile(path, fps=self.sampling_rate)
[ "def", "save", "(", "self", ",", "path", ")", ":", "self", ".", "clip", ".", "write_audiofile", "(", "path", ",", "fps", "=", "self", ".", "sampling_rate", ")" ]
Save clip data to file. Args: path (str): Filename to save audio data to.
[ "Save", "clip", "data", "to", "file", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/stimuli/audio.py#L77-L83
tyarkoni/pliers
pliers/config.py
_update_from_standard_locations
def _update_from_standard_locations(): ''' Check standard locations for config files and update settings if found. Order is user's home dir, environment variable ($PLIERS_CONFIG), and then current directory--with later files taking precedence over earlier ones. ''' locs = [ join(expanduser('...
python
def _update_from_standard_locations(): ''' Check standard locations for config files and update settings if found. Order is user's home dir, environment variable ($PLIERS_CONFIG), and then current directory--with later files taking precedence over earlier ones. ''' locs = [ join(expanduser('...
[ "def", "_update_from_standard_locations", "(", ")", ":", "locs", "=", "[", "join", "(", "expanduser", "(", "'~'", ")", ",", "_config_name", ")", ",", "join", "(", "'.'", ",", "_config_name", ")", "]", "if", "'PLIERS_CONFIG'", "in", "os", ".", "environ", ...
Check standard locations for config files and update settings if found. Order is user's home dir, environment variable ($PLIERS_CONFIG), and then current directory--with later files taking precedence over earlier ones.
[ "Check", "standard", "locations", "for", "config", "files", "and", "update", "settings", "if", "found", ".", "Order", "is", "user", "s", "home", "dir", "environment", "variable", "(", "$PLIERS_CONFIG", ")", "and", "then", "current", "directory", "--", "with", ...
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/config.py#L77-L89
tyarkoni/pliers
pliers/converters/base.py
get_converter
def get_converter(in_type, out_type, *args, **kwargs): ''' Scans the list of available Converters and returns an instantiation of the first one whose input and output types match those passed in. Args: in_type (type): The type of input the converter must have. out_type (type): The type of o...
python
def get_converter(in_type, out_type, *args, **kwargs): ''' Scans the list of available Converters and returns an instantiation of the first one whose input and output types match those passed in. Args: in_type (type): The type of input the converter must have. out_type (type): The type of o...
[ "def", "get_converter", "(", "in_type", ",", "out_type", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "convs", "=", "pliers", ".", "converters", ".", "__all__", "# If config includes default converters for this combination, try them", "# first", "out_type", ...
Scans the list of available Converters and returns an instantiation of the first one whose input and output types match those passed in. Args: in_type (type): The type of input the converter must have. out_type (type): The type of output the converter must have. args, kwargs: Optional p...
[ "Scans", "the", "list", "of", "available", "Converters", "and", "returns", "an", "instantiation", "of", "the", "first", "one", "whose", "input", "and", "output", "types", "match", "those", "passed", "in", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/converters/base.py#L27-L61
tyarkoni/pliers
pliers/external/tensorflow/classify_image.py
create_graph
def create_graph(): """Creates a graph from saved GraphDef file and returns a saver.""" # Creates graph from saved graph_def.pb. with tf.gfile.FastGFile(os.path.join( FLAGS.model_dir, 'classify_image_graph_def.pb'), 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) _ = tf...
python
def create_graph(): """Creates a graph from saved GraphDef file and returns a saver.""" # Creates graph from saved graph_def.pb. with tf.gfile.FastGFile(os.path.join( FLAGS.model_dir, 'classify_image_graph_def.pb'), 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) _ = tf...
[ "def", "create_graph", "(", ")", ":", "# Creates graph from saved graph_def.pb.", "with", "tf", ".", "gfile", ".", "FastGFile", "(", "os", ".", "path", ".", "join", "(", "FLAGS", ".", "model_dir", ",", "'classify_image_graph_def.pb'", ")", ",", "'rb'", ")", "a...
Creates a graph from saved GraphDef file and returns a saver.
[ "Creates", "a", "graph", "from", "saved", "GraphDef", "file", "and", "returns", "a", "saver", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/external/tensorflow/classify_image.py#L120-L127
tyarkoni/pliers
pliers/external/tensorflow/classify_image.py
run_inference_on_image
def run_inference_on_image(image): """Runs inference on an image. Args: image: Image file name. Returns: Nothing """ if not tf.gfile.Exists(image): tf.logging.fatal('File does not exist %s', image) image_data = tf.gfile.FastGFile(image, 'rb').read() # Creates graph from saved GraphDef. cr...
python
def run_inference_on_image(image): """Runs inference on an image. Args: image: Image file name. Returns: Nothing """ if not tf.gfile.Exists(image): tf.logging.fatal('File does not exist %s', image) image_data = tf.gfile.FastGFile(image, 'rb').read() # Creates graph from saved GraphDef. cr...
[ "def", "run_inference_on_image", "(", "image", ")", ":", "if", "not", "tf", ".", "gfile", ".", "Exists", "(", "image", ")", ":", "tf", ".", "logging", ".", "fatal", "(", "'File does not exist %s'", ",", "image", ")", "image_data", "=", "tf", ".", "gfile"...
Runs inference on an image. Args: image: Image file name. Returns: Nothing
[ "Runs", "inference", "on", "an", "image", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/external/tensorflow/classify_image.py#L130-L167
tyarkoni/pliers
pliers/external/tensorflow/classify_image.py
NodeLookup.load
def load(self, label_lookup_path, uid_lookup_path): """Loads a human readable English name for each softmax node. Args: label_lookup_path: string UID to integer node ID. uid_lookup_path: string UID to human-readable string. Returns: dict from integer node ID to human-readable string. ...
python
def load(self, label_lookup_path, uid_lookup_path): """Loads a human readable English name for each softmax node. Args: label_lookup_path: string UID to integer node ID. uid_lookup_path: string UID to human-readable string. Returns: dict from integer node ID to human-readable string. ...
[ "def", "load", "(", "self", ",", "label_lookup_path", ",", "uid_lookup_path", ")", ":", "if", "not", "tf", ".", "gfile", ".", "Exists", "(", "uid_lookup_path", ")", ":", "tf", ".", "logging", ".", "fatal", "(", "'File does not exist %s'", ",", "uid_lookup_pa...
Loads a human readable English name for each softmax node. Args: label_lookup_path: string UID to integer node ID. uid_lookup_path: string UID to human-readable string. Returns: dict from integer node ID to human-readable string.
[ "Loads", "a", "human", "readable", "English", "name", "for", "each", "softmax", "node", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/external/tensorflow/classify_image.py#L69-L112
tyarkoni/pliers
pliers/datasets/text.py
fetch_dictionary
def fetch_dictionary(name, url=None, format=None, index=0, rename=None, save=True, force_retrieve=False): ''' Retrieve a dictionary of text norms from the web or local storage. Args: name (str): The name of the dictionary. If no url is passed, this must match either one...
python
def fetch_dictionary(name, url=None, format=None, index=0, rename=None, save=True, force_retrieve=False): ''' Retrieve a dictionary of text norms from the web or local storage. Args: name (str): The name of the dictionary. If no url is passed, this must match either one...
[ "def", "fetch_dictionary", "(", "name", ",", "url", "=", "None", ",", "format", "=", "None", ",", "index", "=", "0", ",", "rename", "=", "None", ",", "save", "=", "True", ",", "force_retrieve", "=", "False", ")", ":", "file_path", "=", "os", ".", "...
Retrieve a dictionary of text norms from the web or local storage. Args: name (str): The name of the dictionary. If no url is passed, this must match either one of the keys in the predefined dictionary file (see dictionaries.json), or the name assigned to a previous dictionary ...
[ "Retrieve", "a", "dictionary", "of", "text", "norms", "from", "the", "web", "or", "local", "storage", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/datasets/text.py#L57-L111
tyarkoni/pliers
pliers/extractors/api/google.py
GoogleVisionAPIFaceExtractor._to_df
def _to_df(self, result, handle_annotations=None): ''' Converts a Google API Face JSON response into a Pandas Dataframe. Args: result (ExtractorResult): Result object from which to parse out a Dataframe. handle_annotations (str): How returned face annotat...
python
def _to_df(self, result, handle_annotations=None): ''' Converts a Google API Face JSON response into a Pandas Dataframe. Args: result (ExtractorResult): Result object from which to parse out a Dataframe. handle_annotations (str): How returned face annotat...
[ "def", "_to_df", "(", "self", ",", "result", ",", "handle_annotations", "=", "None", ")", ":", "annotations", "=", "result", ".", "_data", "if", "handle_annotations", "==", "'first'", ":", "annotations", "=", "[", "annotations", "[", "0", "]", "]", "face_r...
Converts a Google API Face JSON response into a Pandas Dataframe. Args: result (ExtractorResult): Result object from which to parse out a Dataframe. handle_annotations (str): How returned face annotations should be handled in cases where there are multipl...
[ "Converts", "a", "Google", "API", "Face", "JSON", "response", "into", "a", "Pandas", "Dataframe", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/extractors/api/google.py#L50-L89
tyarkoni/pliers
pliers/diagnostics/diagnostics.py
correlation_matrix
def correlation_matrix(df): ''' Returns a pandas DataFrame with the pair-wise correlations of the columns. Args: df: pandas DataFrame with columns to run diagnostics on ''' columns = df.columns.tolist() corr = pd.DataFrame( np.corrcoef(df, rowvar=0), columns=columns, index=colum...
python
def correlation_matrix(df): ''' Returns a pandas DataFrame with the pair-wise correlations of the columns. Args: df: pandas DataFrame with columns to run diagnostics on ''' columns = df.columns.tolist() corr = pd.DataFrame( np.corrcoef(df, rowvar=0), columns=columns, index=colum...
[ "def", "correlation_matrix", "(", "df", ")", ":", "columns", "=", "df", ".", "columns", ".", "tolist", "(", ")", "corr", "=", "pd", ".", "DataFrame", "(", "np", ".", "corrcoef", "(", "df", ",", "rowvar", "=", "0", ")", ",", "columns", "=", "columns...
Returns a pandas DataFrame with the pair-wise correlations of the columns. Args: df: pandas DataFrame with columns to run diagnostics on
[ "Returns", "a", "pandas", "DataFrame", "with", "the", "pair", "-", "wise", "correlations", "of", "the", "columns", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/diagnostics/diagnostics.py#L12-L22
tyarkoni/pliers
pliers/diagnostics/diagnostics.py
eigenvalues
def eigenvalues(df): ''' Returns a pandas Series with eigenvalues of the correlation matrix. Args: df: pandas DataFrame with columns to run diagnostics on ''' corr = np.corrcoef(df, rowvar=0) eigvals = np.linalg.eigvals(corr) return pd.Series(eigvals, df.columns, name='Eigenvalue')
python
def eigenvalues(df): ''' Returns a pandas Series with eigenvalues of the correlation matrix. Args: df: pandas DataFrame with columns to run diagnostics on ''' corr = np.corrcoef(df, rowvar=0) eigvals = np.linalg.eigvals(corr) return pd.Series(eigvals, df.columns, name='Eigenvalue')
[ "def", "eigenvalues", "(", "df", ")", ":", "corr", "=", "np", ".", "corrcoef", "(", "df", ",", "rowvar", "=", "0", ")", "eigvals", "=", "np", ".", "linalg", ".", "eigvals", "(", "corr", ")", "return", "pd", ".", "Series", "(", "eigvals", ",", "df...
Returns a pandas Series with eigenvalues of the correlation matrix. Args: df: pandas DataFrame with columns to run diagnostics on
[ "Returns", "a", "pandas", "Series", "with", "eigenvalues", "of", "the", "correlation", "matrix", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/diagnostics/diagnostics.py#L25-L34
tyarkoni/pliers
pliers/diagnostics/diagnostics.py
condition_indices
def condition_indices(df): ''' Returns a pandas Series with condition indices of the df columns. Args: df: pandas DataFrame with columns to run diagnostics on ''' eigvals = eigenvalues(df) cond_idx = np.sqrt(eigvals.max() / eigvals) return pd.Series(cond_idx, df.columns, name='Condi...
python
def condition_indices(df): ''' Returns a pandas Series with condition indices of the df columns. Args: df: pandas DataFrame with columns to run diagnostics on ''' eigvals = eigenvalues(df) cond_idx = np.sqrt(eigvals.max() / eigvals) return pd.Series(cond_idx, df.columns, name='Condi...
[ "def", "condition_indices", "(", "df", ")", ":", "eigvals", "=", "eigenvalues", "(", "df", ")", "cond_idx", "=", "np", ".", "sqrt", "(", "eigvals", ".", "max", "(", ")", "/", "eigvals", ")", "return", "pd", ".", "Series", "(", "cond_idx", ",", "df", ...
Returns a pandas Series with condition indices of the df columns. Args: df: pandas DataFrame with columns to run diagnostics on
[ "Returns", "a", "pandas", "Series", "with", "condition", "indices", "of", "the", "df", "columns", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/diagnostics/diagnostics.py#L37-L46
tyarkoni/pliers
pliers/diagnostics/diagnostics.py
variance_inflation_factors
def variance_inflation_factors(df): ''' Computes the variance inflation factor (VIF) for each column in the df. Returns a pandas Series of VIFs Args: df: pandas DataFrame with columns to run diagnostics on ''' corr = np.corrcoef(df, rowvar=0) corr_inv = np.linalg.inv(corr) vifs ...
python
def variance_inflation_factors(df): ''' Computes the variance inflation factor (VIF) for each column in the df. Returns a pandas Series of VIFs Args: df: pandas DataFrame with columns to run diagnostics on ''' corr = np.corrcoef(df, rowvar=0) corr_inv = np.linalg.inv(corr) vifs ...
[ "def", "variance_inflation_factors", "(", "df", ")", ":", "corr", "=", "np", ".", "corrcoef", "(", "df", ",", "rowvar", "=", "0", ")", "corr_inv", "=", "np", ".", "linalg", ".", "inv", "(", "corr", ")", "vifs", "=", "np", ".", "diagonal", "(", "cor...
Computes the variance inflation factor (VIF) for each column in the df. Returns a pandas Series of VIFs Args: df: pandas DataFrame with columns to run diagnostics on
[ "Computes", "the", "variance", "inflation", "factor", "(", "VIF", ")", "for", "each", "column", "in", "the", "df", ".", "Returns", "a", "pandas", "Series", "of", "VIFs" ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/diagnostics/diagnostics.py#L49-L60
tyarkoni/pliers
pliers/diagnostics/diagnostics.py
mahalanobis_distances
def mahalanobis_distances(df, axis=0): ''' Returns a pandas Series with Mahalanobis distances for each sample on the axis. Note: does not work well when # of observations < # of dimensions Will either return NaN in answer or (in the extreme case) fail with a Singular Matrix LinAlgError Arg...
python
def mahalanobis_distances(df, axis=0): ''' Returns a pandas Series with Mahalanobis distances for each sample on the axis. Note: does not work well when # of observations < # of dimensions Will either return NaN in answer or (in the extreme case) fail with a Singular Matrix LinAlgError Arg...
[ "def", "mahalanobis_distances", "(", "df", ",", "axis", "=", "0", ")", ":", "df", "=", "df", ".", "transpose", "(", ")", "if", "axis", "==", "1", "else", "df", "means", "=", "df", ".", "mean", "(", ")", "try", ":", "inv_cov", "=", "np", ".", "l...
Returns a pandas Series with Mahalanobis distances for each sample on the axis. Note: does not work well when # of observations < # of dimensions Will either return NaN in answer or (in the extreme case) fail with a Singular Matrix LinAlgError Args: df: pandas DataFrame with columns to run...
[ "Returns", "a", "pandas", "Series", "with", "Mahalanobis", "distances", "for", "each", "sample", "on", "the", "axis", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/diagnostics/diagnostics.py#L63-L87
tyarkoni/pliers
pliers/diagnostics/diagnostics.py
Diagnostics.summary
def summary(self, stdout=True, plot=False): ''' Displays diagnostics to the user Args: stdout (bool): print results to the console plot (bool): use Seaborn to plot results ''' if stdout: print('Collinearity summary:') print(pd.conc...
python
def summary(self, stdout=True, plot=False): ''' Displays diagnostics to the user Args: stdout (bool): print results to the console plot (bool): use Seaborn to plot results ''' if stdout: print('Collinearity summary:') print(pd.conc...
[ "def", "summary", "(", "self", ",", "stdout", "=", "True", ",", "plot", "=", "False", ")", ":", "if", "stdout", ":", "print", "(", "'Collinearity summary:'", ")", "print", "(", "pd", ".", "concat", "(", "[", "self", ".", "results", "[", "'Eigenvalues'"...
Displays diagnostics to the user Args: stdout (bool): print results to the console plot (bool): use Seaborn to plot results
[ "Displays", "diagnostics", "to", "the", "user" ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/diagnostics/diagnostics.py#L128-L161
tyarkoni/pliers
pliers/diagnostics/diagnostics.py
Diagnostics.flag
def flag(self, diagnostic, thresh=None): ''' Returns indices of diagnostic that satisfy (return True from) the threshold predicate. Will use class-level default threshold if None provided. Args: diagnostic (str): name of the diagnostic thresh (func): thre...
python
def flag(self, diagnostic, thresh=None): ''' Returns indices of diagnostic that satisfy (return True from) the threshold predicate. Will use class-level default threshold if None provided. Args: diagnostic (str): name of the diagnostic thresh (func): thre...
[ "def", "flag", "(", "self", ",", "diagnostic", ",", "thresh", "=", "None", ")", ":", "if", "thresh", "is", "None", ":", "thresh", "=", "self", ".", "defaults", "[", "diagnostic", "]", "result", "=", "self", ".", "results", "[", "diagnostic", "]", "if...
Returns indices of diagnostic that satisfy (return True from) the threshold predicate. Will use class-level default threshold if None provided. Args: diagnostic (str): name of the diagnostic thresh (func): threshold function (boolean predicate) to apply to ea...
[ "Returns", "indices", "of", "diagnostic", "that", "satisfy", "(", "return", "True", "from", ")", "the", "threshold", "predicate", ".", "Will", "use", "class", "-", "level", "default", "threshold", "if", "None", "provided", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/diagnostics/diagnostics.py#L163-L184
tyarkoni/pliers
pliers/diagnostics/diagnostics.py
Diagnostics.flag_all
def flag_all(self, thresh_dict=None, include=None, exclude=None): ''' Returns indices of (rows, columns) that satisfy flag() on any diagnostic. Uses user-provided thresholds in thresh_dict/ Args: thresh_dict (dict): dictionary of diagnostic->threshold functions i...
python
def flag_all(self, thresh_dict=None, include=None, exclude=None): ''' Returns indices of (rows, columns) that satisfy flag() on any diagnostic. Uses user-provided thresholds in thresh_dict/ Args: thresh_dict (dict): dictionary of diagnostic->threshold functions i...
[ "def", "flag_all", "(", "self", ",", "thresh_dict", "=", "None", ",", "include", "=", "None", ",", "exclude", "=", "None", ")", ":", "if", "thresh_dict", "is", "None", ":", "thresh_dict", "=", "{", "}", "row_idx", "=", "set", "(", ")", "col_idx", "="...
Returns indices of (rows, columns) that satisfy flag() on any diagnostic. Uses user-provided thresholds in thresh_dict/ Args: thresh_dict (dict): dictionary of diagnostic->threshold functions include (list): optional sublist of diagnostics to flag exclude (list): opt...
[ "Returns", "indices", "of", "(", "rows", "columns", ")", "that", "satisfy", "flag", "()", "on", "any", "diagnostic", ".", "Uses", "user", "-", "provided", "thresholds", "in", "thresh_dict", "/" ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/diagnostics/diagnostics.py#L186-L214
tyarkoni/pliers
pliers/graph.py
Graph.add_nodes
def add_nodes(self, nodes, parent=None, mode='horizontal'): ''' Adds one or more nodes to the current graph. Args: nodes (list): A list of nodes to add. Each element must be one of the following: * A dict containing keyword args to pass onto to the Node init...
python
def add_nodes(self, nodes, parent=None, mode='horizontal'): ''' Adds one or more nodes to the current graph. Args: nodes (list): A list of nodes to add. Each element must be one of the following: * A dict containing keyword args to pass onto to the Node init...
[ "def", "add_nodes", "(", "self", ",", "nodes", ",", "parent", "=", "None", ",", "mode", "=", "'horizontal'", ")", ":", "for", "n", "in", "nodes", ":", "node_args", "=", "self", ".", "_parse_node_args", "(", "n", ")", "if", "mode", "==", "'horizontal'",...
Adds one or more nodes to the current graph. Args: nodes (list): A list of nodes to add. Each element must be one of the following: * A dict containing keyword args to pass onto to the Node init. * An iterable containing 1 - 3 elements. The first ele...
[ "Adds", "one", "or", "more", "nodes", "to", "the", "current", "graph", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/graph.py#L107-L144
tyarkoni/pliers
pliers/graph.py
Graph.add_node
def add_node(self, transformer, name=None, children=None, parent=None, parameters={}, return_node=False): ''' Adds a node to the current graph. Args: transformer (str, Transformer): The pliers Transformer to use at the to-be-added node. Either a case-insensi...
python
def add_node(self, transformer, name=None, children=None, parent=None, parameters={}, return_node=False): ''' Adds a node to the current graph. Args: transformer (str, Transformer): The pliers Transformer to use at the to-be-added node. Either a case-insensi...
[ "def", "add_node", "(", "self", ",", "transformer", ",", "name", "=", "None", ",", "children", "=", "None", ",", "parent", "=", "None", ",", "parameters", "=", "{", "}", ",", "return_node", "=", "False", ")", ":", "node", "=", "Node", "(", "transform...
Adds a node to the current graph. Args: transformer (str, Transformer): The pliers Transformer to use at the to-be-added node. Either a case-insensitive string giving the name of a Transformer class, or an initialized Transformer instance. ...
[ "Adds", "a", "node", "to", "the", "current", "graph", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/graph.py#L154-L192
tyarkoni/pliers
pliers/graph.py
Graph.run
def run(self, stim, merge=True, **merge_kwargs): ''' Executes the graph by calling all Transformers in sequence. Args: stim (str, Stim, list): One or more valid inputs to any Transformer's 'transform' call. merge (bool): If True, all results are merged into a sin...
python
def run(self, stim, merge=True, **merge_kwargs): ''' Executes the graph by calling all Transformers in sequence. Args: stim (str, Stim, list): One or more valid inputs to any Transformer's 'transform' call. merge (bool): If True, all results are merged into a sin...
[ "def", "run", "(", "self", ",", "stim", ",", "merge", "=", "True", ",", "*", "*", "merge_kwargs", ")", ":", "results", "=", "list", "(", "chain", "(", "*", "[", "self", ".", "run_node", "(", "n", ",", "stim", ")", "for", "n", "in", "self", ".",...
Executes the graph by calling all Transformers in sequence. Args: stim (str, Stim, list): One or more valid inputs to any Transformer's 'transform' call. merge (bool): If True, all results are merged into a single pandas DataFrame before being returned. I...
[ "Executes", "the", "graph", "by", "calling", "all", "Transformers", "in", "sequence", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/graph.py#L194-L210
tyarkoni/pliers
pliers/graph.py
Graph.run_node
def run_node(self, node, stim): ''' Executes the Transformer at a specific node. Args: node (str, Node): If a string, the name of the Node in the current Graph. Otherwise the Node instance to execute. stim (str, stim, list): Any valid input to the Transformer sto...
python
def run_node(self, node, stim): ''' Executes the Transformer at a specific node. Args: node (str, Node): If a string, the name of the Node in the current Graph. Otherwise the Node instance to execute. stim (str, stim, list): Any valid input to the Transformer sto...
[ "def", "run_node", "(", "self", ",", "node", ",", "stim", ")", ":", "if", "isinstance", "(", "node", ",", "string_types", ")", ":", "node", "=", "self", ".", "nodes", "[", "node", "]", "result", "=", "node", ".", "transformer", ".", "transform", "(",...
Executes the Transformer at a specific node. Args: node (str, Node): If a string, the name of the Node in the current Graph. Otherwise the Node instance to execute. stim (str, stim, list): Any valid input to the Transformer stored at the target node.
[ "Executes", "the", "Transformer", "at", "a", "specific", "node", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/graph.py#L214-L235
tyarkoni/pliers
pliers/graph.py
Graph.draw
def draw(self, filename, color=True): ''' Render a plot of the graph via pygraphviz. Args: filename (str): Path to save the generated image to. color (bool): If True, will color graph nodes based on their type, otherwise will draw a black-and-white graph. ...
python
def draw(self, filename, color=True): ''' Render a plot of the graph via pygraphviz. Args: filename (str): Path to save the generated image to. color (bool): If True, will color graph nodes based on their type, otherwise will draw a black-and-white graph. ...
[ "def", "draw", "(", "self", ",", "filename", ",", "color", "=", "True", ")", ":", "verify_dependencies", "(", "[", "'pgv'", "]", ")", "if", "not", "hasattr", "(", "self", ",", "'_results'", ")", ":", "raise", "RuntimeError", "(", "\"Graph cannot be drawn b...
Render a plot of the graph via pygraphviz. Args: filename (str): Path to save the generated image to. color (bool): If True, will color graph nodes based on their type, otherwise will draw a black-and-white graph.
[ "Render", "a", "plot", "of", "the", "graph", "via", "pygraphviz", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/graph.py#L237-L298
tyarkoni/pliers
pliers/graph.py
Graph.to_json
def to_json(self): ''' Returns the JSON representation of this graph. ''' roots = [] for r in self.roots: roots.append(r.to_json()) return {'roots': roots}
python
def to_json(self): ''' Returns the JSON representation of this graph. ''' roots = [] for r in self.roots: roots.append(r.to_json()) return {'roots': roots}
[ "def", "to_json", "(", "self", ")", ":", "roots", "=", "[", "]", "for", "r", "in", "self", ".", "roots", ":", "roots", ".", "append", "(", "r", ".", "to_json", "(", ")", ")", "return", "{", "'roots'", ":", "roots", "}" ]
Returns the JSON representation of this graph.
[ "Returns", "the", "JSON", "representation", "of", "this", "graph", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/graph.py#L300-L305
tyarkoni/pliers
pliers/graph.py
Graph.save
def save(self, filename): ''' Writes the JSON representation of this graph to the provided filename, such that the graph can be easily reconstructed using Graph(spec=filename). Args: filename (str): Path at which to write out the json file. ''' with open(file...
python
def save(self, filename): ''' Writes the JSON representation of this graph to the provided filename, such that the graph can be easily reconstructed using Graph(spec=filename). Args: filename (str): Path at which to write out the json file. ''' with open(file...
[ "def", "save", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "outfile", ":", "json", ".", "dump", "(", "self", ".", "to_json", "(", ")", ",", "outfile", ")" ]
Writes the JSON representation of this graph to the provided filename, such that the graph can be easily reconstructed using Graph(spec=filename). Args: filename (str): Path at which to write out the json file.
[ "Writes", "the", "JSON", "representation", "of", "this", "graph", "to", "the", "provided", "filename", "such", "that", "the", "graph", "can", "be", "easily", "reconstructed", "using", "Graph", "(", "spec", "=", "filename", ")", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/graph.py#L307-L316
tyarkoni/pliers
pliers/utils/base.py
flatten
def flatten(l): ''' Flatten an iterable. ''' for el in l: if isinstance(el, collections.Iterable) and not isinstance(el, string_types): for sub in flatten(el): yield sub else: yield el
python
def flatten(l): ''' Flatten an iterable. ''' for el in l: if isinstance(el, collections.Iterable) and not isinstance(el, string_types): for sub in flatten(el): yield sub else: yield el
[ "def", "flatten", "(", "l", ")", ":", "for", "el", "in", "l", ":", "if", "isinstance", "(", "el", ",", "collections", ".", "Iterable", ")", "and", "not", "isinstance", "(", "el", ",", "string_types", ")", ":", "for", "sub", "in", "flatten", "(", "e...
Flatten an iterable.
[ "Flatten", "an", "iterable", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/utils/base.py#L20-L27
tyarkoni/pliers
pliers/utils/base.py
batch_iterable
def batch_iterable(l, n): ''' Chunks iterable into n sized batches Solution from: http://stackoverflow.com/questions/1915170/split-a-generator-iterable-every-n-items-in-python-splitevery''' i = iter(l) piece = list(islice(i, n)) while piece: yield piece piece = list(islice(i, n))
python
def batch_iterable(l, n): ''' Chunks iterable into n sized batches Solution from: http://stackoverflow.com/questions/1915170/split-a-generator-iterable-every-n-items-in-python-splitevery''' i = iter(l) piece = list(islice(i, n)) while piece: yield piece piece = list(islice(i, n))
[ "def", "batch_iterable", "(", "l", ",", "n", ")", ":", "i", "=", "iter", "(", "l", ")", "piece", "=", "list", "(", "islice", "(", "i", ",", "n", ")", ")", "while", "piece", ":", "yield", "piece", "piece", "=", "list", "(", "islice", "(", "i", ...
Chunks iterable into n sized batches Solution from: http://stackoverflow.com/questions/1915170/split-a-generator-iterable-every-n-items-in-python-splitevery
[ "Chunks", "iterable", "into", "n", "sized", "batches", "Solution", "from", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "1915170", "/", "split", "-", "a", "-", "generator", "-", "iterable", "-", "every", "-", "n", "-", "i...
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/utils/base.py#L45-L52
tyarkoni/pliers
pliers/utils/base.py
set_iterable_type
def set_iterable_type(obj): ''' Returns either a generator or a list depending on config-level settings. Should be used to wrap almost every internal iterable return. Also inspects elements recursively in the case of list returns, to ensure that there are no nested generators. ''' if not isiterable(...
python
def set_iterable_type(obj): ''' Returns either a generator or a list depending on config-level settings. Should be used to wrap almost every internal iterable return. Also inspects elements recursively in the case of list returns, to ensure that there are no nested generators. ''' if not isiterable(...
[ "def", "set_iterable_type", "(", "obj", ")", ":", "if", "not", "isiterable", "(", "obj", ")", ":", "return", "obj", "if", "config", ".", "get_option", "(", "'use_generators'", ")", ":", "return", "obj", "if", "isgenerator", "(", "obj", ")", "else", "(", ...
Returns either a generator or a list depending on config-level settings. Should be used to wrap almost every internal iterable return. Also inspects elements recursively in the case of list returns, to ensure that there are no nested generators.
[ "Returns", "either", "a", "generator", "or", "a", "list", "depending", "on", "config", "-", "level", "settings", ".", "Should", "be", "used", "to", "wrap", "almost", "every", "internal", "iterable", "return", ".", "Also", "inspects", "elements", "recursively",...
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/utils/base.py#L55-L66
tyarkoni/pliers
pliers/utils/base.py
isgenerator
def isgenerator(obj): ''' Returns True if object is a generator, or a generator wrapped by a tqdm object. ''' return isinstance(obj, GeneratorType) or (hasattr(obj, 'iterable') and isinstance(getattr(obj, 'iterable'), GeneratorType))
python
def isgenerator(obj): ''' Returns True if object is a generator, or a generator wrapped by a tqdm object. ''' return isinstance(obj, GeneratorType) or (hasattr(obj, 'iterable') and isinstance(getattr(obj, 'iterable'), GeneratorType))
[ "def", "isgenerator", "(", "obj", ")", ":", "return", "isinstance", "(", "obj", ",", "GeneratorType", ")", "or", "(", "hasattr", "(", "obj", ",", "'iterable'", ")", "and", "isinstance", "(", "getattr", "(", "obj", ",", "'iterable'", ")", ",", "GeneratorT...
Returns True if object is a generator, or a generator wrapped by a tqdm object.
[ "Returns", "True", "if", "object", "is", "a", "generator", "or", "a", "generator", "wrapped", "by", "a", "tqdm", "object", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/utils/base.py#L85-L89
tyarkoni/pliers
pliers/utils/base.py
progress_bar_wrapper
def progress_bar_wrapper(iterable, **kwargs): ''' Wrapper that applies tqdm progress bar conditional on config settings. ''' return tqdm(iterable, **kwargs) if (config.get_option('progress_bar') and not isinstance(iterable, tqdm)) else iterable
python
def progress_bar_wrapper(iterable, **kwargs): ''' Wrapper that applies tqdm progress bar conditional on config settings. ''' return tqdm(iterable, **kwargs) if (config.get_option('progress_bar') and not isinstance(iterable, tqdm)) else iterable
[ "def", "progress_bar_wrapper", "(", "iterable", ",", "*", "*", "kwargs", ")", ":", "return", "tqdm", "(", "iterable", ",", "*", "*", "kwargs", ")", "if", "(", "config", ".", "get_option", "(", "'progress_bar'", ")", "and", "not", "isinstance", "(", "iter...
Wrapper that applies tqdm progress bar conditional on config settings.
[ "Wrapper", "that", "applies", "tqdm", "progress", "bar", "conditional", "on", "config", "settings", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/utils/base.py#L92-L96
tyarkoni/pliers
pliers/stimuli/video.py
VideoFrameCollectionStim.get_frame
def get_frame(self, index): ''' Get video frame at the specified index. Args: index (int): Positional index of the desired frame. ''' frame_num = self.frame_index[index] onset = float(frame_num) / self.fps if index < self.n_frames - 1: next_fram...
python
def get_frame(self, index): ''' Get video frame at the specified index. Args: index (int): Positional index of the desired frame. ''' frame_num = self.frame_index[index] onset = float(frame_num) / self.fps if index < self.n_frames - 1: next_fram...
[ "def", "get_frame", "(", "self", ",", "index", ")", ":", "frame_num", "=", "self", ".", "frame_index", "[", "index", "]", "onset", "=", "float", "(", "frame_num", ")", "/", "self", ".", "fps", "if", "index", "<", "self", ".", "n_frames", "-", "1", ...
Get video frame at the specified index. Args: index (int): Positional index of the desired frame.
[ "Get", "video", "frame", "at", "the", "specified", "index", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/stimuli/video.py#L94-L114
tyarkoni/pliers
pliers/stimuli/video.py
VideoFrameCollectionStim.save
def save(self, path): ''' Save source video to file. Args: path (str): Filename to save to. Notes: Saves entire source video to file, not just currently selected frames. ''' # IMPORTANT WARNING: saves entire source video self.clip.write_videofile...
python
def save(self, path): ''' Save source video to file. Args: path (str): Filename to save to. Notes: Saves entire source video to file, not just currently selected frames. ''' # IMPORTANT WARNING: saves entire source video self.clip.write_videofile...
[ "def", "save", "(", "self", ",", "path", ")", ":", "# IMPORTANT WARNING: saves entire source video", "self", ".", "clip", ".", "write_videofile", "(", "path", ",", "audio_fps", "=", "self", ".", "clip", ".", "audio", ".", "fps", ")" ]
Save source video to file. Args: path (str): Filename to save to. Notes: Saves entire source video to file, not just currently selected frames.
[ "Save", "source", "video", "to", "file", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/stimuli/video.py#L125-L135
tyarkoni/pliers
pliers/stimuli/video.py
VideoStim.get_frame
def get_frame(self, index=None, onset=None): ''' Overrides the default behavior by giving access to the onset argument. Args: index (int): Positional index of the desired frame. onset (float): Onset (in seconds) of the desired frame. ''' if onset: ...
python
def get_frame(self, index=None, onset=None): ''' Overrides the default behavior by giving access to the onset argument. Args: index (int): Positional index of the desired frame. onset (float): Onset (in seconds) of the desired frame. ''' if onset: ...
[ "def", "get_frame", "(", "self", ",", "index", "=", "None", ",", "onset", "=", "None", ")", ":", "if", "onset", ":", "index", "=", "int", "(", "onset", "*", "self", ".", "fps", ")", "return", "super", "(", "VideoStim", ",", "self", ")", ".", "get...
Overrides the default behavior by giving access to the onset argument. Args: index (int): Positional index of the desired frame. onset (float): Onset (in seconds) of the desired frame.
[ "Overrides", "the", "default", "behavior", "by", "giving", "access", "to", "the", "onset", "argument", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/stimuli/video.py#L159-L170
tyarkoni/pliers
pliers/utils/updater.py
hash_data
def hash_data(data, blocksize=65536): """" Hashes list of data, strings or data """ data = pickle.dumps(data) hasher = hashlib.sha1() hasher.update(data) return hasher.hexdigest()
python
def hash_data(data, blocksize=65536): """" Hashes list of data, strings or data """ data = pickle.dumps(data) hasher = hashlib.sha1() hasher.update(data) return hasher.hexdigest()
[ "def", "hash_data", "(", "data", ",", "blocksize", "=", "65536", ")", ":", "data", "=", "pickle", ".", "dumps", "(", "data", ")", "hasher", "=", "hashlib", ".", "sha1", "(", ")", "hasher", ".", "update", "(", "data", ")", "return", "hasher", ".", "...
Hashes list of data, strings or data
[ "Hashes", "list", "of", "data", "strings", "or", "data" ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/utils/updater.py#L13-L20
tyarkoni/pliers
pliers/utils/updater.py
check_updates
def check_updates(transformers, datastore=None, stimuli=None): """ Run transformers through a battery of stimuli, and check if output has changed. Store results in csv file for comparison. Args: transformers (list): A list of tuples of transformer names and dictionary of parameters to i...
python
def check_updates(transformers, datastore=None, stimuli=None): """ Run transformers through a battery of stimuli, and check if output has changed. Store results in csv file for comparison. Args: transformers (list): A list of tuples of transformer names and dictionary of parameters to i...
[ "def", "check_updates", "(", "transformers", ",", "datastore", "=", "None", ",", "stimuli", "=", "None", ")", ":", "# Find datastore file", "datastore", "=", "datastore", "or", "expanduser", "(", "'~/.pliers_updates'", ")", "prior_data", "=", "pd", ".", "read_cs...
Run transformers through a battery of stimuli, and check if output has changed. Store results in csv file for comparison. Args: transformers (list): A list of tuples of transformer names and dictionary of parameters to instantiate with (or empty dict). datastore (str): Filepath of C...
[ "Run", "transformers", "through", "a", "battery", "of", "stimuli", "and", "check", "if", "output", "has", "changed", ".", "Store", "results", "in", "csv", "file", "for", "comparison", "." ]
train
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/utils/updater.py#L23-L95
open-homeautomation/miflora
demo.py
valid_miflora_mac
def valid_miflora_mac(mac, pat=re.compile(r"C4:7C:8D:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}")): """Check for valid mac adresses.""" if not pat.match(mac.upper()): raise argparse.ArgumentTypeError('The MAC address "{}" seems to be in the wrong format'.format(mac)) return mac
python
def valid_miflora_mac(mac, pat=re.compile(r"C4:7C:8D:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}")): """Check for valid mac adresses.""" if not pat.match(mac.upper()): raise argparse.ArgumentTypeError('The MAC address "{}" seems to be in the wrong format'.format(mac)) return mac
[ "def", "valid_miflora_mac", "(", "mac", ",", "pat", "=", "re", ".", "compile", "(", "r\"C4:7C:8D:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}\"", ")", ")", ":", "if", "not", "pat", ".", "match", "(", "mac", ".", "upper", "(", ")", ")", ":", "raise", "argparse", "."...
Check for valid mac adresses.
[ "Check", "for", "valid", "mac", "adresses", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/demo.py#L16-L20
open-homeautomation/miflora
demo.py
poll
def poll(args): """Poll data from the sensor.""" backend = _get_backend(args) poller = MiFloraPoller(args.mac, backend) print("Getting data from Mi Flora") print("FW: {}".format(poller.firmware_version())) print("Name: {}".format(poller.name())) print("Temperature: {}".format(poller.paramete...
python
def poll(args): """Poll data from the sensor.""" backend = _get_backend(args) poller = MiFloraPoller(args.mac, backend) print("Getting data from Mi Flora") print("FW: {}".format(poller.firmware_version())) print("Name: {}".format(poller.name())) print("Temperature: {}".format(poller.paramete...
[ "def", "poll", "(", "args", ")", ":", "backend", "=", "_get_backend", "(", "args", ")", "poller", "=", "MiFloraPoller", "(", "args", ".", "mac", ",", "backend", ")", "print", "(", "\"Getting data from Mi Flora\"", ")", "print", "(", "\"FW: {}\"", ".", "for...
Poll data from the sensor.
[ "Poll", "data", "from", "the", "sensor", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/demo.py#L23-L34
open-homeautomation/miflora
demo.py
scan
def scan(args): """Scan for sensors.""" backend = _get_backend(args) print('Scanning for 10 seconds...') devices = miflora_scanner.scan(backend, 10) print('Found {} devices:'.format(len(devices))) for device in devices: print(' {}'.format(device))
python
def scan(args): """Scan for sensors.""" backend = _get_backend(args) print('Scanning for 10 seconds...') devices = miflora_scanner.scan(backend, 10) print('Found {} devices:'.format(len(devices))) for device in devices: print(' {}'.format(device))
[ "def", "scan", "(", "args", ")", ":", "backend", "=", "_get_backend", "(", "args", ")", "print", "(", "'Scanning for 10 seconds...'", ")", "devices", "=", "miflora_scanner", ".", "scan", "(", "backend", ",", "10", ")", "print", "(", "'Found {} devices:'", "....
Scan for sensors.
[ "Scan", "for", "sensors", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/demo.py#L37-L44
open-homeautomation/miflora
demo.py
_get_backend
def _get_backend(args): """Extract the backend class from the command line arguments.""" if args.backend == 'gatttool': backend = GatttoolBackend elif args.backend == 'bluepy': backend = BluepyBackend elif args.backend == 'pygatt': backend = PygattBackend else: raise ...
python
def _get_backend(args): """Extract the backend class from the command line arguments.""" if args.backend == 'gatttool': backend = GatttoolBackend elif args.backend == 'bluepy': backend = BluepyBackend elif args.backend == 'pygatt': backend = PygattBackend else: raise ...
[ "def", "_get_backend", "(", "args", ")", ":", "if", "args", ".", "backend", "==", "'gatttool'", ":", "backend", "=", "GatttoolBackend", "elif", "args", ".", "backend", "==", "'bluepy'", ":", "backend", "=", "BluepyBackend", "elif", "args", ".", "backend", ...
Extract the backend class from the command line arguments.
[ "Extract", "the", "backend", "class", "from", "the", "command", "line", "arguments", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/demo.py#L47-L57
open-homeautomation/miflora
demo.py
list_backends
def list_backends(_): """List all available backends.""" backends = [b.__name__ for b in available_backends()] print('\n'.join(backends))
python
def list_backends(_): """List all available backends.""" backends = [b.__name__ for b in available_backends()] print('\n'.join(backends))
[ "def", "list_backends", "(", "_", ")", ":", "backends", "=", "[", "b", ".", "__name__", "for", "b", "in", "available_backends", "(", ")", "]", "print", "(", "'\\n'", ".", "join", "(", "backends", ")", ")" ]
List all available backends.
[ "List", "all", "available", "backends", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/demo.py#L60-L63
open-homeautomation/miflora
demo.py
main
def main(): """Main function. Mostly parsing the command line arguments. """ parser = argparse.ArgumentParser() parser.add_argument('--backend', choices=['gatttool', 'bluepy', 'pygatt'], default='gatttool') parser.add_argument('-v', '--verbose', action='store_const', const=True) subparsers ...
python
def main(): """Main function. Mostly parsing the command line arguments. """ parser = argparse.ArgumentParser() parser.add_argument('--backend', choices=['gatttool', 'bluepy', 'pygatt'], default='gatttool') parser.add_argument('-v', '--verbose', action='store_const', const=True) subparsers ...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'--backend'", ",", "choices", "=", "[", "'gatttool'", ",", "'bluepy'", ",", "'pygatt'", "]", ",", "default", "=", "'gatttool'", ...
Main function. Mostly parsing the command line arguments.
[ "Main", "function", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/demo.py#L66-L95
open-homeautomation/miflora
miflora/miflora_scanner.py
scan
def scan(backend, timeout=10): """Scan for miflora devices. Note: this must be run as root! """ result = [] for (mac, name) in backend.scan_for_devices(timeout): if (name is not None and name.lower() in VALID_DEVICE_NAMES) or \ mac is not None and mac.upper().startswith(DEVI...
python
def scan(backend, timeout=10): """Scan for miflora devices. Note: this must be run as root! """ result = [] for (mac, name) in backend.scan_for_devices(timeout): if (name is not None and name.lower() in VALID_DEVICE_NAMES) or \ mac is not None and mac.upper().startswith(DEVI...
[ "def", "scan", "(", "backend", ",", "timeout", "=", "10", ")", ":", "result", "=", "[", "]", "for", "(", "mac", ",", "name", ")", "in", "backend", ".", "scan_for_devices", "(", "timeout", ")", ":", "if", "(", "name", "is", "not", "None", "and", "...
Scan for miflora devices. Note: this must be run as root!
[ "Scan", "for", "miflora", "devices", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/miflora/miflora_scanner.py#L10-L20
open-homeautomation/miflora
miflora/miflora_poller.py
MiFloraPoller.fill_cache
def fill_cache(self): """Fill the cache with new data from the sensor.""" _LOGGER.debug('Filling cache with new sensor data.') try: firmware_version = self.firmware_version() except BluetoothBackendException: # If a sensor doesn't work, wait 5 minutes before retry...
python
def fill_cache(self): """Fill the cache with new data from the sensor.""" _LOGGER.debug('Filling cache with new sensor data.') try: firmware_version = self.firmware_version() except BluetoothBackendException: # If a sensor doesn't work, wait 5 minutes before retry...
[ "def", "fill_cache", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "'Filling cache with new sensor data.'", ")", "try", ":", "firmware_version", "=", "self", ".", "firmware_version", "(", ")", "except", "BluetoothBackendException", ":", "# If a sensor doesn't w...
Fill the cache with new data from the sensor.
[ "Fill", "the", "cache", "with", "new", "data", "from", "the", "sensor", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/miflora/miflora_poller.py#L57-L87
open-homeautomation/miflora
miflora/miflora_poller.py
MiFloraPoller.firmware_version
def firmware_version(self): """Return the firmware version.""" if (self._firmware_version is None) or \ (datetime.now() - timedelta(hours=24) > self._fw_last_read): self._fw_last_read = datetime.now() with self._bt_interface.connect(self._mac) as connection: ...
python
def firmware_version(self): """Return the firmware version.""" if (self._firmware_version is None) or \ (datetime.now() - timedelta(hours=24) > self._fw_last_read): self._fw_last_read = datetime.now() with self._bt_interface.connect(self._mac) as connection: ...
[ "def", "firmware_version", "(", "self", ")", ":", "if", "(", "self", ".", "_firmware_version", "is", "None", ")", "or", "(", "datetime", ".", "now", "(", ")", "-", "timedelta", "(", "hours", "=", "24", ")", ">", "self", ".", "_fw_last_read", ")", ":"...
Return the firmware version.
[ "Return", "the", "firmware", "version", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/miflora/miflora_poller.py#L98-L113
open-homeautomation/miflora
miflora/miflora_poller.py
MiFloraPoller.parameter_value
def parameter_value(self, parameter, read_cached=True): """Return a value of one of the monitored paramaters. This method will try to retrieve the data from cache and only request it by bluetooth if no cached value is stored or the cache is expired. This behaviour can be overwri...
python
def parameter_value(self, parameter, read_cached=True): """Return a value of one of the monitored paramaters. This method will try to retrieve the data from cache and only request it by bluetooth if no cached value is stored or the cache is expired. This behaviour can be overwri...
[ "def", "parameter_value", "(", "self", ",", "parameter", ",", "read_cached", "=", "True", ")", ":", "# Special handling for battery attribute", "if", "parameter", "==", "MI_BATTERY", ":", "return", "self", ".", "battery_level", "(", ")", "# Use the lock to make sure t...
Return a value of one of the monitored paramaters. This method will try to retrieve the data from cache and only request it by bluetooth if no cached value is stored or the cache is expired. This behaviour can be overwritten by the "read_cached" parameter.
[ "Return", "a", "value", "of", "one", "of", "the", "monitored", "paramaters", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/miflora/miflora_poller.py#L115-L141
open-homeautomation/miflora
miflora/miflora_poller.py
MiFloraPoller._check_data
def _check_data(self): """Ensure that the data in the cache is valid. If it's invalid, the cache is wiped. """ if not self.cache_available(): return if self._cache[7] > 100: # moisture over 100 procent self.clear_cache() return if sel...
python
def _check_data(self): """Ensure that the data in the cache is valid. If it's invalid, the cache is wiped. """ if not self.cache_available(): return if self._cache[7] > 100: # moisture over 100 procent self.clear_cache() return if sel...
[ "def", "_check_data", "(", "self", ")", ":", "if", "not", "self", ".", "cache_available", "(", ")", ":", "return", "if", "self", ".", "_cache", "[", "7", "]", ">", "100", ":", "# moisture over 100 procent", "self", ".", "clear_cache", "(", ")", "return",...
Ensure that the data in the cache is valid. If it's invalid, the cache is wiped.
[ "Ensure", "that", "the", "data", "in", "the", "cache", "is", "valid", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/miflora/miflora_poller.py#L143-L159
open-homeautomation/miflora
miflora/miflora_poller.py
MiFloraPoller._parse_data
def _parse_data(self): """Parses the byte array returned by the sensor. The sensor returns 16 bytes in total. It's unclear what the meaning of these bytes is beyond what is decoded in this method. semantics of the data (in little endian encoding): bytes 0-1: temperature in 0....
python
def _parse_data(self): """Parses the byte array returned by the sensor. The sensor returns 16 bytes in total. It's unclear what the meaning of these bytes is beyond what is decoded in this method. semantics of the data (in little endian encoding): bytes 0-1: temperature in 0....
[ "def", "_parse_data", "(", "self", ")", ":", "data", "=", "self", ".", "_cache", "res", "=", "dict", "(", ")", "temp", ",", "res", "[", "MI_LIGHT", "]", ",", "res", "[", "MI_MOISTURE", "]", ",", "res", "[", "MI_CONDUCTIVITY", "]", "=", "unpack", "(...
Parses the byte array returned by the sensor. The sensor returns 16 bytes in total. It's unclear what the meaning of these bytes is beyond what is decoded in this method. semantics of the data (in little endian encoding): bytes 0-1: temperature in 0.1 °C byte 2: unknown ...
[ "Parses", "the", "byte", "array", "returned", "by", "the", "sensor", "." ]
train
https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/miflora/miflora_poller.py#L170-L189
halcy/Mastodon.py
mastodon/Mastodon.py
parse_version_string
def parse_version_string(version_string): """Parses a semver version string, stripping off "rc" stuff if present.""" string_parts = version_string.split(".") version_parts = [ int(re.match("([0-9]*)", string_parts[0]).group(0)), int(re.match("([0-9]*)", string_parts[1]).group(0)), i...
python
def parse_version_string(version_string): """Parses a semver version string, stripping off "rc" stuff if present.""" string_parts = version_string.split(".") version_parts = [ int(re.match("([0-9]*)", string_parts[0]).group(0)), int(re.match("([0-9]*)", string_parts[1]).group(0)), i...
[ "def", "parse_version_string", "(", "version_string", ")", ":", "string_parts", "=", "version_string", ".", "split", "(", "\".\"", ")", "version_parts", "=", "[", "int", "(", "re", ".", "match", "(", "\"([0-9]*)\"", ",", "string_parts", "[", "0", "]", ")", ...
Parses a semver version string, stripping off "rc" stuff if present.
[ "Parses", "a", "semver", "version", "string", "stripping", "off", "rc", "stuff", "if", "present", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L42-L50
halcy/Mastodon.py
mastodon/Mastodon.py
bigger_version
def bigger_version(version_string_a, version_string_b): """Returns the bigger version of two version strings.""" major_a, minor_a, patch_a = parse_version_string(version_string_a) major_b, minor_b, patch_b = parse_version_string(version_string_b) if major_a > major_b: return version_string_a ...
python
def bigger_version(version_string_a, version_string_b): """Returns the bigger version of two version strings.""" major_a, minor_a, patch_a = parse_version_string(version_string_a) major_b, minor_b, patch_b = parse_version_string(version_string_b) if major_a > major_b: return version_string_a ...
[ "def", "bigger_version", "(", "version_string_a", ",", "version_string_b", ")", ":", "major_a", ",", "minor_a", ",", "patch_a", "=", "parse_version_string", "(", "version_string_a", ")", "major_b", ",", "minor_b", ",", "patch_b", "=", "parse_version_string", "(", ...
Returns the bigger version of two version strings.
[ "Returns", "the", "bigger", "version", "of", "two", "version", "strings", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L52-L63
halcy/Mastodon.py
mastodon/Mastodon.py
api_version
def api_version(created_ver, last_changed_ver, return_value_ver): """Version check decorator. Currently only checks Bigger Than.""" def api_min_version_decorator(function): def wrapper(function, self, *args, **kwargs): if not self.version_check_mode == "none": if self.v...
python
def api_version(created_ver, last_changed_ver, return_value_ver): """Version check decorator. Currently only checks Bigger Than.""" def api_min_version_decorator(function): def wrapper(function, self, *args, **kwargs): if not self.version_check_mode == "none": if self.v...
[ "def", "api_version", "(", "created_ver", ",", "last_changed_ver", ",", "return_value_ver", ")", ":", "def", "api_min_version_decorator", "(", "function", ")", ":", "def", "wrapper", "(", "function", ",", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")...
Version check decorator. Currently only checks Bigger Than.
[ "Version", "check", "decorator", ".", "Currently", "only", "checks", "Bigger", "Than", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L65-L85
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.create_app
def create_app(client_name, scopes=__DEFAULT_SCOPES, redirect_uris=None, website=None, to_file=None, api_base_url=__DEFAULT_BASE_URL, request_timeout=__DEFAULT_TIMEOUT, session=None): """ Create a new app with given `client_name` and `scopes` (The basic scropse are "read", "write", "f...
python
def create_app(client_name, scopes=__DEFAULT_SCOPES, redirect_uris=None, website=None, to_file=None, api_base_url=__DEFAULT_BASE_URL, request_timeout=__DEFAULT_TIMEOUT, session=None): """ Create a new app with given `client_name` and `scopes` (The basic scropse are "read", "write", "f...
[ "def", "create_app", "(", "client_name", ",", "scopes", "=", "__DEFAULT_SCOPES", ",", "redirect_uris", "=", "None", ",", "website", "=", "None", ",", "to_file", "=", "None", ",", "api_base_url", "=", "__DEFAULT_BASE_URL", ",", "request_timeout", "=", "__DEFAULT_...
Create a new app with given `client_name` and `scopes` (The basic scropse are "read", "write", "follow" and "push" - more granular scopes are available, please refere to Mastodon documentation for which). Specify `redirect_uris` if you want users to be redirected to a certain page after authenticating...
[ "Create", "a", "new", "app", "with", "given", "client_name", "and", "scopes", "(", "The", "basic", "scropse", "are", "read", "write", "follow", "and", "push", "-", "more", "granular", "scopes", "are", "available", "please", "refere", "to", "Mastodon", "docum...
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L190-L242
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.retrieve_mastodon_version
def retrieve_mastodon_version(self): """ Determine installed mastodon version and set major, minor and patch (not including RC info) accordingly. Returns the version string, possibly including rc info. """ try: version_str = self.__instance()["version"] ...
python
def retrieve_mastodon_version(self): """ Determine installed mastodon version and set major, minor and patch (not including RC info) accordingly. Returns the version string, possibly including rc info. """ try: version_str = self.__instance()["version"] ...
[ "def", "retrieve_mastodon_version", "(", "self", ")", ":", "try", ":", "version_str", "=", "self", ".", "__instance", "(", ")", "[", "\"version\"", "]", "except", ":", "# instance() was added in 1.1.0, so our best guess is 1.0.0.", "version_str", "=", "\"1.0.0\"", "se...
Determine installed mastodon version and set major, minor and patch (not including RC info) accordingly. Returns the version string, possibly including rc info.
[ "Determine", "installed", "mastodon", "version", "and", "set", "major", "minor", "and", "patch", "(", "not", "including", "RC", "info", ")", "accordingly", ".", "Returns", "the", "version", "string", "possibly", "including", "rc", "info", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L344-L357
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.verify_minimum_version
def verify_minimum_version(self, version_str): """ Update version info from server and verify that at least the specified version is present. Returns True if version requirement is satisfied, False if not. """ self.retrieve_mastodon_version() major, minor, patch ...
python
def verify_minimum_version(self, version_str): """ Update version info from server and verify that at least the specified version is present. Returns True if version requirement is satisfied, False if not. """ self.retrieve_mastodon_version() major, minor, patch ...
[ "def", "verify_minimum_version", "(", "self", ",", "version_str", ")", ":", "self", ".", "retrieve_mastodon_version", "(", ")", "major", ",", "minor", ",", "patch", "=", "parse_version_string", "(", "version_str", ")", "if", "major", ">", "self", ".", "mastodo...
Update version info from server and verify that at least the specified version is present. Returns True if version requirement is satisfied, False if not.
[ "Update", "version", "info", "from", "server", "and", "verify", "that", "at", "least", "the", "specified", "version", "is", "present", ".", "Returns", "True", "if", "version", "requirement", "is", "satisfied", "False", "if", "not", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L359-L373
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.auth_request_url
def auth_request_url(self, client_id=None, redirect_uris="urn:ietf:wg:oauth:2.0:oob", scopes=__DEFAULT_SCOPES, force_login=False): """ Returns the url that a client needs to request an oauth grant from the server. To log in with oauth, send your user to this URL...
python
def auth_request_url(self, client_id=None, redirect_uris="urn:ietf:wg:oauth:2.0:oob", scopes=__DEFAULT_SCOPES, force_login=False): """ Returns the url that a client needs to request an oauth grant from the server. To log in with oauth, send your user to this URL...
[ "def", "auth_request_url", "(", "self", ",", "client_id", "=", "None", ",", "redirect_uris", "=", "\"urn:ietf:wg:oauth:2.0:oob\"", ",", "scopes", "=", "__DEFAULT_SCOPES", ",", "force_login", "=", "False", ")", ":", "if", "client_id", "is", "None", ":", "client_i...
Returns the url that a client needs to request an oauth grant from the server. To log in with oauth, send your user to this URL. The user will then log in and get a code which you can pass to log_in. scopes are as in `log_in()`_, redirect_uris is where the user should be redire...
[ "Returns", "the", "url", "that", "a", "client", "needs", "to", "request", "an", "oauth", "grant", "from", "the", "server", ".", "To", "log", "in", "with", "oauth", "send", "your", "user", "to", "this", "URL", ".", "The", "user", "will", "then", "log", ...
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L382-L412
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.log_in
def log_in(self, username=None, password=None, code=None, redirect_uri="urn:ietf:wg:oauth:2.0:oob", refresh_token=None, scopes=__DEFAULT_SCOPES, to_file=None): """ Get the access token for a user. The username is the e-mail used to log in into mastodon. ...
python
def log_in(self, username=None, password=None, code=None, redirect_uri="urn:ietf:wg:oauth:2.0:oob", refresh_token=None, scopes=__DEFAULT_SCOPES, to_file=None): """ Get the access token for a user. The username is the e-mail used to log in into mastodon. ...
[ "def", "log_in", "(", "self", ",", "username", "=", "None", ",", "password", "=", "None", ",", "code", "=", "None", ",", "redirect_uri", "=", "\"urn:ietf:wg:oauth:2.0:oob\"", ",", "refresh_token", "=", "None", ",", "scopes", "=", "__DEFAULT_SCOPES", ",", "to...
Get the access token for a user. The username is the e-mail used to log in into mastodon. Can persist access token to file `to_file`, to be used in the constructor. Handles password and OAuth-based authorization. Will throw a `MastodonIllegalArgumentError` if the OAut...
[ "Get", "the", "access", "token", "for", "a", "user", ".", "The", "username", "is", "the", "e", "-", "mail", "used", "to", "log", "in", "into", "mastodon", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L414-L481
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.create_account
def create_account(self, username, password, email, agreement=False, locale="en", scopes=__DEFAULT_SCOPES, to_file=None): """ Creates a new user account with the given username, password and email. "agreement" must be set to true (after showing the user the instances user agreement and having ...
python
def create_account(self, username, password, email, agreement=False, locale="en", scopes=__DEFAULT_SCOPES, to_file=None): """ Creates a new user account with the given username, password and email. "agreement" must be set to true (after showing the user the instances user agreement and having ...
[ "def", "create_account", "(", "self", ",", "username", ",", "password", ",", "email", ",", "agreement", "=", "False", ",", "locale", "=", "\"en\"", ",", "scopes", "=", "__DEFAULT_SCOPES", ",", "to_file", "=", "None", ")", ":", "params", "=", "self", ".",...
Creates a new user account with the given username, password and email. "agreement" must be set to true (after showing the user the instances user agreement and having them agree to it), "locale" specifies the language for the confirmation e-mail as an ISO 639-1 (two-letter) language code. ...
[ "Creates", "a", "new", "user", "account", "with", "the", "given", "username", "password", "and", "email", ".", "agreement", "must", "be", "set", "to", "true", "(", "after", "showing", "the", "user", "the", "instances", "user", "agreement", "and", "having", ...
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L484-L545
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.timeline
def timeline(self, timeline="home", max_id=None, min_id=None, since_id=None, limit=None): """ Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public', 'tag/hashtag' or 'list/id'. See the following functions documentation for what those do. Local hashtag timeli...
python
def timeline(self, timeline="home", max_id=None, min_id=None, since_id=None, limit=None): """ Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public', 'tag/hashtag' or 'list/id'. See the following functions documentation for what those do. Local hashtag timeli...
[ "def", "timeline", "(", "self", ",", "timeline", "=", "\"home\"", ",", "max_id", "=", "None", ",", "min_id", "=", "None", ",", "since_id", "=", "None", ",", "limit", "=", "None", ")", ":", "if", "max_id", "!=", "None", ":", "max_id", "=", "self", "...
Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public', 'tag/hashtag' or 'list/id'. See the following functions documentation for what those do. Local hashtag timelines are supported via the `timeline_hashtag()`_ function. The default timeline is the "home" ...
[ "Fetch", "statuses", "most", "recent", "ones", "first", ".", "timeline", "can", "be", "home", "local", "public", "tag", "/", "hashtag", "or", "list", "/", "id", ".", "See", "the", "following", "functions", "documentation", "for", "what", "those", "do", "."...
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L593-L622
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.timeline_home
def timeline_home(self, max_id=None, min_id=None, since_id=None, limit=None): """ Fetch the logged-in users home timeline (i.e. followed users and self). Returns a list of `toot dicts`_. """ return self.timeline('home', max_id=max_id, min_id=min_id, ...
python
def timeline_home(self, max_id=None, min_id=None, since_id=None, limit=None): """ Fetch the logged-in users home timeline (i.e. followed users and self). Returns a list of `toot dicts`_. """ return self.timeline('home', max_id=max_id, min_id=min_id, ...
[ "def", "timeline_home", "(", "self", ",", "max_id", "=", "None", ",", "min_id", "=", "None", ",", "since_id", "=", "None", ",", "limit", "=", "None", ")", ":", "return", "self", ".", "timeline", "(", "'home'", ",", "max_id", "=", "max_id", ",", "min_...
Fetch the logged-in users home timeline (i.e. followed users and self). Returns a list of `toot dicts`_.
[ "Fetch", "the", "logged", "-", "in", "users", "home", "timeline", "(", "i", ".", "e", ".", "followed", "users", "and", "self", ")", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L625-L632
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.timeline_local
def timeline_local(self, max_id=None, min_id=None, since_id=None, limit=None): """ Fetches the local / instance-wide timeline, not including replies. Returns a list of `toot dicts`_. """ return self.timeline('local', max_id=max_id, min_id=min_id, sin...
python
def timeline_local(self, max_id=None, min_id=None, since_id=None, limit=None): """ Fetches the local / instance-wide timeline, not including replies. Returns a list of `toot dicts`_. """ return self.timeline('local', max_id=max_id, min_id=min_id, sin...
[ "def", "timeline_local", "(", "self", ",", "max_id", "=", "None", ",", "min_id", "=", "None", ",", "since_id", "=", "None", ",", "limit", "=", "None", ")", ":", "return", "self", ".", "timeline", "(", "'local'", ",", "max_id", "=", "max_id", ",", "mi...
Fetches the local / instance-wide timeline, not including replies. Returns a list of `toot dicts`_.
[ "Fetches", "the", "local", "/", "instance", "-", "wide", "timeline", "not", "including", "replies", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L635-L642
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.timeline_public
def timeline_public(self, max_id=None, min_id=None, since_id=None, limit=None, only_media=False): """ Fetches the public / visible-network timeline, not including replies. Set `only_media` to True to retrieve only statuses with media attachments. Returns a list of `toot dicts`_. ...
python
def timeline_public(self, max_id=None, min_id=None, since_id=None, limit=None, only_media=False): """ Fetches the public / visible-network timeline, not including replies. Set `only_media` to True to retrieve only statuses with media attachments. Returns a list of `toot dicts`_. ...
[ "def", "timeline_public", "(", "self", ",", "max_id", "=", "None", ",", "min_id", "=", "None", ",", "since_id", "=", "None", ",", "limit", "=", "None", ",", "only_media", "=", "False", ")", ":", "if", "max_id", "!=", "None", ":", "max_id", "=", "self...
Fetches the public / visible-network timeline, not including replies. Set `only_media` to True to retrieve only statuses with media attachments. Returns a list of `toot dicts`_.
[ "Fetches", "the", "public", "/", "visible", "-", "network", "timeline", "not", "including", "replies", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L645-L670
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.timeline_hashtag
def timeline_hashtag(self, hashtag, local=False, max_id=None, min_id=None, since_id=None, limit=None, only_media=False): """ Fetch a timeline of toots with a given hashtag. The hashtag parameter should not contain the leading #. Set `local` to True to retrieve only instance-local tagged...
python
def timeline_hashtag(self, hashtag, local=False, max_id=None, min_id=None, since_id=None, limit=None, only_media=False): """ Fetch a timeline of toots with a given hashtag. The hashtag parameter should not contain the leading #. Set `local` to True to retrieve only instance-local tagged...
[ "def", "timeline_hashtag", "(", "self", ",", "hashtag", ",", "local", "=", "False", ",", "max_id", "=", "None", ",", "min_id", "=", "None", ",", "since_id", "=", "None", ",", "limit", "=", "None", ",", "only_media", "=", "False", ")", ":", "if", "has...
Fetch a timeline of toots with a given hashtag. The hashtag parameter should not contain the leading #. Set `local` to True to retrieve only instance-local tagged posts. Set `only_media` to True to retrieve only statuses with media attachments. Returns a list of `toot dicts`_.
[ "Fetch", "a", "timeline", "of", "toots", "with", "a", "given", "hashtag", ".", "The", "hashtag", "parameter", "should", "not", "contain", "the", "leading", "#", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L673-L706
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.timeline_list
def timeline_list(self, id, max_id=None, min_id=None, since_id=None, limit=None): """ Fetches a timeline containing all the toots by users in a given list. Returns a list of `toot dicts`_. """ id = self.__unpack_id(id) return self.timeline('list/{0}'.format(id), max_id=m...
python
def timeline_list(self, id, max_id=None, min_id=None, since_id=None, limit=None): """ Fetches a timeline containing all the toots by users in a given list. Returns a list of `toot dicts`_. """ id = self.__unpack_id(id) return self.timeline('list/{0}'.format(id), max_id=m...
[ "def", "timeline_list", "(", "self", ",", "id", ",", "max_id", "=", "None", ",", "min_id", "=", "None", ",", "since_id", "=", "None", ",", "limit", "=", "None", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "return", "self", ".",...
Fetches a timeline containing all the toots by users in a given list. Returns a list of `toot dicts`_.
[ "Fetches", "a", "timeline", "containing", "all", "the", "toots", "by", "users", "in", "a", "given", "list", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L709-L717
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.conversations
def conversations(self, max_id=None, min_id=None, since_id=None, limit=None): """ Fetches a users conversations. Returns a list of `conversation dicts`_. """ if max_id != None: max_id = self.__unpack_id(max_id) if min_id != None: ...
python
def conversations(self, max_id=None, min_id=None, since_id=None, limit=None): """ Fetches a users conversations. Returns a list of `conversation dicts`_. """ if max_id != None: max_id = self.__unpack_id(max_id) if min_id != None: ...
[ "def", "conversations", "(", "self", ",", "max_id", "=", "None", ",", "min_id", "=", "None", ",", "since_id", "=", "None", ",", "limit", "=", "None", ")", ":", "if", "max_id", "!=", "None", ":", "max_id", "=", "self", ".", "__unpack_id", "(", "max_id...
Fetches a users conversations. Returns a list of `conversation dicts`_.
[ "Fetches", "a", "users", "conversations", ".", "Returns", "a", "list", "of", "conversation", "dicts", "_", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L720-L736
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.status
def status(self, id): """ Fetch information about a single toot. Does not require authentication for publicly visible statuses. Returns a `toot dict`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}'.format(str(id)) return self.__api_request('...
python
def status(self, id): """ Fetch information about a single toot. Does not require authentication for publicly visible statuses. Returns a `toot dict`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}'.format(str(id)) return self.__api_request('...
[ "def", "status", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "url", "=", "'/api/v1/statuses/{0}'", ".", "format", "(", "str", "(", "id", ")", ")", "return", "self", ".", "__api_request", "(", "'GET'", ",",...
Fetch information about a single toot. Does not require authentication for publicly visible statuses. Returns a `toot dict`_.
[ "Fetch", "information", "about", "a", "single", "toot", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L742-L752
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.status_card
def status_card(self, id): """ Fetch a card associated with a status. A card describes an object (such as an external video or link) embedded into a status. Does not require authentication for publicly visible statuses. Returns a `card dict`_. """ id = self.__un...
python
def status_card(self, id): """ Fetch a card associated with a status. A card describes an object (such as an external video or link) embedded into a status. Does not require authentication for publicly visible statuses. Returns a `card dict`_. """ id = self.__un...
[ "def", "status_card", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "url", "=", "'/api/v1/statuses/{0}/card'", ".", "format", "(", "str", "(", "id", ")", ")", "return", "self", ".", "__api_request", "(", "'GET...
Fetch a card associated with a status. A card describes an object (such as an external video or link) embedded into a status. Does not require authentication for publicly visible statuses. Returns a `card dict`_.
[ "Fetch", "a", "card", "associated", "with", "a", "status", ".", "A", "card", "describes", "an", "object", "(", "such", "as", "an", "external", "video", "or", "link", ")", "embedded", "into", "a", "status", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L755-L766
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.status_context
def status_context(self, id): """ Fetch information about ancestors and descendants of a toot. Does not require authentication for publicly visible statuses. Returns a `context dict`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/context'.format(str...
python
def status_context(self, id): """ Fetch information about ancestors and descendants of a toot. Does not require authentication for publicly visible statuses. Returns a `context dict`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/context'.format(str...
[ "def", "status_context", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "url", "=", "'/api/v1/statuses/{0}/context'", ".", "format", "(", "str", "(", "id", ")", ")", "return", "self", ".", "__api_request", "(", ...
Fetch information about ancestors and descendants of a toot. Does not require authentication for publicly visible statuses. Returns a `context dict`_.
[ "Fetch", "information", "about", "ancestors", "and", "descendants", "of", "a", "toot", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L769-L779
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.status_reblogged_by
def status_reblogged_by(self, id): """ Fetch a list of users that have reblogged a status. Does not require authentication for publicly visible statuses. Returns a list of `user dicts`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/reblogged_by'.for...
python
def status_reblogged_by(self, id): """ Fetch a list of users that have reblogged a status. Does not require authentication for publicly visible statuses. Returns a list of `user dicts`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/reblogged_by'.for...
[ "def", "status_reblogged_by", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "url", "=", "'/api/v1/statuses/{0}/reblogged_by'", ".", "format", "(", "str", "(", "id", ")", ")", "return", "self", ".", "__api_request"...
Fetch a list of users that have reblogged a status. Does not require authentication for publicly visible statuses. Returns a list of `user dicts`_.
[ "Fetch", "a", "list", "of", "users", "that", "have", "reblogged", "a", "status", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L782-L792
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.status_favourited_by
def status_favourited_by(self, id): """ Fetch a list of users that have favourited a status. Does not require authentication for publicly visible statuses. Returns a list of `user dicts`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/favourited_by'....
python
def status_favourited_by(self, id): """ Fetch a list of users that have favourited a status. Does not require authentication for publicly visible statuses. Returns a list of `user dicts`_. """ id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/favourited_by'....
[ "def", "status_favourited_by", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "url", "=", "'/api/v1/statuses/{0}/favourited_by'", ".", "format", "(", "str", "(", "id", ")", ")", "return", "self", ".", "__api_reques...
Fetch a list of users that have favourited a status. Does not require authentication for publicly visible statuses. Returns a list of `user dicts`_.
[ "Fetch", "a", "list", "of", "users", "that", "have", "favourited", "a", "status", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L795-L805
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.scheduled_status
def scheduled_status(self, id): """ Fetch information about the scheduled status with the given id. Returns a `scheduled toot dict`_. """ id = self.__unpack_id(id) url = '/api/v1/scheduled_statuses/{0}'.format(str(id)) return self.__api_request('GET', url)
python
def scheduled_status(self, id): """ Fetch information about the scheduled status with the given id. Returns a `scheduled toot dict`_. """ id = self.__unpack_id(id) url = '/api/v1/scheduled_statuses/{0}'.format(str(id)) return self.__api_request('GET', url)
[ "def", "scheduled_status", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "url", "=", "'/api/v1/scheduled_statuses/{0}'", ".", "format", "(", "str", "(", "id", ")", ")", "return", "self", ".", "__api_request", "(...
Fetch information about the scheduled status with the given id. Returns a `scheduled toot dict`_.
[ "Fetch", "information", "about", "the", "scheduled", "status", "with", "the", "given", "id", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L820-L828
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.poll
def poll(self, id): """ Fetch information about the poll with the given id Returns a `poll dict`_. """ id = self.__unpack_id(id) url = '/api/v1/polls/{0}'.format(str(id)) return self.__api_request('GET', url)
python
def poll(self, id): """ Fetch information about the poll with the given id Returns a `poll dict`_. """ id = self.__unpack_id(id) url = '/api/v1/polls/{0}'.format(str(id)) return self.__api_request('GET', url)
[ "def", "poll", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "url", "=", "'/api/v1/polls/{0}'", ".", "format", "(", "str", "(", "id", ")", ")", "return", "self", ".", "__api_request", "(", "'GET'", ",", "u...
Fetch information about the poll with the given id Returns a `poll dict`_.
[ "Fetch", "information", "about", "the", "poll", "with", "the", "given", "id" ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L834-L842
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.account
def account(self, id): """ Fetch account information by user `id`. Does not require authentication. Returns a `user dict`_. """ id = self.__unpack_id(id) url = '/api/v1/accounts/{0}'.format(str(id)) return self.__api_request('GET', url)
python
def account(self, id): """ Fetch account information by user `id`. Does not require authentication. Returns a `user dict`_. """ id = self.__unpack_id(id) url = '/api/v1/accounts/{0}'.format(str(id)) return self.__api_request('GET', url)
[ "def", "account", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "url", "=", "'/api/v1/accounts/{0}'", ".", "format", "(", "str", "(", "id", ")", ")", "return", "self", ".", "__api_request", "(", "'GET'", ","...
Fetch account information by user `id`. Does not require authentication. Returns a `user dict`_.
[ "Fetch", "account", "information", "by", "user", "id", ".", "Does", "not", "require", "authentication", ".", "Returns", "a", "user", "dict", "_", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L878-L888
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.account_statuses
def account_statuses(self, id, only_media=False, pinned=False, exclude_replies=False, max_id=None, min_id=None, since_id=None, limit=None): """ Fetch statuses by user `id`. Same options as `timeline()`_ are permitted. Returned toots are from the perspective of the logged-in user, i.e. al...
python
def account_statuses(self, id, only_media=False, pinned=False, exclude_replies=False, max_id=None, min_id=None, since_id=None, limit=None): """ Fetch statuses by user `id`. Same options as `timeline()`_ are permitted. Returned toots are from the perspective of the logged-in user, i.e. al...
[ "def", "account_statuses", "(", "self", ",", "id", ",", "only_media", "=", "False", ",", "pinned", "=", "False", ",", "exclude_replies", "=", "False", ",", "max_id", "=", "None", ",", "min_id", "=", "None", ",", "since_id", "=", "None", ",", "limit", "...
Fetch statuses by user `id`. Same options as `timeline()`_ are permitted. Returned toots are from the perspective of the logged-in user, i.e. all statuses visible to the logged-in user (including DMs) are included. If `only_media` is set, return only statuses with media attachments. ...
[ "Fetch", "statuses", "by", "user", "id", ".", "Same", "options", "as", "timeline", "()", "_", "are", "permitted", ".", "Returned", "toots", "are", "from", "the", "perspective", "of", "the", "logged", "-", "in", "user", "i", ".", "e", ".", "all", "statu...
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L900-L935
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.account_following
def account_following(self, id, max_id=None, min_id=None, since_id=None, limit=None): """ Fetch users the given user is following. Returns a list of `user dicts`_. """ id = self.__unpack_id(id) if max_id != None: max_id = self.__unpack_id(max_id) ...
python
def account_following(self, id, max_id=None, min_id=None, since_id=None, limit=None): """ Fetch users the given user is following. Returns a list of `user dicts`_. """ id = self.__unpack_id(id) if max_id != None: max_id = self.__unpack_id(max_id) ...
[ "def", "account_following", "(", "self", ",", "id", ",", "max_id", "=", "None", ",", "min_id", "=", "None", ",", "since_id", "=", "None", ",", "limit", "=", "None", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "if", "max_id", "!...
Fetch users the given user is following. Returns a list of `user dicts`_.
[ "Fetch", "users", "the", "given", "user", "is", "following", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L938-L956
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.account_relationships
def account_relationships(self, id): """ Fetch relationship (following, followed_by, blocking, follow requested) of the logged in user to a given account. `id` can be a list. Returns a list of `relationship dicts`_. """ id = self.__unpack_id(id) params = self.__...
python
def account_relationships(self, id): """ Fetch relationship (following, followed_by, blocking, follow requested) of the logged in user to a given account. `id` can be a list. Returns a list of `relationship dicts`_. """ id = self.__unpack_id(id) params = self.__...
[ "def", "account_relationships", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "params", "=", "self", ".", "__generate_params", "(", "locals", "(", ")", ")", "return", "self", ".", "__api_request", "(", "'GET'", ...
Fetch relationship (following, followed_by, blocking, follow requested) of the logged in user to a given account. `id` can be a list. Returns a list of `relationship dicts`_.
[ "Fetch", "relationship", "(", "following", "followed_by", "blocking", "follow", "requested", ")", "of", "the", "logged", "in", "user", "to", "a", "given", "account", ".", "id", "can", "be", "a", "list", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L980-L990
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.account_search
def account_search(self, q, limit=None, following=False): """ Fetch matching accounts. Will lookup an account remotely if the search term is in the username@domain format and not yet in the database. Set `following` to True to limit the search to users the logged-in user follows. ...
python
def account_search(self, q, limit=None, following=False): """ Fetch matching accounts. Will lookup an account remotely if the search term is in the username@domain format and not yet in the database. Set `following` to True to limit the search to users the logged-in user follows. ...
[ "def", "account_search", "(", "self", ",", "q", ",", "limit", "=", "None", ",", "following", "=", "False", ")", ":", "params", "=", "self", ".", "__generate_params", "(", "locals", "(", ")", ")", "if", "params", "[", "\"following\"", "]", "==", "False"...
Fetch matching accounts. Will lookup an account remotely if the search term is in the username@domain format and not yet in the database. Set `following` to True to limit the search to users the logged-in user follows. Returns a list of `user dicts`_.
[ "Fetch", "matching", "accounts", ".", "Will", "lookup", "an", "account", "remotely", "if", "the", "search", "term", "is", "in", "the", "username@domain", "format", "and", "not", "yet", "in", "the", "database", ".", "Set", "following", "to", "True", "to", "...
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L993-L1006
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.account_lists
def account_lists(self, id): """ Get all of the logged-in users lists which the specified user is a member of. Returns a list of `list dicts`_. """ id = self.__unpack_id(id) params = self.__generate_params(locals(), ['id']) url = '/api/v1/accounts...
python
def account_lists(self, id): """ Get all of the logged-in users lists which the specified user is a member of. Returns a list of `list dicts`_. """ id = self.__unpack_id(id) params = self.__generate_params(locals(), ['id']) url = '/api/v1/accounts...
[ "def", "account_lists", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "params", "=", "self", ".", "__generate_params", "(", "locals", "(", ")", ",", "[", "'id'", "]", ")", "url", "=", "'/api/v1/accounts/{0}/li...
Get all of the logged-in users lists which the specified user is a member of. Returns a list of `list dicts`_.
[ "Get", "all", "of", "the", "logged", "-", "in", "users", "lists", "which", "the", "specified", "user", "is", "a", "member", "of", ".", "Returns", "a", "list", "of", "list", "dicts", "_", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L1009-L1019
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.filter
def filter(self, id): """ Fetches information about the filter with the specified `id`. Returns a `filter dict`_. """ id = self.__unpack_id(id) url = '/api/v1/filters/{0}'.format(str(id)) return self.__api_request('GET', url)
python
def filter(self, id): """ Fetches information about the filter with the specified `id`. Returns a `filter dict`_. """ id = self.__unpack_id(id) url = '/api/v1/filters/{0}'.format(str(id)) return self.__api_request('GET', url)
[ "def", "filter", "(", "self", ",", "id", ")", ":", "id", "=", "self", ".", "__unpack_id", "(", "id", ")", "url", "=", "'/api/v1/filters/{0}'", ".", "format", "(", "str", "(", "id", ")", ")", "return", "self", ".", "__api_request", "(", "'GET'", ",", ...
Fetches information about the filter with the specified `id`. Returns a `filter dict`_.
[ "Fetches", "information", "about", "the", "filter", "with", "the", "specified", "id", ".", "Returns", "a", "filter", "dict", "_", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L1034-L1042
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.filters_apply
def filters_apply(self, objects, filters, context): """ Helper function: Applies a list of filters to a list of either statuses or notifications and returns only those matched by none. This function will apply all filters that match the context provided in `context`, i.e. if you...
python
def filters_apply(self, objects, filters, context): """ Helper function: Applies a list of filters to a list of either statuses or notifications and returns only those matched by none. This function will apply all filters that match the context provided in `context`, i.e. if you...
[ "def", "filters_apply", "(", "self", ",", "objects", ",", "filters", ",", "context", ")", ":", "# Build filter regex", "filter_strings", "=", "[", "]", "for", "keyword_filter", "in", "filters", ":", "if", "not", "context", "in", "keyword_filter", "[", "\"conte...
Helper function: Applies a list of filters to a list of either statuses or notifications and returns only those matched by none. This function will apply all filters that match the context provided in `context`, i.e. if you want to apply only notification-relevant filters, specify 'noti...
[ "Helper", "function", ":", "Applies", "a", "list", "of", "filters", "to", "a", "list", "of", "either", "statuses", "or", "notifications", "and", "returns", "only", "those", "matched", "by", "none", ".", "This", "function", "will", "apply", "all", "filters", ...
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L1045-L1077
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.search
def search(self, q, resolve=True, result_type=None, account_id=None, offset=None, min_id=None, max_id=None): """ Fetch matching hashtags, accounts and statuses. Will perform webfinger lookups if resolve is True. Full-text search is only enabled if the instance supports it, and is restric...
python
def search(self, q, resolve=True, result_type=None, account_id=None, offset=None, min_id=None, max_id=None): """ Fetch matching hashtags, accounts and statuses. Will perform webfinger lookups if resolve is True. Full-text search is only enabled if the instance supports it, and is restric...
[ "def", "search", "(", "self", ",", "q", ",", "resolve", "=", "True", ",", "result_type", "=", "None", ",", "account_id", "=", "None", ",", "offset", "=", "None", ",", "min_id", "=", "None", ",", "max_id", "=", "None", ")", ":", "return", "self", "....
Fetch matching hashtags, accounts and statuses. Will perform webfinger lookups if resolve is True. Full-text search is only enabled if the instance supports it, and is restricted to statuses the logged-in user wrote or was mentioned in. `result_type` can be one of "accounts", "h...
[ "Fetch", "matching", "hashtags", "accounts", "and", "statuses", ".", "Will", "perform", "webfinger", "lookups", "if", "resolve", "is", "True", ".", "Full", "-", "text", "search", "is", "only", "enabled", "if", "the", "instance", "supports", "it", "and", "is"...
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L1110-L1127
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.search_v1
def search_v1(self, q, resolve=False): """ Identical to `search_v2()`, except in that it does not return tags as `hashtag dicts`_. Returns a `search result dict`_. """ params = self.__generate_params(locals()) if resolve == False: del params['resolve'...
python
def search_v1(self, q, resolve=False): """ Identical to `search_v2()`, except in that it does not return tags as `hashtag dicts`_. Returns a `search result dict`_. """ params = self.__generate_params(locals()) if resolve == False: del params['resolve'...
[ "def", "search_v1", "(", "self", ",", "q", ",", "resolve", "=", "False", ")", ":", "params", "=", "self", ".", "__generate_params", "(", "locals", "(", ")", ")", "if", "resolve", "==", "False", ":", "del", "params", "[", "'resolve'", "]", "return", "...
Identical to `search_v2()`, except in that it does not return tags as `hashtag dicts`_. Returns a `search result dict`_.
[ "Identical", "to", "search_v2", "()", "except", "in", "that", "it", "does", "not", "return", "tags", "as", "hashtag", "dicts", "_", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L1130-L1140
halcy/Mastodon.py
mastodon/Mastodon.py
Mastodon.search_v2
def search_v2(self, q, resolve=True, result_type=None, account_id=None, offset=None, min_id=None, max_id=None): """ Identical to `search_v1()`, except in that it returns tags as `hashtag dicts`_, has more parameters, and resolves by default. Returns a `search result dict`_. """ ...
python
def search_v2(self, q, resolve=True, result_type=None, account_id=None, offset=None, min_id=None, max_id=None): """ Identical to `search_v1()`, except in that it returns tags as `hashtag dicts`_, has more parameters, and resolves by default. Returns a `search result dict`_. """ ...
[ "def", "search_v2", "(", "self", ",", "q", ",", "resolve", "=", "True", ",", "result_type", "=", "None", ",", "account_id", "=", "None", ",", "offset", "=", "None", ",", "min_id", "=", "None", ",", "max_id", "=", "None", ")", ":", "params", "=", "s...
Identical to `search_v1()`, except in that it returns tags as `hashtag dicts`_, has more parameters, and resolves by default. Returns a `search result dict`_.
[ "Identical", "to", "search_v1", "()", "except", "in", "that", "it", "returns", "tags", "as", "hashtag", "dicts", "_", "has", "more", "parameters", "and", "resolves", "by", "default", "." ]
train
https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L1143-L1159