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_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | 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,... | [
"def",
"activate_legislators",
"(",
"current_term",
",",
"abbr",
")",
":",
"for",
"legislator",
"in",
"db",
".",
"legislators",
".",
"find",
"(",
"{",
"'roles'",
":",
"{",
"'$elemMatch'",
":",
"{",
"settings",
".",
"LEVEL_FIELD",
":",
"abbr",
",",
"'term'"... | Sets the 'active' flag on legislators and populates top-level
district/chamber/party fields for currently serving legislators. | [
"Sets",
"the",
"active",
"flag",
"on",
"legislators",
"and",
"populates",
"top",
"-",
"level",
"district",
"/",
"chamber",
"/",
"party",
"fields",
"for",
"currently",
"serving",
"legislators",
"."
] | train | 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,
... | [
"def",
"add_role",
"(",
"self",
",",
"role",
",",
"term",
",",
"start_date",
"=",
"None",
",",
"end_date",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"[",
"'roles'",
"]",
".",
"append",
"(",
"dict",
"(",
"role",
"=",
"role",
",",
"te... | Examples:
leg.add_role('member', term='2009', chamber='upper',
party='Republican', district='10th') | [
"Examples",
":"
] | train | 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,... | [
"def",
"add_office",
"(",
"self",
",",
"type",
",",
"name",
",",
"address",
"=",
"None",
",",
"phone",
"=",
"None",
",",
"fax",
"=",
"None",
",",
"email",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"office_dict",
"=",
"dict",
"(",
"type",
"=... | Allowed office types:
capitol
district | [
"Allowed",
"office",
"types",
":",
"capitol",
"district"
] | train | 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_... | [
"def",
"metadata",
"(",
"abbr",
",",
"__metadata",
"=",
"__metadata",
")",
":",
"# This data should change very rarely and is queried very often so",
"# cache it here",
"abbr",
"=",
"abbr",
".",
"lower",
"(",
")",
"if",
"abbr",
"in",
"__metadata",
":",
"return",
"__... | Grab the metadata for the given two-letter abbreviation. | [
"Grab",
"the",
"metadata",
"for",
"the",
"given",
"two",
"-",
"letter",
"abbreviation",
"."
] | train | 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) | [
"def",
"cd",
"(",
"path",
")",
":",
"old_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"try",
":",
"os",
".",
"makedirs",
"(",
"path",
")",
"except",
"OSError",
":",
"pass",
"os",
".",
"chdir",
"(",
"path",
")",
"try",
":",
"yield",
"finally",
":",
... | Creates the path if it doesn't exist | [
"Creates",
"the",
"path",
"if",
"it",
"doesn",
"t",
"exist"
] | train | 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... | [
"def",
"_get_property_dict",
"(",
"schema",
")",
":",
"pdict",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"schema",
"[",
"'properties'",
"]",
".",
"items",
"(",
")",
":",
"pdict",
"[",
"k",
"]",
"=",
"{",
"}",
"if",
"'items'",
"in",
"v",
"and",
... | given a schema object produce a nested dictionary of fields | [
"given",
"a",
"schema",
"object",
"produce",
"a",
"nested",
"dictionary",
"of",
"fields"
] | train | 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... | [
"def",
"insert_with_id",
"(",
"obj",
")",
":",
"if",
"'_id'",
"in",
"obj",
":",
"raise",
"ValueError",
"(",
"\"object already has '_id' field\"",
")",
"# add created_at/updated_at on insert",
"obj",
"[",
"'created_at'",
"]",
"=",
"datetime",
".",
"datetime",
".",
... | Generates a unique ID for the supplied legislator/committee/bill
and inserts it into the appropriate collection. | [
"Generates",
"a",
"unique",
"ID",
"for",
"the",
"supplied",
"legislator",
"/",
"committee",
"/",
"bill",
"and",
"inserts",
"it",
"into",
"the",
"appropriate",
"collection",
"."
] | train | 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... | [
"def",
"update",
"(",
"old",
",",
"new",
",",
"collection",
",",
"sneaky_update_filter",
"=",
"None",
")",
":",
"# need_save = something has changed",
"need_save",
"=",
"False",
"locked_fields",
"=",
"old",
".",
"get",
"(",
"'_locked_fields'",
",",
"[",
"]",
"... | 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... | [
"update",
"an",
"existing",
"object",
"with",
"a",
"new",
"one",
"only",
"saving",
"it",
"and",
"setting",
"updated_at",
"if",
"something",
"has",
"changed"
] | train | 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:
... | [
"def",
"convert_timestamps",
"(",
"obj",
")",
":",
"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. | [
"Convert",
"unix",
"timestamps",
"in",
"the",
"scraper",
"output",
"to",
"python",
"datetimes",
"so",
"that",
"they",
"will",
"be",
"saved",
"properly",
"as",
"Mongo",
"datetimes",
"."
] | train | 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... | [
"def",
"split_name",
"(",
"obj",
")",
":",
"if",
"obj",
"[",
"'_type'",
"]",
"in",
"(",
"'person'",
",",
"'legislator'",
")",
":",
"for",
"key",
"in",
"(",
"'first_name'",
",",
"'last_name'",
")",
":",
"if",
"key",
"not",
"in",
"obj",
"or",
"not",
... | If the supplied legislator/person object is missing 'first_name'
or 'last_name' then use name_tools to split. | [
"If",
"the",
"supplied",
"legislator",
"/",
"person",
"object",
"is",
"missing",
"first_name",
"or",
"last_name",
"then",
"use",
"name_tools",
"to",
"split",
"."
] | train | 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):
... | [
"def",
"_make_plus_helper",
"(",
"obj",
",",
"fields",
")",
":",
"new_obj",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"obj",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"fields",
"or",
"key",
".",
"startswith",
"(",
"'_'",
")",
":",
"#... | add a + prefix to any fields in obj that aren't in fields | [
"add",
"a",
"+",
"prefix",
"to",
"any",
"fields",
"in",
"obj",
"that",
"aren",
"t",
"in",
"fields"
] | train | 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) | [
"def",
"make_plus_fields",
"(",
"obj",
")",
":",
"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 | [
"Add",
"a",
"+",
"to",
"the",
"key",
"of",
"non",
"-",
"standard",
"fields",
"."
] | train | 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... | [
"def",
"get_object",
"(",
"cls",
",",
"abbr",
")",
":",
"obj",
"=",
"get_metadata",
"(",
"abbr",
")",
"if",
"obj",
"is",
"None",
":",
"msg",
"=",
"'No metadata found for abbreviation %r'",
"%",
"abbr",
"raise",
"DoesNotExist",
"(",
"msg",
")",
"return",
"c... | 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. | [
"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",
"."
] | train | 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... | [
"def",
"committees_legislators",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"committees",
"=",
"list",
"(",
"self",
".",
"committees",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")",
"legislators",
"=",
"self",
".",
"legis... | 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. | [
"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",
"."
] | train | 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)
... | [
"def",
"extract_fields",
"(",
"d",
",",
"fields",
",",
"delimiter",
"=",
"'|'",
")",
":",
"rd",
"=",
"{",
"}",
"for",
"f",
"in",
"fields",
":",
"v",
"=",
"d",
".",
"get",
"(",
"f",
",",
"None",
")",
"if",
"isinstance",
"(",
"v",
",",
"(",
"st... | get values out of an object ``d`` for saving to a csv | [
"get",
"values",
"out",
"of",
"an",
"object",
"d",
"for",
"saving",
"to",
"a",
"csv"
] | train | 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_... | [
"def",
"bill",
"(",
"request",
",",
"abbr",
",",
"session",
",",
"bill_id",
")",
":",
"# get fixed version",
"fixed_bill_id",
"=",
"fix_bill_id",
"(",
"bill_id",
")",
"# redirect if URL's id isn't fixed id without spaces",
"if",
"fixed_bill_id",
".",
"replace",
"(",
... | 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 | [
"Context",
":",
"-",
"vote_preview_row_template",
"-",
"abbr",
"-",
"metadata",
"-",
"bill",
"-",
"show_all_sponsors",
"-",
"sponsors",
"-",
"sources",
"-",
"nav_active"
] | train | 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... | [
"def",
"vote",
"(",
"request",
",",
"abbr",
",",
"vote_id",
")",
":",
"vote",
"=",
"db",
".",
"votes",
".",
"find_one",
"(",
"vote_id",
")",
"if",
"vote",
"is",
"None",
":",
"raise",
"Http404",
"(",
"'no such vote: {0}'",
".",
"format",
"(",
"vote_id",... | Context:
- abbr
- metadata
- bill
- vote
- nav_active
Templates:
- vote.html | [
"Context",
":",
"-",
"abbr",
"-",
"metadata",
"-",
"bill",
"-",
"vote",
"-",
"nav_active"
] | train | 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... | [
"def",
"document",
"(",
"request",
",",
"abbr",
",",
"session",
",",
"bill_id",
",",
"doc_id",
")",
":",
"# get fixed version",
"fixed_bill_id",
"=",
"fix_bill_id",
"(",
"bill_id",
")",
"# redirect if URL's id isn't fixed id without spaces",
"if",
"fixed_bill_id",
"."... | Context:
- abbr
- session
- bill
- version
- metadata
- nav_active
Templates:
- billy/web/public/document.html | [
"Context",
":",
"-",
"abbr",
"-",
"session",
"-",
"bill",
"-",
"version",
"-",
"metadata",
"-",
"nav_active"
] | train | 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):
# ... | [
"def",
"show_all",
"(",
"key",
")",
":",
"def",
"func",
"(",
"request",
",",
"abbr",
",",
"session",
",",
"bill_id",
",",
"key",
")",
":",
"# get fixed version",
"fixed_bill_id",
"=",
"fix_bill_id",
"(",
"bill_id",
")",
"# redirect if URL's id isn't fixed id wit... | Context:
- abbr
- metadata
- bill
- sources
- nav_active
Templates:
- billy/web/public/bill_all_{key}.html
- where key is passed in, like "actions", etc. | [
"Context",
":",
"-",
"abbr",
"-",
"metadata",
"-",
"bill",
"-",
"sources",
"-",
"nav_active"
] | train | 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... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"super",
"(",
"RelatedBillsList",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"metadata",
"=",
... | 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... | [
"Context",
":",
"If",
"GET",
"parameters",
"are",
"given",
":",
"-",
"search_text",
"-",
"form",
"(",
"FilterBillsForm",
")",
"-",
"long_description",
"-",
"description",
"-",
"get_params",
"Otherwise",
"the",
"only",
"context",
"item",
"is",
"an",
"unbound",
... | train | 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) | [
"def",
"region_selection",
"(",
"request",
")",
":",
"form",
"=",
"get_region_select_form",
"(",
"request",
".",
"GET",
")",
"abbr",
"=",
"form",
".",
"data",
".",
"get",
"(",
"'abbr'",
")",
"if",
"not",
"abbr",
"or",
"len",
"(",
"abbr",
")",
"!=",
"... | Handle submission of the region selection form in the base template. | [
"Handle",
"submission",
"of",
"the",
"region",
"selection",
"form",
"in",
"the",
"base",
"template",
"."
] | train | 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:
... | [
"def",
"region",
"(",
"request",
",",
"abbr",
")",
":",
"report",
"=",
"db",
".",
"reports",
".",
"find_one",
"(",
"{",
"'_id'",
":",
"abbr",
"}",
")",
"try",
":",
"meta",
"=",
"Metadata",
".",
"get_object",
"(",
"abbr",
")",
"except",
"DoesNotExist"... | Context:
- abbr
- metadata
- sessions
- chambers
- joint_committee_count
- geo_bounds
- nav_active
Templates:
- bill/web/public/region.html | [
"Context",
":",
"-",
"abbr",
"-",
"metadata",
"-",
"sessions",
"-",
"chambers",
"-",
"joint_committee_count",
"-",
"geo_bounds",
"-",
"nav_active"
] | train | 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/... | [
"def",
"search",
"(",
"request",
",",
"abbr",
")",
":",
"if",
"not",
"request",
".",
"GET",
":",
"return",
"render",
"(",
"request",
",",
"templatename",
"(",
"'search_results_no_query'",
")",
",",
"{",
"'abbr'",
":",
"abbr",
"}",
")",
"search_text",
"="... | 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... | [
"Context",
":",
"-",
"search_text",
"-",
"abbr",
"-",
"metadata",
"-",
"found_by_id",
"-",
"bill_results",
"-",
"more_bills_available",
"-",
"legislators_list",
"-",
"nav_active"
] | train | 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... | [
"def",
"add_member",
"(",
"self",
",",
"legislator",
",",
"role",
"=",
"'member'",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"[",
"'members'",
"]",
".",
"append",
"(",
"dict",
"(",
"name",
"=",
"legislator",
",",
"role",
"=",
"role",
",",
"*",
"*"... | 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' | [
"Add",
"a",
"member",
"to",
"the",
"committee",
"object",
"."
] | train | 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... | [
"def",
"action_display",
"(",
"self",
")",
":",
"action",
"=",
"self",
"[",
"'action'",
"]",
"annotations",
"=",
"[",
"]",
"abbr",
"=",
"self",
".",
"bill",
"[",
"settings",
".",
"LEVEL_FIELD",
"]",
"if",
"'related_entities'",
"in",
"self",
":",
"for",
... | The action text, with any hyperlinked related entities. | [
"The",
"action",
"text",
"with",
"any",
"hyperlinked",
"related",
"entities",
"."
] | train | 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... | [
"def",
"_bytype",
"(",
"self",
",",
"action_type",
",",
"action_spec",
"=",
"None",
")",
":",
"for",
"action",
"in",
"reversed",
"(",
"self",
".",
"bill",
"[",
"'actions'",
"]",
")",
":",
"if",
"action_type",
"in",
"action",
"[",
"'type'",
"]",
":",
... | Return the most recent date on which action_type occurred.
Action spec is a dictionary of key-value attrs to match. | [
"Return",
"the",
"most",
"recent",
"date",
"on",
"which",
"action_type",
"occurred",
".",
"Action",
"spec",
"is",
"a",
"dictionary",
"of",
"key",
"-",
"value",
"attrs",
"to",
"match",
"."
] | train | 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) | [
"def",
"_ratio",
"(",
"self",
",",
"key",
")",
":",
"total",
"=",
"float",
"(",
"self",
".",
"_total_votes",
"(",
")",
")",
"try",
":",
"return",
"math",
".",
"floor",
"(",
"self",
"[",
"key",
"]",
"/",
"total",
"*",
"100",
")",
"except",
"ZeroDi... | Return the yes/total ratio as a percetage string
suitable for use as as css attribute. | [
"Return",
"the",
"yes",
"/",
"total",
"ratio",
"as",
"a",
"percetage",
"string",
"suitable",
"for",
"use",
"as",
"as",
"css",
"attribute",
"."
] | train | 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... | [
"def",
"_legislator_objects",
"(",
"self",
")",
":",
"kwargs",
"=",
"{",
"}",
"id_getter",
"=",
"operator",
".",
"itemgetter",
"(",
"'leg_id'",
")",
"ids",
"=",
"[",
"]",
"for",
"k",
"in",
"(",
"'yes'",
",",
"'no'",
",",
"'other'",
")",
":",
"ids",
... | A cache of dereferenced legislator objects. | [
"A",
"cache",
"of",
"dereferenced",
"legislator",
"objects",
"."
] | train | 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 ... | [
"def",
"legislator_vote_value",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'legislator'",
")",
":",
"msg",
"=",
"(",
"'legislator_vote_value can only be called '",
"'from a vote accessed by legislator.votes_manager.'",
")",
"raise",
"ValueError",
... | If this vote was accessed through the legislator.votes_manager,
return the value of this legislator's vote. | [
"If",
"this",
"vote",
"was",
"accessed",
"through",
"the",
"legislator",
".",
"votes_manager",
"return",
"the",
"value",
"of",
"this",
"legislator",
"s",
"vote",
"."
] | train | 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 = []
... | [
"def",
"_vote_legislators",
"(",
"self",
",",
"yes_no_other",
")",
":",
"#id_getter = operator.itemgetter('leg_id')",
"#ids = map(id_getter, self['%s_votes' % yes_no_other])",
"#return map(self._legislator_objects.get, ids)",
"result",
"=",
"[",
"]",
"for",
"voter",
"in",
"self",... | Return all legislators who votes yes/no/other on this bill. | [
"Return",
"all",
"legislators",
"who",
"votes",
"yes",
"/",
"no",
"/",
"other",
"on",
"this",
"bill",
"."
] | train | 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():
... | [
"def",
"is_probably_a_voice_vote",
"(",
"self",
")",
":",
"if",
"'+voice_vote'",
"in",
"self",
":",
"return",
"True",
"if",
"'+vote_type'",
"in",
"self",
":",
"if",
"self",
"[",
"'+vote_type'",
"]",
"==",
"'Voice'",
":",
"return",
"True",
"if",
"'voice vote'... | Guess whether this vote is a "voice vote". | [
"Guess",
"whether",
"this",
"vote",
"is",
"a",
"voice",
"vote",
"."
] | train | 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'])
... | [
"def",
"bill_objects",
"(",
"self",
")",
":",
"bills",
"=",
"[",
"]",
"for",
"bill",
"in",
"self",
"[",
"'related_bills'",
"]",
":",
"if",
"'id'",
"in",
"bill",
":",
"bills",
".",
"append",
"(",
"bill",
"[",
"'id'",
"]",
")",
"return",
"db",
".",
... | 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. | [
"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",
"."
] | train | 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".
... | [
"def",
"host",
"(",
"self",
")",
":",
"_id",
"=",
"None",
"for",
"participant",
"in",
"self",
"[",
"'participants'",
"]",
":",
"if",
"participant",
"[",
"'type'",
"]",
"==",
"'host'",
":",
"if",
"set",
"(",
"[",
"'participant_type'",
",",
"'id'",
"]",
... | Return the host committee. | [
"Return",
"the",
"host",
"committee",
"."
] | train | 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.
... | [
"def",
"host_chairs",
"(",
"self",
")",
":",
"chairs",
"=",
"[",
"]",
"# Host is guaranteed to be a committe or none.",
"host",
"=",
"self",
".",
"host",
"(",
")",
"if",
"host",
"is",
"None",
":",
"return",
"for",
"member",
",",
"full_member",
"in",
"host",
... | 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'. | [
"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",
... | train | 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 | [
"def",
"host_members",
"(",
"self",
")",
":",
"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. | [
"Return",
"the",
"members",
"of",
"the",
"host",
"committee",
"."
] | train | 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
... | [
"def",
"committees",
"(",
"request",
",",
"abbr",
")",
":",
"try",
":",
"meta",
"=",
"Metadata",
".",
"get_object",
"(",
"abbr",
")",
"except",
"DoesNotExist",
":",
"raise",
"Http404",
"chamber",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'chamber'",
... | 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... | [
"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"
] | train | 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:
... | [
"def",
"committee",
"(",
"request",
",",
"abbr",
",",
"committee_id",
")",
":",
"committee",
"=",
"db",
".",
"committees",
".",
"find_one",
"(",
"{",
"'_id'",
":",
"committee_id",
"}",
")",
"if",
"committee",
"is",
"None",
":",
"raise",
"Http404",
"retur... | Context:
- committee
- abbr
- metadata
- sources
- nav_active
Tempaltes:
- billy/web/public/committee.html | [
"Context",
":",
"-",
"committee",
"-",
"abbr",
"-",
"metadata",
"-",
"sources",
"-",
"nav_active"
] | train | 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:
... | [
"def",
"update_common",
"(",
"obj",
",",
"report",
")",
":",
"# updated checks",
"if",
"obj",
"[",
"'updated_at'",
"]",
">=",
"yesterday",
":",
"report",
"[",
"'_updated_today_count'",
"]",
"+=",
"1",
"if",
"obj",
"[",
"'updated_at'",
"]",
">=",
"last_month"... | do updated_at checks | [
"do",
"updated_at",
"checks"
] | train | 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... | [
"def",
"legislators",
"(",
"request",
",",
"abbr",
")",
":",
"try",
":",
"meta",
"=",
"Metadata",
".",
"get_object",
"(",
"abbr",
")",
"except",
"DoesNotExist",
":",
"raise",
"Http404",
"spec",
"=",
"{",
"'active'",
":",
"True",
",",
"'district'",
":",
... | 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... | [
"Context",
":",
"-",
"metadata",
"-",
"chamber",
"-",
"chamber_title",
"-",
"chamber_select_template",
"-",
"chamber_select_collection",
"-",
"chamber_select_chambers",
"-",
"show_chamber_column",
"-",
"abbr",
"-",
"legislators",
"-",
"sort_order",
"-",
"sort_key",
"-... | train | 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... | [
"def",
"legislator",
"(",
"request",
",",
"abbr",
",",
"_id",
",",
"slug",
"=",
"None",
")",
":",
"try",
":",
"meta",
"=",
"Metadata",
".",
"get_object",
"(",
"abbr",
")",
"except",
"DoesNotExist",
":",
"raise",
"Http404",
"legislator",
"=",
"db",
".",... | 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... | [
"Context",
":",
"-",
"vote_preview_row_template",
"-",
"roles",
"-",
"abbr",
"-",
"district_id",
"-",
"metadata",
"-",
"legislator",
"-",
"sources",
"-",
"sponsored_bills",
"-",
"legislator_votes",
"-",
"has_votes",
"-",
"nav_active"
] | train | 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:
... | [
"def",
"legislator_inactive",
"(",
"request",
",",
"abbr",
",",
"legislator",
")",
":",
"sponsored_bills",
"=",
"legislator",
".",
"sponsored_bills",
"(",
"limit",
"=",
"6",
",",
"sort",
"=",
"[",
"(",
"'action_dates.first'",
",",
"pymongo",
".",
"DESCENDING",... | 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... | [
"Context",
":",
"-",
"vote_preview_row_template",
"-",
"old_roles",
"-",
"abbr",
"-",
"metadata",
"-",
"legislator",
"-",
"sources",
"-",
"sponsored_bills",
"-",
"legislator_votes",
"-",
"has_votes",
"-",
"nav_active"
] | train | 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... | [
"def",
"normalize_rank",
"(",
"rank",
")",
":",
"normalized_ranks",
"=",
"{",
"'BA'",
":",
"'UNDERGRADUATE'",
",",
"'BACHELOR'",
":",
"'UNDERGRADUATE'",
",",
"'BS'",
":",
"'UNDERGRADUATE'",
",",
"'BSC'",
":",
"'UNDERGRADUATE'",
",",
"'JUNIOR'",
":",
"'JUNIOR'",
... | Normalize a rank in order to be schema-compliant. | [
"Normalize",
"a",
"rank",
"in",
"order",
"to",
"be",
"schema",
"-",
"compliant",
"."
] | train | 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]) | [
"def",
"get_recid_from_ref",
"(",
"ref_obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"ref_obj",
",",
"dict",
")",
":",
"return",
"None",
"url",
"=",
"ref_obj",
".",
"get",
"(",
"'$ref'",
",",
"''",
")",
"return",
"maybe_int",
"(",
"url",
".",
"split"... | Retrieve recid from jsonref reference object.
If no recid can be parsed, returns None. | [
"Retrieve",
"recid",
"from",
"jsonref",
"reference",
"object",
"."
] | train | 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... | [
"def",
"absolute_url",
"(",
"relative_url",
")",
":",
"default_server",
"=",
"'http://inspirehep.net'",
"server",
"=",
"current_app",
".",
"config",
".",
"get",
"(",
"'SERVER_NAME'",
",",
"default_server",
")",
"if",
"not",
"re",
".",
"match",
"(",
"'^https?://'... | 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``. | [
"Returns",
"an",
"absolute",
"URL",
"from",
"a",
"URL",
"relative",
"to",
"the",
"server",
"root",
"."
] | train | 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.... | [
"def",
"afs_url",
"(",
"file_path",
")",
":",
"default_afs_path",
"=",
"'/afs/cern.ch/project/inspire/PROD'",
"afs_path",
"=",
"current_app",
".",
"config",
".",
"get",
"(",
"'LEGACY_AFS_PATH'",
",",
"default_afs_path",
")",
"if",
"file_path",
"is",
"None",
":",
"... | 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``. | [
"Convert",
"a",
"file",
"path",
"to",
"a",
"URL",
"pointing",
"to",
"its",
"path",
"on",
"AFS",
"."
] | train | 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... | [
"def",
"strip_empty_values",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"new_obj",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"obj",
".",
"items",
"(",
")",
":",
"new_val",
"=",
"strip_empty_values",
"(",
"val",
... | Recursively strips empty values. | [
"Recursively",
"strips",
"empty",
"values",
"."
] | train | 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... | [
"def",
"dedupe_all_lists",
"(",
"obj",
",",
"exclude_keys",
"=",
"(",
")",
")",
":",
"squared_dedupe_len",
"=",
"10",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"new_obj",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"obj",
".",
"item... | Recursively remove duplucates from all lists.
Args:
obj: collection to deduplicate
exclude_keys (Container[str]): key names to ignore for deduplication | [
"Recursively",
"remove",
"duplucates",
"from",
"all",
"lists",
"."
] | train | 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... | [
"def",
"normalize_date_aggressively",
"(",
"date",
")",
":",
"def",
"_strip_last_part",
"(",
"date",
")",
":",
"parts",
"=",
"date",
".",
"split",
"(",
"'-'",
")",
"return",
"'-'",
".",
"join",
"(",
"parts",
"[",
":",
"-",
"1",
"]",
")",
"fake_dates",
... | Normalize date, stripping date parts until a valid date is obtained. | [
"Normalize",
"date",
"stripping",
"date",
"parts",
"until",
"a",
"valid",
"date",
"is",
"obtained",
"."
] | train | 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):
... | [
"def",
"match_country_name_to_its_code",
"(",
"country_name",
",",
"city",
"=",
"''",
")",
":",
"if",
"country_name",
":",
"country_name",
"=",
"country_name",
".",
"upper",
"(",
")",
".",
"replace",
"(",
"'.'",
",",
"''",
")",
".",
"strip",
"(",
")",
"i... | Try to match country name with its code.
Name of the city helps when country_name is "Korea". | [
"Try",
"to",
"match",
"country",
"name",
"with",
"its",
"code",
"."
] | train | 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:
... | [
"def",
"match_us_state",
"(",
"state_string",
")",
":",
"if",
"state_string",
":",
"state_string",
"=",
"state_string",
".",
"upper",
"(",
")",
".",
"replace",
"(",
"'.'",
",",
"''",
")",
".",
"strip",
"(",
")",
"if",
"us_state_to_iso_code",
".",
"get",
... | Try to match a string with one of the states in the US. | [
"Try",
"to",
"match",
"a",
"string",
"with",
"one",
"of",
"the",
"states",
"in",
"the",
"US",
"."
] | train | 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... | [
"def",
"parse_conference_address",
"(",
"address_string",
")",
":",
"geo_elements",
"=",
"address_string",
".",
"split",
"(",
"','",
")",
"city",
"=",
"geo_elements",
"[",
"0",
"]",
"country_name",
"=",
"geo_elements",
"[",
"-",
"1",
"]",
".",
"upper",
"(",
... | 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. | [
"Parse",
"a",
"conference",
"address",
"."
] | train | 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)
... | [
"def",
"parse_institution_address",
"(",
"address",
",",
"city",
",",
"state_province",
",",
"country",
",",
"postal_code",
",",
"country_code",
")",
":",
"address_list",
"=",
"force_list",
"(",
"address",
")",
"state_province",
"=",
"match_us_state",
"(",
"state_... | Parse an institution address. | [
"Parse",
"an",
"institution",
"address",
"."
] | train | 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... | [
"def",
"ids2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_is_schema_inspire_bai",
"(",
"id_",
",",
"schema",
")",
":",
"return",
"schema",
"==",
"'INSPIRE BAI'",
"def",
"_is_schema_inspire_id",
"(",
"id_",
",",
"schema",
")",
":",
"retur... | Populate the ``035`` MARC field.
Also populates the ``8564`` and ``970`` MARC field through side effects. | [
"Populate",
"the",
"035",
"MARC",
"field",
"."
] | train | 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... | [
"def",
"name",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_get_title",
"(",
"value",
")",
":",
"c_value",
"=",
"force_single_element",
"(",
"value",
".",
"get",
"(",
"'c'",
",",
"''",
")",
")",
"if",
"c_value",
"!=",
"'title (e.g. Sir)'",... | Populate the ``name`` key.
Also populates the ``status``, ``birth_date`` and ``death_date`` keys through side effects. | [
"Populate",
"the",
"name",
"key",
"."
] | train | 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... | [
"def",
"name2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"result",
"=",
"self",
".",
"get",
"(",
"'100'",
",",
"{",
"}",
")",
"result",
"[",
"'a'",
"]",
"=",
"value",
".",
"get",
"(",
"'value'",
")",
"result",
"[",
"'b'",
"]",
"=",
... | Populates the ``100`` field.
Also populates the ``400``, ``880``, and ``667`` fields through side
effects. | [
"Populates",
"the",
"100",
"field",
"."
] | train | 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:
... | [
"def",
"positions",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"email_addresses",
"=",
"self",
".",
"get",
"(",
"\"email_addresses\"",
",",
"[",
"]",
")",
"current",
"=",
"None",
"record",
"=",
"None",
"recid_or_status",
"=",
"force_list",
"(",
"va... | Populate the positions field.
Also populates the email_addresses field by side effect. | [
"Populate",
"the",
"positions",
"field",
"."
] | train | 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:
... | [
"def",
"email_addresses2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"m_or_o",
"=",
"'m'",
"if",
"value",
".",
"get",
"(",
"'current'",
")",
"else",
"'o'",
"element",
"=",
"{",
"m_or_o",
":",
"value",
".",
"get",
"(",
"'value'",
")",
"}",
... | Populate the 595 MARCXML field.
Also populates the 371 field as a side effect. | [
"Populate",
"the",
"595",
"MARCXML",
"field",
"."
] | train | 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'),
... | [
"def",
"email_addresses595",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"emails",
"=",
"self",
".",
"get",
"(",
"'email_addresses'",
",",
"[",
"]",
")",
"if",
"value",
".",
"get",
"(",
"'o'",
")",
":",
"emails",
".",
"append",
"(",
"{",
"'val... | Populates the ``email_addresses`` field using the 595 MARCXML field.
Also populates ``_private_notes`` as a side effect. | [
"Populates",
"the",
"email_addresses",
"field",
"using",
"the",
"595",
"MARCXML",
"field",
"."
] | train | 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... | [
"def",
"arxiv_categories",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_is_arxiv",
"(",
"category",
")",
":",
"return",
"category",
"in",
"valid_arxiv_categories",
"(",
")",
"def",
"_is_inspire",
"(",
"category",
")",
":",
"schema",
"=",
"load... | Populate the ``arxiv_categories`` key.
Also populates the ``inspire_categories`` key through side effects. | [
"Populate",
"the",
"arxiv_categories",
"key",
"."
] | train | 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... | [
"def",
"birth_and_death_date2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"name_field",
"=",
"self",
".",
"get",
"(",
"'100'",
",",
"{",
"}",
")",
"if",
"'d'",
"in",
"name_field",
":",
"if",
"int",
"(",
"name_field",
"[",
"'d'",
"]",
".",
... | 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. | [
"Populate",
"the",
"100__d",
"MARC",
"field",
"which",
"includes",
"the",
"birth",
"and",
"the",
"death",
"date",
"."
] | train | 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... | [
"def",
"urls",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"description",
"=",
"force_single_element",
"(",
"value",
".",
"get",
"(",
"'y'",
")",
")",
"url",
"=",
"value",
".",
"get",
"(",
"'u'",
")",
"linkedin_match",
"=",
"LINKEDIN_URL",
".",
... | Populate the ``url`` key.
Also populates the ``ids`` key through side effects. | [
"Populate",
"the",
"url",
"key",
"."
] | train | 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... | [
"def",
"new_record",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"new_record",
"=",
"self",
".",
"get",
"(",
"'new_record'",
",",
"{",
"}",
")",
"ids",
"=",
"self",
".",
"get",
"(",
"'ids'",
",",
"[",
"]",
")",
"for",
"value",
"in",
"force_l... | Populate the ``new_record`` key.
Also populates the ``ids`` key through side effects. | [
"Populate",
"the",
"new_record",
"key",
"."
] | train | 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'... | [
"def",
"deleted",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_is_deleted",
"(",
"value",
")",
":",
"return",
"force_single_element",
"(",
"value",
".",
"get",
"(",
"'c'",
",",
"''",
")",
")",
".",
"upper",
"(",
")",
"==",
"'DELETED'",
... | Populate the ``deleted`` key.
Also populates the ``stub`` key through side effects. | [
"Populate",
"the",
"deleted",
"key",
"."
] | train | 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'):
... | [
"def",
"authors2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"value",
"=",
"force_list",
"(",
"value",
")",
"def",
"_get_ids",
"(",
"value",
")",
":",
"ids",
"=",
"{",
"'i'",
":",
"[",
"]",
",",
"'j'",
":",
"[",
"]",
",",
"}",
"if",
... | Populate the ``100`` MARC field.
Also populates the ``700`` and the ``701`` MARC fields through side effects. | [
"Populate",
"the",
"100",
"MARC",
"field",
"."
] | train | 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... | [
"def",
"isbns",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_get_medium",
"(",
"value",
")",
":",
"def",
"_normalize",
"(",
"medium",
")",
":",
"schema",
"=",
"load_schema",
"(",
"'hep'",
")",
"valid_media",
"=",
"schema",
"[",
"'propertie... | Populate the ``isbns`` key. | [
"Populate",
"the",
"isbns",
"key",
"."
] | train | 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... | [
"def",
"dois",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_get_first_non_curator_source",
"(",
"sources",
")",
":",
"sources_without_curator",
"=",
"[",
"el",
"for",
"el",
"in",
"sources",
"if",
"el",
".",
"upper",
"(",
")",
"!=",
"'CURATOR... | Populate the ``dois`` key.
Also populates the ``persistent_identifiers`` key through side effects. | [
"Populate",
"the",
"dois",
"key",
"."
] | train | 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'),
} | [
"def",
"dois2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"{",
"'2'",
":",
"'DOI'",
",",
"'9'",
":",
"value",
".",
"get",
"(",
"'source'",
")",
",",
"'a'",
":",
"value",
".",
"get",
"(",
"'value'",
")",
",",
"'q'",
":",
"va... | Populate the ``0247`` MARC field. | [
"Populate",
"the",
"0247",
"MARC",
"field",
"."
] | train | 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'),
} | [
"def",
"persistent_identifiers2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"{",
"'2'",
":",
"value",
".",
"get",
"(",
"'schema'",
")",
",",
"'9'",
":",
"value",
".",
"get",
"(",
"'source'",
")",
",",
"'a'",
":",
"value",
".",
... | Populate the ``0247`` MARC field. | [
"Populate",
"the",
"0247",
"MARC",
"field",
"."
] | train | 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 ('... | [
"def",
"texkeys",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_is_oai",
"(",
"id_",
",",
"schema",
")",
":",
"return",
"id_",
".",
"startswith",
"(",
"'oai:'",
")",
"def",
"_is_desy",
"(",
"id_",
",",
"schema",
")",
":",
"return",
"id_... | Populate the ``texkeys`` key.
Also populates the ``external_system_identifiers`` and ``_desy_bookkeeping`` keys through side effects. | [
"Populate",
"the",
"texkeys",
"key",
"."
] | train | 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({
... | [
"def",
"texkeys2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"result",
"=",
"[",
"]",
"values",
"=",
"force_list",
"(",
"value",
")",
"if",
"values",
":",
"value",
"=",
"values",
"[",
"0",
"]",
"result",
".",
"append",
"(",
"{",
"'9'",
... | Populate the ``035`` MARC field. | [
"Populate",
"the",
"035",
"MARC",
"field",
"."
] | train | 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... | [
"def",
"external_system_identifiers2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_is_scheme_cernkey",
"(",
"id_",
",",
"schema",
")",
":",
"return",
"schema",
"==",
"'CERNKEY'",
"def",
"_is_scheme_spires",
"(",
"id_",
",",
"schema",
")",
"... | 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. | [
"Populate",
"the",
"035",
"MARC",
"field",
"."
] | train | 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 _... | [
"def",
"arxiv_eprints",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_get_clean_arxiv_eprint",
"(",
"id_",
")",
":",
"return",
"id_",
".",
"split",
"(",
"':'",
")",
"[",
"-",
"1",
"]",
"def",
"_is_arxiv_eprint",
"(",
"id_",
",",
"source",
... | Populate the ``arxiv_eprints`` key.
Also populates the ``report_numbers`` key through side effects. | [
"Populate",
"the",
"arxiv_eprints",
"key",
"."
] | train | 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:
... | [
"def",
"arxiv_eprints2marc",
"(",
"self",
",",
"key",
",",
"values",
")",
":",
"result_037",
"=",
"self",
".",
"get",
"(",
"'037'",
",",
"[",
"]",
")",
"result_035",
"=",
"self",
".",
"get",
"(",
"'035'",
",",
"[",
"]",
")",
"result_65017",
"=",
"s... | Populate the ``037`` MARC field.
Also populates the ``035`` and the ``65017`` MARC fields through side effects. | [
"Populate",
"the",
"037",
"MARC",
"field",
"."
] | train | 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 {
... | [
"def",
"report_numbers2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_get_mangled_source",
"(",
"source",
")",
":",
"if",
"source",
"==",
"'arXiv'",
":",
"return",
"'arXiv:reportnumber'",
"return",
"source",
"source",
"=",
"_get_mangled_source"... | Populate the ``037`` MARC field. | [
"Populate",
"the",
"037",
"MARC",
"field",
"."
] | train | 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... | [
"def",
"languages",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"languages",
"=",
"self",
".",
"get",
"(",
"'languages'",
",",
"[",
"]",
")",
"values",
"=",
"force_list",
"(",
"value",
".",
"get",
"(",
"'a'",
")",
")",
"for",
"value",
"in",
... | Populate the ``languages`` key. | [
"Populate",
"the",
"languages",
"key",
"."
] | train | 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()} | [
"def",
"languages2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"{",
"'a'",
":",
"pycountry",
".",
"languages",
".",
"get",
"(",
"alpha_2",
"=",
"value",
")",
".",
"name",
".",
"lower",
"(",
")",
"}"
] | Populate the ``041`` MARC field. | [
"Populate",
"the",
"041",
"MARC",
"field",
"."
] | train | 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'),
} | [
"def",
"record_affiliations",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"record",
"=",
"get_record_ref",
"(",
"value",
".",
"get",
"(",
"'z'",
")",
",",
"'institutions'",
")",
"return",
"{",
"'curated_relation'",
":",
"record",
"is",
"not",
"None",
... | Populate the ``record_affiliations`` key. | [
"Populate",
"the",
"record_affiliations",
"key",
"."
] | train | 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... | [
"def",
"document_type",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"schema",
"=",
"load_schema",
"(",
"'hep'",
")",
"publication_type_schema",
"=",
"schema",
"[",
"'properties'",
"]",
"[",
"'publication_type'",
"]",
"valid_publication_types",
"=",
"publica... | Populate the ``document_type`` key.
Also populates the ``_collections``, ``citeable``, ``core``, ``deleted``,
``refereed``, ``publication_type``, and ``withdrawn`` keys through side
effects. | [
"Populate",
"the",
"document_type",
"key",
"."
] | train | 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]} | [
"def",
"document_type2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"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. | [
"Populate",
"the",
"980",
"MARC",
"field",
"."
] | train | 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(... | [
"def",
"references",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_has_curator_flag",
"(",
"value",
")",
":",
"normalized_nine_values",
"=",
"[",
"el",
".",
"upper",
"(",
")",
"for",
"el",
"in",
"force_list",
"(",
"value",
".",
"get",
"(",
... | Populate the ``references`` key. | [
"Populate",
"the",
"references",
"key",
"."
] | train | 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... | [
"def",
"references2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"reference",
"=",
"value",
".",
"get",
"(",
"'reference'",
",",
"{",
"}",
")",
"pids",
"=",
"force_list",
"(",
"reference",
".",
"get",
"(",
"'persistent_identifiers'",
")",
")",
... | Populate the ``999C5`` MARC field. | [
"Populate",
"the",
"999C5",
"MARC",
"field",
"."
] | train | 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... | [
"def",
"documents",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_is_hidden",
"(",
"value",
")",
":",
"return",
"'HIDDEN'",
"in",
"[",
"val",
".",
"upper",
"(",
")",
"for",
"val",
"in",
"value",
"]",
"or",
"None",
"def",
"_is_figure",
"... | Populate the ``documents`` key.
Also populates the ``figures`` key through side effects. | [
"Populate",
"the",
"documents",
"key",
"."
] | train | 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... | [
"def",
"marcxml2record",
"(",
"marcxml",
")",
":",
"marcjson",
"=",
"create_record",
"(",
"marcxml",
",",
"keep_singletons",
"=",
"False",
")",
"collections",
"=",
"_get_collections",
"(",
"marcjson",
")",
"if",
"'conferences'",
"in",
"collections",
":",
"return... | 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... | [
"Convert",
"a",
"MARCXML",
"string",
"to",
"a",
"JSON",
"record",
"."
] | train | 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... | [
"def",
"record2marcxml",
"(",
"record",
")",
":",
"schema_name",
"=",
"_get_schema_name",
"(",
"record",
")",
"if",
"schema_name",
"==",
"'hep'",
":",
"marcjson",
"=",
"hep2marc",
".",
"do",
"(",
"record",
")",
"elif",
"schema_name",
"==",
"'authors'",
":",
... | 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. | [
"Convert",
"a",
"JSON",
"record",
"to",
"a",
"MARCXML",
"string",
"."
] | train | 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 | [
"def",
"number_of_pages",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"result",
"=",
"maybe_int",
"(",
"force_single_element",
"(",
"value",
".",
"get",
"(",
"'a'",
",",
"''",
")",
")",
")",
"if",
"result",
"and",
"result",
">",
"0",
":",
"retur... | Populate the ``number_of_pages`` key. | [
"Populate",
"the",
"number_of_pages",
"key",
"."
] | train | 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-... | [
"def",
"secondary_report_numbers",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"preliminary_results_prefixes",
"=",
"[",
"'ATLAS-CONF-'",
",",
"'CMS-PAS-'",
",",
"'CMS-DP-'",
",",
"'LHCB-CONF-'",
"]",
"note_prefixes",
"=",
"[",
"'ALICE-INT-'",
",",
"'ATL-'",
... | Populate the ``037`` MARC field.
Also populates the ``500``, ``595`` and ``980`` MARC field through side effects. | [
"Populate",
"the",
"037",
"MARC",
"field",
"."
] | train | 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', '')))... | [
"def",
"nonfirst_authors",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"field_700",
"=",
"self",
".",
"get",
"(",
"'700__'",
",",
"[",
"]",
")",
"field_701",
"=",
"self",
".",
"get",
"(",
"'701__'",
",",
"[",
"]",
")",
"is_supervisor",
"=",
"a... | Populate ``700`` MARC field.
Also populates the ``701`` MARC field through side-effects. | [
"Populate",
"700",
"MARC",
"field",
"."
] | train | 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(... | [
"def",
"urls",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_is_preprint",
"(",
"value",
")",
":",
"return",
"value",
".",
"get",
"(",
"'y'",
",",
"''",
")",
".",
"lower",
"(",
")",
"==",
"'preprint'",
"def",
"_is_fulltext",
"(",
"value... | Populate the ``8564`` MARC field.
Also populate the ``FFT`` field through side effects. | [
"Populate",
"the",
"8564",
"MARC",
"field",
"."
] | train | 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(... | [
"def",
"titles",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"not",
"key",
".",
"startswith",
"(",
"'245'",
")",
":",
"return",
"{",
"'source'",
":",
"value",
".",
"get",
"(",
"'9'",
")",
",",
"'subtitle'",
":",
"value",
".",
"get",
"(... | Populate the ``titles`` key. | [
"Populate",
"the",
"titles",
"key",
"."
] | train | 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'),
} | [
"def",
"title_translations",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"{",
"'language'",
":",
"langdetect",
".",
"detect",
"(",
"value",
".",
"get",
"(",
"'a'",
")",
")",
",",
"'source'",
":",
"value",
".",
"get",
"(",
"'9'",
")",
... | Populate the ``title_translations`` key. | [
"Populate",
"the",
"title_translations",
"key",
"."
] | train | 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... | [
"def",
"titles2marc",
"(",
"self",
",",
"key",
",",
"values",
")",
":",
"first",
",",
"rest",
"=",
"values",
"[",
"0",
"]",
",",
"values",
"[",
"1",
":",
"]",
"self",
".",
"setdefault",
"(",
"'245'",
",",
"[",
"]",
")",
".",
"append",
"(",
"{",... | Populate the ``246`` MARC field.
Also populates the ``245`` MARC field through side effects. | [
"Populate",
"the",
"246",
"MARC",
"field",
"."
] | train | 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'),
} | [
"def",
"title_translations2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"{",
"'a'",
":",
"value",
".",
"get",
"(",
"'title'",
")",
",",
"'b'",
":",
"value",
".",
"get",
"(",
"'subtitle'",
")",
",",
"'9'",
":",
"value",
".",
"ge... | Populate the ``242`` MARC field. | [
"Populate",
"the",
"242",
"MARC",
"field",
"."
] | train | 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')),
} | [
"def",
"imprints",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"{",
"'place'",
":",
"value",
".",
"get",
"(",
"'a'",
")",
",",
"'publisher'",
":",
"value",
".",
"get",
"(",
"'b'",
")",
",",
"'date'",
":",
"normalize_date_aggressively",
... | Populate the ``imprints`` key. | [
"Populate",
"the",
"imprints",
"key",
"."
] | train | 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'),
} | [
"def",
"imprints2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"{",
"'a'",
":",
"value",
".",
"get",
"(",
"'place'",
")",
",",
"'b'",
":",
"value",
".",
"get",
"(",
"'publisher'",
")",
",",
"'c'",
":",
"value",
".",
"get",
"("... | Populate the ``260`` MARC field. | [
"Populate",
"the",
"260",
"MARC",
"field",
"."
] | train | 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... | [
"def",
"public_notes",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_means_not_curated",
"(",
"public_note",
")",
":",
"return",
"public_note",
"in",
"[",
"'*Brief entry*'",
",",
"'* Brief entry *'",
",",
"'*Temporary entry*'",
",",
"'* Temporary entry... | Populate the ``public_notes`` key.
Also populates the ``curated`` and ``thesis_info`` keys through side effects. | [
"Populate",
"the",
"public_notes",
"key",
"."
] | train | 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... | [
"def",
"thesis_info",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_get_degree_type",
"(",
"value",
")",
":",
"DEGREE_TYPES_MAP",
"=",
"{",
"'RAPPORT DE STAGE'",
":",
"'other'",
",",
"'INTERNSHIP REPORT'",
":",
"'other'",
",",
"'DIPLOMA'",
":",
"... | Populate the ``thesis_info`` key. | [
"Populate",
"the",
"thesis_info",
"key",
"."
] | train | 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... | [
"def",
"thesis_info2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"_get_b_value",
"(",
"value",
")",
":",
"DEGREE_TYPES_MAP",
"=",
"{",
"'bachelor'",
":",
"'Bachelor'",
",",
"'diploma'",
":",
"'Diploma'",
",",
"'habilitation'",
":",
"'Habili... | Populate the ``502`` MARC field.
Also populates the ``500`` MARC field through side effects. | [
"Populate",
"the",
"502",
"MARC",
"field",
"."
] | train | 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 | [
"def",
"abstracts",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"result",
"=",
"[",
"]",
"source",
"=",
"force_single_element",
"(",
"value",
".",
"get",
"(",
"'9'",
")",
")",
"for",
"a_value",
"in",
"force_list",
"(",
"value",
".",
"get",
"(",
... | Populate the ``abstracts`` key. | [
"Populate",
"the",
"abstracts",
"key",
"."
] | train | 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'),
} | [
"def",
"funding_info",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"{",
"'agency'",
":",
"value",
".",
"get",
"(",
"'a'",
")",
",",
"'grant_number'",
":",
"value",
".",
"get",
"(",
"'c'",
")",
",",
"'project_number'",
":",
"value",
"."... | Populate the ``funding_info`` key. | [
"Populate",
"the",
"funding_info",
"key",
"."
] | train | 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'),
} | [
"def",
"funding_info2marc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"{",
"'a'",
":",
"value",
".",
"get",
"(",
"'agency'",
")",
",",
"'c'",
":",
"value",
".",
"get",
"(",
"'grant_number'",
")",
",",
"'f'",
":",
"value",
".",
"get... | Populate the ``536`` MARC field. | [
"Populate",
"the",
"536",
"MARC",
"field",
"."
] | train | https://github.com/inspirehep/inspire-dojson/blob/17f3789cd3d5ae58efa1190dc0eea9efb9c8ca59/inspire_dojson/hep/rules/bd5xx.py#L210-L216 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.