repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
chaoss/grimoirelab-sortinghat
sortinghat/cmd/unify.py
Unify.__unify_unique_identities
def __unify_unique_identities(self, uidentities, matcher, fast_matching, interactive): """Unify unique identities looking for similar identities.""" self.total = len(uidentities) self.matched = 0 if self.recovery and self.recovery_file.exists(): ...
python
def __unify_unique_identities(self, uidentities, matcher, fast_matching, interactive): """Unify unique identities looking for similar identities.""" self.total = len(uidentities) self.matched = 0 if self.recovery and self.recovery_file.exists(): ...
[ "def", "__unify_unique_identities", "(", "self", ",", "uidentities", ",", "matcher", ",", "fast_matching", ",", "interactive", ")", ":", "self", ".", "total", "=", "len", "(", "uidentities", ")", "self", ".", "matched", "=", "0", "if", "self", ".", "recove...
Unify unique identities looking for similar identities.
[ "Unify", "unique", "identities", "looking", "for", "similar", "identities", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/unify.py#L166-L184
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/unify.py
Unify.__merge
def __merge(self, matched, interactive): """Merge a lists of matched unique identities""" for m in matched: identities = m['identities'] uuid = identities[0] try: for c in identities[1:]: if self.__merge_unique_identities(c, uuid,...
python
def __merge(self, matched, interactive): """Merge a lists of matched unique identities""" for m in matched: identities = m['identities'] uuid = identities[0] try: for c in identities[1:]: if self.__merge_unique_identities(c, uuid,...
[ "def", "__merge", "(", "self", ",", "matched", ",", "interactive", ")", ":", "for", "m", "in", "matched", ":", "identities", "=", "m", "[", "'identities'", "]", "uuid", "=", "identities", "[", "0", "]", "try", ":", "for", "c", "in", "identities", "["...
Merge a lists of matched unique identities
[ "Merge", "a", "lists", "of", "matched", "unique", "identities" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/unify.py#L186-L206
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/unify.py
Unify.__display_stats
def __display_stats(self): """Display some stats regarding unify process""" self.display('unify.tmpl', processed=self.total, matched=self.matched, unified=self.total - self.matched)
python
def __display_stats(self): """Display some stats regarding unify process""" self.display('unify.tmpl', processed=self.total, matched=self.matched, unified=self.total - self.matched)
[ "def", "__display_stats", "(", "self", ")", ":", "self", ".", "display", "(", "'unify.tmpl'", ",", "processed", "=", "self", ".", "total", ",", "matched", "=", "self", ".", "matched", ",", "unified", "=", "self", ".", "total", "-", "self", ".", "matche...
Display some stats regarding unify process
[ "Display", "some", "stats", "regarding", "unify", "process" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/unify.py#L240-L245
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/unify.py
Unify.__marshal_matches
def __marshal_matches(matched): """Convert matches to JSON format. :param matched: a list of matched identities :returns json_matches: a list of matches in JSON format """ json_matches = [] for m in matched: identities = [i.uuid for i in m] if l...
python
def __marshal_matches(matched): """Convert matches to JSON format. :param matched: a list of matched identities :returns json_matches: a list of matches in JSON format """ json_matches = [] for m in matched: identities = [i.uuid for i in m] if l...
[ "def", "__marshal_matches", "(", "matched", ")", ":", "json_matches", "=", "[", "]", "for", "m", "in", "matched", ":", "identities", "=", "[", "i", ".", "uuid", "for", "i", "in", "m", "]", "if", "len", "(", "identities", ")", "==", "1", ":", "conti...
Convert matches to JSON format. :param matched: a list of matched identities :returns json_matches: a list of matches in JSON format
[ "Convert", "matches", "to", "JSON", "format", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/unify.py#L248-L268
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/unify.py
RecoveryFile.load_matches
def load_matches(self): """Load matches of the previous failed execution from the recovery file. :returns matches: a list of matches in JSON format """ if not self.exists(): return [] matches = [] with open(self.location(), 'r') as f: for line in...
python
def load_matches(self): """Load matches of the previous failed execution from the recovery file. :returns matches: a list of matches in JSON format """ if not self.exists(): return [] matches = [] with open(self.location(), 'r') as f: for line in...
[ "def", "load_matches", "(", "self", ")", ":", "if", "not", "self", ".", "exists", "(", ")", ":", "return", "[", "]", "matches", "=", "[", "]", "with", "open", "(", "self", ".", "location", "(", ")", ",", "'r'", ")", "as", "f", ":", "for", "line...
Load matches of the previous failed execution from the recovery file. :returns matches: a list of matches in JSON format
[ "Load", "matches", "of", "the", "previous", "failed", "execution", "from", "the", "recovery", "file", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/unify.py#L296-L313
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/unify.py
RecoveryFile.save_matches
def save_matches(self, matches): """Save matches of a failed execution to the log. :param matches: a list of matches in JSON format """ if not os.path.exists(os.path.dirname(self.location())): os.makedirs(os.path.dirname(self.location())) with open(self.location(), ...
python
def save_matches(self, matches): """Save matches of a failed execution to the log. :param matches: a list of matches in JSON format """ if not os.path.exists(os.path.dirname(self.location())): os.makedirs(os.path.dirname(self.location())) with open(self.location(), ...
[ "def", "save_matches", "(", "self", ",", "matches", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "dirname", "(", "self", ".", "location", "(", ")", ")", ")", ":", "os", ".", "makedirs", "(", "os", ".", "...
Save matches of a failed execution to the log. :param matches: a list of matches in JSON format
[ "Save", "matches", "of", "a", "failed", "execution", "to", "the", "log", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/unify.py#L315-L327
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/unify.py
RecoveryFile.__uuid
def __uuid(*args): """Generate a UUID based on the given parameters.""" s = '-'.join(args) sha1 = hashlib.sha1(s.encode('utf-8', errors='surrogateescape')) uuid_sha1 = sha1.hexdigest() return uuid_sha1
python
def __uuid(*args): """Generate a UUID based on the given parameters.""" s = '-'.join(args) sha1 = hashlib.sha1(s.encode('utf-8', errors='surrogateescape')) uuid_sha1 = sha1.hexdigest() return uuid_sha1
[ "def", "__uuid", "(", "*", "args", ")", ":", "s", "=", "'-'", ".", "join", "(", "args", ")", "sha1", "=", "hashlib", ".", "sha1", "(", "s", ".", "encode", "(", "'utf-8'", ",", "errors", "=", "'surrogateescape'", ")", ")", "uuid_sha1", "=", "sha1", ...
Generate a UUID based on the given parameters.
[ "Generate", "a", "UUID", "based", "on", "the", "given", "parameters", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/unify.py#L336-L344
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/grimoirelab.py
GrimoireLabParser.__parse
def __parse(self, identities_stream, organizations_stream): """Parse GrimoireLab stream""" if organizations_stream: self.__parse_organizations(organizations_stream) if identities_stream: self.__parse_identities(identities_stream)
python
def __parse(self, identities_stream, organizations_stream): """Parse GrimoireLab stream""" if organizations_stream: self.__parse_organizations(organizations_stream) if identities_stream: self.__parse_identities(identities_stream)
[ "def", "__parse", "(", "self", ",", "identities_stream", ",", "organizations_stream", ")", ":", "if", "organizations_stream", ":", "self", ".", "__parse_organizations", "(", "organizations_stream", ")", "if", "identities_stream", ":", "self", ".", "__parse_identities"...
Parse GrimoireLab stream
[ "Parse", "GrimoireLab", "stream" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/grimoirelab.py#L92-L99
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/grimoirelab.py
GrimoireLabParser.__parse_identities
def __parse_identities(self, stream): """Parse identities using GrimoireLab format. The GrimoireLab identities format is a YAML document following a schema similar to the example below. More information available at https://github.com/bitergia/identities - profile: ...
python
def __parse_identities(self, stream): """Parse identities using GrimoireLab format. The GrimoireLab identities format is a YAML document following a schema similar to the example below. More information available at https://github.com/bitergia/identities - profile: ...
[ "def", "__parse_identities", "(", "self", ",", "stream", ")", ":", "def", "__create_sh_identities", "(", "name", ",", "emails", ",", "yaml_entry", ")", ":", "ids", "=", "[", "]", "ids", ".", "append", "(", "Identity", "(", "name", "=", "name", ",", "so...
Parse identities using GrimoireLab format. The GrimoireLab identities format is a YAML document following a schema similar to the example below. More information available at https://github.com/bitergia/identities - profile: name: Vivek K. is_bot: false ...
[ "Parse", "identities", "using", "GrimoireLab", "format", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/grimoirelab.py#L101-L187
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/grimoirelab.py
GrimoireLabParser.__parse_organizations
def __parse_organizations(self, stream): """Parse GrimoireLab organizations. The GrimoireLab organizations format is a YAML element stored under the "organizations" key. The next example shows the structure of the document: - organizations: Bitergia: ...
python
def __parse_organizations(self, stream): """Parse GrimoireLab organizations. The GrimoireLab organizations format is a YAML element stored under the "organizations" key. The next example shows the structure of the document: - organizations: Bitergia: ...
[ "def", "__parse_organizations", "(", "self", ",", "stream", ")", ":", "if", "not", "stream", ":", "return", "yaml_file", "=", "self", ".", "__load_yml", "(", "stream", ")", "try", ":", "for", "element", "in", "yaml_file", ":", "name", "=", "self", ".", ...
Parse GrimoireLab organizations. The GrimoireLab organizations format is a YAML element stored under the "organizations" key. The next example shows the structure of the document: - organizations: Bitergia: - bitergia.com - support.bitergia.c...
[ "Parse", "GrimoireLab", "organizations", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/grimoirelab.py#L189-L247
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/grimoirelab.py
GrimoireLabParser.__parse_affiliations_yml
def __parse_affiliations_yml(self, affiliations): """Parse identity's affiliations from a yaml dict.""" enrollments = [] for aff in affiliations: name = self.__encode(aff['organization']) if not name: error = "Empty organization name" msg...
python
def __parse_affiliations_yml(self, affiliations): """Parse identity's affiliations from a yaml dict.""" enrollments = [] for aff in affiliations: name = self.__encode(aff['organization']) if not name: error = "Empty organization name" msg...
[ "def", "__parse_affiliations_yml", "(", "self", ",", "affiliations", ")", ":", "enrollments", "=", "[", "]", "for", "aff", "in", "affiliations", ":", "name", "=", "self", ".", "__encode", "(", "aff", "[", "'organization'", "]", ")", "if", "not", "name", ...
Parse identity's affiliations from a yaml dict.
[ "Parse", "identity", "s", "affiliations", "from", "a", "yaml", "dict", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/grimoirelab.py#L249-L285
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/grimoirelab.py
GrimoireLabParser.__force_datetime
def __force_datetime(self, obj): """Converts ojb to time.datetime.datetime YAML parsing returns either date or datetime object depending on how the date is written. YYYY-MM-DD will return a date and YYYY-MM-DDThh:mm:ss will return a datetime :param obj: date or datetime object ...
python
def __force_datetime(self, obj): """Converts ojb to time.datetime.datetime YAML parsing returns either date or datetime object depending on how the date is written. YYYY-MM-DD will return a date and YYYY-MM-DDThh:mm:ss will return a datetime :param obj: date or datetime object ...
[ "def", "__force_datetime", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "datetime", ".", "datetime", ")", ":", "return", "obj", "t", "=", "datetime", ".", "time", "(", "0", ",", "0", ")", "return", "datetime", ".", "datetim...
Converts ojb to time.datetime.datetime YAML parsing returns either date or datetime object depending on how the date is written. YYYY-MM-DD will return a date and YYYY-MM-DDThh:mm:ss will return a datetime :param obj: date or datetime object
[ "Converts", "ojb", "to", "time", ".", "datetime", ".", "datetime" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/grimoirelab.py#L287-L300
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/grimoirelab.py
GrimoireLabParser.__load_yml
def __load_yml(self, stream): """Load yml stream into a dict object """ try: return yaml.load(stream, Loader=yaml.SafeLoader) except ValueError as e: cause = "invalid yml format. %s" % str(e) raise InvalidFormatError(cause=cause)
python
def __load_yml(self, stream): """Load yml stream into a dict object """ try: return yaml.load(stream, Loader=yaml.SafeLoader) except ValueError as e: cause = "invalid yml format. %s" % str(e) raise InvalidFormatError(cause=cause)
[ "def", "__load_yml", "(", "self", ",", "stream", ")", ":", "try", ":", "return", "yaml", ".", "load", "(", "stream", ",", "Loader", "=", "yaml", ".", "SafeLoader", ")", "except", "ValueError", "as", "e", ":", "cause", "=", "\"invalid yml format. %s\"", "...
Load yml stream into a dict object
[ "Load", "yml", "stream", "into", "a", "dict", "object" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/grimoirelab.py#L302-L309
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/grimoirelab.py
GrimoireLabParser.__validate_email
def __validate_email(self, email): """Checks if a string looks like an email address""" e = re.match(self.EMAIL_ADDRESS_REGEX, email, re.UNICODE) if e: return email else: error = "Invalid email address: " + str(email) msg = self.GRIMOIRELAB_INVALID_FO...
python
def __validate_email(self, email): """Checks if a string looks like an email address""" e = re.match(self.EMAIL_ADDRESS_REGEX, email, re.UNICODE) if e: return email else: error = "Invalid email address: " + str(email) msg = self.GRIMOIRELAB_INVALID_FO...
[ "def", "__validate_email", "(", "self", ",", "email", ")", ":", "e", "=", "re", ".", "match", "(", "self", ".", "EMAIL_ADDRESS_REGEX", ",", "email", ",", "re", ".", "UNICODE", ")", "if", "e", ":", "return", "email", "else", ":", "error", "=", "\"Inva...
Checks if a string looks like an email address
[ "Checks", "if", "a", "string", "looks", "like", "an", "email", "address" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/grimoirelab.py#L314-L323
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/grimoirelab.py
GrimoireLabParser.__validate_enrollment_periods
def __validate_enrollment_periods(self, enrollments): """Check for overlapped periods in the enrollments""" for a, b in itertools.combinations(enrollments, 2): max_start = max(a.start, b.start) min_end = min(a.end, b.end) if max_start < min_end: msg...
python
def __validate_enrollment_periods(self, enrollments): """Check for overlapped periods in the enrollments""" for a, b in itertools.combinations(enrollments, 2): max_start = max(a.start, b.start) min_end = min(a.end, b.end) if max_start < min_end: msg...
[ "def", "__validate_enrollment_periods", "(", "self", ",", "enrollments", ")", ":", "for", "a", ",", "b", "in", "itertools", ".", "combinations", "(", "enrollments", ",", "2", ")", ":", "max_start", "=", "max", "(", "a", ".", "start", ",", "b", ".", "st...
Check for overlapped periods in the enrollments
[ "Check", "for", "overlapped", "periods", "in", "the", "enrollments" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/grimoirelab.py#L325-L338
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/sh.py
SortingHatParser.__parse
def __parse(self, stream): """Parse Sorting Hat stream""" if not stream: raise InvalidFormatError(cause="stream cannot be empty or None") json = self.__load_json(stream) self.__parse_organizations(json) self.__parse_identities(json) self.__parse_blacklist(j...
python
def __parse(self, stream): """Parse Sorting Hat stream""" if not stream: raise InvalidFormatError(cause="stream cannot be empty or None") json = self.__load_json(stream) self.__parse_organizations(json) self.__parse_identities(json) self.__parse_blacklist(j...
[ "def", "__parse", "(", "self", ",", "stream", ")", ":", "if", "not", "stream", ":", "raise", "InvalidFormatError", "(", "cause", "=", "\"stream cannot be empty or None\"", ")", "json", "=", "self", ".", "__load_json", "(", "stream", ")", "self", ".", "__pars...
Parse Sorting Hat stream
[ "Parse", "Sorting", "Hat", "stream" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/sh.py#L76-L86
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/sh.py
SortingHatParser.__parse_blacklist
def __parse_blacklist(self, json): """Parse blacklist entries using Sorting Hat format. The Sorting Hat blacklist format is a JSON stream that stores a list of blacklisted entries. Next, there is an example of a valid stream: { "blacklist": [ "John ...
python
def __parse_blacklist(self, json): """Parse blacklist entries using Sorting Hat format. The Sorting Hat blacklist format is a JSON stream that stores a list of blacklisted entries. Next, there is an example of a valid stream: { "blacklist": [ "John ...
[ "def", "__parse_blacklist", "(", "self", ",", "json", ")", ":", "try", ":", "for", "entry", "in", "json", "[", "'blacklist'", "]", ":", "if", "not", "entry", ":", "msg", "=", "\"invalid json format. Blacklist entries cannot be null or empty\"", "raise", "InvalidFo...
Parse blacklist entries using Sorting Hat format. The Sorting Hat blacklist format is a JSON stream that stores a list of blacklisted entries. Next, there is an example of a valid stream: { "blacklist": [ "John Doe", "John Smith", ...
[ "Parse", "blacklist", "entries", "using", "Sorting", "Hat", "format", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/sh.py#L88-L124
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/sh.py
SortingHatParser.__parse_organizations
def __parse_organizations(self, json): """Parse organizations using Sorting Hat format. The Sorting Hat organizations format is a JSON stream which its keys are the name of the organizations. Each organization object has a list of domains. For instance: { "organizat...
python
def __parse_organizations(self, json): """Parse organizations using Sorting Hat format. The Sorting Hat organizations format is a JSON stream which its keys are the name of the organizations. Each organization object has a list of domains. For instance: { "organizat...
[ "def", "__parse_organizations", "(", "self", ",", "json", ")", ":", "try", ":", "for", "organization", "in", "json", "[", "'organizations'", "]", ":", "name", "=", "self", ".", "__encode", "(", "organization", ")", "org", "=", "self", ".", "_organizations"...
Parse organizations using Sorting Hat format. The Sorting Hat organizations format is a JSON stream which its keys are the name of the organizations. Each organization object has a list of domains. For instance: { "organizations": { "Bitergia": [ ...
[ "Parse", "organizations", "using", "Sorting", "Hat", "format", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/sh.py#L282-L333
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load.run
def run(self, *args): """Import data on the registry. By default, it reads the data from the standard input. If a positional argument is given, it will read the data from there. """ params = self.parser.parse_args(args) with params.infile as infile: try: ...
python
def run(self, *args): """Import data on the registry. By default, it reads the data from the standard input. If a positional argument is given, it will read the data from there. """ params = self.parser.parse_args(args) with params.infile as infile: try: ...
[ "def", "run", "(", "self", ",", "*", "args", ")", ":", "params", "=", "self", ".", "parser", ".", "parse_args", "(", "args", ")", "with", "params", ".", "infile", "as", "infile", ":", "try", ":", "stream", "=", "self", ".", "__read_file", "(", "inf...
Import data on the registry. By default, it reads the data from the standard input. If a positional argument is given, it will read the data from there.
[ "Import", "data", "on", "the", "registry", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L129-L167
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load.import_blacklist
def import_blacklist(self, parser): """Import blacklist. New entries parsed by 'parser' will be added to the blacklist. :param parser: sorting hat parser """ blacklist = parser.blacklist self.log("Loading blacklist...") n = 0 for entry in blacklist: ...
python
def import_blacklist(self, parser): """Import blacklist. New entries parsed by 'parser' will be added to the blacklist. :param parser: sorting hat parser """ blacklist = parser.blacklist self.log("Loading blacklist...") n = 0 for entry in blacklist: ...
[ "def", "import_blacklist", "(", "self", ",", "parser", ")", ":", "blacklist", "=", "parser", ".", "blacklist", "self", ".", "log", "(", "\"Loading blacklist...\"", ")", "n", "=", "0", "for", "entry", "in", "blacklist", ":", "try", ":", "api", ".", "add_t...
Import blacklist. New entries parsed by 'parser' will be added to the blacklist. :param parser: sorting hat parser
[ "Import", "blacklist", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L169-L192
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load.import_organizations
def import_organizations(self, parser, overwrite=False): """Import organizations. New domains and organizations parsed by 'parser' will be added to the registry. Remember that a domain can only be assigned to one organization. If one of the given domains is already on the registry, ...
python
def import_organizations(self, parser, overwrite=False): """Import organizations. New domains and organizations parsed by 'parser' will be added to the registry. Remember that a domain can only be assigned to one organization. If one of the given domains is already on the registry, ...
[ "def", "import_organizations", "(", "self", ",", "parser", ",", "overwrite", "=", "False", ")", ":", "orgs", "=", "parser", ".", "organizations", "for", "org", "in", "orgs", ":", "try", ":", "api", ".", "add_organization", "(", "self", ".", "db", ",", ...
Import organizations. New domains and organizations parsed by 'parser' will be added to the registry. Remember that a domain can only be assigned to one organization. If one of the given domains is already on the registry, the new relationship will NOT be created unless 'overwrite' were...
[ "Import", "organizations", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L194-L227
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load.import_identities
def import_identities(self, parser, matching=None, match_new=False, no_strict_matching=False, reset=False, verbose=False): """Import identities information on the registry. New unique identities, organizations and enrollment data parsed by 'pa...
python
def import_identities(self, parser, matching=None, match_new=False, no_strict_matching=False, reset=False, verbose=False): """Import identities information on the registry. New unique identities, organizations and enrollment data parsed by 'pa...
[ "def", "import_identities", "(", "self", ",", "parser", ",", "matching", "=", "None", ",", "match_new", "=", "False", ",", "no_strict_matching", "=", "False", ",", "reset", "=", "False", ",", "verbose", "=", "False", ")", ":", "matcher", "=", "None", "if...
Import identities information on the registry. New unique identities, organizations and enrollment data parsed by 'parser' will be added to the registry. Optionally, this method can look for possible identities that match with the new one to insert using 'matching' method. If a match i...
[ "Import", "identities", "information", "on", "the", "registry", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L229-L276
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load.__load_unique_identities
def __load_unique_identities(self, uidentities, matcher, match_new, reset, verbose): """Load unique identities""" self.new_uids.clear() n = 0 if reset: self.__reset_unique_identities() self.log("Loading unique identities...") ...
python
def __load_unique_identities(self, uidentities, matcher, match_new, reset, verbose): """Load unique identities""" self.new_uids.clear() n = 0 if reset: self.__reset_unique_identities() self.log("Loading unique identities...") ...
[ "def", "__load_unique_identities", "(", "self", ",", "uidentities", ",", "matcher", ",", "match_new", ",", "reset", ",", "verbose", ")", ":", "self", ".", "new_uids", ".", "clear", "(", ")", "n", "=", "0", "if", "reset", ":", "self", ".", "__reset_unique...
Load unique identities
[ "Load", "unique", "identities" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L278-L323
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load.__reset_unique_identities
def __reset_unique_identities(self): """Clear identities relationships and enrollments data""" self.log("Reseting unique identities...") self.log("Clearing identities relationships") nids = 0 uidentities = api.unique_identities(self.db) for uidentity in uidentities: ...
python
def __reset_unique_identities(self): """Clear identities relationships and enrollments data""" self.log("Reseting unique identities...") self.log("Clearing identities relationships") nids = 0 uidentities = api.unique_identities(self.db) for uidentity in uidentities: ...
[ "def", "__reset_unique_identities", "(", "self", ")", ":", "self", ".", "log", "(", "\"Reseting unique identities...\"", ")", "self", ".", "log", "(", "\"Clearing identities relationships\"", ")", "nids", "=", "0", "uidentities", "=", "api", ".", "unique_identities"...
Clear identities relationships and enrollments data
[ "Clear", "identities", "relationships", "and", "enrollments", "data" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L325-L350
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load.__load_unique_identity
def __load_unique_identity(self, uidentity, verbose): """Seek or store unique identity""" uuid = uidentity.uuid if uuid: try: api.unique_identities(self.db, uuid) self.log("-- %s already exists." % uuid, verbose) return uuid ...
python
def __load_unique_identity(self, uidentity, verbose): """Seek or store unique identity""" uuid = uidentity.uuid if uuid: try: api.unique_identities(self.db, uuid) self.log("-- %s already exists." % uuid, verbose) return uuid ...
[ "def", "__load_unique_identity", "(", "self", ",", "uidentity", ",", "verbose", ")", ":", "uuid", "=", "uidentity", ".", "uuid", "if", "uuid", ":", "try", ":", "api", ".", "unique_identities", "(", "self", ".", "db", ",", "uuid", ")", "self", ".", "log...
Seek or store unique identity
[ "Seek", "or", "store", "unique", "identity" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L352-L390
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load.__load_profile
def __load_profile(self, profile, uuid, verbose): """Create a new profile when the unique identity does not have any.""" def is_empty_profile(prf): return not (prf.name or prf.email or prf.gender or prf.gender_acc or prf.is_bot or prf.country_...
python
def __load_profile(self, profile, uuid, verbose): """Create a new profile when the unique identity does not have any.""" def is_empty_profile(prf): return not (prf.name or prf.email or prf.gender or prf.gender_acc or prf.is_bot or prf.country_...
[ "def", "__load_profile", "(", "self", ",", "profile", ",", "uuid", ",", "verbose", ")", ":", "def", "is_empty_profile", "(", "prf", ")", ":", "return", "not", "(", "prf", ".", "name", "or", "prf", ".", "email", "or", "prf", ".", "gender", "or", "prf"...
Create a new profile when the unique identity does not have any.
[ "Create", "a", "new", "profile", "when", "the", "unique", "identity", "does", "not", "have", "any", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L425-L440
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load.__create_profile
def __create_profile(self, profile, uuid, verbose): """Create profile information from a profile object""" # Set parameters to edit kw = profile.to_dict() kw['country_code'] = profile.country_code # Remove unused keywords kw.pop('uuid') kw.pop('country') ...
python
def __create_profile(self, profile, uuid, verbose): """Create profile information from a profile object""" # Set parameters to edit kw = profile.to_dict() kw['country_code'] = profile.country_code # Remove unused keywords kw.pop('uuid') kw.pop('country') ...
[ "def", "__create_profile", "(", "self", ",", "profile", ",", "uuid", ",", "verbose", ")", ":", "kw", "=", "profile", ".", "to_dict", "(", ")", "kw", "[", "'country_code'", "]", "=", "profile", ".", "country_code", "kw", ".", "pop", "(", "'uuid'", ")", ...
Create profile information from a profile object
[ "Create", "profile", "information", "from", "a", "profile", "object" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L442-L455
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load.__create_profile_from_identities
def __create_profile_from_identities(self, identities, uuid, verbose): """Create a profile using the data from the identities""" import re EMAIL_ADDRESS_REGEX = r"^(?P<email>[^\s@]+@[^\s@.]+\.[^\s@]+)$" NAME_REGEX = r"^\w+\s\w+" name = None email = None usernam...
python
def __create_profile_from_identities(self, identities, uuid, verbose): """Create a profile using the data from the identities""" import re EMAIL_ADDRESS_REGEX = r"^(?P<email>[^\s@]+@[^\s@.]+\.[^\s@]+)$" NAME_REGEX = r"^\w+\s\w+" name = None email = None usernam...
[ "def", "__create_profile_from_identities", "(", "self", ",", "identities", ",", "uuid", ",", "verbose", ")", ":", "import", "re", "EMAIL_ADDRESS_REGEX", "=", "r\"^(?P<email>[^\\s@]+@[^\\s@.]+\\.[^\\s@]+)$\"", "NAME_REGEX", "=", "r\"^\\w+\\s\\w+\"", "name", "=", "None", ...
Create a profile using the data from the identities
[ "Create", "a", "profile", "using", "the", "data", "from", "the", "identities" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L457-L502
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load._merge_on_matching
def _merge_on_matching(self, uuid, matcher, verbose): """Merge unique identity with uuid when a match is found""" matches = api.match_identities(self.db, uuid, matcher) new_uuid = uuid u = api.unique_identities(self.db, uuid)[0] for m in matches: if m.uuid == uuid...
python
def _merge_on_matching(self, uuid, matcher, verbose): """Merge unique identity with uuid when a match is found""" matches = api.match_identities(self.db, uuid, matcher) new_uuid = uuid u = api.unique_identities(self.db, uuid)[0] for m in matches: if m.uuid == uuid...
[ "def", "_merge_on_matching", "(", "self", ",", "uuid", ",", "matcher", ",", "verbose", ")", ":", "matches", "=", "api", ".", "match_identities", "(", "self", ".", "db", ",", "uuid", ",", "matcher", ")", "new_uuid", "=", "uuid", "u", "=", "api", ".", ...
Merge unique identity with uuid when a match is found
[ "Merge", "unique", "identity", "with", "uuid", "when", "a", "match", "is", "found" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L544-L565
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/load.py
Load._merge
def _merge(self, from_uid, to_uid, verbose): """Merge unique identity uid on match""" if verbose: self.display('match.tmpl', uid=from_uid, match=to_uid) api.merge_unique_identities(self.db, from_uid.uuid, to_uid.uuid) if verbose: self.display('merge.tmpl', from...
python
def _merge(self, from_uid, to_uid, verbose): """Merge unique identity uid on match""" if verbose: self.display('match.tmpl', uid=from_uid, match=to_uid) api.merge_unique_identities(self.db, from_uid.uuid, to_uid.uuid) if verbose: self.display('merge.tmpl', from...
[ "def", "_merge", "(", "self", ",", "from_uid", ",", "to_uid", ",", "verbose", ")", ":", "if", "verbose", ":", "self", ".", "display", "(", "'match.tmpl'", ",", "uid", "=", "from_uid", ",", "match", "=", "to_uid", ")", "api", ".", "merge_unique_identities...
Merge unique identity uid on match
[ "Merge", "unique", "identity", "uid", "on", "match" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/load.py#L567-L576
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/gitdm.py
GitdmParser.__parse
def __parse(self, aliases, email_to_employer, domain_to_employer): """Parse Gitdm streams""" self.__parse_organizations(domain_to_employer) self.__parse_identities(aliases, email_to_employer)
python
def __parse(self, aliases, email_to_employer, domain_to_employer): """Parse Gitdm streams""" self.__parse_organizations(domain_to_employer) self.__parse_identities(aliases, email_to_employer)
[ "def", "__parse", "(", "self", ",", "aliases", ",", "email_to_employer", ",", "domain_to_employer", ")", ":", "self", ".", "__parse_organizations", "(", "domain_to_employer", ")", "self", ".", "__parse_identities", "(", "aliases", ",", "email_to_employer", ")" ]
Parse Gitdm streams
[ "Parse", "Gitdm", "streams" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/gitdm.py#L96-L100
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/gitdm.py
GitdmParser.__parse_identities
def __parse_identities(self, aliases, email_to_employer): """Parse Gitdm identities""" # Parse streams self.__parse_aliases_stream(aliases) self.__parse_email_to_employer_stream(email_to_employer) # Create unique identities from aliases list for alias, email in self.__r...
python
def __parse_identities(self, aliases, email_to_employer): """Parse Gitdm identities""" # Parse streams self.__parse_aliases_stream(aliases) self.__parse_email_to_employer_stream(email_to_employer) # Create unique identities from aliases list for alias, email in self.__r...
[ "def", "__parse_identities", "(", "self", ",", "aliases", ",", "email_to_employer", ")", ":", "self", ".", "__parse_aliases_stream", "(", "aliases", ")", "self", ".", "__parse_email_to_employer_stream", "(", "email_to_employer", ")", "for", "alias", ",", "email", ...
Parse Gitdm identities
[ "Parse", "Gitdm", "identities" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/gitdm.py#L102-L172
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/gitdm.py
GitdmParser.__parse_organizations
def __parse_organizations(self, domain_to_employer): """Parse Gitdm organizations""" # Parse streams self.__parse_domain_to_employer_stream(domain_to_employer) for org in self.__raw_orgs: o = Organization(name=org) for dom in self.__raw_orgs[org]: ...
python
def __parse_organizations(self, domain_to_employer): """Parse Gitdm organizations""" # Parse streams self.__parse_domain_to_employer_stream(domain_to_employer) for org in self.__raw_orgs: o = Organization(name=org) for dom in self.__raw_orgs[org]: ...
[ "def", "__parse_organizations", "(", "self", ",", "domain_to_employer", ")", ":", "self", ".", "__parse_domain_to_employer_stream", "(", "domain_to_employer", ")", "for", "org", "in", "self", ".", "__raw_orgs", ":", "o", "=", "Organization", "(", "name", "=", "o...
Parse Gitdm organizations
[ "Parse", "Gitdm", "organizations" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/gitdm.py#L174-L187
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/gitdm.py
GitdmParser.__parse_aliases_stream
def __parse_aliases_stream(self, stream): """Parse aliases stream. The stream contains a list of usernames (they can be email addresses their username aliases. Each line has a username and an alias separated by tabs. Comment lines start with the hash character (#). Example: ...
python
def __parse_aliases_stream(self, stream): """Parse aliases stream. The stream contains a list of usernames (they can be email addresses their username aliases. Each line has a username and an alias separated by tabs. Comment lines start with the hash character (#). Example: ...
[ "def", "__parse_aliases_stream", "(", "self", ",", "stream", ")", ":", "if", "not", "stream", ":", "return", "f", "=", "self", ".", "__parse_aliases_line", "for", "alias_entries", "in", "self", ".", "__parse_stream", "(", "stream", ",", "f", ")", ":", "ali...
Parse aliases stream. The stream contains a list of usernames (they can be email addresses their username aliases. Each line has a username and an alias separated by tabs. Comment lines start with the hash character (#). Example: # List of email aliases jsmith@example....
[ "Parse", "aliases", "stream", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/gitdm.py#L189-L213
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/gitdm.py
GitdmParser.__parse_email_to_employer_stream
def __parse_email_to_employer_stream(self, stream): """Parse email to employer stream. The stream contains a list of email addresses and their employers. Each line has an email address and a organization name separated by tabs. Optionally, the date when the identity withdrew from the ...
python
def __parse_email_to_employer_stream(self, stream): """Parse email to employer stream. The stream contains a list of email addresses and their employers. Each line has an email address and a organization name separated by tabs. Optionally, the date when the identity withdrew from the ...
[ "def", "__parse_email_to_employer_stream", "(", "self", ",", "stream", ")", ":", "if", "not", "stream", ":", "return", "f", "=", "self", ".", "__parse_email_to_employer_line", "for", "rol", "in", "self", ".", "__parse_stream", "(", "stream", ",", "f", ")", "...
Parse email to employer stream. The stream contains a list of email addresses and their employers. Each line has an email address and a organization name separated by tabs. Optionally, the date when the identity withdrew from the organization can be included followed by a '<' character....
[ "Parse", "email", "to", "employer", "stream", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/gitdm.py#L215-L247
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/gitdm.py
GitdmParser.__parse_domain_to_employer_stream
def __parse_domain_to_employer_stream(self, stream): """Parse domain to employer stream. Each line of the stream has to contain a domain and a organization, or employer, separated by tabs. Comment lines start with the hash character (#) Example: # Domains from domains....
python
def __parse_domain_to_employer_stream(self, stream): """Parse domain to employer stream. Each line of the stream has to contain a domain and a organization, or employer, separated by tabs. Comment lines start with the hash character (#) Example: # Domains from domains....
[ "def", "__parse_domain_to_employer_stream", "(", "self", ",", "stream", ")", ":", "if", "not", "stream", ":", "return", "f", "=", "self", ".", "__parse_domain_to_employer_line", "for", "o", "in", "self", ".", "__parse_stream", "(", "stream", ",", "f", ")", "...
Parse domain to employer stream. Each line of the stream has to contain a domain and a organization, or employer, separated by tabs. Comment lines start with the hash character (#) Example: # Domains from domains.txt example.org Example example.com ...
[ "Parse", "domain", "to", "employer", "stream", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/gitdm.py#L249-L277
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/gitdm.py
GitdmParser.__parse_stream
def __parse_stream(self, stream, parse_line): """Generic method to parse gitdm streams""" if not stream: raise InvalidFormatError(cause='stream cannot be empty or None') nline = 0 lines = stream.split('\n') for line in lines: nline += 1 # I...
python
def __parse_stream(self, stream, parse_line): """Generic method to parse gitdm streams""" if not stream: raise InvalidFormatError(cause='stream cannot be empty or None') nline = 0 lines = stream.split('\n') for line in lines: nline += 1 # I...
[ "def", "__parse_stream", "(", "self", ",", "stream", ",", "parse_line", ")", ":", "if", "not", "stream", ":", "raise", "InvalidFormatError", "(", "cause", "=", "'stream cannot be empty or None'", ")", "nline", "=", "0", "lines", "=", "stream", ".", "split", ...
Generic method to parse gitdm streams
[ "Generic", "method", "to", "parse", "gitdm", "streams" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/gitdm.py#L279-L306
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/gitdm.py
GitdmParser.__parse_aliases_line
def __parse_aliases_line(self, raw_alias, raw_username): """Parse aliases lines""" alias = self.__encode(raw_alias) username = self.__encode(raw_username) return alias, username
python
def __parse_aliases_line(self, raw_alias, raw_username): """Parse aliases lines""" alias = self.__encode(raw_alias) username = self.__encode(raw_username) return alias, username
[ "def", "__parse_aliases_line", "(", "self", ",", "raw_alias", ",", "raw_username", ")", ":", "alias", "=", "self", ".", "__encode", "(", "raw_alias", ")", "username", "=", "self", ".", "__encode", "(", "raw_username", ")", "return", "alias", ",", "username" ...
Parse aliases lines
[ "Parse", "aliases", "lines" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/gitdm.py#L308-L314
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/gitdm.py
GitdmParser.__parse_email_to_employer_line
def __parse_email_to_employer_line(self, raw_email, raw_enrollment): """Parse email to employer lines""" e = re.match(self.EMAIL_ADDRESS_REGEX, raw_email, re.UNICODE) if not e and self.email_validation: cause = "invalid email format: '%s'" % raw_email raise InvalidFormat...
python
def __parse_email_to_employer_line(self, raw_email, raw_enrollment): """Parse email to employer lines""" e = re.match(self.EMAIL_ADDRESS_REGEX, raw_email, re.UNICODE) if not e and self.email_validation: cause = "invalid email format: '%s'" % raw_email raise InvalidFormat...
[ "def", "__parse_email_to_employer_line", "(", "self", ",", "raw_email", ",", "raw_enrollment", ")", ":", "e", "=", "re", ".", "match", "(", "self", ".", "EMAIL_ADDRESS_REGEX", ",", "raw_email", ",", "re", ".", "UNICODE", ")", "if", "not", "e", "and", "self...
Parse email to employer lines
[ "Parse", "email", "to", "employer", "lines" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/gitdm.py#L316-L348
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/gitdm.py
GitdmParser.__parse_domain_to_employer_line
def __parse_domain_to_employer_line(self, raw_domain, raw_org): """Parse domain to employer lines""" d = re.match(self.DOMAIN_REGEX, raw_domain, re.UNICODE) if not d: cause = "invalid domain format: '%s'" % raw_domain raise InvalidFormatError(cause=cause) dom = ...
python
def __parse_domain_to_employer_line(self, raw_domain, raw_org): """Parse domain to employer lines""" d = re.match(self.DOMAIN_REGEX, raw_domain, re.UNICODE) if not d: cause = "invalid domain format: '%s'" % raw_domain raise InvalidFormatError(cause=cause) dom = ...
[ "def", "__parse_domain_to_employer_line", "(", "self", ",", "raw_domain", ",", "raw_org", ")", ":", "d", "=", "re", ".", "match", "(", "self", ".", "DOMAIN_REGEX", ",", "raw_domain", ",", "re", ".", "UNICODE", ")", "if", "not", "d", ":", "cause", "=", ...
Parse domain to employer lines
[ "Parse", "domain", "to", "employer", "lines" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/gitdm.py#L350-L370
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/log.py
Log.log
def log(self, uuid=None, organization=None, from_date=None, to_date=None): """"List enrollment information available in the registry. Method that returns a list of enrollments. If <uuid> parameter is set, it will return the enrollments related to that unique identity; if <organization> ...
python
def log(self, uuid=None, organization=None, from_date=None, to_date=None): """"List enrollment information available in the registry. Method that returns a list of enrollments. If <uuid> parameter is set, it will return the enrollments related to that unique identity; if <organization> ...
[ "def", "log", "(", "self", ",", "uuid", "=", "None", ",", "organization", "=", "None", ",", "from_date", "=", "None", ",", "to_date", "=", "None", ")", ":", "try", ":", "enrollments", "=", "api", ".", "enrollments", "(", "self", ".", "db", ",", "uu...
List enrollment information available in the registry. Method that returns a list of enrollments. If <uuid> parameter is set, it will return the enrollments related to that unique identity; if <organization> parameter is given, it will return the enrollments related to that organization...
[ "List", "enrollment", "information", "available", "in", "the", "registry", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/log.py#L96-L125
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/init.py
Init.run
def run(self, *args): """Initialize a registry. Create and initialize an empty registry which its name is defined by <name> parameter. Required tables will be also created. """ params = self.parser.parse_args(args) code = self.initialize(name=params.name, reuse=params.r...
python
def run(self, *args): """Initialize a registry. Create and initialize an empty registry which its name is defined by <name> parameter. Required tables will be also created. """ params = self.parser.parse_args(args) code = self.initialize(name=params.name, reuse=params.r...
[ "def", "run", "(", "self", ",", "*", "args", ")", ":", "params", "=", "self", ".", "parser", ".", "parse_args", "(", "args", ")", "code", "=", "self", ".", "initialize", "(", "name", "=", "params", ".", "name", ",", "reuse", "=", "params", ".", "...
Initialize a registry. Create and initialize an empty registry which its name is defined by <name> parameter. Required tables will be also created.
[ "Initialize", "a", "registry", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/init.py#L65-L75
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/init.py
Init.initialize
def initialize(self, name, reuse=False): """Create an empty Sorting Hat registry. This method creates a new database including the schema of Sorting Hat. Any attempt to create a new registry over an existing instance will produce an error, except if reuse=True. In that case, the ...
python
def initialize(self, name, reuse=False): """Create an empty Sorting Hat registry. This method creates a new database including the schema of Sorting Hat. Any attempt to create a new registry over an existing instance will produce an error, except if reuse=True. In that case, the ...
[ "def", "initialize", "(", "self", ",", "name", ",", "reuse", "=", "False", ")", ":", "user", "=", "self", ".", "_kwargs", "[", "'user'", "]", "password", "=", "self", ".", "_kwargs", "[", "'password'", "]", "host", "=", "self", ".", "_kwargs", "[", ...
Create an empty Sorting Hat registry. This method creates a new database including the schema of Sorting Hat. Any attempt to create a new registry over an existing instance will produce an error, except if reuse=True. In that case, the database will be reused, assuming the database sche...
[ "Create", "an", "empty", "Sorting", "Hat", "registry", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/init.py#L77-L116
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/init.py
Init.__load_countries
def __load_countries(self, db): """Load the list of countries""" try: countries = self.__read_countries_file() except IOError as e: raise LoadError(str(e)) try: with db.connect() as session: for country in countries: ...
python
def __load_countries(self, db): """Load the list of countries""" try: countries = self.__read_countries_file() except IOError as e: raise LoadError(str(e)) try: with db.connect() as session: for country in countries: ...
[ "def", "__load_countries", "(", "self", ",", "db", ")", ":", "try", ":", "countries", "=", "self", ".", "__read_countries_file", "(", ")", "except", "IOError", "as", "e", ":", "raise", "LoadError", "(", "str", "(", "e", ")", ")", "try", ":", "with", ...
Load the list of countries
[ "Load", "the", "list", "of", "countries" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/init.py#L118-L131
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/init.py
Init.__read_countries_file
def __read_countries_file(self): """Read countries from a CSV file""" import csv import pkg_resources filename = pkg_resources.resource_filename('sortinghat', 'data/countries.csv') with open(filename, 'r') as f: reader = csv.DictReader(f, fieldnames=['name', 'code',...
python
def __read_countries_file(self): """Read countries from a CSV file""" import csv import pkg_resources filename = pkg_resources.resource_filename('sortinghat', 'data/countries.csv') with open(filename, 'r') as f: reader = csv.DictReader(f, fieldnames=['name', 'code',...
[ "def", "__read_countries_file", "(", "self", ")", ":", "import", "csv", "import", "pkg_resources", "filename", "=", "pkg_resources", ".", "resource_filename", "(", "'sortinghat'", ",", "'data/countries.csv'", ")", "with", "open", "(", "filename", ",", "'r'", ")", ...
Read countries from a CSV file
[ "Read", "countries", "from", "a", "CSV", "file" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/init.py#L133-L144
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/remove.py
Remove.run
def run(self, *args): """Remove unique identities or identities from the registry. By default, it removes the unique identity identified by <identifier>. To remove an identity, set <identity> parameter. """ params = self.parser.parse_args(args) identifier = params.ident...
python
def run(self, *args): """Remove unique identities or identities from the registry. By default, it removes the unique identity identified by <identifier>. To remove an identity, set <identity> parameter. """ params = self.parser.parse_args(args) identifier = params.ident...
[ "def", "run", "(", "self", ",", "*", "args", ")", ":", "params", "=", "self", ".", "parser", ".", "parse_args", "(", "args", ")", "identifier", "=", "params", ".", "identifier", "identity", "=", "params", ".", "identity", "code", "=", "self", ".", "r...
Remove unique identities or identities from the registry. By default, it removes the unique identity identified by <identifier>. To remove an identity, set <identity> parameter.
[ "Remove", "unique", "identities", "or", "identities", "from", "the", "registry", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/remove.py#L71-L84
train
chaoss/grimoirelab-sortinghat
sortinghat/utils.py
merge_date_ranges
def merge_date_ranges(dates): """Merge date ranges. Generator that merges ovelaped data ranges. Default init and end dates (1900-01-01 and 2100-01-01) are considered range limits and will be removed when a set of ranges overlap. For example: * [(1900-01-01, 2010-01-01), (2008-01-01, 2100-01-01)]...
python
def merge_date_ranges(dates): """Merge date ranges. Generator that merges ovelaped data ranges. Default init and end dates (1900-01-01 and 2100-01-01) are considered range limits and will be removed when a set of ranges overlap. For example: * [(1900-01-01, 2010-01-01), (2008-01-01, 2100-01-01)]...
[ "def", "merge_date_ranges", "(", "dates", ")", ":", "if", "not", "dates", ":", "return", "sorted_dates", "=", "sorted", "(", "[", "sorted", "(", "t", ")", "for", "t", "in", "dates", "]", ")", "saved", "=", "list", "(", "sorted_dates", "[", "0", "]", ...
Merge date ranges. Generator that merges ovelaped data ranges. Default init and end dates (1900-01-01 and 2100-01-01) are considered range limits and will be removed when a set of ranges overlap. For example: * [(1900-01-01, 2010-01-01), (2008-01-01, 2100-01-01)] --> (2008-01-01, 2010-01-...
[ "Merge", "date", "ranges", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/utils.py#L33-L84
train
chaoss/grimoirelab-sortinghat
sortinghat/utils.py
uuid
def uuid(source, email=None, name=None, username=None): """Get the UUID related to the identity data. Based on the input data, the function will return the UUID associated to an identity. On this version, the UUID will be the SHA1 of "source:email:name:username" string. This string is case insensitive,...
python
def uuid(source, email=None, name=None, username=None): """Get the UUID related to the identity data. Based on the input data, the function will return the UUID associated to an identity. On this version, the UUID will be the SHA1 of "source:email:name:username" string. This string is case insensitive,...
[ "def", "uuid", "(", "source", ",", "email", "=", "None", ",", "name", "=", "None", ",", "username", "=", "None", ")", ":", "if", "source", "is", "None", ":", "raise", "ValueError", "(", "\"source cannot be None\"", ")", "if", "source", "==", "''", ":",...
Get the UUID related to the identity data. Based on the input data, the function will return the UUID associated to an identity. On this version, the UUID will be the SHA1 of "source:email:name:username" string. This string is case insensitive, which means same values for the input parameters in upper ...
[ "Get", "the", "UUID", "related", "to", "the", "identity", "data", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/utils.py#L122-L167
train
chaoss/grimoirelab-sortinghat
sortinghat/db/database.py
create_database_engine
def create_database_engine(user, password, database, host, port): """Create a database engine""" driver = 'mysql+pymysql' url = URL(driver, user, password, host, port, database, query={'charset': 'utf8mb4'}) return create_engine(url, poolclass=QueuePool, pool_size...
python
def create_database_engine(user, password, database, host, port): """Create a database engine""" driver = 'mysql+pymysql' url = URL(driver, user, password, host, port, database, query={'charset': 'utf8mb4'}) return create_engine(url, poolclass=QueuePool, pool_size...
[ "def", "create_database_engine", "(", "user", ",", "password", ",", "database", ",", "host", ",", "port", ")", ":", "driver", "=", "'mysql+pymysql'", "url", "=", "URL", "(", "driver", ",", "user", ",", "password", ",", "host", ",", "port", ",", "database...
Create a database engine
[ "Create", "a", "database", "engine" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/db/database.py#L170-L178
train
chaoss/grimoirelab-sortinghat
sortinghat/db/database.py
create_database_session
def create_database_session(engine): """Connect to the database""" try: Session = sessionmaker(bind=engine) return Session() except OperationalError as e: raise DatabaseError(error=e.orig.args[1], code=e.orig.args[0])
python
def create_database_session(engine): """Connect to the database""" try: Session = sessionmaker(bind=engine) return Session() except OperationalError as e: raise DatabaseError(error=e.orig.args[1], code=e.orig.args[0])
[ "def", "create_database_session", "(", "engine", ")", ":", "try", ":", "Session", "=", "sessionmaker", "(", "bind", "=", "engine", ")", "return", "Session", "(", ")", "except", "OperationalError", "as", "e", ":", "raise", "DatabaseError", "(", "error", "=", ...
Connect to the database
[ "Connect", "to", "the", "database" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/db/database.py#L181-L188
train
chaoss/grimoirelab-sortinghat
sortinghat/db/database.py
close_database_session
def close_database_session(session): """Close connection with the database""" try: session.close() except OperationalError as e: raise DatabaseError(error=e.orig.args[1], code=e.orig.args[0])
python
def close_database_session(session): """Close connection with the database""" try: session.close() except OperationalError as e: raise DatabaseError(error=e.orig.args[1], code=e.orig.args[0])
[ "def", "close_database_session", "(", "session", ")", ":", "try", ":", "session", ".", "close", "(", ")", "except", "OperationalError", "as", "e", ":", "raise", "DatabaseError", "(", "error", "=", "e", ".", "orig", ".", "args", "[", "1", "]", ",", "cod...
Close connection with the database
[ "Close", "connection", "with", "the", "database" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/db/database.py#L191-L197
train
chaoss/grimoirelab-sortinghat
sortinghat/db/database.py
reflect_table
def reflect_table(engine, klass): """Inspect and reflect objects""" try: meta = MetaData() meta.reflect(bind=engine) except OperationalError as e: raise DatabaseError(error=e.orig.args[1], code=e.orig.args[0]) # Try to reflect from any of the supported tables table = None ...
python
def reflect_table(engine, klass): """Inspect and reflect objects""" try: meta = MetaData() meta.reflect(bind=engine) except OperationalError as e: raise DatabaseError(error=e.orig.args[1], code=e.orig.args[0]) # Try to reflect from any of the supported tables table = None ...
[ "def", "reflect_table", "(", "engine", ",", "klass", ")", ":", "try", ":", "meta", "=", "MetaData", "(", ")", "meta", ".", "reflect", "(", "bind", "=", "engine", ")", "except", "OperationalError", "as", "e", ":", "raise", "DatabaseError", "(", "error", ...
Inspect and reflect objects
[ "Inspect", "and", "reflect", "objects" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/db/database.py#L200-L225
train
chaoss/grimoirelab-sortinghat
sortinghat/db/database.py
find_model_by_table_name
def find_model_by_table_name(name): """Find a model reference by its table name""" for model in ModelBase._decl_class_registry.values(): if hasattr(model, '__table__') and model.__table__.fullname == name: return model return None
python
def find_model_by_table_name(name): """Find a model reference by its table name""" for model in ModelBase._decl_class_registry.values(): if hasattr(model, '__table__') and model.__table__.fullname == name: return model return None
[ "def", "find_model_by_table_name", "(", "name", ")", ":", "for", "model", "in", "ModelBase", ".", "_decl_class_registry", ".", "values", "(", ")", ":", "if", "hasattr", "(", "model", ",", "'__table__'", ")", "and", "model", ".", "__table__", ".", "fullname",...
Find a model reference by its table name
[ "Find", "a", "model", "reference", "by", "its", "table", "name" ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/db/database.py#L228-L234
train
chaoss/grimoirelab-sortinghat
sortinghat/db/database.py
Database.handle_database_error
def handle_database_error(cls, session, exception): """Rollback changes made and handle any type of error raised by the DBMS.""" session.rollback() if isinstance(exception, IntegrityError): cls.handle_integrity_error(exception) elif isinstance(exception, FlushError): ...
python
def handle_database_error(cls, session, exception): """Rollback changes made and handle any type of error raised by the DBMS.""" session.rollback() if isinstance(exception, IntegrityError): cls.handle_integrity_error(exception) elif isinstance(exception, FlushError): ...
[ "def", "handle_database_error", "(", "cls", ",", "session", ",", "exception", ")", ":", "session", ".", "rollback", "(", ")", "if", "isinstance", "(", "exception", ",", "IntegrityError", ")", ":", "cls", ".", "handle_integrity_error", "(", "exception", ")", ...
Rollback changes made and handle any type of error raised by the DBMS.
[ "Rollback", "changes", "made", "and", "handle", "any", "type", "of", "error", "raised", "by", "the", "DBMS", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/db/database.py#L113-L123
train
chaoss/grimoirelab-sortinghat
sortinghat/db/database.py
Database.handle_integrity_error
def handle_integrity_error(cls, exception): """Handle integrity error exceptions.""" m = re.match(cls.MYSQL_INSERT_ERROR_REGEX, exception.statement) if not m: raise exception model = find_model_by_table_name(m.group('table')) if not model: ...
python
def handle_integrity_error(cls, exception): """Handle integrity error exceptions.""" m = re.match(cls.MYSQL_INSERT_ERROR_REGEX, exception.statement) if not m: raise exception model = find_model_by_table_name(m.group('table')) if not model: ...
[ "def", "handle_integrity_error", "(", "cls", ",", "exception", ")", ":", "m", "=", "re", ".", "match", "(", "cls", ".", "MYSQL_INSERT_ERROR_REGEX", ",", "exception", ".", "statement", ")", "if", "not", "m", ":", "raise", "exception", "model", "=", "find_mo...
Handle integrity error exceptions.
[ "Handle", "integrity", "error", "exceptions", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/db/database.py#L126-L149
train
chaoss/grimoirelab-sortinghat
sortinghat/db/database.py
Database.handle_flush_error
def handle_flush_error(cls, exception): """Handle flush error exceptions.""" trace = exception.args[0] m = re.match(cls.MYSQL_FLUSH_ERROR_REGEX, trace) if not m: raise exception entity = m.group('entity') eid = m.group('eid') raise AlreadyExistsErr...
python
def handle_flush_error(cls, exception): """Handle flush error exceptions.""" trace = exception.args[0] m = re.match(cls.MYSQL_FLUSH_ERROR_REGEX, trace) if not m: raise exception entity = m.group('entity') eid = m.group('eid') raise AlreadyExistsErr...
[ "def", "handle_flush_error", "(", "cls", ",", "exception", ")", ":", "trace", "=", "exception", ".", "args", "[", "0", "]", "m", "=", "re", ".", "match", "(", "cls", ".", "MYSQL_FLUSH_ERROR_REGEX", ",", "trace", ")", "if", "not", "m", ":", "raise", "...
Handle flush error exceptions.
[ "Handle", "flush", "error", "exceptions", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/db/database.py#L152-L164
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/affiliate.py
Affiliate.run
def run(self, *args): """Affiliate unique identities to organizations.""" self.parser.parse_args(args) code = self.affiliate() return code
python
def run(self, *args): """Affiliate unique identities to organizations.""" self.parser.parse_args(args) code = self.affiliate() return code
[ "def", "run", "(", "self", ",", "*", "args", ")", ":", "self", ".", "parser", ".", "parse_args", "(", "args", ")", "code", "=", "self", ".", "affiliate", "(", ")", "return", "code" ]
Affiliate unique identities to organizations.
[ "Affiliate", "unique", "identities", "to", "organizations", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/affiliate.py#L62-L69
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/affiliate.py
Affiliate.affiliate
def affiliate(self): """Affiliate unique identities. This method enrolls unique identities to organizations using email addresses and top/sub domains data. Only new enrollments will be created. """ try: uidentities = api.unique_identities(self.db) for ui...
python
def affiliate(self): """Affiliate unique identities. This method enrolls unique identities to organizations using email addresses and top/sub domains data. Only new enrollments will be created. """ try: uidentities = api.unique_identities(self.db) for ui...
[ "def", "affiliate", "(", "self", ")", ":", "try", ":", "uidentities", "=", "api", ".", "unique_identities", "(", "self", ".", "db", ")", "for", "uid", "in", "uidentities", ":", "uid", ".", "identities", ".", "sort", "(", "key", "=", "lambda", "x", ":...
Affiliate unique identities. This method enrolls unique identities to organizations using email addresses and top/sub domains data. Only new enrollments will be created.
[ "Affiliate", "unique", "identities", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/affiliate.py#L71-L121
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/countries.py
Countries.run
def run(self, *args): """Show information about countries.""" params = self.parser.parse_args(args) ct = params.code_or_term if ct and len(ct) < 2: self.error('Code country or term must have 2 or more characters length') return CODE_INVALID_FORMAT_ERROR ...
python
def run(self, *args): """Show information about countries.""" params = self.parser.parse_args(args) ct = params.code_or_term if ct and len(ct) < 2: self.error('Code country or term must have 2 or more characters length') return CODE_INVALID_FORMAT_ERROR ...
[ "def", "run", "(", "self", ",", "*", "args", ")", ":", "params", "=", "self", ".", "parser", ".", "parse_args", "(", "args", ")", "ct", "=", "params", ".", "code_or_term", "if", "ct", "and", "len", "(", "ct", ")", "<", "2", ":", "self", ".", "e...
Show information about countries.
[ "Show", "information", "about", "countries", "." ]
391cd37a75fea26311dc6908bc1c953c540a8e04
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/countries.py#L64-L85
train
rigetti/rpcq
rpcq/_client.py
Client._call_async
async def _call_async(self, method_name: str, *args, **kwargs): """ Sends a request to the socket and then wait for the reply. To deal with multiple, asynchronous requests we do not expect that the receive reply task scheduled from this call is the one that receives this call's reply an...
python
async def _call_async(self, method_name: str, *args, **kwargs): """ Sends a request to the socket and then wait for the reply. To deal with multiple, asynchronous requests we do not expect that the receive reply task scheduled from this call is the one that receives this call's reply an...
[ "async", "def", "_call_async", "(", "self", ",", "method_name", ":", "str", ",", "*", "args", ",", "**", "kwargs", ")", ":", "request", "=", "utils", ".", "rpc_request", "(", "method_name", ",", "*", "args", ",", "**", "kwargs", ")", "_log", ".", "de...
Sends a request to the socket and then wait for the reply. To deal with multiple, asynchronous requests we do not expect that the receive reply task scheduled from this call is the one that receives this call's reply and instead rely on Events to signal across multiple _async_call/_recv_reply t...
[ "Sends", "a", "request", "to", "the", "socket", "and", "then", "wait", "for", "the", "reply", "." ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_client.py#L97-L123
train
rigetti/rpcq
rpcq/_client.py
Client._recv_reply
async def _recv_reply(self): """ Helper task to recieve a reply store the result and trigger the associated event. """ raw_reply, = await self._async_socket.recv_multipart() reply = from_msgpack(raw_reply) _log.debug("Received reply: %s", reply) self._replies[repl...
python
async def _recv_reply(self): """ Helper task to recieve a reply store the result and trigger the associated event. """ raw_reply, = await self._async_socket.recv_multipart() reply = from_msgpack(raw_reply) _log.debug("Received reply: %s", reply) self._replies[repl...
[ "async", "def", "_recv_reply", "(", "self", ")", ":", "raw_reply", ",", "=", "await", "self", ".", "_async_socket", ".", "recv_multipart", "(", ")", "reply", "=", "from_msgpack", "(", "raw_reply", ")", "_log", ".", "debug", "(", "\"Received reply: %s\"", ","...
Helper task to recieve a reply store the result and trigger the associated event.
[ "Helper", "task", "to", "recieve", "a", "reply", "store", "the", "result", "and", "trigger", "the", "associated", "event", "." ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_client.py#L125-L133
train
rigetti/rpcq
rpcq/_client.py
Client.call
def call(self, method_name: str, *args, rpc_timeout: float = None, **kwargs): """ Send JSON RPC request to a backend socket and receive reply Note that this uses the default event loop to run in a blocking manner. If you would rather run in an async fashion or provide your own event loop...
python
def call(self, method_name: str, *args, rpc_timeout: float = None, **kwargs): """ Send JSON RPC request to a backend socket and receive reply Note that this uses the default event loop to run in a blocking manner. If you would rather run in an async fashion or provide your own event loop...
[ "def", "call", "(", "self", ",", "method_name", ":", "str", ",", "*", "args", ",", "rpc_timeout", ":", "float", "=", "None", ",", "**", "kwargs", ")", ":", "request", "=", "utils", ".", "rpc_request", "(", "method_name", ",", "*", "args", ",", "**", ...
Send JSON RPC request to a backend socket and receive reply Note that this uses the default event loop to run in a blocking manner. If you would rather run in an async fashion or provide your own event loop then use .async_call instead :param method_name: Method name :param args: Args t...
[ "Send", "JSON", "RPC", "request", "to", "a", "backend", "socket", "and", "receive", "reply", "Note", "that", "this", "uses", "the", "default", "event", "loop", "to", "run", "in", "a", "blocking", "manner", ".", "If", "you", "would", "rather", "run", "in"...
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_client.py#L135-L182
train
rigetti/rpcq
rpcq/_client.py
Client.close
def close(self): """ Close the sockets """ self._socket.close() if self._async_socket_cache: self._async_socket_cache.close() self._async_socket_cache = None
python
def close(self): """ Close the sockets """ self._socket.close() if self._async_socket_cache: self._async_socket_cache.close() self._async_socket_cache = None
[ "def", "close", "(", "self", ")", ":", "self", ".", "_socket", ".", "close", "(", ")", "if", "self", ".", "_async_socket_cache", ":", "self", ".", "_async_socket_cache", ".", "close", "(", ")", "self", ".", "_async_socket_cache", "=", "None" ]
Close the sockets
[ "Close", "the", "sockets" ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_client.py#L184-L191
train
rigetti/rpcq
rpcq/_client.py
Client._connect_to_socket
def _connect_to_socket(self, context: zmq.Context, endpoint: str): """ Connect to a DEALER socket at endpoint and turn off lingering. :param context: ZMQ Context to use (potentially async) :param endpoint: Endpoint :return: Connected socket """ socket = context.s...
python
def _connect_to_socket(self, context: zmq.Context, endpoint: str): """ Connect to a DEALER socket at endpoint and turn off lingering. :param context: ZMQ Context to use (potentially async) :param endpoint: Endpoint :return: Connected socket """ socket = context.s...
[ "def", "_connect_to_socket", "(", "self", ",", "context", ":", "zmq", ".", "Context", ",", "endpoint", ":", "str", ")", ":", "socket", "=", "context", ".", "socket", "(", "zmq", ".", "DEALER", ")", "socket", ".", "connect", "(", "endpoint", ")", "socke...
Connect to a DEALER socket at endpoint and turn off lingering. :param context: ZMQ Context to use (potentially async) :param endpoint: Endpoint :return: Connected socket
[ "Connect", "to", "a", "DEALER", "socket", "at", "endpoint", "and", "turn", "off", "lingering", "." ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_client.py#L193-L205
train
rigetti/rpcq
rpcq/_client.py
Client._async_socket
def _async_socket(self): """ Creates a new async socket if one doesn't already exist for this Client """ if not self._async_socket_cache: self._async_socket_cache = self._connect_to_socket(zmq.asyncio.Context(), self.endpoint) return self._async_socket_cache
python
def _async_socket(self): """ Creates a new async socket if one doesn't already exist for this Client """ if not self._async_socket_cache: self._async_socket_cache = self._connect_to_socket(zmq.asyncio.Context(), self.endpoint) return self._async_socket_cache
[ "def", "_async_socket", "(", "self", ")", ":", "if", "not", "self", ".", "_async_socket_cache", ":", "self", ".", "_async_socket_cache", "=", "self", ".", "_connect_to_socket", "(", "zmq", ".", "asyncio", ".", "Context", "(", ")", ",", "self", ".", "endpoi...
Creates a new async socket if one doesn't already exist for this Client
[ "Creates", "a", "new", "async", "socket", "if", "one", "doesn", "t", "already", "exist", "for", "this", "Client" ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_client.py#L208-L215
train
rigetti/rpcq
rpcq/_server.py
Server.run
def run(self, endpoint: str, loop: AbstractEventLoop = None): """ Run server main task. :param endpoint: Socket endpoint to listen to, e.g. "tcp://*:1234" :param loop: Event loop to run server in (alternatively just use run_async method) """ if not loop: loop...
python
def run(self, endpoint: str, loop: AbstractEventLoop = None): """ Run server main task. :param endpoint: Socket endpoint to listen to, e.g. "tcp://*:1234" :param loop: Event loop to run server in (alternatively just use run_async method) """ if not loop: loop...
[ "def", "run", "(", "self", ",", "endpoint", ":", "str", ",", "loop", ":", "AbstractEventLoop", "=", "None", ")", ":", "if", "not", "loop", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "try", ":", "loop", ".", "run_until_complete", "(",...
Run server main task. :param endpoint: Socket endpoint to listen to, e.g. "tcp://*:1234" :param loop: Event loop to run server in (alternatively just use run_async method)
[ "Run", "server", "main", "task", "." ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_server.py#L132-L145
train
rigetti/rpcq
rpcq/_server.py
Server._shutdown
def _shutdown(self): """ Shut down the server. """ for exit_handler in self._exit_handlers: exit_handler() if self._socket: self._socket.close() self._socket = None
python
def _shutdown(self): """ Shut down the server. """ for exit_handler in self._exit_handlers: exit_handler() if self._socket: self._socket.close() self._socket = None
[ "def", "_shutdown", "(", "self", ")", ":", "for", "exit_handler", "in", "self", ".", "_exit_handlers", ":", "exit_handler", "(", ")", "if", "self", ".", "_socket", ":", "self", ".", "_socket", ".", "close", "(", ")", "self", ".", "_socket", "=", "None"...
Shut down the server.
[ "Shut", "down", "the", "server", "." ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_server.py#L153-L162
train
rigetti/rpcq
rpcq/_server.py
Server._connect
def _connect(self, endpoint: str): """ Connect the server to an endpoint. Creates a ZMQ ROUTER socket for the given endpoint. :param endpoint: Socket endpoint, e.g. "tcp://*:1234" """ if self._socket: raise RuntimeError('Cannot run multiple Servers on the same socket...
python
def _connect(self, endpoint: str): """ Connect the server to an endpoint. Creates a ZMQ ROUTER socket for the given endpoint. :param endpoint: Socket endpoint, e.g. "tcp://*:1234" """ if self._socket: raise RuntimeError('Cannot run multiple Servers on the same socket...
[ "def", "_connect", "(", "self", ",", "endpoint", ":", "str", ")", ":", "if", "self", ".", "_socket", ":", "raise", "RuntimeError", "(", "'Cannot run multiple Servers on the same socket'", ")", "context", "=", "zmq", ".", "asyncio", ".", "Context", "(", ")", ...
Connect the server to an endpoint. Creates a ZMQ ROUTER socket for the given endpoint. :param endpoint: Socket endpoint, e.g. "tcp://*:1234"
[ "Connect", "the", "server", "to", "an", "endpoint", ".", "Creates", "a", "ZMQ", "ROUTER", "socket", "for", "the", "given", "endpoint", "." ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_server.py#L164-L177
train
rigetti/rpcq
rpcq/_server.py
Server._process_request
async def _process_request(self, identity: bytes, empty_frame: list, request: RPCRequest): """ Executes the method specified in a JSON RPC request and then sends the reply to the socket. :param identity: Client identity provided by ZeroMQ :param empty_frame: Either an empty list or a si...
python
async def _process_request(self, identity: bytes, empty_frame: list, request: RPCRequest): """ Executes the method specified in a JSON RPC request and then sends the reply to the socket. :param identity: Client identity provided by ZeroMQ :param empty_frame: Either an empty list or a si...
[ "async", "def", "_process_request", "(", "self", ",", "identity", ":", "bytes", ",", "empty_frame", ":", "list", ",", "request", ":", "RPCRequest", ")", ":", "try", ":", "_log", ".", "debug", "(", "\"Client %s sent request: %s\"", ",", "identity", ",", "requ...
Executes the method specified in a JSON RPC request and then sends the reply to the socket. :param identity: Client identity provided by ZeroMQ :param empty_frame: Either an empty list or a single null frame depending on the client type :param request: JSON RPC request
[ "Executes", "the", "method", "specified", "in", "a", "JSON", "RPC", "request", "and", "then", "sends", "the", "reply", "to", "the", "socket", "." ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_server.py#L179-L201
train
rigetti/rpcq
rpcq/_spec.py
RPCSpec.add_handler
def add_handler(self, f): """ Adds the function f to a dictionary of JSON RPC methods. :param callable f: Method to be exposed :return: """ if f.__name__.startswith('rpc_'): raise ValueError("Server method names cannot start with rpc_.") self._json_rp...
python
def add_handler(self, f): """ Adds the function f to a dictionary of JSON RPC methods. :param callable f: Method to be exposed :return: """ if f.__name__.startswith('rpc_'): raise ValueError("Server method names cannot start with rpc_.") self._json_rp...
[ "def", "add_handler", "(", "self", ",", "f", ")", ":", "if", "f", ".", "__name__", ".", "startswith", "(", "'rpc_'", ")", ":", "raise", "ValueError", "(", "\"Server method names cannot start with rpc_.\"", ")", "self", ".", "_json_rpc_methods", "[", "f", ".", ...
Adds the function f to a dictionary of JSON RPC methods. :param callable f: Method to be exposed :return:
[ "Adds", "the", "function", "f", "to", "a", "dictionary", "of", "JSON", "RPC", "methods", "." ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_spec.py#L74-L84
train
rigetti/rpcq
rpcq/_spec.py
RPCSpec.get_handler
def get_handler(self, request): """ Get callable from JSON RPC request :param RPCRequest request: JSON RPC request :return: Method :rtype: callable """ try: f = self._json_rpc_methods[request.method] except (AttributeError, KeyError): # prag...
python
def get_handler(self, request): """ Get callable from JSON RPC request :param RPCRequest request: JSON RPC request :return: Method :rtype: callable """ try: f = self._json_rpc_methods[request.method] except (AttributeError, KeyError): # prag...
[ "def", "get_handler", "(", "self", ",", "request", ")", ":", "try", ":", "f", "=", "self", ".", "_json_rpc_methods", "[", "request", ".", "method", "]", "except", "(", "AttributeError", ",", "KeyError", ")", ":", "raise", "RPCMethodError", "(", "\"Received...
Get callable from JSON RPC request :param RPCRequest request: JSON RPC request :return: Method :rtype: callable
[ "Get", "callable", "from", "JSON", "RPC", "request" ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_spec.py#L86-L100
train
rigetti/rpcq
rpcq/_spec.py
RPCSpec.run_handler
async def run_handler(self, request: RPCRequest) -> Union[RPCReply, RPCError]: """ Process a JSON RPC request :param RPCRequest request: JSON RPC request :return: JSON RPC reply """ with catch_warnings(record=True) as warnings: try: rpc_handle...
python
async def run_handler(self, request: RPCRequest) -> Union[RPCReply, RPCError]: """ Process a JSON RPC request :param RPCRequest request: JSON RPC request :return: JSON RPC reply """ with catch_warnings(record=True) as warnings: try: rpc_handle...
[ "async", "def", "run_handler", "(", "self", ",", "request", ":", "RPCRequest", ")", "->", "Union", "[", "RPCReply", ",", "RPCError", "]", ":", "with", "catch_warnings", "(", "record", "=", "True", ")", "as", "warnings", ":", "try", ":", "rpc_handler", "=...
Process a JSON RPC request :param RPCRequest request: JSON RPC request :return: JSON RPC reply
[ "Process", "a", "JSON", "RPC", "request" ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_spec.py#L102-L135
train
rigetti/rpcq
rpcq/_utils.py
rpc_request
def rpc_request(method_name: str, *args, **kwargs) -> rpcq.messages.RPCRequest: """ Create RPC request :param method_name: Method name :param args: Positional arguments :param kwargs: Keyword arguments :return: JSON RPC formatted dict """ if args: kwargs['*args'] = args ret...
python
def rpc_request(method_name: str, *args, **kwargs) -> rpcq.messages.RPCRequest: """ Create RPC request :param method_name: Method name :param args: Positional arguments :param kwargs: Keyword arguments :return: JSON RPC formatted dict """ if args: kwargs['*args'] = args ret...
[ "def", "rpc_request", "(", "method_name", ":", "str", ",", "*", "args", ",", "**", "kwargs", ")", "->", "rpcq", ".", "messages", ".", "RPCRequest", ":", "if", "args", ":", "kwargs", "[", "'*args'", "]", "=", "args", "return", "rpcq", ".", "messages", ...
Create RPC request :param method_name: Method name :param args: Positional arguments :param kwargs: Keyword arguments :return: JSON RPC formatted dict
[ "Create", "RPC", "request" ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_utils.py#L28-L45
train
rigetti/rpcq
rpcq/_utils.py
rpc_reply
def rpc_reply(id: Union[str, int], result: Optional[object], warnings: Optional[List[Warning]] = None) -> rpcq.messages.RPCReply: """ Create RPC reply :param str|int id: Request ID :param result: Result :param warnings: List of warnings to attach to the message :return: JSON RPC f...
python
def rpc_reply(id: Union[str, int], result: Optional[object], warnings: Optional[List[Warning]] = None) -> rpcq.messages.RPCReply: """ Create RPC reply :param str|int id: Request ID :param result: Result :param warnings: List of warnings to attach to the message :return: JSON RPC f...
[ "def", "rpc_reply", "(", "id", ":", "Union", "[", "str", ",", "int", "]", ",", "result", ":", "Optional", "[", "object", "]", ",", "warnings", ":", "Optional", "[", "List", "[", "Warning", "]", "]", "=", "None", ")", "->", "rpcq", ".", "messages", ...
Create RPC reply :param str|int id: Request ID :param result: Result :param warnings: List of warnings to attach to the message :return: JSON RPC formatted dict
[ "Create", "RPC", "reply" ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_utils.py#L48-L65
train
rigetti/rpcq
rpcq/_utils.py
rpc_error
def rpc_error(id: Union[str, int], error_msg: str, warnings: List[Any] = []) -> rpcq.messages.RPCError: """ Create RPC error :param id: Request ID :param error_msg: Error message :param warning: List of warnings to attach to the message :return: JSON RPC formatted dict """ ...
python
def rpc_error(id: Union[str, int], error_msg: str, warnings: List[Any] = []) -> rpcq.messages.RPCError: """ Create RPC error :param id: Request ID :param error_msg: Error message :param warning: List of warnings to attach to the message :return: JSON RPC formatted dict """ ...
[ "def", "rpc_error", "(", "id", ":", "Union", "[", "str", ",", "int", "]", ",", "error_msg", ":", "str", ",", "warnings", ":", "List", "[", "Any", "]", "=", "[", "]", ")", "->", "rpcq", ".", "messages", ".", "RPCError", ":", "return", "rpcq", ".",...
Create RPC error :param id: Request ID :param error_msg: Error message :param warning: List of warnings to attach to the message :return: JSON RPC formatted dict
[ "Create", "RPC", "error" ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_utils.py#L68-L82
train
rigetti/rpcq
rpcq/_utils.py
get_input
def get_input(params: Union[dict, list]) -> Tuple[list, dict]: """ Get positional or keyword arguments from JSON RPC params :param params: Parameters passed through JSON RPC :return: args, kwargs """ # Backwards compatibility for old clients that send params as a list if isinstance(params, ...
python
def get_input(params: Union[dict, list]) -> Tuple[list, dict]: """ Get positional or keyword arguments from JSON RPC params :param params: Parameters passed through JSON RPC :return: args, kwargs """ # Backwards compatibility for old clients that send params as a list if isinstance(params, ...
[ "def", "get_input", "(", "params", ":", "Union", "[", "dict", ",", "list", "]", ")", "->", "Tuple", "[", "list", ",", "dict", "]", ":", "if", "isinstance", "(", "params", ",", "list", ")", ":", "args", "=", "params", "kwargs", "=", "{", "}", "eli...
Get positional or keyword arguments from JSON RPC params :param params: Parameters passed through JSON RPC :return: args, kwargs
[ "Get", "positional", "or", "keyword", "arguments", "from", "JSON", "RPC", "params" ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_utils.py#L85-L103
train
rigetti/rpcq
rpcq/_base.py
repr_value
def repr_value(value): """ Represent a value in human readable form. For long list's this truncates the printed representation. :param value: The value to represent. :return: A string representation. :rtype: basestring """ if isinstance(value, list) and len(value) > REPR_LIST_TRUNCATION...
python
def repr_value(value): """ Represent a value in human readable form. For long list's this truncates the printed representation. :param value: The value to represent. :return: A string representation. :rtype: basestring """ if isinstance(value, list) and len(value) > REPR_LIST_TRUNCATION...
[ "def", "repr_value", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", "and", "len", "(", "value", ")", ">", "REPR_LIST_TRUNCATION", ":", "return", "\"[{},...]\"", ".", "format", "(", "\", \"", ".", "join", "(", "map", "(", "r...
Represent a value in human readable form. For long list's this truncates the printed representation. :param value: The value to represent. :return: A string representation. :rtype: basestring
[ "Represent", "a", "value", "in", "human", "readable", "form", ".", "For", "long", "list", "s", "this", "truncates", "the", "printed", "representation", "." ]
9091e3541c4419d7ab882bb32a8b86aa85cedb6f
https://github.com/rigetti/rpcq/blob/9091e3541c4419d7ab882bb32a8b86aa85cedb6f/rpcq/_base.py#L28-L40
train
klen/graphite-beacon
graphite_beacon/alerts.py
AlertFabric.get
def get(cls, reactor, source='graphite', **options): """Get Alert Class by source.""" acls = cls.alerts[source] return acls(reactor, **options)
python
def get(cls, reactor, source='graphite', **options): """Get Alert Class by source.""" acls = cls.alerts[source] return acls(reactor, **options)
[ "def", "get", "(", "cls", ",", "reactor", ",", "source", "=", "'graphite'", ",", "**", "options", ")", ":", "acls", "=", "cls", ".", "alerts", "[", "source", "]", "return", "acls", "(", "reactor", ",", "**", "options", ")" ]
Get Alert Class by source.
[ "Get", "Alert", "Class", "by", "source", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/alerts.py#L52-L55
train
klen/graphite-beacon
graphite_beacon/alerts.py
BaseAlert.convert
def convert(self, value): """Convert self value.""" try: return convert_to_format(value, self._format) except (ValueError, TypeError): return value
python
def convert(self, value): """Convert self value.""" try: return convert_to_format(value, self._format) except (ValueError, TypeError): return value
[ "def", "convert", "(", "self", ",", "value", ")", ":", "try", ":", "return", "convert_to_format", "(", "value", ",", "self", ".", "_format", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "return", "value" ]
Convert self value.
[ "Convert", "self", "value", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/alerts.py#L144-L149
train
klen/graphite-beacon
graphite_beacon/alerts.py
BaseAlert.check
def check(self, records): """Check current value.""" for value, target in records: LOGGER.info("%s [%s]: %s", self.name, target, value) if value is None: self.notify(self.no_data, value, target) continue for rule in self.rules: ...
python
def check(self, records): """Check current value.""" for value, target in records: LOGGER.info("%s [%s]: %s", self.name, target, value) if value is None: self.notify(self.no_data, value, target) continue for rule in self.rules: ...
[ "def", "check", "(", "self", ",", "records", ")", ":", "for", "value", ",", "target", "in", "records", ":", "LOGGER", ".", "info", "(", "\"%s [%s]: %s\"", ",", "self", ".", "name", ",", "target", ",", "value", ")", "if", "value", "is", "None", ":", ...
Check current value.
[ "Check", "current", "value", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/alerts.py#L168-L182
train
klen/graphite-beacon
graphite_beacon/alerts.py
BaseAlert.evaluate_rule
def evaluate_rule(self, rule, value, target): """Calculate the value.""" def evaluate(expr): if expr in LOGICAL_OPERATORS.values(): return expr rvalue = self.get_value_for_expr(expr, target) if rvalue is None: return False # ignore thi...
python
def evaluate_rule(self, rule, value, target): """Calculate the value.""" def evaluate(expr): if expr in LOGICAL_OPERATORS.values(): return expr rvalue = self.get_value_for_expr(expr, target) if rvalue is None: return False # ignore thi...
[ "def", "evaluate_rule", "(", "self", ",", "rule", ",", "value", ",", "target", ")", ":", "def", "evaluate", "(", "expr", ")", ":", "if", "expr", "in", "LOGICAL_OPERATORS", ".", "values", "(", ")", ":", "return", "expr", "rvalue", "=", "self", ".", "g...
Calculate the value.
[ "Calculate", "the", "value", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/alerts.py#L184-L199
train
klen/graphite-beacon
graphite_beacon/alerts.py
BaseAlert.get_value_for_expr
def get_value_for_expr(self, expr, target): """I have no idea.""" if expr in LOGICAL_OPERATORS.values(): return None rvalue = expr['value'] if rvalue == HISTORICAL: history = self.history[target] if len(history) < self.history_size: ret...
python
def get_value_for_expr(self, expr, target): """I have no idea.""" if expr in LOGICAL_OPERATORS.values(): return None rvalue = expr['value'] if rvalue == HISTORICAL: history = self.history[target] if len(history) < self.history_size: ret...
[ "def", "get_value_for_expr", "(", "self", ",", "expr", ",", "target", ")", ":", "if", "expr", "in", "LOGICAL_OPERATORS", ".", "values", "(", ")", ":", "return", "None", "rvalue", "=", "expr", "[", "'value'", "]", "if", "rvalue", "==", "HISTORICAL", ":", ...
I have no idea.
[ "I", "have", "no", "idea", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/alerts.py#L201-L213
train
klen/graphite-beacon
graphite_beacon/alerts.py
BaseAlert.notify
def notify(self, level, value, target=None, ntype=None, rule=None): """Notify main reactor about event.""" # Did we see the event before? if target in self.state and level == self.state[target]: return False # Do we see the event first time? if target not in self.sta...
python
def notify(self, level, value, target=None, ntype=None, rule=None): """Notify main reactor about event.""" # Did we see the event before? if target in self.state and level == self.state[target]: return False # Do we see the event first time? if target not in self.sta...
[ "def", "notify", "(", "self", ",", "level", ",", "value", ",", "target", "=", "None", ",", "ntype", "=", "None", ",", "rule", "=", "None", ")", ":", "if", "target", "in", "self", ".", "state", "and", "level", "==", "self", ".", "state", "[", "tar...
Notify main reactor about event.
[ "Notify", "main", "reactor", "about", "event", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/alerts.py#L215-L227
train
klen/graphite-beacon
graphite_beacon/alerts.py
GraphiteAlert.load
def load(self): """Load data from Graphite.""" LOGGER.debug('%s: start checking: %s', self.name, self.query) if self.waiting: self.notify('warning', 'Process takes too much time', target='waiting', ntype='common') else: self.waiting = True try: ...
python
def load(self): """Load data from Graphite.""" LOGGER.debug('%s: start checking: %s', self.name, self.query) if self.waiting: self.notify('warning', 'Process takes too much time', target='waiting', ntype='common') else: self.waiting = True try: ...
[ "def", "load", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "'%s: start checking: %s'", ",", "self", ".", "name", ",", "self", ".", "query", ")", "if", "self", ".", "waiting", ":", "self", ".", "notify", "(", "'warning'", ",", "'Process takes too ...
Load data from Graphite.
[ "Load", "data", "from", "Graphite", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/alerts.py#L259-L285
train
klen/graphite-beacon
graphite_beacon/alerts.py
GraphiteAlert.get_graph_url
def get_graph_url(self, target, graphite_url=None): """Get Graphite URL.""" return self._graphite_url(target, graphite_url=graphite_url, raw_data=False)
python
def get_graph_url(self, target, graphite_url=None): """Get Graphite URL.""" return self._graphite_url(target, graphite_url=graphite_url, raw_data=False)
[ "def", "get_graph_url", "(", "self", ",", "target", ",", "graphite_url", "=", "None", ")", ":", "return", "self", ".", "_graphite_url", "(", "target", ",", "graphite_url", "=", "graphite_url", ",", "raw_data", "=", "False", ")" ]
Get Graphite URL.
[ "Get", "Graphite", "URL", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/alerts.py#L287-L289
train
klen/graphite-beacon
graphite_beacon/alerts.py
GraphiteAlert._graphite_url
def _graphite_url(self, query, raw_data=False, graphite_url=None): """Build Graphite URL.""" query = escape.url_escape(query) graphite_url = graphite_url or self.reactor.options.get('public_graphite_url') url = "{base}/render/?target={query}&from=-{from_time}&until=-{until}".format( ...
python
def _graphite_url(self, query, raw_data=False, graphite_url=None): """Build Graphite URL.""" query = escape.url_escape(query) graphite_url = graphite_url or self.reactor.options.get('public_graphite_url') url = "{base}/render/?target={query}&from=-{from_time}&until=-{until}".format( ...
[ "def", "_graphite_url", "(", "self", ",", "query", ",", "raw_data", "=", "False", ",", "graphite_url", "=", "None", ")", ":", "query", "=", "escape", ".", "url_escape", "(", "query", ")", "graphite_url", "=", "graphite_url", "or", "self", ".", "reactor", ...
Build Graphite URL.
[ "Build", "Graphite", "URL", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/alerts.py#L291-L303
train
klen/graphite-beacon
graphite_beacon/alerts.py
URLAlert.load
def load(self): """Load URL.""" LOGGER.debug('%s: start checking: %s', self.name, self.query) if self.waiting: self.notify('warning', 'Process takes too much time', target='waiting', ntype='common') else: self.waiting = True try: respon...
python
def load(self): """Load URL.""" LOGGER.debug('%s: start checking: %s', self.name, self.query) if self.waiting: self.notify('warning', 'Process takes too much time', target='waiting', ntype='common') else: self.waiting = True try: respon...
[ "def", "load", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "'%s: start checking: %s'", ",", "self", ".", "name", ",", "self", ".", "query", ")", "if", "self", ".", "waiting", ":", "self", ".", "notify", "(", "'warning'", ",", "'Process takes too ...
Load URL.
[ "Load", "URL", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/alerts.py#L318-L337
train
klen/graphite-beacon
graphite_beacon/core.py
_get_loader
def _get_loader(config): """Determine which config file type and loader to use based on a filename. :param config str: filename to config file :return: a tuple of the loader type and callable to load :rtype: (str, Callable) """ if config.endswith('.yml') or config.endswith('.yaml'): if ...
python
def _get_loader(config): """Determine which config file type and loader to use based on a filename. :param config str: filename to config file :return: a tuple of the loader type and callable to load :rtype: (str, Callable) """ if config.endswith('.yml') or config.endswith('.yaml'): if ...
[ "def", "_get_loader", "(", "config", ")", ":", "if", "config", ".", "endswith", "(", "'.yml'", ")", "or", "config", ".", "endswith", "(", "'.yaml'", ")", ":", "if", "not", "yaml", ":", "LOGGER", ".", "error", "(", "\"pyyaml must be installed to use the YAML ...
Determine which config file type and loader to use based on a filename. :param config str: filename to config file :return: a tuple of the loader type and callable to load :rtype: (str, Callable)
[ "Determine", "which", "config", "file", "type", "and", "loader", "to", "use", "based", "on", "a", "filename", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/core.py#L185-L199
train
klen/graphite-beacon
graphite_beacon/core.py
Reactor.start
def start(self, start_loop=True): """Start all the things. :param start_loop bool: whether to start the ioloop. should be False if the IOLoop is managed externally """ self.start_alerts() if self.options.get('pidfile'): with open(self....
python
def start(self, start_loop=True): """Start all the things. :param start_loop bool: whether to start the ioloop. should be False if the IOLoop is managed externally """ self.start_alerts() if self.options.get('pidfile'): with open(self....
[ "def", "start", "(", "self", ",", "start_loop", "=", "True", ")", ":", "self", ".", "start_alerts", "(", ")", "if", "self", ".", "options", ".", "get", "(", "'pidfile'", ")", ":", "with", "open", "(", "self", ".", "options", ".", "get", "(", "'pidf...
Start all the things. :param start_loop bool: whether to start the ioloop. should be False if the IOLoop is managed externally
[ "Start", "all", "the", "things", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/core.py#L148-L162
train
klen/graphite-beacon
graphite_beacon/core.py
Reactor.notify
def notify(self, level, alert, value, target=None, ntype=None, rule=None): """ Provide the event to the handlers. """ LOGGER.info('Notify %s:%s:%s:%s', level, alert, value, target or "") if ntype is None: ntype = alert.source for handler in self.handlers.get(level, []): ...
python
def notify(self, level, alert, value, target=None, ntype=None, rule=None): """ Provide the event to the handlers. """ LOGGER.info('Notify %s:%s:%s:%s', level, alert, value, target or "") if ntype is None: ntype = alert.source for handler in self.handlers.get(level, []): ...
[ "def", "notify", "(", "self", ",", "level", ",", "alert", ",", "value", ",", "target", "=", "None", ",", "ntype", "=", "None", ",", "rule", "=", "None", ")", ":", "LOGGER", ".", "info", "(", "'Notify %s:%s:%s:%s'", ",", "level", ",", "alert", ",", ...
Provide the event to the handlers.
[ "Provide", "the", "event", "to", "the", "handlers", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/core.py#L173-L182
train
klen/graphite-beacon
graphite_beacon/handlers/telegram.py
write_to_file
def write_to_file(chats, chatfile): """called every time chats are modified""" with open(chatfile, 'w') as handler: handler.write('\n'.join((str(id_) for id_ in chats)))
python
def write_to_file(chats, chatfile): """called every time chats are modified""" with open(chatfile, 'w') as handler: handler.write('\n'.join((str(id_) for id_ in chats)))
[ "def", "write_to_file", "(", "chats", ",", "chatfile", ")", ":", "with", "open", "(", "chatfile", ",", "'w'", ")", "as", "handler", ":", "handler", ".", "write", "(", "'\\n'", ".", "join", "(", "(", "str", "(", "id_", ")", "for", "id_", "in", "chat...
called every time chats are modified
[ "called", "every", "time", "chats", "are", "modified" ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/handlers/telegram.py#L174-L177
train
klen/graphite-beacon
graphite_beacon/handlers/telegram.py
get_chatlist
def get_chatlist(chatfile): """Try reading ids of saved chats from file. If we fail, return empty set""" if not chatfile: return set() try: with open(chatfile) as file_contents: return set(int(chat) for chat in file_contents) except (OSError, IOError) as exc: LOGG...
python
def get_chatlist(chatfile): """Try reading ids of saved chats from file. If we fail, return empty set""" if not chatfile: return set() try: with open(chatfile) as file_contents: return set(int(chat) for chat in file_contents) except (OSError, IOError) as exc: LOGG...
[ "def", "get_chatlist", "(", "chatfile", ")", ":", "if", "not", "chatfile", ":", "return", "set", "(", ")", "try", ":", "with", "open", "(", "chatfile", ")", "as", "file_contents", ":", "return", "set", "(", "int", "(", "chat", ")", "for", "chat", "in...
Try reading ids of saved chats from file. If we fail, return empty set
[ "Try", "reading", "ids", "of", "saved", "chats", "from", "file", ".", "If", "we", "fail", "return", "empty", "set" ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/handlers/telegram.py#L180-L190
train
klen/graphite-beacon
graphite_beacon/handlers/telegram.py
get_data
def get_data(upd, bot_ident): """Parse telegram update.""" update_content = json.loads(upd.decode()) result = update_content['result'] data = (get_fields(update, bot_ident) for update in result) return (dt for dt in data if dt is not None)
python
def get_data(upd, bot_ident): """Parse telegram update.""" update_content = json.loads(upd.decode()) result = update_content['result'] data = (get_fields(update, bot_ident) for update in result) return (dt for dt in data if dt is not None)
[ "def", "get_data", "(", "upd", ",", "bot_ident", ")", ":", "update_content", "=", "json", ".", "loads", "(", "upd", ".", "decode", "(", ")", ")", "result", "=", "update_content", "[", "'result'", "]", "data", "=", "(", "get_fields", "(", "update", ",",...
Parse telegram update.
[ "Parse", "telegram", "update", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/handlers/telegram.py#L193-L199
train
klen/graphite-beacon
graphite_beacon/handlers/telegram.py
get_fields
def get_fields(upd, bot_ident): """In telegram api, not every update has message field, and not every message has update field. We skip those cases. Rest of fields are mandatory. We also skip if text is not a valid command to handler. """ msg = upd.get('message', {}) text = msg.get('text') ...
python
def get_fields(upd, bot_ident): """In telegram api, not every update has message field, and not every message has update field. We skip those cases. Rest of fields are mandatory. We also skip if text is not a valid command to handler. """ msg = upd.get('message', {}) text = msg.get('text') ...
[ "def", "get_fields", "(", "upd", ",", "bot_ident", ")", ":", "msg", "=", "upd", ".", "get", "(", "'message'", ",", "{", "}", ")", "text", "=", "msg", ".", "get", "(", "'text'", ")", "if", "not", "text", ":", "return", "chat_id", "=", "msg", "[", ...
In telegram api, not every update has message field, and not every message has update field. We skip those cases. Rest of fields are mandatory. We also skip if text is not a valid command to handler.
[ "In", "telegram", "api", "not", "every", "update", "has", "message", "field", "and", "not", "every", "message", "has", "update", "field", ".", "We", "skip", "those", "cases", ".", "Rest", "of", "fields", "are", "mandatory", ".", "We", "also", "skip", "if...
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/handlers/telegram.py#L202-L216
train
klen/graphite-beacon
graphite_beacon/handlers/telegram.py
TelegramHandler._listen_commands
def _listen_commands(self): """Monitor new updates and send them further to self._respond_commands, where bot actions are decided. """ self._last_update = None update_body = {'timeout': 2} while True: latest = self._last_update # increase...
python
def _listen_commands(self): """Monitor new updates and send them further to self._respond_commands, where bot actions are decided. """ self._last_update = None update_body = {'timeout': 2} while True: latest = self._last_update # increase...
[ "def", "_listen_commands", "(", "self", ")", ":", "self", ".", "_last_update", "=", "None", "update_body", "=", "{", "'timeout'", ":", "2", "}", "while", "True", ":", "latest", "=", "self", ".", "_last_update", "update_body", ".", "update", "(", "{", "'o...
Monitor new updates and send them further to self._respond_commands, where bot actions are decided.
[ "Monitor", "new", "updates", "and", "send", "them", "further", "to", "self", ".", "_respond_commands", "where", "bot", "actions", "are", "decided", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/handlers/telegram.py#L70-L85
train
klen/graphite-beacon
graphite_beacon/handlers/telegram.py
TelegramHandler._respond_commands
def _respond_commands(self, update_response): """Extract commands to bot from update and act accordingly. For description of commands, see HELP_MESSAGE variable on top of this module. """ chatfile = self.chatfile chats = self.chats exc, upd = update_response.exc...
python
def _respond_commands(self, update_response): """Extract commands to bot from update and act accordingly. For description of commands, see HELP_MESSAGE variable on top of this module. """ chatfile = self.chatfile chats = self.chats exc, upd = update_response.exc...
[ "def", "_respond_commands", "(", "self", ",", "update_response", ")", ":", "chatfile", "=", "self", ".", "chatfile", "chats", "=", "self", ".", "chats", "exc", ",", "upd", "=", "update_response", ".", "exception", "(", ")", ",", "update_response", ".", "re...
Extract commands to bot from update and act accordingly. For description of commands, see HELP_MESSAGE variable on top of this module.
[ "Extract", "commands", "to", "bot", "from", "update", "and", "act", "accordingly", ".", "For", "description", "of", "commands", "see", "HELP_MESSAGE", "variable", "on", "top", "of", "this", "module", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/handlers/telegram.py#L88-L144
train
klen/graphite-beacon
graphite_beacon/handlers/telegram.py
TelegramHandler.notify
def notify(self, level, *args, **kwargs): """Sends alerts to telegram chats. This method is called from top level module. Do not rename it. """ LOGGER.debug('Handler (%s) %s', self.name, level) notify_text = self.get_message(level, *args, **kwargs) for chat in s...
python
def notify(self, level, *args, **kwargs): """Sends alerts to telegram chats. This method is called from top level module. Do not rename it. """ LOGGER.debug('Handler (%s) %s', self.name, level) notify_text = self.get_message(level, *args, **kwargs) for chat in s...
[ "def", "notify", "(", "self", ",", "level", ",", "*", "args", ",", "**", "kwargs", ")", ":", "LOGGER", ".", "debug", "(", "'Handler (%s) %s'", ",", "self", ".", "name", ",", "level", ")", "notify_text", "=", "self", ".", "get_message", "(", "level", ...
Sends alerts to telegram chats. This method is called from top level module. Do not rename it.
[ "Sends", "alerts", "to", "telegram", "chats", ".", "This", "method", "is", "called", "from", "top", "level", "module", ".", "Do", "not", "rename", "it", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/handlers/telegram.py#L147-L158
train
klen/graphite-beacon
graphite_beacon/handlers/telegram.py
TelegramHandler.get_message
def get_message(self, level, alert, value, **kwargs): """Standart alert message. Same format across all graphite-beacon handlers. """ target, ntype = kwargs.get('target'), kwargs.get('ntype') msg_type = 'telegram' if ntype == 'graphite' else 'short' tmpl = TEMPLATES[ntyp...
python
def get_message(self, level, alert, value, **kwargs): """Standart alert message. Same format across all graphite-beacon handlers. """ target, ntype = kwargs.get('target'), kwargs.get('ntype') msg_type = 'telegram' if ntype == 'graphite' else 'short' tmpl = TEMPLATES[ntyp...
[ "def", "get_message", "(", "self", ",", "level", ",", "alert", ",", "value", ",", "**", "kwargs", ")", ":", "target", ",", "ntype", "=", "kwargs", ".", "get", "(", "'target'", ")", ",", "kwargs", ".", "get", "(", "'ntype'", ")", "msg_type", "=", "'...
Standart alert message. Same format across all graphite-beacon handlers.
[ "Standart", "alert", "message", ".", "Same", "format", "across", "all", "graphite", "-", "beacon", "handlers", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/handlers/telegram.py#L160-L171
train
klen/graphite-beacon
graphite_beacon/handlers/telegram.py
CustomClient.fetchmaker
def fetchmaker(self, telegram_api_method): """Receives api method as string and returns wrapper around AsyncHTTPClient's fetch method """ fetch = self.client.fetch request = self.url(telegram_api_method) def _fetcher(body, method='POST', headers=None): """Us...
python
def fetchmaker(self, telegram_api_method): """Receives api method as string and returns wrapper around AsyncHTTPClient's fetch method """ fetch = self.client.fetch request = self.url(telegram_api_method) def _fetcher(body, method='POST', headers=None): """Us...
[ "def", "fetchmaker", "(", "self", ",", "telegram_api_method", ")", ":", "fetch", "=", "self", ".", "client", ".", "fetch", "request", "=", "self", ".", "url", "(", "telegram_api_method", ")", "def", "_fetcher", "(", "body", ",", "method", "=", "'POST'", ...
Receives api method as string and returns wrapper around AsyncHTTPClient's fetch method
[ "Receives", "api", "method", "as", "string", "and", "returns", "wrapper", "around", "AsyncHTTPClient", "s", "fetch", "method" ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/handlers/telegram.py#L259-L275
train
klen/graphite-beacon
graphite_beacon/units.py
TimeUnit._normalize_value_ms
def _normalize_value_ms(cls, value): """Normalize a value in ms to the largest unit possible without decimal places. Note that this ignores fractions of a second and always returns a value _at least_ in seconds. :return: the normalized value and unit name :rtype: Tuple[Union[in...
python
def _normalize_value_ms(cls, value): """Normalize a value in ms to the largest unit possible without decimal places. Note that this ignores fractions of a second and always returns a value _at least_ in seconds. :return: the normalized value and unit name :rtype: Tuple[Union[in...
[ "def", "_normalize_value_ms", "(", "cls", ",", "value", ")", ":", "value", "=", "round", "(", "value", "/", "1000", ")", "*", "1000", "sorted_units", "=", "sorted", "(", "cls", ".", "UNITS_IN_MILLISECONDS", ".", "items", "(", ")", ",", "key", "=", "lam...
Normalize a value in ms to the largest unit possible without decimal places. Note that this ignores fractions of a second and always returns a value _at least_ in seconds. :return: the normalized value and unit name :rtype: Tuple[Union[int, float], str]
[ "Normalize", "a", "value", "in", "ms", "to", "the", "largest", "unit", "possible", "without", "decimal", "places", "." ]
c1f071e9f557693bc90f6acbc314994985dc3b77
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/units.py#L101-L118
train