# Path: stackalytics/processor/launchpad_utils.py
# LOG = logging.getLogger(__name__)
# BUG_STATUSES = ['New', 'Incomplete', 'Opinion', 'Invalid', 'Won\'t Fix',
#                 'Expired', 'Confirmed', 'Triaged', 'In Progress',
#                 'Fix Committed', 'Fix Released',
#                 'Incomplete (with response)',
#                 'Incomplete (without response)']
# LP_URI_V1 = 'https://api.launchpad.net/1.0/%s'
# LP_URI_DEVEL = 'https://api.launchpad.net/devel/%s'
# def link_to_launchpad_id(link):
# def lp_profile_by_launchpad_id(launchpad_id):
# def lp_profile_by_email(email):
# def lp_module_exists(module):
# def lp_blueprint_generator(module):
# def lp_bug_generator(module, modified_since):
# 
# Path: stackalytics/processor/user_processor.py
# LOG = logging.getLogger(__name__)
# def make_user_id(emails=None, launchpad_id=None, gerrit_id=None,
#                  member_id=None, github_id=None, ldap_id=None, ci_id=None,
#                  zanata_id=None):
# def store_user(runtime_storage_inst, user):
# def load_user(runtime_storage_inst, seq=None, user_id=None, email=None,
#               launchpad_id=None, gerrit_id=None, member_id=None,
#               github_id=None, ldap_id=None, zanata_id=None):
# def delete_user(runtime_storage_inst, user):
# def update_user_profile(stored_user, user):
# 
# Path: stackalytics/processor/utils.py
# LOG = logging.getLogger(__name__)
# BAD_NAME_SUFFIXES = ['Ltd', 'Pvt', 'Inc', 'GmbH', 'AG', 'Corporation', 'Corp',
#                      'Company', 'Co', 'Group', 'Srl', 'Limited', 'LLC', 'IT']
# BAD_NAME_SUFFIXES_WITH_STOPS = ['S.p.A.', 's.r.o.', 'L.P.', 'B.V.', 'K.K.',
#                                 'd.o.o.']
# def init_config_and_logging(opts):
# def date_to_timestamp(d):
# def date_to_timestamp_ext(d):
# def member_date_to_timestamp(d):
# def iso8601_to_timestamp(s):
# def timestamp_to_date(timestamp):
# def timestamp_to_week(timestamp):
# def week_to_date(week):
# def timestamp_to_day(timestamp):
# def timestamp_to_utc_date(timestamp):
# def round_timestamp_to_day(timestamp):
# def check_email_validity(email):
# def _session_request(session, uri, method):
# def do_request(uri, method='get', session=None):
# def read_uri(uri, session=None):
# def read_json_from_uri(uri, session=None):
# def read_yaml_from_uri(uri):
# def _gzip_decompress(content):
# def read_gzip_from_uri(uri):
# def get_uri_last_modified(uri):
# def cmp_to_key(mycmp):  # ported from python 3
#         def __init__(self, obj):
#         def __lt__(self, other):
#         def __gt__(self, other):
#         def __eq__(self, other):
#         def __le__(self, other):
#         def __ge__(self, other):
#         def __ne__(self, other):
# def make_range(start, stop, step):
# def load_repos(runtime_storage_inst):
# def unwrap_text(text):
# def format_text(s):
#     def replace_dots(match_obj):
# def make_age_string(seconds):
# def merge_records(original, new):
# def get_blueprint_id(module, name):
# def make_bug_id(bug_id, module, release=None):
# def get_patch_id(review_id, patch_number):
# def add_index(sequence, start=1, item_filter=lambda x: True):
# def safe_encode(s):
# def keep_safe_chars(s):
# def make_module_group(module_group_id, name=None, modules=None, tag='module'):
# def normalize_company_name(name):
# def normalize_company_draft(name):
# def validate_lp_display_name(lp_profile):
# def make_pipeline_processor(processors):
#     def get_passes(_processors):
#     def pipeline_processor(record_generator):
#     class K(object):


