repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
openstates/billy
billy/importers/legislators.py
activate_legislators
def activate_legislators(current_term, abbr): """ Sets the 'active' flag on legislators and populates top-level district/chamber/party fields for currently serving legislators. """ for legislator in db.legislators.find( {'roles': {'$elemMatch': {settings.LEVEL_FIELD: abbr,...
python
def activate_legislators(current_term, abbr): """ Sets the 'active' flag on legislators and populates top-level district/chamber/party fields for currently serving legislators. """ for legislator in db.legislators.find( {'roles': {'$elemMatch': {settings.LEVEL_FIELD: abbr,...
Sets the 'active' flag on legislators and populates top-level district/chamber/party fields for currently serving legislators.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/importers/legislators.py#L45-L62
openstates/billy
billy/scrape/legislators.py
Person.add_role
def add_role(self, role, term, start_date=None, end_date=None, **kwargs): """ Examples: leg.add_role('member', term='2009', chamber='upper', party='Republican', district='10th') """ self['roles'].append(dict(role=role, term=term, ...
python
def add_role(self, role, term, start_date=None, end_date=None, **kwargs): """ Examples: leg.add_role('member', term='2009', chamber='upper', party='Republican', district='10th') """ self['roles'].append(dict(role=role, term=term, ...
Examples: leg.add_role('member', term='2009', chamber='upper', party='Republican', district='10th')
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/scrape/legislators.py#L46-L56
openstates/billy
billy/scrape/legislators.py
Person.add_office
def add_office(self, type, name, address=None, phone=None, fax=None, email=None, **kwargs): """ Allowed office types: capitol district """ office_dict = dict(type=type, address=address, name=name, phone=phone, fax=fax,...
python
def add_office(self, type, name, address=None, phone=None, fax=None, email=None, **kwargs): """ Allowed office types: capitol district """ office_dict = dict(type=type, address=address, name=name, phone=phone, fax=fax,...
Allowed office types: capitol district
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/scrape/legislators.py#L58-L67
openstates/billy
billy/utils/__init__.py
metadata
def metadata(abbr, __metadata=__metadata): """ Grab the metadata for the given two-letter abbreviation. """ # This data should change very rarely and is queried very often so # cache it here abbr = abbr.lower() if abbr in __metadata: return __metadata[abbr] rv = db.metadata.find_...
python
def metadata(abbr, __metadata=__metadata): """ Grab the metadata for the given two-letter abbreviation. """ # This data should change very rarely and is queried very often so # cache it here abbr = abbr.lower() if abbr in __metadata: return __metadata[abbr] rv = db.metadata.find_...
Grab the metadata for the given two-letter abbreviation.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/utils/__init__.py#L22-L34
openstates/billy
billy/utils/__init__.py
cd
def cd(path): '''Creates the path if it doesn't exist''' old_dir = os.getcwd() try: os.makedirs(path) except OSError: pass os.chdir(path) try: yield finally: os.chdir(old_dir)
python
def cd(path): '''Creates the path if it doesn't exist''' old_dir = os.getcwd() try: os.makedirs(path) except OSError: pass os.chdir(path) try: yield finally: os.chdir(old_dir)
Creates the path if it doesn't exist
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/utils/__init__.py#L147-L158
openstates/billy
billy/importers/utils.py
_get_property_dict
def _get_property_dict(schema): """ given a schema object produce a nested dictionary of fields """ pdict = {} for k, v in schema['properties'].items(): pdict[k] = {} if 'items' in v and 'properties' in v['items']: pdict[k] = _get_property_dict(v['items']) pdict[settings.LEVE...
python
def _get_property_dict(schema): """ given a schema object produce a nested dictionary of fields """ pdict = {} for k, v in schema['properties'].items(): pdict[k] = {} if 'items' in v and 'properties' in v['items']: pdict[k] = _get_property_dict(v['items']) pdict[settings.LEVE...
given a schema object produce a nested dictionary of fields
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/importers/utils.py#L16-L24
openstates/billy
billy/importers/utils.py
insert_with_id
def insert_with_id(obj): """ Generates a unique ID for the supplied legislator/committee/bill and inserts it into the appropriate collection. """ if '_id' in obj: raise ValueError("object already has '_id' field") # add created_at/updated_at on insert obj['created_at'] = datetime.da...
python
def insert_with_id(obj): """ Generates a unique ID for the supplied legislator/committee/bill and inserts it into the appropriate collection. """ if '_id' in obj: raise ValueError("object already has '_id' field") # add created_at/updated_at on insert obj['created_at'] = datetime.da...
Generates a unique ID for the supplied legislator/committee/bill and inserts it into the appropriate collection.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/importers/utils.py#L37-L88
openstates/billy
billy/importers/utils.py
update
def update(old, new, collection, sneaky_update_filter=None): """ update an existing object with a new one, only saving it and setting updated_at if something has changed old old object new new object collection collection to save changed o...
python
def update(old, new, collection, sneaky_update_filter=None): """ update an existing object with a new one, only saving it and setting updated_at if something has changed old old object new new object collection collection to save changed o...
update an existing object with a new one, only saving it and setting updated_at if something has changed old old object new new object collection collection to save changed object to sneaky_update_filter a filter for updates to obj...
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/importers/utils.py#L130-L176
openstates/billy
billy/importers/utils.py
convert_timestamps
def convert_timestamps(obj): """ Convert unix timestamps in the scraper output to python datetimes so that they will be saved properly as Mongo datetimes. """ for key in ('date', 'when', 'end', 'start_date', 'end_date'): value = obj.get(key) if value: try: ...
python
def convert_timestamps(obj): """ Convert unix timestamps in the scraper output to python datetimes so that they will be saved properly as Mongo datetimes. """ for key in ('date', 'when', 'end', 'start_date', 'end_date'): value = obj.get(key) if value: try: ...
Convert unix timestamps in the scraper output to python datetimes so that they will be saved properly as Mongo datetimes.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/importers/utils.py#L179-L196
openstates/billy
billy/importers/utils.py
split_name
def split_name(obj): """ If the supplied legislator/person object is missing 'first_name' or 'last_name' then use name_tools to split. """ if obj['_type'] in ('person', 'legislator'): for key in ('first_name', 'last_name'): if key not in obj or not obj[key]: # Nee...
python
def split_name(obj): """ If the supplied legislator/person object is missing 'first_name' or 'last_name' then use name_tools to split. """ if obj['_type'] in ('person', 'legislator'): for key in ('first_name', 'last_name'): if key not in obj or not obj[key]: # Nee...
If the supplied legislator/person object is missing 'first_name' or 'last_name' then use name_tools to split.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/importers/utils.py#L199-L212
openstates/billy
billy/importers/utils.py
_make_plus_helper
def _make_plus_helper(obj, fields): """ add a + prefix to any fields in obj that aren't in fields """ new_obj = {} for key, value in obj.items(): if key in fields or key.startswith('_'): # if there's a subschema apply it to a list or subdict if fields.get(key): ...
python
def _make_plus_helper(obj, fields): """ add a + prefix to any fields in obj that aren't in fields """ new_obj = {} for key, value in obj.items(): if key in fields or key.startswith('_'): # if there's a subschema apply it to a list or subdict if fields.get(key): ...
add a + prefix to any fields in obj that aren't in fields
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/importers/utils.py#L215-L232
openstates/billy
billy/importers/utils.py
make_plus_fields
def make_plus_fields(obj): """ Add a '+' to the key of non-standard fields. dispatch to recursive _make_plus_helper based on _type field """ fields = standard_fields.get(obj['_type'], dict()) return _make_plus_helper(obj, fields)
python
def make_plus_fields(obj): """ Add a '+' to the key of non-standard fields. dispatch to recursive _make_plus_helper based on _type field """ fields = standard_fields.get(obj['_type'], dict()) return _make_plus_helper(obj, fields)
Add a '+' to the key of non-standard fields. dispatch to recursive _make_plus_helper based on _type field
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/importers/utils.py#L235-L242
openstates/billy
billy/models/metadata.py
Metadata.get_object
def get_object(cls, abbr): ''' This particular model needs its own constructor in order to take advantage of the metadata cache in billy.util, which would otherwise return unwrapped objects. ''' obj = get_metadata(abbr) if obj is None: msg = 'No metada...
python
def get_object(cls, abbr): ''' This particular model needs its own constructor in order to take advantage of the metadata cache in billy.util, which would otherwise return unwrapped objects. ''' obj = get_metadata(abbr) if obj is None: msg = 'No metada...
This particular model needs its own constructor in order to take advantage of the metadata cache in billy.util, which would otherwise return unwrapped objects.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/metadata.py#L88-L98
openstates/billy
billy/models/metadata.py
Metadata.committees_legislators
def committees_legislators(self, *args, **kwargs): '''Return an iterable of committees with all the legislators cached for reference in the Committee model. So do a "select_related" operation on committee members. ''' committees = list(self.committees(*args, **kwargs)) le...
python
def committees_legislators(self, *args, **kwargs): '''Return an iterable of committees with all the legislators cached for reference in the Committee model. So do a "select_related" operation on committee members. ''' committees = list(self.committees(*args, **kwargs)) le...
Return an iterable of committees with all the legislators cached for reference in the Committee model. So do a "select_related" operation on committee members.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/metadata.py#L168-L191
openstates/billy
billy/bin/commands/dump.py
extract_fields
def extract_fields(d, fields, delimiter='|'): """ get values out of an object ``d`` for saving to a csv """ rd = {} for f in fields: v = d.get(f, None) if isinstance(v, (str, unicode)): v = v.encode('utf8') elif isinstance(v, list): v = delimiter.join(v) ...
python
def extract_fields(d, fields, delimiter='|'): """ get values out of an object ``d`` for saving to a csv """ rd = {} for f in fields: v = d.get(f, None) if isinstance(v, (str, unicode)): v = v.encode('utf8') elif isinstance(v, list): v = delimiter.join(v) ...
get values out of an object ``d`` for saving to a csv
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/bin/commands/dump.py#L46-L56
openstates/billy
billy/web/public/views/bills.py
bill
def bill(request, abbr, session, bill_id): ''' Context: - vote_preview_row_template - abbr - metadata - bill - show_all_sponsors - sponsors - sources - nav_active Templates: - billy/web/public/bill.html - billy/web/public/vote_...
python
def bill(request, abbr, session, bill_id): ''' Context: - vote_preview_row_template - abbr - metadata - bill - show_all_sponsors - sponsors - sources - nav_active Templates: - billy/web/public/bill.html - billy/web/public/vote_...
Context: - vote_preview_row_template - abbr - metadata - bill - show_all_sponsors - sponsors - sources - nav_active Templates: - billy/web/public/bill.html - billy/web/public/vote_preview_row.html
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/bills.py#L360-L401
openstates/billy
billy/web/public/views/bills.py
vote
def vote(request, abbr, vote_id): ''' Context: - abbr - metadata - bill - vote - nav_active Templates: - vote.html ''' vote = db.votes.find_one(vote_id) if vote is None: raise Http404('no such vote: {0}'.format(vote_id)) bill = vote.bi...
python
def vote(request, abbr, vote_id): ''' Context: - abbr - metadata - bill - vote - nav_active Templates: - vote.html ''' vote = db.votes.find_one(vote_id) if vote is None: raise Http404('no such vote: {0}'.format(vote_id)) bill = vote.bi...
Context: - abbr - metadata - bill - vote - nav_active Templates: - vote.html
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/bills.py#L404-L425
openstates/billy
billy/web/public/views/bills.py
document
def document(request, abbr, session, bill_id, doc_id): ''' Context: - abbr - session - bill - version - metadata - nav_active Templates: - billy/web/public/document.html ''' # get fixed version fixed_bill_id = fix_bill_id(bill_id) # re...
python
def document(request, abbr, session, bill_id, doc_id): ''' Context: - abbr - session - bill - version - metadata - nav_active Templates: - billy/web/public/document.html ''' # get fixed version fixed_bill_id = fix_bill_id(bill_id) # re...
Context: - abbr - session - bill - version - metadata - nav_active Templates: - billy/web/public/document.html
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/bills.py#L428-L465
openstates/billy
billy/web/public/views/bills.py
show_all
def show_all(key): ''' Context: - abbr - metadata - bill - sources - nav_active Templates: - billy/web/public/bill_all_{key}.html - where key is passed in, like "actions", etc. ''' def func(request, abbr, session, bill_id, key): # ...
python
def show_all(key): ''' Context: - abbr - metadata - bill - sources - nav_active Templates: - billy/web/public/bill_all_{key}.html - where key is passed in, like "actions", etc. ''' def func(request, abbr, session, bill_id, key): # ...
Context: - abbr - metadata - bill - sources - nav_active Templates: - billy/web/public/bill_all_{key}.html - where key is passed in, like "actions", etc.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/bills.py#L473-L503
openstates/billy
billy/web/public/views/bills.py
RelatedBillsList.get_context_data
def get_context_data(self, *args, **kwargs): ''' Context: If GET parameters are given: - search_text - form (FilterBillsForm) - long_description - description - get_params Otherwise, the only context item is an unbound F...
python
def get_context_data(self, *args, **kwargs): ''' Context: If GET parameters are given: - search_text - form (FilterBillsForm) - long_description - description - get_params Otherwise, the only context item is an unbound F...
Context: If GET parameters are given: - search_text - form (FilterBillsForm) - long_description - description - get_params Otherwise, the only context item is an unbound FilterBillsForm. Templates: - Are specified i...
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/bills.py#L29-L123
openstates/billy
billy/web/public/views/region.py
region_selection
def region_selection(request): '''Handle submission of the region selection form in the base template. ''' form = get_region_select_form(request.GET) abbr = form.data.get('abbr') if not abbr or len(abbr) != 2: return redirect('homepage') return redirect('region', abbr=abbr)
python
def region_selection(request): '''Handle submission of the region selection form in the base template. ''' form = get_region_select_form(request.GET) abbr = form.data.get('abbr') if not abbr or len(abbr) != 2: return redirect('homepage') return redirect('region', abbr=abbr)
Handle submission of the region selection form in the base template.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/region.py#L17-L23
openstates/billy
billy/web/public/views/region.py
region
def region(request, abbr): ''' Context: - abbr - metadata - sessions - chambers - joint_committee_count - geo_bounds - nav_active Templates: - bill/web/public/region.html ''' report = db.reports.find_one({'_id': abbr}) try: ...
python
def region(request, abbr): ''' Context: - abbr - metadata - sessions - chambers - joint_committee_count - geo_bounds - nav_active Templates: - bill/web/public/region.html ''' report = db.reports.find_one({'_id': abbr}) try: ...
Context: - abbr - metadata - sessions - chambers - joint_committee_count - geo_bounds - nav_active Templates: - bill/web/public/region.html
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/region.py#L26-L103
openstates/billy
billy/web/public/views/region.py
search
def search(request, abbr): ''' Context: - search_text - abbr - metadata - found_by_id - bill_results - more_bills_available - legislators_list - nav_active Tempaltes: - billy/web/public/search_results_no_query.html - billy/web/...
python
def search(request, abbr): ''' Context: - search_text - abbr - metadata - found_by_id - bill_results - more_bills_available - legislators_list - nav_active Tempaltes: - billy/web/public/search_results_no_query.html - billy/web/...
Context: - search_text - abbr - metadata - found_by_id - bill_results - more_bills_available - legislators_list - nav_active Tempaltes: - billy/web/public/search_results_no_query.html - billy/web/public/search_results_bills_legislators...
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/region.py#L106-L185
openstates/billy
billy/scrape/committees.py
Committee.add_member
def add_member(self, legislator, role='member', **kwargs): """ Add a member to the committee object. :param legislator: name of the legislator :param role: role that legislator holds in the committee (eg. chairman) default: 'member' """ self['members'].append...
python
def add_member(self, legislator, role='member', **kwargs): """ Add a member to the committee object. :param legislator: name of the legislator :param role: role that legislator holds in the committee (eg. chairman) default: 'member' """ self['members'].append...
Add a member to the committee object. :param legislator: name of the legislator :param role: role that legislator holds in the committee (eg. chairman) default: 'member'
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/scrape/committees.py#L32-L41
openstates/billy
billy/models/bills.py
Action.action_display
def action_display(self): '''The action text, with any hyperlinked related entities.''' action = self['action'] annotations = [] abbr = self.bill[settings.LEVEL_FIELD] if 'related_entities' in self: for entity in self['related_entities']: name = entity...
python
def action_display(self): '''The action text, with any hyperlinked related entities.''' action = self['action'] annotations = [] abbr = self.bill[settings.LEVEL_FIELD] if 'related_entities' in self: for entity in self['related_entities']: name = entity...
The action text, with any hyperlinked related entities.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/bills.py#L129-L151
openstates/billy
billy/models/bills.py
ActionsManager._bytype
def _bytype(self, action_type, action_spec=None): '''Return the most recent date on which action_type occurred. Action spec is a dictionary of key-value attrs to match.''' for action in reversed(self.bill['actions']): if action_type in action['type']: for k, v in acti...
python
def _bytype(self, action_type, action_spec=None): '''Return the most recent date on which action_type occurred. Action spec is a dictionary of key-value attrs to match.''' for action in reversed(self.bill['actions']): if action_type in action['type']: for k, v in acti...
Return the most recent date on which action_type occurred. Action spec is a dictionary of key-value attrs to match.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/bills.py#L161-L168
openstates/billy
billy/models/bills.py
BillVote._ratio
def _ratio(self, key): '''Return the yes/total ratio as a percetage string suitable for use as as css attribute.''' total = float(self._total_votes()) try: return math.floor(self[key] / total * 100) except ZeroDivisionError: return float(0)
python
def _ratio(self, key): '''Return the yes/total ratio as a percetage string suitable for use as as css attribute.''' total = float(self._total_votes()) try: return math.floor(self[key] / total * 100) except ZeroDivisionError: return float(0)
Return the yes/total ratio as a percetage string suitable for use as as css attribute.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/bills.py#L199-L206
openstates/billy
billy/models/bills.py
BillVote._legislator_objects
def _legislator_objects(self): '''A cache of dereferenced legislator objects. ''' kwargs = {} id_getter = operator.itemgetter('leg_id') ids = [] for k in ('yes', 'no', 'other'): ids.extend(map(id_getter, self[k + '_votes'])) objs = db.legislators.find...
python
def _legislator_objects(self): '''A cache of dereferenced legislator objects. ''' kwargs = {} id_getter = operator.itemgetter('leg_id') ids = [] for k in ('yes', 'no', 'other'): ids.extend(map(id_getter, self[k + '_votes'])) objs = db.legislators.find...
A cache of dereferenced legislator objects.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/bills.py#L226-L245
openstates/billy
billy/models/bills.py
BillVote.legislator_vote_value
def legislator_vote_value(self): '''If this vote was accessed through the legislator.votes_manager, return the value of this legislator's vote. ''' if not hasattr(self, 'legislator'): msg = ('legislator_vote_value can only be called ' 'from a vote accessed ...
python
def legislator_vote_value(self): '''If this vote was accessed through the legislator.votes_manager, return the value of this legislator's vote. ''' if not hasattr(self, 'legislator'): msg = ('legislator_vote_value can only be called ' 'from a vote accessed ...
If this vote was accessed through the legislator.votes_manager, return the value of this legislator's vote.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/bills.py#L248-L260
openstates/billy
billy/models/bills.py
BillVote._vote_legislators
def _vote_legislators(self, yes_no_other): '''Return all legislators who votes yes/no/other on this bill. ''' #id_getter = operator.itemgetter('leg_id') #ids = map(id_getter, self['%s_votes' % yes_no_other]) #return map(self._legislator_objects.get, ids) result = [] ...
python
def _vote_legislators(self, yes_no_other): '''Return all legislators who votes yes/no/other on this bill. ''' #id_getter = operator.itemgetter('leg_id') #ids = map(id_getter, self['%s_votes' % yes_no_other]) #return map(self._legislator_objects.get, ids) result = [] ...
Return all legislators who votes yes/no/other on this bill.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/bills.py#L262-L274
openstates/billy
billy/models/bills.py
BillVote.is_probably_a_voice_vote
def is_probably_a_voice_vote(self): '''Guess whether this vote is a "voice vote".''' if '+voice_vote' in self: return True if '+vote_type' in self: if self['+vote_type'] == 'Voice': return True if 'voice vote' in self['motion'].lower(): ...
python
def is_probably_a_voice_vote(self): '''Guess whether this vote is a "voice vote".''' if '+voice_vote' in self: return True if '+vote_type' in self: if self['+vote_type'] == 'Voice': return True if 'voice vote' in self['motion'].lower(): ...
Guess whether this vote is a "voice vote".
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/bills.py#L291-L300
openstates/billy
billy/models/events.py
Event.bill_objects
def bill_objects(self): '''Returns a cursor of full bill objects for any bills that have ids. Not in use anyware as of 12/18/12, but handy to have around. ''' bills = [] for bill in self['related_bills']: if 'id' in bill: bills.append(bill['id']) ...
python
def bill_objects(self): '''Returns a cursor of full bill objects for any bills that have ids. Not in use anyware as of 12/18/12, but handy to have around. ''' bills = [] for bill in self['related_bills']: if 'id' in bill: bills.append(bill['id']) ...
Returns a cursor of full bill objects for any bills that have ids. Not in use anyware as of 12/18/12, but handy to have around.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/events.py#L22-L30
openstates/billy
billy/models/events.py
Event.host
def host(self): '''Return the host committee. ''' _id = None for participant in self['participants']: if participant['type'] == 'host': if set(['participant_type', 'id']) < set(participant): # This event uses the id keyname "id". ...
python
def host(self): '''Return the host committee. ''' _id = None for participant in self['participants']: if participant['type'] == 'host': if set(['participant_type', 'id']) < set(participant): # This event uses the id keyname "id". ...
Return the host committee.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/events.py#L62-L76
openstates/billy
billy/models/events.py
Event.host_chairs
def host_chairs(self): '''Returns a list of members that chair the host committee, including "co-chair" and "chairperson." This could concievalby yield a false positive if the person's title is 'dunce chair'. ''' chairs = [] # Host is guaranteed to be a committe or none. ...
python
def host_chairs(self): '''Returns a list of members that chair the host committee, including "co-chair" and "chairperson." This could concievalby yield a false positive if the person's title is 'dunce chair'. ''' chairs = [] # Host is guaranteed to be a committe or none. ...
Returns a list of members that chair the host committee, including "co-chair" and "chairperson." This could concievalby yield a false positive if the person's title is 'dunce chair'.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/events.py#L83-L96
openstates/billy
billy/models/events.py
Event.host_members
def host_members(self): '''Return the members of the host committee. ''' host = self.host() if host is None: return for member, full_member in host.members_objects: yield full_member
python
def host_members(self): '''Return the members of the host committee. ''' host = self.host() if host is None: return for member, full_member in host.members_objects: yield full_member
Return the members of the host committee.
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/models/events.py#L103-L110
openstates/billy
billy/web/public/views/committees.py
committees
def committees(request, abbr): ''' Context: chamber committees abbr metadata chamber_name chamber_select_template chamber_select_collection chamber_select_chambers committees_table_template show_chamber_column sort_order ...
python
def committees(request, abbr): ''' Context: chamber committees abbr metadata chamber_name chamber_select_template chamber_select_collection chamber_select_chambers committees_table_template show_chamber_column sort_order ...
Context: chamber committees abbr metadata chamber_name chamber_select_template chamber_select_collection chamber_select_chambers committees_table_template show_chamber_column sort_order nav_active Templates: - b...
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/committees.py#L19-L85
openstates/billy
billy/web/public/views/committees.py
committee
def committee(request, abbr, committee_id): ''' Context: - committee - abbr - metadata - sources - nav_active Tempaltes: - billy/web/public/committee.html ''' committee = db.committees.find_one({'_id': committee_id}) if committee is None: ...
python
def committee(request, abbr, committee_id): ''' Context: - committee - abbr - metadata - sources - nav_active Tempaltes: - billy/web/public/committee.html ''' committee = db.committees.find_one({'_id': committee_id}) if committee is None: ...
Context: - committee - abbr - metadata - sources - nav_active Tempaltes: - billy/web/public/committee.html
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/committees.py#L89-L109
openstates/billy
billy/reports/utils.py
update_common
def update_common(obj, report): """ do updated_at checks """ # updated checks if obj['updated_at'] >= yesterday: report['_updated_today_count'] += 1 if obj['updated_at'] >= last_month: report['_updated_this_month_count'] += 1 if obj['updated_at'] >= last_year: ...
python
def update_common(obj, report): """ do updated_at checks """ # updated checks if obj['updated_at'] >= yesterday: report['_updated_today_count'] += 1 if obj['updated_at'] >= last_month: report['_updated_this_month_count'] += 1 if obj['updated_at'] >= last_year: ...
do updated_at checks
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/reports/utils.py#L11-L19
openstates/billy
billy/web/public/views/legislators.py
legislators
def legislators(request, abbr): ''' Context: - metadata - chamber - chamber_title - chamber_select_template - chamber_select_collection - chamber_select_chambers - show_chamber_column - abbr - legislators - sort_order - sort...
python
def legislators(request, abbr): ''' Context: - metadata - chamber - chamber_title - chamber_select_template - chamber_select_collection - chamber_select_chambers - show_chamber_column - abbr - legislators - sort_order - sort...
Context: - metadata - chamber - chamber_title - chamber_select_template - chamber_select_collection - chamber_select_chambers - show_chamber_column - abbr - legislators - sort_order - sort_key - legislator_table - na...
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/legislators.py#L25-L106
openstates/billy
billy/web/public/views/legislators.py
legislator
def legislator(request, abbr, _id, slug=None): ''' Context: - vote_preview_row_template - roles - abbr - district_id - metadata - legislator - sources - sponsored_bills - legislator_votes - has_votes - nav_active Templa...
python
def legislator(request, abbr, _id, slug=None): ''' Context: - vote_preview_row_template - roles - abbr - district_id - metadata - legislator - sources - sponsored_bills - legislator_votes - has_votes - nav_active Templa...
Context: - vote_preview_row_template - roles - abbr - district_id - metadata - legislator - sources - sponsored_bills - legislator_votes - has_votes - nav_active Templates: - billy/web/public/legislator.html - b...
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/legislators.py#L110-L173
openstates/billy
billy/web/public/views/legislators.py
legislator_inactive
def legislator_inactive(request, abbr, legislator): ''' Context: - vote_preview_row_template - old_roles - abbr - metadata - legislator - sources - sponsored_bills - legislator_votes - has_votes - nav_active Templates: ...
python
def legislator_inactive(request, abbr, legislator): ''' Context: - vote_preview_row_template - old_roles - abbr - metadata - legislator - sources - sponsored_bills - legislator_votes - has_votes - nav_active Templates: ...
Context: - vote_preview_row_template - old_roles - abbr - metadata - legislator - sources - sponsored_bills - legislator_votes - has_votes - nav_active Templates: - billy/web/public/legislator.html - billy/web/public/vo...
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/web/public/views/legislators.py#L176-L211
inspirehep/inspire-dojson
inspire_dojson/utils/__init__.py
normalize_rank
def normalize_rank(rank): """Normalize a rank in order to be schema-compliant.""" normalized_ranks = { 'BA': 'UNDERGRADUATE', 'BACHELOR': 'UNDERGRADUATE', 'BS': 'UNDERGRADUATE', 'BSC': 'UNDERGRADUATE', 'JUNIOR': 'JUNIOR', 'MAS': 'MASTER', 'MASTER': 'MASTER...
python
def normalize_rank(rank): """Normalize a rank in order to be schema-compliant.""" normalized_ranks = { 'BA': 'UNDERGRADUATE', 'BACHELOR': 'UNDERGRADUATE', 'BS': 'UNDERGRADUATE', 'BSC': 'UNDERGRADUATE', 'JUNIOR': 'JUNIOR', 'MAS': 'MASTER', 'MASTER': 'MASTER...
Normalize a rank in order to be schema-compliant.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/utils/__init__.py#L50-L76
inspirehep/inspire-dojson
inspire_dojson/utils/__init__.py
get_recid_from_ref
def get_recid_from_ref(ref_obj): """Retrieve recid from jsonref reference object. If no recid can be parsed, returns None. """ if not isinstance(ref_obj, dict): return None url = ref_obj.get('$ref', '') return maybe_int(url.split('/')[-1])
python
def get_recid_from_ref(ref_obj): """Retrieve recid from jsonref reference object. If no recid can be parsed, returns None. """ if not isinstance(ref_obj, dict): return None url = ref_obj.get('$ref', '') return maybe_int(url.split('/')[-1])
Retrieve recid from jsonref reference object. If no recid can be parsed, returns None.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/utils/__init__.py#L87-L95
inspirehep/inspire-dojson
inspire_dojson/utils/__init__.py
absolute_url
def absolute_url(relative_url): """Returns an absolute URL from a URL relative to the server root. The base URL is taken from the Flask app config if present, otherwise it falls back to ``http://inspirehep.net``. """ default_server = 'http://inspirehep.net' server = current_app.config.get('SERV...
python
def absolute_url(relative_url): """Returns an absolute URL from a URL relative to the server root. The base URL is taken from the Flask app config if present, otherwise it falls back to ``http://inspirehep.net``. """ default_server = 'http://inspirehep.net' server = current_app.config.get('SERV...
Returns an absolute URL from a URL relative to the server root. The base URL is taken from the Flask app config if present, otherwise it falls back to ``http://inspirehep.net``.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/utils/__init__.py#L98-L108
inspirehep/inspire-dojson
inspire_dojson/utils/__init__.py
afs_url
def afs_url(file_path): """Convert a file path to a URL pointing to its path on AFS. If ``file_path`` doesn't start with ``/opt/cds-invenio/``, and hence is not on AFS, it returns it unchanged. The base AFS path is taken from the Flask app config if present, otherwise it falls back to ``/afs/cern....
python
def afs_url(file_path): """Convert a file path to a URL pointing to its path on AFS. If ``file_path`` doesn't start with ``/opt/cds-invenio/``, and hence is not on AFS, it returns it unchanged. The base AFS path is taken from the Flask app config if present, otherwise it falls back to ``/afs/cern....
Convert a file path to a URL pointing to its path on AFS. If ``file_path`` doesn't start with ``/opt/cds-invenio/``, and hence is not on AFS, it returns it unchanged. The base AFS path is taken from the Flask app config if present, otherwise it falls back to ``/afs/cern.ch/project/inspire/PROD``.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/utils/__init__.py#L111-L131
inspirehep/inspire-dojson
inspire_dojson/utils/__init__.py
strip_empty_values
def strip_empty_values(obj): """Recursively strips empty values.""" if isinstance(obj, dict): new_obj = {} for key, val in obj.items(): new_val = strip_empty_values(val) if new_val is not None: new_obj[key] = new_val return new_obj or None elif...
python
def strip_empty_values(obj): """Recursively strips empty values.""" if isinstance(obj, dict): new_obj = {} for key, val in obj.items(): new_val = strip_empty_values(val) if new_val is not None: new_obj[key] = new_val return new_obj or None elif...
Recursively strips empty values.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/utils/__init__.py#L145-L164
inspirehep/inspire-dojson
inspire_dojson/utils/__init__.py
dedupe_all_lists
def dedupe_all_lists(obj, exclude_keys=()): """Recursively remove duplucates from all lists. Args: obj: collection to deduplicate exclude_keys (Container[str]): key names to ignore for deduplication """ squared_dedupe_len = 10 if isinstance(obj, dict): new_obj = {} f...
python
def dedupe_all_lists(obj, exclude_keys=()): """Recursively remove duplucates from all lists. Args: obj: collection to deduplicate exclude_keys (Container[str]): key names to ignore for deduplication """ squared_dedupe_len = 10 if isinstance(obj, dict): new_obj = {} f...
Recursively remove duplucates from all lists. Args: obj: collection to deduplicate exclude_keys (Container[str]): key names to ignore for deduplication
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/utils/__init__.py#L167-L191
inspirehep/inspire-dojson
inspire_dojson/utils/__init__.py
normalize_date_aggressively
def normalize_date_aggressively(date): """Normalize date, stripping date parts until a valid date is obtained.""" def _strip_last_part(date): parts = date.split('-') return '-'.join(parts[:-1]) fake_dates = {'0000', '9999'} if date in fake_dates: return None try: ret...
python
def normalize_date_aggressively(date): """Normalize date, stripping date parts until a valid date is obtained.""" def _strip_last_part(date): parts = date.split('-') return '-'.join(parts[:-1]) fake_dates = {'0000', '9999'} if date in fake_dates: return None try: ret...
Normalize date, stripping date parts until a valid date is obtained.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/utils/__init__.py#L194-L210
inspirehep/inspire-dojson
inspire_dojson/utils/geo.py
match_country_name_to_its_code
def match_country_name_to_its_code(country_name, city=''): """Try to match country name with its code. Name of the city helps when country_name is "Korea". """ if country_name: country_name = country_name.upper().replace('.', '').strip() if country_to_iso_code.get(country_name): ...
python
def match_country_name_to_its_code(country_name, city=''): """Try to match country name with its code. Name of the city helps when country_name is "Korea". """ if country_name: country_name = country_name.upper().replace('.', '').strip() if country_to_iso_code.get(country_name): ...
Try to match country name with its code. Name of the city helps when country_name is "Korea".
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/utils/geo.py#L469-L488
inspirehep/inspire-dojson
inspire_dojson/utils/geo.py
match_us_state
def match_us_state(state_string): """Try to match a string with one of the states in the US.""" if state_string: state_string = state_string.upper().replace('.', '').strip() if us_state_to_iso_code.get(state_string): return us_state_to_iso_code.get(state_string) else: ...
python
def match_us_state(state_string): """Try to match a string with one of the states in the US.""" if state_string: state_string = state_string.upper().replace('.', '').strip() if us_state_to_iso_code.get(state_string): return us_state_to_iso_code.get(state_string) else: ...
Try to match a string with one of the states in the US.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/utils/geo.py#L491-L502
inspirehep/inspire-dojson
inspire_dojson/utils/geo.py
parse_conference_address
def parse_conference_address(address_string): """Parse a conference address. This is a pretty dummy address parser. It only extracts country and state (for US) and should be replaced with something better, like Google Geocoding. """ geo_elements = address_string.split(',') city = geo_eleme...
python
def parse_conference_address(address_string): """Parse a conference address. This is a pretty dummy address parser. It only extracts country and state (for US) and should be replaced with something better, like Google Geocoding. """ geo_elements = address_string.split(',') city = geo_eleme...
Parse a conference address. This is a pretty dummy address parser. It only extracts country and state (for US) and should be replaced with something better, like Google Geocoding.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/utils/geo.py#L505-L542
inspirehep/inspire-dojson
inspire_dojson/utils/geo.py
parse_institution_address
def parse_institution_address(address, city, state_province, country, postal_code, country_code): """Parse an institution address.""" address_list = force_list(address) state_province = match_us_state(state_province) or state_province postal_code = force_list(postal_code) ...
python
def parse_institution_address(address, city, state_province, country, postal_code, country_code): """Parse an institution address.""" address_list = force_list(address) state_province = match_us_state(state_province) or state_province postal_code = force_list(postal_code) ...
Parse an institution address.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/utils/geo.py#L545-L573
inspirehep/inspire-dojson
inspire_dojson/hepnames/rules.py
ids2marc
def ids2marc(self, key, value): """Populate the ``035`` MARC field. Also populates the ``8564`` and ``970`` MARC field through side effects. """ def _is_schema_inspire_bai(id_, schema): return schema == 'INSPIRE BAI' def _is_schema_inspire_id(id_, schema): return schema == 'INSPIRE...
python
def ids2marc(self, key, value): """Populate the ``035`` MARC field. Also populates the ``8564`` and ``970`` MARC field through side effects. """ def _is_schema_inspire_bai(id_, schema): return schema == 'INSPIRE BAI' def _is_schema_inspire_id(id_, schema): return schema == 'INSPIRE...
Populate the ``035`` MARC field. Also populates the ``8564`` and ``970`` MARC field through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hepnames/rules.py#L119-L172
inspirehep/inspire-dojson
inspire_dojson/hepnames/rules.py
name
def name(self, key, value): """Populate the ``name`` key. Also populates the ``status``, ``birth_date`` and ``death_date`` keys through side effects. """ def _get_title(value): c_value = force_single_element(value.get('c', '')) if c_value != 'title (e.g. Sir)': return c_valu...
python
def name(self, key, value): """Populate the ``name`` key. Also populates the ``status``, ``birth_date`` and ``death_date`` keys through side effects. """ def _get_title(value): c_value = force_single_element(value.get('c', '')) if c_value != 'title (e.g. Sir)': return c_valu...
Populate the ``name`` key. Also populates the ``status``, ``birth_date`` and ``death_date`` keys through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hepnames/rules.py#L176-L209
inspirehep/inspire-dojson
inspire_dojson/hepnames/rules.py
name2marc
def name2marc(self, key, value): """Populates the ``100`` field. Also populates the ``400``, ``880``, and ``667`` fields through side effects. """ result = self.get('100', {}) result['a'] = value.get('value') result['b'] = value.get('numeration') result['c'] = value.get('title') re...
python
def name2marc(self, key, value): """Populates the ``100`` field. Also populates the ``400``, ``880``, and ``667`` fields through side effects. """ result = self.get('100', {}) result['a'] = value.get('value') result['b'] = value.get('numeration') result['c'] = value.get('title') re...
Populates the ``100`` field. Also populates the ``400``, ``880``, and ``667`` fields through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hepnames/rules.py#L213-L237
inspirehep/inspire-dojson
inspire_dojson/hepnames/rules.py
positions
def positions(self, key, value): """Populate the positions field. Also populates the email_addresses field by side effect. """ email_addresses = self.get("email_addresses", []) current = None record = None recid_or_status = force_list(value.get('z')) for el in recid_or_status: ...
python
def positions(self, key, value): """Populate the positions field. Also populates the email_addresses field by side effect. """ email_addresses = self.get("email_addresses", []) current = None record = None recid_or_status = force_list(value.get('z')) for el in recid_or_status: ...
Populate the positions field. Also populates the email_addresses field by side effect.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hepnames/rules.py#L251-L294
inspirehep/inspire-dojson
inspire_dojson/hepnames/rules.py
email_addresses2marc
def email_addresses2marc(self, key, value): """Populate the 595 MARCXML field. Also populates the 371 field as a side effect. """ m_or_o = 'm' if value.get('current') else 'o' element = { m_or_o: value.get('value') } if value.get('hidden'): return element else: ...
python
def email_addresses2marc(self, key, value): """Populate the 595 MARCXML field. Also populates the 371 field as a side effect. """ m_or_o = 'm' if value.get('current') else 'o' element = { m_or_o: value.get('value') } if value.get('hidden'): return element else: ...
Populate the 595 MARCXML field. Also populates the 371 field as a side effect.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hepnames/rules.py#L327-L341
inspirehep/inspire-dojson
inspire_dojson/hepnames/rules.py
email_addresses595
def email_addresses595(self, key, value): """Populates the ``email_addresses`` field using the 595 MARCXML field. Also populates ``_private_notes`` as a side effect. """ emails = self.get('email_addresses', []) if value.get('o'): emails.append({ 'value': value.get('o'), ...
python
def email_addresses595(self, key, value): """Populates the ``email_addresses`` field using the 595 MARCXML field. Also populates ``_private_notes`` as a side effect. """ emails = self.get('email_addresses', []) if value.get('o'): emails.append({ 'value': value.get('o'), ...
Populates the ``email_addresses`` field using the 595 MARCXML field. Also populates ``_private_notes`` as a side effect.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hepnames/rules.py#L345-L376
inspirehep/inspire-dojson
inspire_dojson/hepnames/rules.py
arxiv_categories
def arxiv_categories(self, key, value): """Populate the ``arxiv_categories`` key. Also populates the ``inspire_categories`` key through side effects. """ def _is_arxiv(category): return category in valid_arxiv_categories() def _is_inspire(category): schema = load_schema('elements/i...
python
def arxiv_categories(self, key, value): """Populate the ``arxiv_categories`` key. Also populates the ``inspire_categories`` key through side effects. """ def _is_arxiv(category): return category in valid_arxiv_categories() def _is_inspire(category): schema = load_schema('elements/i...
Populate the ``arxiv_categories`` key. Also populates the ``inspire_categories`` key through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hepnames/rules.py#L392-L450
inspirehep/inspire-dojson
inspire_dojson/hepnames/rules.py
birth_and_death_date2marc
def birth_and_death_date2marc(self, key, value): """Populate the ``100__d`` MARC field, which includes the birth and the death date. By not using the decorator ```for_each_value```, the values of the fields ```birth_date``` and ```death_date``` are both added to ```values``` as a list. """ name_fie...
python
def birth_and_death_date2marc(self, key, value): """Populate the ``100__d`` MARC field, which includes the birth and the death date. By not using the decorator ```for_each_value```, the values of the fields ```birth_date``` and ```death_date``` are both added to ```values``` as a list. """ name_fie...
Populate the ``100__d`` MARC field, which includes the birth and the death date. By not using the decorator ```for_each_value```, the values of the fields ```birth_date``` and ```death_date``` are both added to ```values``` as a list.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hepnames/rules.py#L497-L515
inspirehep/inspire-dojson
inspire_dojson/hepnames/rules.py
urls
def urls(self, key, value): """Populate the ``url`` key. Also populates the ``ids`` key through side effects. """ description = force_single_element(value.get('y')) url = value.get('u') linkedin_match = LINKEDIN_URL.match(url) twitter_match = TWITTER_URL.match(url) wikipedia_match = WI...
python
def urls(self, key, value): """Populate the ``url`` key. Also populates the ``ids`` key through side effects. """ description = force_single_element(value.get('y')) url = value.get('u') linkedin_match = LINKEDIN_URL.match(url) twitter_match = TWITTER_URL.match(url) wikipedia_match = WI...
Populate the ``url`` key. Also populates the ``ids`` key through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hepnames/rules.py#L656-L696
inspirehep/inspire-dojson
inspire_dojson/hepnames/rules.py
new_record
def new_record(self, key, value): """Populate the ``new_record`` key. Also populates the ``ids`` key through side effects. """ new_record = self.get('new_record', {}) ids = self.get('ids', []) for value in force_list(value): for id_ in force_list(value.get('a')): ids.append...
python
def new_record(self, key, value): """Populate the ``new_record`` key. Also populates the ``ids`` key through side effects. """ new_record = self.get('new_record', {}) ids = self.get('ids', []) for value in force_list(value): for id_ in force_list(value.get('a')): ids.append...
Populate the ``new_record`` key. Also populates the ``ids`` key through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hepnames/rules.py#L707-L727
inspirehep/inspire-dojson
inspire_dojson/hepnames/rules.py
deleted
def deleted(self, key, value): """Populate the ``deleted`` key. Also populates the ``stub`` key through side effects. """ def _is_deleted(value): return force_single_element(value.get('c', '')).upper() == 'DELETED' def _is_stub(value): return not (force_single_element(value.get('a'...
python
def deleted(self, key, value): """Populate the ``deleted`` key. Also populates the ``stub`` key through side effects. """ def _is_deleted(value): return force_single_element(value.get('c', '')).upper() == 'DELETED' def _is_stub(value): return not (force_single_element(value.get('a'...
Populate the ``deleted`` key. Also populates the ``stub`` key through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hepnames/rules.py#L731-L750
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd1xx.py
authors2marc
def authors2marc(self, key, value): """Populate the ``100`` MARC field. Also populates the ``700`` and the ``701`` MARC fields through side effects. """ value = force_list(value) def _get_ids(value): ids = { 'i': [], 'j': [], } if value.get('ids'): ...
python
def authors2marc(self, key, value): """Populate the ``100`` MARC field. Also populates the ``700`` and the ``701`` MARC fields through side effects. """ value = force_list(value) def _get_ids(value): ids = { 'i': [], 'j': [], } if value.get('ids'): ...
Populate the ``100`` MARC field. Also populates the ``700`` and the ``701`` MARC fields through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd1xx.py#L196-L274
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
isbns
def isbns(self, key, value): """Populate the ``isbns`` key.""" def _get_medium(value): def _normalize(medium): schema = load_schema('hep') valid_media = schema['properties']['isbns']['items']['properties']['medium']['enum'] medium = medium.lower().replace('-', '').re...
python
def isbns(self, key, value): """Populate the ``isbns`` key.""" def _get_medium(value): def _normalize(medium): schema = load_schema('hep') valid_media = schema['properties']['isbns']['items']['properties']['medium']['enum'] medium = medium.lower().replace('-', '').re...
Populate the ``isbns`` key.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L48-L79
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
dois
def dois(self, key, value): """Populate the ``dois`` key. Also populates the ``persistent_identifiers`` key through side effects. """ def _get_first_non_curator_source(sources): sources_without_curator = [el for el in sources if el.upper() != 'CURATOR'] return force_single_element(sourc...
python
def dois(self, key, value): """Populate the ``dois`` key. Also populates the ``persistent_identifiers`` key through side effects. """ def _get_first_non_curator_source(sources): sources_without_curator = [el for el in sources if el.upper() != 'CURATOR'] return force_single_element(sourc...
Populate the ``dois`` key. Also populates the ``persistent_identifiers`` key through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L93-L146
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
dois2marc
def dois2marc(self, key, value): """Populate the ``0247`` MARC field.""" return { '2': 'DOI', '9': value.get('source'), 'a': value.get('value'), 'q': value.get('material'), }
python
def dois2marc(self, key, value): """Populate the ``0247`` MARC field.""" return { '2': 'DOI', '9': value.get('source'), 'a': value.get('value'), 'q': value.get('material'), }
Populate the ``0247`` MARC field.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L151-L158
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
persistent_identifiers2marc
def persistent_identifiers2marc(self, key, value): """Populate the ``0247`` MARC field.""" return { '2': value.get('schema'), '9': value.get('source'), 'a': value.get('value'), 'q': value.get('material'), }
python
def persistent_identifiers2marc(self, key, value): """Populate the ``0247`` MARC field.""" return { '2': value.get('schema'), '9': value.get('source'), 'a': value.get('value'), 'q': value.get('material'), }
Populate the ``0247`` MARC field.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L163-L170
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
texkeys
def texkeys(self, key, value): """Populate the ``texkeys`` key. Also populates the ``external_system_identifiers`` and ``_desy_bookkeeping`` keys through side effects. """ def _is_oai(id_, schema): return id_.startswith('oai:') def _is_desy(id_, schema): return id_ and schema in ('...
python
def texkeys(self, key, value): """Populate the ``texkeys`` key. Also populates the ``external_system_identifiers`` and ``_desy_bookkeeping`` keys through side effects. """ def _is_oai(id_, schema): return id_.startswith('oai:') def _is_desy(id_, schema): return id_ and schema in ('...
Populate the ``texkeys`` key. Also populates the ``external_system_identifiers`` and ``_desy_bookkeeping`` keys through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L174-L234
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
texkeys2marc
def texkeys2marc(self, key, value): """Populate the ``035`` MARC field.""" result = [] values = force_list(value) if values: value = values[0] result.append({ '9': 'INSPIRETeX', 'a': value, }) for value in values[1:]: result.append({ ...
python
def texkeys2marc(self, key, value): """Populate the ``035`` MARC field.""" result = [] values = force_list(value) if values: value = values[0] result.append({ '9': 'INSPIRETeX', 'a': value, }) for value in values[1:]: result.append({ ...
Populate the ``035`` MARC field.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L238-L256
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
external_system_identifiers2marc
def external_system_identifiers2marc(self, key, value): """Populate the ``035`` MARC field. Also populates the ``970`` MARC field through side effects and an extra ``id_dict`` dictionary that holds potentially duplicate IDs that are post-processed in a filter. """ def _is_scheme_cernkey(id_, sc...
python
def external_system_identifiers2marc(self, key, value): """Populate the ``035`` MARC field. Also populates the ``970`` MARC field through side effects and an extra ``id_dict`` dictionary that holds potentially duplicate IDs that are post-processed in a filter. """ def _is_scheme_cernkey(id_, sc...
Populate the ``035`` MARC field. Also populates the ``970`` MARC field through side effects and an extra ``id_dict`` dictionary that holds potentially duplicate IDs that are post-processed in a filter.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L260-L296
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
arxiv_eprints
def arxiv_eprints(self, key, value): """Populate the ``arxiv_eprints`` key. Also populates the ``report_numbers`` key through side effects. """ def _get_clean_arxiv_eprint(id_): return id_.split(':')[-1] def _is_arxiv_eprint(id_, source): return source.lower() == 'arxiv' def _...
python
def arxiv_eprints(self, key, value): """Populate the ``arxiv_eprints`` key. Also populates the ``report_numbers`` key through side effects. """ def _get_clean_arxiv_eprint(id_): return id_.split(':')[-1] def _is_arxiv_eprint(id_, source): return source.lower() == 'arxiv' def _...
Populate the ``arxiv_eprints`` key. Also populates the ``report_numbers`` key through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L300-L348
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
arxiv_eprints2marc
def arxiv_eprints2marc(self, key, values): """Populate the ``037`` MARC field. Also populates the ``035`` and the ``65017`` MARC fields through side effects. """ result_037 = self.get('037', []) result_035 = self.get('035', []) result_65017 = self.get('65017', []) for value in values: ...
python
def arxiv_eprints2marc(self, key, values): """Populate the ``037`` MARC field. Also populates the ``035`` and the ``65017`` MARC fields through side effects. """ result_037 = self.get('037', []) result_035 = self.get('035', []) result_65017 = self.get('65017', []) for value in values: ...
Populate the ``037`` MARC field. Also populates the ``035`` and the ``65017`` MARC fields through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L352-L384
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
report_numbers2marc
def report_numbers2marc(self, key, value): """Populate the ``037`` MARC field.""" def _get_mangled_source(source): if source == 'arXiv': return 'arXiv:reportnumber' return source source = _get_mangled_source(value.get('source')) if value.get('hidden'): return { ...
python
def report_numbers2marc(self, key, value): """Populate the ``037`` MARC field.""" def _get_mangled_source(source): if source == 'arXiv': return 'arXiv:reportnumber' return source source = _get_mangled_source(value.get('source')) if value.get('hidden'): return { ...
Populate the ``037`` MARC field.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L389-L407
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
languages
def languages(self, key, value): """Populate the ``languages`` key.""" languages = self.get('languages', []) values = force_list(value.get('a')) for value in values: for language in RE_LANGUAGE.split(value): try: name = language.strip().capitalize() l...
python
def languages(self, key, value): """Populate the ``languages`` key.""" languages = self.get('languages', []) values = force_list(value.get('a')) for value in values: for language in RE_LANGUAGE.split(value): try: name = language.strip().capitalize() l...
Populate the ``languages`` key.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L411-L424
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd0xx.py
languages2marc
def languages2marc(self, key, value): """Populate the ``041`` MARC field.""" return {'a': pycountry.languages.get(alpha_2=value).name.lower()}
python
def languages2marc(self, key, value): """Populate the ``041`` MARC field.""" return {'a': pycountry.languages.get(alpha_2=value).name.lower()}
Populate the ``041`` MARC field.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd0xx.py#L429-L431
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd9xx.py
record_affiliations
def record_affiliations(self, key, value): """Populate the ``record_affiliations`` key.""" record = get_record_ref(value.get('z'), 'institutions') return { 'curated_relation': record is not None, 'record': record, 'value': value.get('a'), }
python
def record_affiliations(self, key, value): """Populate the ``record_affiliations`` key.""" record = get_record_ref(value.get('z'), 'institutions') return { 'curated_relation': record is not None, 'record': record, 'value': value.get('a'), }
Populate the ``record_affiliations`` key.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd9xx.py#L121-L129
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd9xx.py
document_type
def document_type(self, key, value): """Populate the ``document_type`` key. Also populates the ``_collections``, ``citeable``, ``core``, ``deleted``, ``refereed``, ``publication_type``, and ``withdrawn`` keys through side effects. """ schema = load_schema('hep') publication_type_schema = sc...
python
def document_type(self, key, value): """Populate the ``document_type`` key. Also populates the ``_collections``, ``citeable``, ``core``, ``deleted``, ``refereed``, ``publication_type``, and ``withdrawn`` keys through side effects. """ schema = load_schema('hep') publication_type_schema = sc...
Populate the ``document_type`` key. Also populates the ``_collections``, ``citeable``, ``core``, ``deleted``, ``refereed``, ``publication_type``, and ``withdrawn`` keys through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd9xx.py#L140-L186
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd9xx.py
document_type2marc
def document_type2marc(self, key, value): """Populate the ``980`` MARC field.""" if value in DOCUMENT_TYPE_REVERSE_MAP and DOCUMENT_TYPE_REVERSE_MAP[value]: return {'a': DOCUMENT_TYPE_REVERSE_MAP[value]}
python
def document_type2marc(self, key, value): """Populate the ``980`` MARC field.""" if value in DOCUMENT_TYPE_REVERSE_MAP and DOCUMENT_TYPE_REVERSE_MAP[value]: return {'a': DOCUMENT_TYPE_REVERSE_MAP[value]}
Populate the ``980`` MARC field.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd9xx.py#L241-L244
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd9xx.py
references
def references(self, key, value): """Populate the ``references`` key.""" def _has_curator_flag(value): normalized_nine_values = [el.upper() for el in force_list(value.get('9'))] return 'CURATOR' in normalized_nine_values def _is_curated(value): return force_single_element(value.get(...
python
def references(self, key, value): """Populate the ``references`` key.""" def _has_curator_flag(value): normalized_nine_values = [el.upper() for el in force_list(value.get('9'))] return 'CURATOR' in normalized_nine_values def _is_curated(value): return force_single_element(value.get(...
Populate the ``references`` key.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd9xx.py#L256-L306
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd9xx.py
references2marc
def references2marc(self, key, value): """Populate the ``999C5`` MARC field.""" reference = value.get('reference', {}) pids = force_list(reference.get('persistent_identifiers')) a_values = ['doi:' + el for el in force_list(reference.get('dois'))] a_values.extend(['hdl:' + el['value'] for el in pids...
python
def references2marc(self, key, value): """Populate the ``999C5`` MARC field.""" reference = value.get('reference', {}) pids = force_list(reference.get('persistent_identifiers')) a_values = ['doi:' + el for el in force_list(reference.get('dois'))] a_values.extend(['hdl:' + el['value'] for el in pids...
Populate the ``999C5`` MARC field.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd9xx.py#L311-L366
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bdFFT.py
documents
def documents(self, key, value): """Populate the ``documents`` key. Also populates the ``figures`` key through side effects. """ def _is_hidden(value): return 'HIDDEN' in [val.upper() for val in value] or None def _is_figure(value): figures_extensions = ['.png'] return valu...
python
def documents(self, key, value): """Populate the ``documents`` key. Also populates the ``figures`` key through side effects. """ def _is_hidden(value): return 'HIDDEN' in [val.upper() for val in value] or None def _is_figure(value): figures_extensions = ['.png'] return valu...
Populate the ``documents`` key. Also populates the ``figures`` key through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bdFFT.py#L40-L101
inspirehep/inspire-dojson
inspire_dojson/api.py
marcxml2record
def marcxml2record(marcxml): """Convert a MARCXML string to a JSON record. Tries to guess which set of rules to use by inspecting the contents of the ``980__a`` MARC field, but falls back to HEP in case nothing matches, because records belonging to special collections logically belong to the Litera...
python
def marcxml2record(marcxml): """Convert a MARCXML string to a JSON record. Tries to guess which set of rules to use by inspecting the contents of the ``980__a`` MARC field, but falls back to HEP in case nothing matches, because records belonging to special collections logically belong to the Litera...
Convert a MARCXML string to a JSON record. Tries to guess which set of rules to use by inspecting the contents of the ``980__a`` MARC field, but falls back to HEP in case nothing matches, because records belonging to special collections logically belong to the Literature collection but don't have ``980...
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/api.py#L66-L98
inspirehep/inspire-dojson
inspire_dojson/api.py
record2marcxml
def record2marcxml(record): """Convert a JSON record to a MARCXML string. Deduces which set of rules to use by parsing the ``$schema`` key, as it unequivocally determines which kind of record we have. Args: record(dict): a JSON record. Returns: str: a MARCXML string converted from...
python
def record2marcxml(record): """Convert a JSON record to a MARCXML string. Deduces which set of rules to use by parsing the ``$schema`` key, as it unequivocally determines which kind of record we have. Args: record(dict): a JSON record. Returns: str: a MARCXML string converted from...
Convert a JSON record to a MARCXML string. Deduces which set of rules to use by parsing the ``$schema`` key, as it unequivocally determines which kind of record we have. Args: record(dict): a JSON record. Returns: str: a MARCXML string converted from the record.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/api.py#L101-L142
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd3xx.py
number_of_pages
def number_of_pages(self, key, value): """Populate the ``number_of_pages`` key.""" result = maybe_int(force_single_element(value.get('a', ''))) if result and result > 0: return result
python
def number_of_pages(self, key, value): """Populate the ``number_of_pages`` key.""" result = maybe_int(force_single_element(value.get('a', ''))) if result and result > 0: return result
Populate the ``number_of_pages`` key.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd3xx.py#L34-L38
inspirehep/inspire-dojson
inspire_dojson/cds/rules.py
secondary_report_numbers
def secondary_report_numbers(self, key, value): """Populate the ``037`` MARC field. Also populates the ``500``, ``595`` and ``980`` MARC field through side effects. """ preliminary_results_prefixes = ['ATLAS-CONF-', 'CMS-PAS-', 'CMS-DP-', 'LHCB-CONF-'] note_prefixes = ['ALICE-INT-', 'ATL-', 'ATLAS-...
python
def secondary_report_numbers(self, key, value): """Populate the ``037`` MARC field. Also populates the ``500``, ``595`` and ``980`` MARC field through side effects. """ preliminary_results_prefixes = ['ATLAS-CONF-', 'CMS-PAS-', 'CMS-DP-', 'LHCB-CONF-'] note_prefixes = ['ALICE-INT-', 'ATL-', 'ATLAS-...
Populate the ``037`` MARC field. Also populates the ``500``, ``595`` and ``980`` MARC field through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/cds/rules.py#L143-L178
inspirehep/inspire-dojson
inspire_dojson/cds/rules.py
nonfirst_authors
def nonfirst_authors(self, key, value): """Populate ``700`` MARC field. Also populates the ``701`` MARC field through side-effects. """ field_700 = self.get('700__', []) field_701 = self.get('701__', []) is_supervisor = any(el.lower().startswith('dir') for el in force_list(value.get('e', '')))...
python
def nonfirst_authors(self, key, value): """Populate ``700`` MARC field. Also populates the ``701`` MARC field through side-effects. """ field_700 = self.get('700__', []) field_701 = self.get('701__', []) is_supervisor = any(el.lower().startswith('dir') for el in force_list(value.get('e', '')))...
Populate ``700`` MARC field. Also populates the ``701`` MARC field through side-effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/cds/rules.py#L254-L269
inspirehep/inspire-dojson
inspire_dojson/cds/rules.py
urls
def urls(self, key, value): """Populate the ``8564`` MARC field. Also populate the ``FFT`` field through side effects. """ def _is_preprint(value): return value.get('y', '').lower() == 'preprint' def _is_fulltext(value): return value['u'].endswith('.pdf') and value['u'].startswith(...
python
def urls(self, key, value): """Populate the ``8564`` MARC field. Also populate the ``FFT`` field through side effects. """ def _is_preprint(value): return value.get('y', '').lower() == 'preprint' def _is_fulltext(value): return value['u'].endswith('.pdf') and value['u'].startswith(...
Populate the ``8564`` MARC field. Also populate the ``FFT`` field through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/cds/rules.py#L400-L453
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd2xx.py
titles
def titles(self, key, value): """Populate the ``titles`` key.""" if not key.startswith('245'): return { 'source': value.get('9'), 'subtitle': value.get('b'), 'title': value.get('a'), } self.setdefault('titles', []).insert(0, { 'source': value.get(...
python
def titles(self, key, value): """Populate the ``titles`` key.""" if not key.startswith('245'): return { 'source': value.get('9'), 'subtitle': value.get('b'), 'title': value.get('a'), } self.setdefault('titles', []).insert(0, { 'source': value.get(...
Populate the ``titles`` key.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd2xx.py#L39-L52
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd2xx.py
title_translations
def title_translations(self, key, value): """Populate the ``title_translations`` key.""" return { 'language': langdetect.detect(value.get('a')), 'source': value.get('9'), 'subtitle': value.get('b'), 'title': value.get('a'), }
python
def title_translations(self, key, value): """Populate the ``title_translations`` key.""" return { 'language': langdetect.detect(value.get('a')), 'source': value.get('9'), 'subtitle': value.get('b'), 'title': value.get('a'), }
Populate the ``title_translations`` key.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd2xx.py#L57-L64
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd2xx.py
titles2marc
def titles2marc(self, key, values): """Populate the ``246`` MARC field. Also populates the ``245`` MARC field through side effects. """ first, rest = values[0], values[1:] self.setdefault('245', []).append({ 'a': first.get('title'), 'b': first.get('subtitle'), '9': first.ge...
python
def titles2marc(self, key, values): """Populate the ``246`` MARC field. Also populates the ``245`` MARC field through side effects. """ first, rest = values[0], values[1:] self.setdefault('245', []).append({ 'a': first.get('title'), 'b': first.get('subtitle'), '9': first.ge...
Populate the ``246`` MARC field. Also populates the ``245`` MARC field through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd2xx.py#L68-L87
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd2xx.py
title_translations2marc
def title_translations2marc(self, key, value): """Populate the ``242`` MARC field.""" return { 'a': value.get('title'), 'b': value.get('subtitle'), '9': value.get('source'), }
python
def title_translations2marc(self, key, value): """Populate the ``242`` MARC field.""" return { 'a': value.get('title'), 'b': value.get('subtitle'), '9': value.get('source'), }
Populate the ``242`` MARC field.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd2xx.py#L92-L98
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd2xx.py
imprints
def imprints(self, key, value): """Populate the ``imprints`` key.""" return { 'place': value.get('a'), 'publisher': value.get('b'), 'date': normalize_date_aggressively(value.get('c')), }
python
def imprints(self, key, value): """Populate the ``imprints`` key.""" return { 'place': value.get('a'), 'publisher': value.get('b'), 'date': normalize_date_aggressively(value.get('c')), }
Populate the ``imprints`` key.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd2xx.py#L118-L124
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd2xx.py
imprints2marc
def imprints2marc(self, key, value): """Populate the ``260`` MARC field.""" return { 'a': value.get('place'), 'b': value.get('publisher'), 'c': value.get('date'), }
python
def imprints2marc(self, key, value): """Populate the ``260`` MARC field.""" return { 'a': value.get('place'), 'b': value.get('publisher'), 'c': value.get('date'), }
Populate the ``260`` MARC field.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd2xx.py#L129-L135
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd5xx.py
public_notes
def public_notes(self, key, value): """Populate the ``public_notes`` key. Also populates the ``curated`` and ``thesis_info`` keys through side effects. """ def _means_not_curated(public_note): return public_note in [ '*Brief entry*', '* Brief entry *', '*Temp...
python
def public_notes(self, key, value): """Populate the ``public_notes`` key. Also populates the ``curated`` and ``thesis_info`` keys through side effects. """ def _means_not_curated(public_note): return public_note in [ '*Brief entry*', '* Brief entry *', '*Temp...
Populate the ``public_notes`` key. Also populates the ``curated`` and ``thesis_info`` keys through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L42-L81
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd5xx.py
thesis_info
def thesis_info(self, key, value): """Populate the ``thesis_info`` key.""" def _get_degree_type(value): DEGREE_TYPES_MAP = { 'RAPPORT DE STAGE': 'other', 'INTERNSHIP REPORT': 'other', 'DIPLOMA': 'diploma', 'BACHELOR': 'bachelor', 'LAUREA': 'lau...
python
def thesis_info(self, key, value): """Populate the ``thesis_info`` key.""" def _get_degree_type(value): DEGREE_TYPES_MAP = { 'RAPPORT DE STAGE': 'other', 'INTERNSHIP REPORT': 'other', 'DIPLOMA': 'diploma', 'BACHELOR': 'bachelor', 'LAUREA': 'lau...
Populate the ``thesis_info`` key.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L85-L127
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd5xx.py
thesis_info2marc
def thesis_info2marc(self, key, value): """Populate the ``502`` MARC field. Also populates the ``500`` MARC field through side effects. """ def _get_b_value(value): DEGREE_TYPES_MAP = { 'bachelor': 'Bachelor', 'diploma': 'Diploma', 'habilitation': 'Habilitati...
python
def thesis_info2marc(self, key, value): """Populate the ``502`` MARC field. Also populates the ``500`` MARC field through side effects. """ def _get_b_value(value): DEGREE_TYPES_MAP = { 'bachelor': 'Bachelor', 'diploma': 'Diploma', 'habilitation': 'Habilitati...
Populate the ``502`` MARC field. Also populates the ``500`` MARC field through side effects.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L131-L166
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd5xx.py
abstracts
def abstracts(self, key, value): """Populate the ``abstracts`` key.""" result = [] source = force_single_element(value.get('9')) for a_value in force_list(value.get('a')): result.append({ 'source': source, 'value': a_value, }) return result
python
def abstracts(self, key, value): """Populate the ``abstracts`` key.""" result = [] source = force_single_element(value.get('9')) for a_value in force_list(value.get('a')): result.append({ 'source': source, 'value': a_value, }) return result
Populate the ``abstracts`` key.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L172-L184
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd5xx.py
funding_info
def funding_info(self, key, value): """Populate the ``funding_info`` key.""" return { 'agency': value.get('a'), 'grant_number': value.get('c'), 'project_number': value.get('f'), }
python
def funding_info(self, key, value): """Populate the ``funding_info`` key.""" return { 'agency': value.get('a'), 'grant_number': value.get('c'), 'project_number': value.get('f'), }
Populate the ``funding_info`` key.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L199-L205
inspirehep/inspire-dojson
inspire_dojson/hep/rules/bd5xx.py
funding_info2marc
def funding_info2marc(self, key, value): """Populate the ``536`` MARC field.""" return { 'a': value.get('agency'), 'c': value.get('grant_number'), 'f': value.get('project_number'), }
python
def funding_info2marc(self, key, value): """Populate the ``536`` MARC field.""" return { 'a': value.get('agency'), 'c': value.get('grant_number'), 'f': value.get('project_number'), }
Populate the ``536`` MARC field.
https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L210-L216