_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q242100
MailmapParser.__parse
train
def __parse(self, stream, has_orgs): """Parse identities and organizations using mailmap format. Mailmap format is a text plain document that stores on each line a map between an email address and its aliases. Each line follows any of the next formats: Proper Name <commit@e...
python
{ "resource": "" }
q242101
MailmapParser.__parse_organizations
train
def __parse_organizations(self, stream): """Parse organizations stream""" for aliases in self.__parse_stream(stream): # Parse identity identity = self.__parse_alias(aliases[1]) uuid = identity.email uid = self._identities.get(uuid, None) if ...
python
{ "resource": "" }
q242102
MailmapParser.__parse_identities
train
def __parse_identities(self, stream): """Parse identities stream""" for aliases in self.__parse_stream(stream): identity = self.__parse_alias(aliases[0]) uuid = identity.email uid = self._identities.get(uuid, None) if not uid: uid = Uniq...
python
{ "resource": "" }
q242103
MailmapParser.__parse_stream
train
def __parse_stream(self, stream): """Generic method to parse mailmap streams""" nline = 0 lines = stream.split('\n') for line in lines: nline += 1 # Ignore blank lines and comments m = re.match(self.LINES_TO_IGNORE_REGEX, line, re.UNICODE) ...
python
{ "resource": "" }
q242104
Merge.run
train
def run(self, *args): """Merge two identities. When <from_uuid> or <to_uuid> are empty the command does not have any effect. The same happens when both <from_uuid> and <to_uuid> are the same unique identity. """ params = self.parser.parse_args(args) from_uuid = ...
python
{ "resource": "" }
q242105
create_identity_matcher
train
def create_identity_matcher(matcher='default', blacklist=None, sources=None, strict=True): """Create an identity matcher of the given type. Factory function that creates an identity matcher object of the type defined on 'matcher' parameter. A blacklist can also be added to i...
python
{ "resource": "" }
q242106
match
train
def match(uidentities, matcher, fastmode=False): """Find matches in a set of unique identities. This function looks for possible similar or equal identities from a set of unique identities. The result will be a list of subsets where each subset is a list of matching identities. When `fastmode` is ...
python
{ "resource": "" }
q242107
_match
train
def _match(filtered, matcher): """Old method to find matches in a set of filtered identities.""" def match_filtered_identities(x, ids, matcher): """Check if an identity matches a set of identities""" for y in ids: if x.uuid == y.uuid: return True if matc...
python
{ "resource": "" }
q242108
_match_with_pandas
train
def _match_with_pandas(filtered, matcher): """Find matches in a set using Pandas' library.""" import pandas data = [fl.to_dict() for fl in filtered] if not data: return [] df = pandas.DataFrame(data) df = df.sort_values(['uuid']) cdfs = [] criteria = matcher.matching_criteri...
python
{ "resource": "" }
q242109
_filter_unique_identities
train
def _filter_unique_identities(uidentities, matcher): """Filter a set of unique identities. This function will use the `matcher` to generate a list of `FilteredIdentity` objects. It will return a tuple with the list of filtered objects, the unique identities not filtered and a table mapping uuids wi...
python
{ "resource": "" }
q242110
_build_matches
train
def _build_matches(matches, uuids, no_filtered, fastmode=False): """Build a list with matching subsets""" result = [] for m in matches: mk = m[0].uuid if not fastmode else m[0] subset = [uuids[mk]] for id_ in m[1:]: uk = id_.uuid if not fastmode else id_ u ...
python
{ "resource": "" }
q242111
_calculate_matches_closures
train
def _calculate_matches_closures(groups): """Find the transitive closure of each unique identity. This function uses a BFS algorithm to build set of matches. For instance, given a list of matched unique identities like A = {A, B}; B = {B,A,C}, C = {C,} and D = {D,} the output will be A = {A, B, C} a...
python
{ "resource": "" }
q242112
EmailNameMatcher.match
train
def match(self, a, b): """Determine if two unique identities are the same. This method compares the email addresses or the names of each identity to check if the given unique identities are the same. When the given unique identities are the same object or share the same UUID, th...
python
{ "resource": "" }
q242113
find_unique_identity
train
def find_unique_identity(session, uuid): """Find a unique identity. Find a unique identity by its UUID using the given `session`. When the unique identity does not exist the function will return `None`. :param session: database session :param uuid: id of the unique identity to find :retur...
python
{ "resource": "" }
q242114
find_identity
train
def find_identity(session, id_): """Find an identity. Find an identity by its ID using the given `session`. When the identity does not exist the function will return `None`. :param session: database session :param id_: id of the identity to find :returns: an identity object; `None` when t...
python
{ "resource": "" }
q242115
find_organization
train
def find_organization(session, name): """Find an organization. Find an organization by its `name` using the given `session`. When the organization does not exist the function will return `None`. :param session: database session :param name: name of the organization to find :returns: an or...
python
{ "resource": "" }
q242116
find_domain
train
def find_domain(session, name): """Find a domain. Find a domain by its domain name using the given `session`. When the domain does not exist the function will return `None`. :param session: database session :param name: name of the domain to find :returns: a domain object; `None` when the...
python
{ "resource": "" }
q242117
find_country
train
def find_country(session, code): """Find a country. Find a country by its ISO-3166 `code` (i.e ES for Spain, US for United States of America) using the given `session. When the country does not exist the function will return `None`. :param session: database session :param code: ISO-3166 co...
python
{ "resource": "" }
q242118
add_unique_identity
train
def add_unique_identity(session, uuid): """Add a unique identity to the session. This function adds a unique identity to the session with `uuid` string as unique identifier. This identifier cannot be empty or `None`. When the unique identity is added, a new empty profile for this object is cre...
python
{ "resource": "" }
q242119
add_identity
train
def add_identity(session, uidentity, identity_id, source, name=None, email=None, username=None): """Add an identity to the session. This function adds a new identity to the session using `identity_id` as its identifier. The new identity will also be linked to the unique identity object...
python
{ "resource": "" }
q242120
delete_identity
train
def delete_identity(session, identity): """Remove an identity from the session. This function removes from the session the identity given in `identity`. Take into account this function does not remove unique identities in the case they get empty. :param session: database session :param identit...
python
{ "resource": "" }
q242121
add_organization
train
def add_organization(session, name): """Add an organization to the session. This function adds a new organization to the session, using the given `name` as an identifier. Name cannot be empty or `None`. It returns a new `Organization` object. :param session: database session :param name: ...
python
{ "resource": "" }
q242122
delete_organization
train
def delete_organization(session, organization): """Remove an organization from the session. Function that removes from the session the organization given in `organization`. Data related such as domains or enrollments are also removed. :param session: database session :param organization: organ...
python
{ "resource": "" }
q242123
add_domain
train
def add_domain(session, organization, domain_name, is_top_domain=False): """Add a domain to the session. This function adds a new domain to the session using `domain_name` as its identifier. The new domain will also be linked to the organization object of `organization`. Values assigned to `domain...
python
{ "resource": "" }
q242124
delete_enrollment
train
def delete_enrollment(session, enrollment): """Remove an enrollment from the session. This function removes from the session the given enrollment. :param session: database session :param enrollment: enrollment to remove """ uidentity = enrollment.uidentity uidentity.last_modified = datetim...
python
{ "resource": "" }
q242125
move_enrollment
train
def move_enrollment(session, enrollment, uidentity): """Move an enrollment to a unique identity. Shifts `enrollment` to the unique identity given in `uidentity`. The function returns whether the operation was executed successfully. When `uidentity` is the unique identity currently related to `...
python
{ "resource": "" }
q242126
add_to_matching_blacklist
train
def add_to_matching_blacklist(session, term): """Add term to the matching blacklist. This function adds a `term` to the matching blacklist. The term to add cannot have a `None` or empty value, on this case an `ValueError` will be raised. :param session: database session :param term: term, word...
python
{ "resource": "" }
q242127
genderize
train
def genderize(name, api_token=None): """Fetch gender from genderize.io""" GENDERIZE_API_URL = "https://api.genderize.io/" TOTAL_RETRIES = 10 MAX_RETRIES = 5 SLEEP_TIME = 0.25 STATUS_FORCELIST = [502] params = { 'name': name } if api_token: params['apikey'] = api_to...
python
{ "resource": "" }
q242128
AutoGender.run
train
def run(self, *args): """Autocomplete gender information.""" params = self.parser.parse_args(args) api_token = params.api_token genderize_all = params.genderize_all code = self.autogender(api_token=api_token, genderize_all=genderize_all) r...
python
{ "resource": "" }
q242129
AutoGender.autogender
train
def autogender(self, api_token=None, genderize_all=False): """Autocomplete gender information of unique identities. Autocomplete unique identities gender using genderize.io API. Only those unique identities without an assigned gender will be updated unless `genderize_all` option is give...
python
{ "resource": "" }
q242130
MozilliansParser.__parse_identities
train
def __parse_identities(self, json): """Parse identities using Mozillians format. The Mozillians identities format is a JSON document under the "results" key. The document should follow the next schema: { "results" : [ { "_url": "https://example.co...
python
{ "resource": "" }
q242131
Organizations.run
train
def run(self, *args): """List, add or delete organizations and domains from the registry. By default, it prints the list of organizations available on the registry. """ params = self.parser.parse_args(args) organization = params.organization domain = params.doma...
python
{ "resource": "" }
q242132
Organizations.add
train
def add(self, organization, domain=None, is_top_domain=False, overwrite=False): """Add organizations and domains to the registry. This method adds the given 'organization' or 'domain' to the registry, but not both at the same time. When 'organization' is the only parameter given, it wi...
python
{ "resource": "" }
q242133
Organizations.delete
train
def delete(self, organization, domain=None): """Remove organizations and domains from the registry. The method removes the given 'organization' or 'domain' from the registry, but not both at the same time. When 'organization' is the only parameter given, it will be removed from ...
python
{ "resource": "" }
q242134
Organizations.registry
train
def registry(self, term=None): """List organizations and domains. When no term is given, the method will list the organizations existing in the registry. If 'term' is set, the method will list only those organizations and domains that match with that term. :param term: term to ...
python
{ "resource": "" }
q242135
create_organizations_parser
train
def create_organizations_parser(stream): """Create an organizations parser for the given stream. Factory function that creates an organizations parser for the given stream. The stream is only used to guess the type of the required parser. :param stream: stream used to guess the type of the parser ...
python
{ "resource": "" }
q242136
Enroll.enroll
train
def enroll(self, uuid, organization, from_date=MIN_PERIOD_DATE, to_date=MAX_PERIOD_DATE, merge=False): """Enroll a unique identity in an organization. This method adds a new relationship between the unique identity, identified by <uuid>, and <organization>. Both entities must exi...
python
{ "resource": "" }
q242137
EclipseParser.__parse_identities
train
def __parse_identities(self, json): """Parse identities using Eclipse format. The Eclipse identities format is a JSON document under the "commiters" key. The document should follow the next schema: { 'committers' : { 'john': { 'affiliations': {...
python
{ "resource": "" }
q242138
EclipseParser.__parse_organizations
train
def __parse_organizations(self, json): """Parse Eclipse organizations. The Eclipse organizations format is a JSON document stored under the "organizations" key. The next JSON shows the structure of the document: { 'organizations' : { '1': { ...
python
{ "resource": "" }
q242139
EclipseParser.__parse_affiliations_json
train
def __parse_affiliations_json(self, affiliations, uuid): """Parse identity's affiliations from a json dict""" enrollments = [] for affiliation in affiliations.values(): name = self.__encode(affiliation['name']) try: start_date = str_to_datetime(affiliat...
python
{ "resource": "" }
q242140
add_unique_identity
train
def add_unique_identity(db, uuid): """Add a unique identity to the registry. This function adds a unique identity to the registry. First, it checks if the unique identifier (uuid) used to create the identity is already on the registry. When it is not found, a new unique identity is created. Otherwi...
python
{ "resource": "" }
q242141
add_organization
train
def add_organization(db, organization): """Add an organization to the registry. This function adds an organization to the registry. It checks first whether the organization is already on the registry. When it is not found, the new organization is added. Otherwise, it raises a 'AlreadyExistsError' e...
python
{ "resource": "" }
q242142
add_domain
train
def add_domain(db, organization, domain, is_top_domain=False, overwrite=False): """Add a domain to the registry. This function adds a new domain to the given organization. The organization must exists on the registry prior to insert the new domain. Otherwise, it will raise a 'NotFoundError' exception. ...
python
{ "resource": "" }
q242143
add_to_matching_blacklist
train
def add_to_matching_blacklist(db, entity): """Add entity to the matching blacklist. This function adds an 'entity' o term to the matching blacklist. The term to add cannot have a None or empty value, in this case a InvalidValueError will be raised. If the given 'entity' exists in the registry, the ...
python
{ "resource": "" }
q242144
delete_unique_identity
train
def delete_unique_identity(db, uuid): """Remove a unique identity from the registry. Function that removes from the registry, the unique identity that matches with uuid. Data related to this identity will be also removed. It checks first whether the unique identity is already on the registry. ...
python
{ "resource": "" }
q242145
delete_from_matching_blacklist
train
def delete_from_matching_blacklist(db, entity): """Remove an blacklisted entity from the registry. This function removes the given blacklisted entity from the registry. It checks first whether the excluded entity is already on the registry. When it is found, the entity is removed. Otherwise, it will ra...
python
{ "resource": "" }
q242146
merge_enrollments
train
def merge_enrollments(db, uuid, organization): """Merge overlapping enrollments. This function merges those enrollments, related to the given 'uuid' and 'organization', that have overlapping dates. Default start and end dates (1900-01-01 and 2100-01-01) are considered range limits and will be remov...
python
{ "resource": "" }
q242147
match_identities
train
def match_identities(db, uuid, matcher): """Search for similar unique identities. The function will search in the registry for similar identities to 'uuid'. The result will be a list matches containing unique identities objects. This list will not(!) include the given unique identity. The criteria...
python
{ "resource": "" }
q242148
unique_identities
train
def unique_identities(db, uuid=None, source=None): """List the unique identities available in the registry. The function returns a list of unique identities. When 'uuid' parameter is set, it will only return the information related to the unique identity identified by 'uuid'. When 'source' is given...
python
{ "resource": "" }
q242149
search_unique_identities
train
def search_unique_identities(db, term, source=None): """Look for unique identities. This function returns those unique identities which match with the given 'term'. The term will be compated with name, email, username and source values of each identity. When `source` is given, this search will be o...
python
{ "resource": "" }
q242150
search_unique_identities_slice
train
def search_unique_identities_slice(db, term, offset, limit): """Look for unique identities using slicing. This function returns those unique identities which match with the given `term`. The term will be compared with name, email, username and source values of each identity. When an empty term is given...
python
{ "resource": "" }
q242151
search_last_modified_identities
train
def search_last_modified_identities(db, after): """Look for the uuids of identities modified on or after a given date. This function returns the uuids of identities modified on the given date or after it. The result is a list of uuids identities. :param db: database manager :param after: look ...
python
{ "resource": "" }
q242152
search_last_modified_unique_identities
train
def search_last_modified_unique_identities(db, after): """Look for the uuids of unique identities modified on or after a given date. This function returns the uuids of unique identities modified on the given date or after it. The result is a list of uuids unique identities. :param db: database...
python
{ "resource": "" }
q242153
search_profiles
train
def search_profiles(db, no_gender=False): """List unique identities profiles. The function will return the list of profiles filtered by the given parameters. When `no_gender` is set, only profiles without gender values will be returned. :param db: database manager :param no_gender: return only...
python
{ "resource": "" }
q242154
registry
train
def registry(db, term=None): """List the organizations available in the registry. The function will return the list of organizations. If term parameter is set, it will only return the information about the organizations which match that term. When the given term does not match with any organization...
python
{ "resource": "" }
q242155
domains
train
def domains(db, domain=None, top=False): """List the domains available in the registry. The function will return the list of domains. Settting the top flag, it will look for those domains that are top domains. If domain parameter is set, it will only return the information about that domain. When ...
python
{ "resource": "" }
q242156
countries
train
def countries(db, code=None, term=None): """List the countries available in the registry. The function will return the list of countries. When either 'code' or 'term' parameters are set, it will only return the information about those countries that match them. Take into account that 'code' is a c...
python
{ "resource": "" }
q242157
enrollments
train
def enrollments(db, uuid=None, organization=None, from_date=None, to_date=None): """List the enrollment information available in the registry. This function will return a list of enrollments. If 'uuid' parameter is set, it will return the enrollments related to that unique identity; if 'organization' p...
python
{ "resource": "" }
q242158
blacklist
train
def blacklist(db, term=None): """List the blacklisted entities available in the registry. The function will return the list of blacklisted entities. If term parameter is set, it will only return the information about the entities which match that term. When the given term does not match with any en...
python
{ "resource": "" }
q242159
Profile.run
train
def run(self, *args): """Endit profile information.""" uuid, kwargs = self.__parse_arguments(*args) code = self.edit_profile(uuid, **kwargs) return code
python
{ "resource": "" }
q242160
Unify.__unify_unique_identities
train
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
{ "resource": "" }
q242161
Unify.__merge
train
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
{ "resource": "" }
q242162
Unify.__display_stats
train
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
{ "resource": "" }
q242163
Unify.__marshal_matches
train
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
{ "resource": "" }
q242164
RecoveryFile.load_matches
train
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
{ "resource": "" }
q242165
RecoveryFile.save_matches
train
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
{ "resource": "" }
q242166
RecoveryFile.__uuid
train
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
{ "resource": "" }
q242167
GrimoireLabParser.__parse
train
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
{ "resource": "" }
q242168
GrimoireLabParser.__parse_identities
train
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
{ "resource": "" }
q242169
GrimoireLabParser.__parse_organizations
train
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
{ "resource": "" }
q242170
GrimoireLabParser.__parse_affiliations_yml
train
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
{ "resource": "" }
q242171
GrimoireLabParser.__force_datetime
train
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
{ "resource": "" }
q242172
GrimoireLabParser.__load_yml
train
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
{ "resource": "" }
q242173
GrimoireLabParser.__validate_email
train
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
{ "resource": "" }
q242174
GrimoireLabParser.__validate_enrollment_periods
train
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
{ "resource": "" }
q242175
SortingHatParser.__parse
train
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
{ "resource": "" }
q242176
SortingHatParser.__parse_blacklist
train
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
{ "resource": "" }
q242177
SortingHatParser.__parse_organizations
train
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
{ "resource": "" }
q242178
Load.run
train
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
{ "resource": "" }
q242179
Load.import_blacklist
train
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
{ "resource": "" }
q242180
Load.import_organizations
train
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
{ "resource": "" }
q242181
Load.import_identities
train
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
{ "resource": "" }
q242182
Load.__load_unique_identities
train
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
{ "resource": "" }
q242183
Load.__reset_unique_identities
train
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
{ "resource": "" }
q242184
Load.__load_unique_identity
train
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
{ "resource": "" }
q242185
Load.__load_profile
train
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
{ "resource": "" }
q242186
Load.__create_profile
train
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
{ "resource": "" }
q242187
Load.__create_profile_from_identities
train
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
{ "resource": "" }
q242188
Load._merge_on_matching
train
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
{ "resource": "" }
q242189
Load._merge
train
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
{ "resource": "" }
q242190
GitdmParser.__parse
train
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
{ "resource": "" }
q242191
GitdmParser.__parse_identities
train
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
{ "resource": "" }
q242192
GitdmParser.__parse_organizations
train
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
{ "resource": "" }
q242193
GitdmParser.__parse_aliases_stream
train
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
{ "resource": "" }
q242194
GitdmParser.__parse_email_to_employer_stream
train
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
{ "resource": "" }
q242195
GitdmParser.__parse_domain_to_employer_stream
train
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
{ "resource": "" }
q242196
GitdmParser.__parse_stream
train
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
{ "resource": "" }
q242197
GitdmParser.__parse_aliases_line
train
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
{ "resource": "" }
q242198
GitdmParser.__parse_email_to_employer_line
train
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
{ "resource": "" }
q242199
GitdmParser.__parse_domain_to_employer_line
train
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
{ "resource": "" }