import bisect
import collections
import copy
import functools
import time
import six
from oslo_log import log as logging
from stackalytics.processor import launchpad_utils
from stackalytics.processor import user_processor
from stackalytics.processor import utils
        if (('date_fix_committed' in record or 'date_fix_released' in record)
                and record['status'] in FIXED_BUGS):
            bug_fixed = record.copy()
            bug_fixed['primary_key'] = 'bugr:' + record['id']
            bug_fixed['record_type'] = 'bugr'
            bug_fixed['launchpad_id'] = record.get('assignee') or '*unassigned'
            # It appears that launchpad automatically sets the
            # date_fix_committed field when a bug moves from an open
            # state to Fix Released, however it isn't clear that this
            # is documented. So, we take the commit date if it is
            # present or the release date if no commit date is
            # present.
            bug_fixed['date'] = (
                record.get('date_fix_committed') or
                record['date_fix_released']
            )

            self._update_record_and_user(bug_fixed)

            yield bug_fixed

    def _process_member(self, record):
        user_id = user_processor.make_user_id(member_id=record['member_id'])
        record['primary_key'] = user_id
        record['date'] = utils.member_date_to_timestamp(record['date_joined'])
        record['author_name'] = record['member_name']
        record['module'] = 'unknown'
        company_draft = record['company_draft']

        company_name = self.domains_index.get(utils.normalize_company_name(

# Path: stackalytics/processor/launchpad_utils.py
# LOG = logging.getLogger(__name__)
# BUG_STATUSES = ['New', 'Incomplete', 'Opinion', 'Invalid', 'Won\'t Fix',
#                 'Expired', 'Confirmed', 'Triaged', 'In Progress',
#                 'Fix Committed', 'Fix Released',
#                 'Incomplete (with response)',
#                 'Incomplete (without response)']
# LP_URI_V1 = 'https://api.launchpad.net/1.0/%s'
# LP_URI_DEVEL = 'https://api.launchpad.net/devel/%s'
# def link_to_launchpad_id(link):
# def lp_profile_by_launchpad_id(launchpad_id):
# def lp_profile_by_email(email):
# def lp_module_exists(module):
# def lp_blueprint_generator(module):
# def lp_bug_generator(module, modified_since):
# 
# Path: stackalytics/processor/user_processor.py
# LOG = logging.getLogger(__name__)
# def make_user_id(emails=None, launchpad_id=None, gerrit_id=None,
#                  member_id=None, github_id=None, ldap_id=None, ci_id=None,
#                  zanata_id=None):
# def store_user(runtime_storage_inst, user):
# def load_user(runtime_storage_inst, seq=None, user_id=None, email=None,
#               launchpad_id=None, gerrit_id=None, member_id=None,
#               github_id=None, ldap_id=None, zanata_id=None):
# def delete_user(runtime_storage_inst, user):
# def update_user_profile(stored_user, user):
# 
# Path: stackalytics/processor/utils.py
# LOG = logging.getLogger(__name__)
# BAD_NAME_SUFFIXES = ['Ltd', 'Pvt', 'Inc', 'GmbH', 'AG', 'Corporation', 'Corp',
#                      'Company', 'Co', 'Group', 'Srl', 'Limited', 'LLC', 'IT']
# BAD_NAME_SUFFIXES_WITH_STOPS = ['S.p.A.', 's.r.o.', 'L.P.', 'B.V.', 'K.K.',
#                                 'd.o.o.']
# def init_config_and_logging(opts):
# def date_to_timestamp(d):
# def date_to_timestamp_ext(d):
# def member_date_to_timestamp(d):
# def iso8601_to_timestamp(s):
# def timestamp_to_date(timestamp):
# def timestamp_to_week(timestamp):
# def week_to_date(week):
# def timestamp_to_day(timestamp):
# def timestamp_to_utc_date(timestamp):
# def round_timestamp_to_day(timestamp):
# def check_email_validity(email):
# def _session_request(session, uri, method):
# def do_request(uri, method='get', session=None):
# def read_uri(uri, session=None):
# def read_json_from_uri(uri, session=None):
# def read_yaml_from_uri(uri):
# def _gzip_decompress(content):
# def read_gzip_from_uri(uri):
# def get_uri_last_modified(uri):
# def cmp_to_key(mycmp):  # ported from python 3
#         def __init__(self, obj):
#         def __lt__(self, other):
#         def __gt__(self, other):
#         def __eq__(self, other):
#         def __le__(self, other):
#         def __ge__(self, other):
#         def __ne__(self, other):
# def make_range(start, stop, step):
# def load_repos(runtime_storage_inst):
# def unwrap_text(text):
# def format_text(s):
#     def replace_dots(match_obj):
# def make_age_string(seconds):
# def merge_records(original, new):
# def get_blueprint_id(module, name):
# def make_bug_id(bug_id, module, release=None):
# def get_patch_id(review_id, patch_number):
# def add_index(sequence, start=1, item_filter=lambda x: True):
# def safe_encode(s):
# def keep_safe_chars(s):
# def make_module_group(module_group_id, name=None, modules=None, tag='module'):
# def normalize_company_name(name):
# def normalize_company_draft(name):
# def validate_lp_display_name(lp_profile):
# def make_pipeline_processor(processors):
#     def get_passes(_processors):
#     def pipeline_processor(record_generator):
#     class K(object):


# Path: stackalytics/processor/record_processor.py
import bisect
import collections
import copy
import functools
import time
import six
from oslo_log import log as logging
from stackalytics.processor import launchpad_utils
from stackalytics.processor import user_processor
from stackalytics.processor import utils

        if (('date_fix_committed' in record or 'date_fix_released' in record)
                and record['status'] in FIXED_BUGS):
            bug_fixed = record.copy()
            bug_fixed['primary_key'] = 'bugr:' + record['id']
            bug_fixed['record_type'] = 'bugr'
            bug_fixed['launchpad_id'] = record.get('assignee') or '*unassigned'
            # It appears that launchpad automatically sets the
            # date_fix_committed field when a bug moves from an open
            # state to Fix Released, however it isn't clear that this
            # is documented. So, we take the commit date if it is
            # present or the release date if no commit date is
            # present.
            bug_fixed['date'] = (
                record.get('date_fix_committed') or
                record['date_fix_released']
            )

            self._update_record_and_user(bug_fixed)

            yield bug_fixed

    def _process_member(self, record):
        user_id = user_processor.make_user_id(member_id=record['member_id'])
        record['primary_key'] = user_id
        record['date'] = utils.member_date_to_timestamp(record['date_joined'])
        record['author_name'] = record['member_name']
        record['module'] = 'unknown'
        company_draft = record['company_draft']

        company_name = self.domains_index.get(utils.normalize_company_name(

            company_draft)) or (utils.normalize_company_draft(company_draft))