def parse_statements(): cfs_elements = case.findall('case-file-statements/case-file-statement') lst = [] for child in cfs_elements: case_file_statements = { 'serial_number': doc_id, 'type_code': get_text_or_none(child, 'type-code/text()'), 'text': get_text_or_none(child, 'text/text()') } lst.append(case_file_statements) dbc.insert_listdict(lst, 'trademark_app_case_file_statements')
def parse_classifications(): classification_elements = case.findall( 'classifications/classification') for child in classification_elements: classifications = {'serial_number': doc_id} classifications_items = ('international_code_total_no', 'us_code_total_no', 'international_code', 'status_code', 'status_date', 'first_use_anywhere_date', 'first_use_in_commerce_date', 'primary_code') for hitem in classifications_items: search_term = hitem.replace('_', '-') + '/text()' classifications[hitem] = get_text_or_none(child, search_term) classification_id = dbc.insert_dict( classifications, 'trademark_app_classifications') code_elements = child.findall('us-code') lst = [] for subchild in code_elements: case_file_us_codes = { 'serial_number': doc_id, 'classification_id': classification_id, 'us_code': subchild.text } lst.append(case_file_us_codes) dbc.insert_listdict(lst, 'trademark_app_us_codes')
def parse_design_searches(): cfds_elements = case.findall('design-searches/design-search') lst = [] for child in cfds_elements: case_file_design_searches = { 'serial_number': doc_id, 'code': get_text_or_none(child, 'code/text()') } lst.append(case_file_design_searches) dbc.insert_listdict(lst, 'trademark_app_design_searches')
def parse_owners(): cfo_elements = case.findall('case-file-owners/case-file-owner') lst = [] for child in cfo_elements: case_file_owners = {'serial_number': doc_id} case_file_owners_items = ('entry_number', 'party_type', 'legal_entity_type_code', 'entity_statement', 'party_name', 'address_1', 'address_2', 'city', 'state', 'country', 'other', 'postcode', 'dba_aka_text', 'composed_of_statement', 'name_change_explanation') for hitem in case_file_owners_items: search_term = hitem.replace('_', '-') + '/text()' case_file_owners[hitem] = get_text_or_none(child, search_term) case_file_owners['nationality'] = get_text_or_none( child, 'nationality/country/text()') lst.append(case_file_owners) dbc.insert_listdict(lst, 'trademark_app_case_file_owners')
def parse_prior_registration_applications(): pra_elements = case.findall( 'prior-registration-applications/prior-registration-application') other_related_in = get_text_or_none( case, 'prior-registration-applications/other-related-in/text()') lst = [] for child in pra_elements: prior_registration_applications = { 'serial_number': doc_id, 'other_related_in': other_related_in, 'relationship_type': get_text_or_none(child, 'relationship-type/text()'), 'number': get_text_or_none(child, 'number/text()') } lst.append(prior_registration_applications) dbc.insert_listdict(lst, 'trademark_app_prior_registration_applications')
def parse_event_statements(): cfes_elements = case.findall( 'case-file-event-statements/case-file-event-statement') lst = [] for child in cfes_elements: case_file_event_statements = { 'serial_number': doc_id, 'code': get_text_or_none(child, 'code/text()'), 'type': get_text_or_none(child, 'type/text()'), 'description_text': get_text_or_none(child, 'description-text/text()'), 'date': get_text_or_none(child, 'date/text()'), 'number': get_text_or_none(child, 'number/text()') } lst.append(case_file_event_statements) dbc.insert_listdict(lst, 'trademark_app_case_file_event_statements')
def parse_madrid_international_filing_record(): mifr_elements = case.findall( 'madrid-international-filing-requests/madrid-international-filing-record' ) for child in mifr_elements: madrid_international_filing_record = {'serial_number': doc_id} madrid_international_filing_record_items = ( 'entry_number', 'reference_number', 'original_filing_date_uspto', 'international_registration_number', 'international_registration_date', 'international_status_code', 'international_status_date', 'irregularity_reply_by_date', 'international_renewal_date') for hitem in madrid_international_filing_record_items: search_term = hitem.replace('_', '-') + '/text()' madrid_international_filing_record[hitem] = get_text_or_none( child, search_term) mifr_id = dbc.insert_dict( madrid_international_filing_record, 'trademark_app_madrid_international_filing_record') mhe_elements = child.findall( 'madrid-history-events/madrid-history-event') lst = [] for subchild in mhe_elements: madrid_history_events = { 'serial_number': doc_id, 'madrid_international_filing_record_id': mifr_id } madrid_history_events_items = ('code', 'date', 'description_text', 'entry_number') for hitem in madrid_history_events_items: search_term = hitem.replace('_', '-') + '/text()' madrid_history_events[hitem] = get_text_or_none( subchild, search_term) lst.append(madrid_history_events) result = dbc.insert_listdict( lst, 'trademark_app_madrid_history_events')
def parse_correspondents(): correspondent_elements = case.findall('correspondent') lst = [] for child in correspondent_elements: case_file_correspondent = {'serial_number': doc_id} case_file_correspondent_items = ('address_1', 'address_2', 'address_3', 'address_4', 'address_5') for hitem in case_file_correspondent_items: search_term = hitem.replace('_', '-') + '/text()' case_file_correspondent[hitem] = get_text_or_none( child, search_term) lst.append(case_file_correspondent) dbc.insert_listdict(lst, 'trademark_app_correspondents')
def parse_foreign_applications(): fa_elements = case.findall('foreign-applications/foreign-application') lst = [] for child in fa_elements: foreign_applications = {'serial_number': doc_id} foreign_applications_items = ( 'filing_date', 'registration_date', 'registration_expiration_date', 'registration_renewal_date', 'registration_renewal_expiration_date', 'entry_number', 'application_number', 'country', 'other', 'registration_number', 'renewal_number', 'foreign_priority_claim_in') for hitem in foreign_applications_items: search_term = hitem.replace('_', '-') + '/text()' foreign_applications[hitem] = get_text_or_none( child, search_term) lst.append(foreign_applications) dbc.insert_listdict(lst, 'trademark_app_foreign_applications')
def parse_international_registration(): cfir_elements = case.findall('international-registration') lst = [] for child in cfir_elements: case_file_international_registration = {'serial_number': doc_id} case_file_international_registration_items = ( 'international_registration_number', 'international_registration_date', 'international_publication_date', 'international_renewal_date', 'auto_protection_date', 'international_death_date', 'international_status_code', 'international_status_date', 'priority_claimed_in', 'priority_claimed_date', 'first_refusal_in') for hitem in case_file_international_registration_items: search_term = hitem.replace('_', '-') + '/text()' case_file_international_registration[hitem] = get_text_or_none( child, search_term) lst.append(case_file_international_registration) dbc.insert_listdict(lst, 'trademark_app_international_registration')