repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
astropy/astropy-healpix | astropy_healpix/healpy.py | ang2vec | def ang2vec(theta, phi, lonlat=False):
"""Drop-in replacement for healpy `~healpy.pixelfunc.ang2vec`."""
lon, lat = _healpy_to_lonlat(theta, phi, lonlat=lonlat)
rep_sph = UnitSphericalRepresentation(lon, lat)
rep_car = rep_sph.represent_as(CartesianRepresentation)
return rep_car.xyz.value | python | def ang2vec(theta, phi, lonlat=False):
"""Drop-in replacement for healpy `~healpy.pixelfunc.ang2vec`."""
lon, lat = _healpy_to_lonlat(theta, phi, lonlat=lonlat)
rep_sph = UnitSphericalRepresentation(lon, lat)
rep_car = rep_sph.represent_as(CartesianRepresentation)
return rep_car.xyz.value | Drop-in replacement for healpy `~healpy.pixelfunc.ang2vec`. | https://github.com/astropy/astropy-healpix/blob/c7fbe36305aadda9946dd37969d5dcb9ff6b1440/astropy_healpix/healpy.py#L169-L174 |
astropy/astropy-healpix | astropy_healpix/healpy.py | get_interp_weights | def get_interp_weights(nside, theta, phi=None, nest=False, lonlat=False):
"""
Drop-in replacement for healpy `~healpy.pixelfunc.get_interp_weights`.
Although note that the order of the weights and pixels may differ.
"""
# if phi is not given, theta is interpreted as pixel number
if phi is None:... | python | def get_interp_weights(nside, theta, phi=None, nest=False, lonlat=False):
"""
Drop-in replacement for healpy `~healpy.pixelfunc.get_interp_weights`.
Although note that the order of the weights and pixels may differ.
"""
# if phi is not given, theta is interpreted as pixel number
if phi is None:... | Drop-in replacement for healpy `~healpy.pixelfunc.get_interp_weights`.
Although note that the order of the weights and pixels may differ. | https://github.com/astropy/astropy-healpix/blob/c7fbe36305aadda9946dd37969d5dcb9ff6b1440/astropy_healpix/healpy.py#L177-L188 |
astropy/astropy-healpix | astropy_healpix/healpy.py | get_interp_val | def get_interp_val(m, theta, phi, nest=False, lonlat=False):
"""
Drop-in replacement for healpy `~healpy.pixelfunc.get_interp_val`.
"""
lon, lat = _healpy_to_lonlat(theta, phi, lonlat=lonlat)
return interpolate_bilinear_lonlat(lon, lat, m, order='nested' if nest else 'ring') | python | def get_interp_val(m, theta, phi, nest=False, lonlat=False):
"""
Drop-in replacement for healpy `~healpy.pixelfunc.get_interp_val`.
"""
lon, lat = _healpy_to_lonlat(theta, phi, lonlat=lonlat)
return interpolate_bilinear_lonlat(lon, lat, m, order='nested' if nest else 'ring') | Drop-in replacement for healpy `~healpy.pixelfunc.get_interp_val`. | https://github.com/astropy/astropy-healpix/blob/c7fbe36305aadda9946dd37969d5dcb9ff6b1440/astropy_healpix/healpy.py#L191-L196 |
astropy/astropy-healpix | astropy_healpix/bench.py | bench_run | def bench_run(fast=False):
"""Run all benchmarks. Return results as a dict."""
results = []
if fast:
SIZES = [10, 1e3, 1e5]
else:
SIZES = [10, 1e3, 1e6]
for nest in [True, False]:
for size in SIZES:
for nside in [1, 128]:
results.append(run_singl... | python | def bench_run(fast=False):
"""Run all benchmarks. Return results as a dict."""
results = []
if fast:
SIZES = [10, 1e3, 1e5]
else:
SIZES = [10, 1e3, 1e6]
for nest in [True, False]:
for size in SIZES:
for nside in [1, 128]:
results.append(run_singl... | Run all benchmarks. Return results as a dict. | https://github.com/astropy/astropy-healpix/blob/c7fbe36305aadda9946dd37969d5dcb9ff6b1440/astropy_healpix/bench.py#L150-L188 |
astropy/astropy-healpix | astropy_healpix/bench.py | bench_report | def bench_report(results):
"""Print a report for given benchmark results to the console."""
table = Table(names=['function', 'nest', 'nside', 'size',
'time_healpy', 'time_self', 'ratio'],
dtype=['S20', bool, int, int, float, float, float], masked=True)
for row in ... | python | def bench_report(results):
"""Print a report for given benchmark results to the console."""
table = Table(names=['function', 'nest', 'nside', 'size',
'time_healpy', 'time_self', 'ratio'],
dtype=['S20', bool, int, int, float, float, float], masked=True)
for row in ... | Print a report for given benchmark results to the console. | https://github.com/astropy/astropy-healpix/blob/c7fbe36305aadda9946dd37969d5dcb9ff6b1440/astropy_healpix/bench.py#L191-L207 |
astropy/astropy-healpix | astropy_healpix/bench.py | main | def main(fast=False):
"""Run all benchmarks and print report to the console."""
print('Running benchmarks...\n')
results = bench_run(fast=fast)
bench_report(results) | python | def main(fast=False):
"""Run all benchmarks and print report to the console."""
print('Running benchmarks...\n')
results = bench_run(fast=fast)
bench_report(results) | Run all benchmarks and print report to the console. | https://github.com/astropy/astropy-healpix/blob/c7fbe36305aadda9946dd37969d5dcb9ff6b1440/astropy_healpix/bench.py#L210-L214 |
dtheodor/flask-sqlalchemy-session | flask_sqlalchemy_session/__init__.py | flask_scoped_session.init_app | def init_app(self, app):
"""Setup scoped sesssion creation and teardown for the passed ``app``.
:param app: a :class:`~flask.Flask` application
"""
app.scoped_session = self
@app.teardown_appcontext
def remove_scoped_session(*args, **kwargs):
# pylint: disab... | python | def init_app(self, app):
"""Setup scoped sesssion creation and teardown for the passed ``app``.
:param app: a :class:`~flask.Flask` application
"""
app.scoped_session = self
@app.teardown_appcontext
def remove_scoped_session(*args, **kwargs):
# pylint: disab... | Setup scoped sesssion creation and teardown for the passed ``app``.
:param app: a :class:`~flask.Flask` application | https://github.com/dtheodor/flask-sqlalchemy-session/blob/c7ddb03e85cdd27fcdcc809b9e1c29d7738d8ebf/flask_sqlalchemy_session/__init__.py#L66-L76 |
viniciuschiele/flask-apidoc | flask_apidoc/utils.py | cached | def cached(f):
"""
Cache decorator for functions taking one or more arguments.
:param f: The function to be cached.
:return: The cached value.
"""
cache = f.cache = {}
@functools.wraps(f)
def decorator(*args, **kwargs):
key = str(args) + str(kwargs)
if key not in cache:... | python | def cached(f):
"""
Cache decorator for functions taking one or more arguments.
:param f: The function to be cached.
:return: The cached value.
"""
cache = f.cache = {}
@functools.wraps(f)
def decorator(*args, **kwargs):
key = str(args) + str(kwargs)
if key not in cache:... | Cache decorator for functions taking one or more arguments.
:param f: The function to be cached.
:return: The cached value. | https://github.com/viniciuschiele/flask-apidoc/blob/5c3dfd9aae7780622e843bf7e95863264df3a488/flask_apidoc/utils.py#L8-L23 |
rdidyk/falcon-swagger-ui | falcon_swagger_ui/resources.py | register_swaggerui_app | def register_swaggerui_app(app, swagger_uri, api_url, page_title='Swagger UI', favicon_url=None, config=None, uri_prefix=""):
""":type app: falcon.API"""
templates_folder = 'templates'
static_folder = 'dist'
default_config = {
'client_realm': 'null',
'client_id': 'null',
'clie... | python | def register_swaggerui_app(app, swagger_uri, api_url, page_title='Swagger UI', favicon_url=None, config=None, uri_prefix=""):
""":type app: falcon.API"""
templates_folder = 'templates'
static_folder = 'dist'
default_config = {
'client_realm': 'null',
'client_id': 'null',
'clie... | :type app: falcon.API | https://github.com/rdidyk/falcon-swagger-ui/blob/ea6909d78cd03178b1b0888452b2b4bb14e9d571/falcon_swagger_ui/resources.py#L62-L106 |
viniciuschiele/flask-apidoc | flask_apidoc/apidoc.py | ApiDoc.init_app | def init_app(self, app):
"""
Adds the flask url routes for the apidoc files.
:param app: the flask application.
"""
self.app = app
self.dynamic_url = self.app.config.get('APIDOC_DYNAMIC_URL', self.dynamic_url)
self.allow_absolute_url = self.app.config.get('APIDO... | python | def init_app(self, app):
"""
Adds the flask url routes for the apidoc files.
:param app: the flask application.
"""
self.app = app
self.dynamic_url = self.app.config.get('APIDOC_DYNAMIC_URL', self.dynamic_url)
self.allow_absolute_url = self.app.config.get('APIDO... | Adds the flask url routes for the apidoc files.
:param app: the flask application. | https://github.com/viniciuschiele/flask-apidoc/blob/5c3dfd9aae7780622e843bf7e95863264df3a488/flask_apidoc/apidoc.py#L43-L60 |
viniciuschiele/flask-apidoc | flask_apidoc/apidoc.py | ApiDoc.__send_static_file | def __send_static_file(self, path=None):
"""
Send apidoc files from the apidoc folder to the browser.
:param path: the apidoc file.
"""
if not path:
path = 'index.html'
file_name = join(self.folder_path, path)
# the api_project.js has the absolute u... | python | def __send_static_file(self, path=None):
"""
Send apidoc files from the apidoc folder to the browser.
:param path: the apidoc file.
"""
if not path:
path = 'index.html'
file_name = join(self.folder_path, path)
# the api_project.js has the absolute u... | Send apidoc files from the apidoc folder to the browser.
:param path: the apidoc file. | https://github.com/viniciuschiele/flask-apidoc/blob/5c3dfd9aae7780622e843bf7e95863264df3a488/flask_apidoc/apidoc.py#L62-L82 |
viniciuschiele/flask-apidoc | flask_apidoc/apidoc.py | ApiDoc.__send_api_file | def __send_api_file(self, file_name):
"""
Send apidoc files from the apidoc folder to the browser.
This method replaces all absolute urls in the file by
the current url.
:param file_name: the apidoc file.
"""
file_name = join(self.app.static_folder, file_name)
... | python | def __send_api_file(self, file_name):
"""
Send apidoc files from the apidoc folder to the browser.
This method replaces all absolute urls in the file by
the current url.
:param file_name: the apidoc file.
"""
file_name = join(self.app.static_folder, file_name)
... | Send apidoc files from the apidoc folder to the browser.
This method replaces all absolute urls in the file by
the current url.
:param file_name: the apidoc file. | https://github.com/viniciuschiele/flask-apidoc/blob/5c3dfd9aae7780622e843bf7e95863264df3a488/flask_apidoc/apidoc.py#L85-L121 |
viniciuschiele/flask-apidoc | flask_apidoc/apidoc.py | ApiDoc.__send_main_file | def __send_main_file(self, file_name):
"""
Send apidoc files from the apidoc folder to the browser.
This method replaces all absolute urls in the file by
the current url.
:param file_name: the apidoc file.
"""
file_name = join(self.app.static_folder, file_name)
... | python | def __send_main_file(self, file_name):
"""
Send apidoc files from the apidoc folder to the browser.
This method replaces all absolute urls in the file by
the current url.
:param file_name: the apidoc file.
"""
file_name = join(self.app.static_folder, file_name)
... | Send apidoc files from the apidoc folder to the browser.
This method replaces all absolute urls in the file by
the current url.
:param file_name: the apidoc file. | https://github.com/viniciuschiele/flask-apidoc/blob/5c3dfd9aae7780622e843bf7e95863264df3a488/flask_apidoc/apidoc.py#L124-L152 |
viniciuschiele/flask-apidoc | flask_apidoc/apidoc.py | ApiDoc.__read_api_project | def __read_api_project(self):
"""
Reads the api_project.json file from apidoc folder as a json string.
:return: a json string
"""
file_name = join(self.app.static_folder, self.folder_path, 'api_project.json')
with open(file_name, 'rt') as file:
data = file.r... | python | def __read_api_project(self):
"""
Reads the api_project.json file from apidoc folder as a json string.
:return: a json string
"""
file_name = join(self.app.static_folder, self.folder_path, 'api_project.json')
with open(file_name, 'rt') as file:
data = file.r... | Reads the api_project.json file from apidoc folder as a json string.
:return: a json string | https://github.com/viniciuschiele/flask-apidoc/blob/5c3dfd9aae7780622e843bf7e95863264df3a488/flask_apidoc/apidoc.py#L155-L166 |
dchaplinsky/aiohttp_validate | aiohttp_validate/__init__.py | _raise_exception | def _raise_exception(cls, reason, data=None):
"""
Raise aiohttp exception and pass payload/reason into it.
"""
text_dict = {
"error": reason
}
if data is not None:
text_dict["errors"] = data
raise cls(
text=json.dumps(text_dict),
content_type="application/js... | python | def _raise_exception(cls, reason, data=None):
"""
Raise aiohttp exception and pass payload/reason into it.
"""
text_dict = {
"error": reason
}
if data is not None:
text_dict["errors"] = data
raise cls(
text=json.dumps(text_dict),
content_type="application/js... | Raise aiohttp exception and pass payload/reason into it. | https://github.com/dchaplinsky/aiohttp_validate/blob/e581cf51df6fcc377c7704315a487b10c3dd6000/aiohttp_validate/__init__.py#L15-L29 |
dchaplinsky/aiohttp_validate | aiohttp_validate/__init__.py | _validate_data | def _validate_data(data, schema, validator_cls):
"""
Validate the dict against given schema (using given validator class).
"""
validator = validator_cls(schema)
_errors = defaultdict(list)
for err in validator.iter_errors(data):
path = err.schema_path
# Code courtesy: Ruslan Kar... | python | def _validate_data(data, schema, validator_cls):
"""
Validate the dict against given schema (using given validator class).
"""
validator = validator_cls(schema)
_errors = defaultdict(list)
for err in validator.iter_errors(data):
path = err.schema_path
# Code courtesy: Ruslan Kar... | Validate the dict against given schema (using given validator class). | https://github.com/dchaplinsky/aiohttp_validate/blob/e581cf51df6fcc377c7704315a487b10c3dd6000/aiohttp_validate/__init__.py#L32-L74 |
dchaplinsky/aiohttp_validate | aiohttp_validate/__init__.py | validate | def validate(request_schema=None, response_schema=None):
"""
Decorate request handler to make it automagically validate it's request
and response.
"""
def wrapper(func):
# Validating the schemas itself.
# Die with exception if they aren't valid
if request_schema is not None:
... | python | def validate(request_schema=None, response_schema=None):
"""
Decorate request handler to make it automagically validate it's request
and response.
"""
def wrapper(func):
# Validating the schemas itself.
# Die with exception if they aren't valid
if request_schema is not None:
... | Decorate request handler to make it automagically validate it's request
and response. | https://github.com/dchaplinsky/aiohttp_validate/blob/e581cf51df6fcc377c7704315a487b10c3dd6000/aiohttp_validate/__init__.py#L77-L148 |
biolink/biolink-model | metamodel/generators/jsonschemagen.py | cli | def cli(yamlfile, inline, format):
""" Generate JSON Schema representation of a biolink model """
print(JsonSchemaGenerator(yamlfile, format).serialize(inline=inline)) | python | def cli(yamlfile, inline, format):
""" Generate JSON Schema representation of a biolink model """
print(JsonSchemaGenerator(yamlfile, format).serialize(inline=inline)) | Generate JSON Schema representation of a biolink model | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/jsonschemagen.py#L90-L92 |
biolink/biolink-model | metamodel/utils/yamlutils.py | root_representer | def root_representer(dumper: yaml.Dumper, data: YAMLRoot):
""" YAML callback -- used to filter out empty values (None, {}, [] and false)
@param dumper: data dumper
@param data: data to be dumped
@return:
"""
rval = dict()
for k, v in data.__dict__.items():
if not k.startswith('_') a... | python | def root_representer(dumper: yaml.Dumper, data: YAMLRoot):
""" YAML callback -- used to filter out empty values (None, {}, [] and false)
@param dumper: data dumper
@param data: data to be dumped
@return:
"""
rval = dict()
for k, v in data.__dict__.items():
if not k.startswith('_') a... | YAML callback -- used to filter out empty values (None, {}, [] and false)
@param dumper: data dumper
@param data: data to be dumped
@return: | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/yamlutils.py#L47-L58 |
biolink/biolink-model | metamodel/generators/markdowngen.py | cli | def cli(yamlfile, format, dir, classes, img, noimages):
""" Generate markdown documentation of a biolink model """
MarkdownGenerator(yamlfile, format).serialize(classes=classes, directory=dir, image_dir=img, noimages=noimages) | python | def cli(yamlfile, format, dir, classes, img, noimages):
""" Generate markdown documentation of a biolink model """
MarkdownGenerator(yamlfile, format).serialize(classes=classes, directory=dir, image_dir=img, noimages=noimages) | Generate markdown documentation of a biolink model | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/markdowngen.py#L316-L318 |
biolink/biolink-model | metamodel/generators/markdowngen.py | MarkdownGenerator.is_secondary_ref | def is_secondary_ref(self, en: str) -> bool:
""" Determine whether 'en' is the name of something in the neighborhood of the requested classes
@param en: element name
@return: True if 'en' is the name of a slot, class or type in the immediate neighborhood of of what we are
building
... | python | def is_secondary_ref(self, en: str) -> bool:
""" Determine whether 'en' is the name of something in the neighborhood of the requested classes
@param en: element name
@return: True if 'en' is the name of a slot, class or type in the immediate neighborhood of of what we are
building
... | Determine whether 'en' is the name of something in the neighborhood of the requested classes
@param en: element name
@return: True if 'en' is the name of a slot, class or type in the immediate neighborhood of of what we are
building | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/markdowngen.py#L191-L207 |
biolink/biolink-model | metamodel/generators/markdowngen.py | MarkdownGenerator.bbin | def bbin(obj: Union[str, Element]) -> str:
""" Boldify built in types
@param obj: object name or id
@return:
"""
return obj.name if isinstance(obj, Element ) else f'**{obj}**' if obj in builtin_names else obj | python | def bbin(obj: Union[str, Element]) -> str:
""" Boldify built in types
@param obj: object name or id
@return:
"""
return obj.name if isinstance(obj, Element ) else f'**{obj}**' if obj in builtin_names else obj | Boldify built in types
@param obj: object name or id
@return: | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/markdowngen.py#L254-L260 |
biolink/biolink-model | metamodel/generators/markdowngen.py | MarkdownGenerator.desc_for | def desc_for(self, obj: Element, doing_descs: bool) -> str:
""" Return a description for object if it is unique (different than its parent)
@param obj: object to be described
@param doing_descs: If false, always return an empty string
@return: text or empty string
"""
if... | python | def desc_for(self, obj: Element, doing_descs: bool) -> str:
""" Return a description for object if it is unique (different than its parent)
@param obj: object to be described
@param doing_descs: If false, always return an empty string
@return: text or empty string
"""
if... | Return a description for object if it is unique (different than its parent)
@param obj: object to be described
@param doing_descs: If false, always return an empty string
@return: text or empty string | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/markdowngen.py#L262-L277 |
biolink/biolink-model | metamodel/generators/markdowngen.py | MarkdownGenerator.link | def link(self, ref: Optional[Union[str, Element]], *, after_link: str = None, use_desc: bool=False,
add_subset: bool=True) -> str:
""" Create a link to ref if appropriate.
@param ref: the name or value of a class, slot, type or the name of a built in type.
@param after_link: Text t... | python | def link(self, ref: Optional[Union[str, Element]], *, after_link: str = None, use_desc: bool=False,
add_subset: bool=True) -> str:
""" Create a link to ref if appropriate.
@param ref: the name or value of a class, slot, type or the name of a built in type.
@param after_link: Text t... | Create a link to ref if appropriate.
@param ref: the name or value of a class, slot, type or the name of a built in type.
@param after_link: Text to put between link and description
@param use_desc: True means append a description after the link if available
@param add_subset: True mean... | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/markdowngen.py#L279-L303 |
biolink/biolink-model | metamodel/generators/owlgen.py | cli | def cli(yamlfile, format, output):
""" Generate an OWL representation of a biolink model """
print(OwlSchemaGenerator(yamlfile, format).serialize(output=output)) | python | def cli(yamlfile, format, output):
""" Generate an OWL representation of a biolink model """
print(OwlSchemaGenerator(yamlfile, format).serialize(output=output)) | Generate an OWL representation of a biolink model | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/owlgen.py#L197-L199 |
biolink/biolink-model | metamodel/generators/owlgen.py | OwlSchemaGenerator.visit_slot | def visit_slot(self, slot_name: str, slot: SlotDefinition) -> None:
""" Add a slot definition per slot
@param slot_name:
@param slot:
@return:
"""
# Note: We use the raw name in OWL and add a subProperty arc
slot_uri = self.prop_uri(slot.name)
# Parent s... | python | def visit_slot(self, slot_name: str, slot: SlotDefinition) -> None:
""" Add a slot definition per slot
@param slot_name:
@param slot:
@return:
"""
# Note: We use the raw name in OWL and add a subProperty arc
slot_uri = self.prop_uri(slot.name)
# Parent s... | Add a slot definition per slot
@param slot_name:
@param slot:
@return: | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/owlgen.py#L153-L189 |
biolink/biolink-model | metamodel/utils/loadschema.py | load_raw_schema | def load_raw_schema(data: Union[str, TextIO],
source_file: str=None,
source_file_date: str=None,
source_file_size: int=None,
base_dir: Optional[str]=None) -> SchemaDefinition:
""" Load and flatten SchemaDefinition from a file name, a UR... | python | def load_raw_schema(data: Union[str, TextIO],
source_file: str=None,
source_file_date: str=None,
source_file_size: int=None,
base_dir: Optional[str]=None) -> SchemaDefinition:
""" Load and flatten SchemaDefinition from a file name, a UR... | Load and flatten SchemaDefinition from a file name, a URL or a block of text
@param data: URL, file name or block of text
@param source_file: Source file name for the schema
@param source_file_date: timestamp of source file
@param source_file_size: size of source file
@param base_dir: Working direc... | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/loadschema.py#L14-L61 |
biolink/biolink-model | metamodel/utils/loadschema.py | DupCheckYamlLoader.map_constructor | def map_constructor(self, loader, node, deep=False):
""" Walk the mapping, recording any duplicate keys.
"""
mapping = {}
for key_node, value_node in node.value:
key = loader.construct_object(key_node, deep=deep)
value = loader.construct_object(value_node, deep=... | python | def map_constructor(self, loader, node, deep=False):
""" Walk the mapping, recording any duplicate keys.
"""
mapping = {}
for key_node, value_node in node.value:
key = loader.construct_object(key_node, deep=deep)
value = loader.construct_object(value_node, deep=... | Walk the mapping, recording any duplicate keys. | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/loadschema.py#L69-L81 |
biolink/biolink-model | metamodel/utils/comparefiles.py | cli | def cli(file1, file2, comments) -> int:
""" Compare file1 to file2 using a filter """
sys.exit(compare_files(file1, file2, comments)) | python | def cli(file1, file2, comments) -> int:
""" Compare file1 to file2 using a filter """
sys.exit(compare_files(file1, file2, comments)) | Compare file1 to file2 using a filter | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/comparefiles.py#L26-L28 |
biolink/biolink-model | metamodel/generators/golrgen.py | cli | def cli(file, dir, format):
""" Generate GOLR representation of a biolink model """
print(GolrSchemaGenerator(file, format).serialize(dirname=dir)) | python | def cli(file, dir, format):
""" Generate GOLR representation of a biolink model """
print(GolrSchemaGenerator(file, format).serialize(dirname=dir)) | Generate GOLR representation of a biolink model | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/golrgen.py#L87-L89 |
biolink/biolink-model | metamodel/generators/dotgen.py | cli | def cli(yamlfile, directory, out, classname, format):
""" Generate graphviz representations of the biolink model """
DotGenerator(yamlfile, format).serialize(classname=classname, dirname=directory, filename=out) | python | def cli(yamlfile, directory, out, classname, format):
""" Generate graphviz representations of the biolink model """
DotGenerator(yamlfile, format).serialize(classname=classname, dirname=directory, filename=out) | Generate graphviz representations of the biolink model | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/dotgen.py#L101-L103 |
biolink/biolink-model | metamodel/generators/jsonldgen.py | cli | def cli(yamlfile, format, context):
""" Generate JSONLD file from biolink schema """
print(JSONLDGenerator(yamlfile, format).serialize(context=context)) | python | def cli(yamlfile, format, context):
""" Generate JSONLD file from biolink schema """
print(JSONLDGenerator(yamlfile, format).serialize(context=context)) | Generate JSONLD file from biolink schema | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/jsonldgen.py#L102-L104 |
biolink/biolink-model | metamodel/generators/rdfgen.py | cli | def cli(yamlfile, format, output, context):
""" Generate an RDF representation of a biolink model """
print(RDFGenerator(yamlfile, format).serialize(output=output, context=context)) | python | def cli(yamlfile, format, output, context):
""" Generate an RDF representation of a biolink model """
print(RDFGenerator(yamlfile, format).serialize(output=output, context=context)) | Generate an RDF representation of a biolink model | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/rdfgen.py#L48-L50 |
biolink/biolink-model | metamodel/utils/generator.py | Generator.cls_slots | def cls_slots(self, cls: CLASS_OR_CLASSNAME) -> List[SlotDefinition]:
""" Return the list of slots directly included in the class definition. Includes slots whose
domain is cls -- as declared in slot.domain or class.slots
Does not include slots declared in mixins, apply_to or is_a links
... | python | def cls_slots(self, cls: CLASS_OR_CLASSNAME) -> List[SlotDefinition]:
""" Return the list of slots directly included in the class definition. Includes slots whose
domain is cls -- as declared in slot.domain or class.slots
Does not include slots declared in mixins, apply_to or is_a links
... | Return the list of slots directly included in the class definition. Includes slots whose
domain is cls -- as declared in slot.domain or class.slots
Does not include slots declared in mixins, apply_to or is_a links
@param cls: class name or class definition name
@return: all direct cla... | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/generator.py#L95-L106 |
biolink/biolink-model | metamodel/utils/generator.py | Generator.all_slots | def all_slots(self, cls: CLASS_OR_CLASSNAME, *, cls_slots_first: bool = False) \
-> List[SlotDefinition]:
""" Return all slots that are part of the class definition. This includes all is_a, mixin and apply_to slots
but does NOT include slot_usage targets. If class B has a slot_usage entry ... | python | def all_slots(self, cls: CLASS_OR_CLASSNAME, *, cls_slots_first: bool = False) \
-> List[SlotDefinition]:
""" Return all slots that are part of the class definition. This includes all is_a, mixin and apply_to slots
but does NOT include slot_usage targets. If class B has a slot_usage entry ... | Return all slots that are part of the class definition. This includes all is_a, mixin and apply_to slots
but does NOT include slot_usage targets. If class B has a slot_usage entry for slot "s", only the slot
definition for the redefined slot will be included, not its base. Slots are added in the orde... | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/generator.py#L108-L143 |
biolink/biolink-model | metamodel/utils/generator.py | Generator.ancestors | def ancestors(self, definition: Union[SLOT_OR_SLOTNAME,
CLASS_OR_CLASSNAME]) \
-> List[Union[SlotDefinitionName, ClassDefinitionName]]:
""" Return an ordered list of ancestor names for the supplied slot or class
@param definition: Slot or class name... | python | def ancestors(self, definition: Union[SLOT_OR_SLOTNAME,
CLASS_OR_CLASSNAME]) \
-> List[Union[SlotDefinitionName, ClassDefinitionName]]:
""" Return an ordered list of ancestor names for the supplied slot or class
@param definition: Slot or class name... | Return an ordered list of ancestor names for the supplied slot or class
@param definition: Slot or class name or definition
@return: List of ancestor names | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/generator.py#L145-L157 |
biolink/biolink-model | metamodel/utils/generator.py | Generator.neighborhood | def neighborhood(self, elements: List[ELEMENT_NAME]) \
-> References:
""" Return a list of all slots, classes and types that touch any element in elements, including the element
itself
@param elements: Elements to do proximity with
@return: All slots and classes that touch e... | python | def neighborhood(self, elements: List[ELEMENT_NAME]) \
-> References:
""" Return a list of all slots, classes and types that touch any element in elements, including the element
itself
@param elements: Elements to do proximity with
@return: All slots and classes that touch e... | Return a list of all slots, classes and types that touch any element in elements, including the element
itself
@param elements: Elements to do proximity with
@return: All slots and classes that touch element | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/generator.py#L159-L211 |
biolink/biolink-model | metamodel/utils/generator.py | Generator.grounded_slot_range | def grounded_slot_range(self, slot: Optional[Union[SlotDefinition, Optional[str]]]) -> str:
""" Chase the slot range to its final form
@param slot: slot to check
@return: name of resolved range
"""
if slot is not None and not isinstance(slot, str):
slot = slot.range
... | python | def grounded_slot_range(self, slot: Optional[Union[SlotDefinition, Optional[str]]]) -> str:
""" Chase the slot range to its final form
@param slot: slot to check
@return: name of resolved range
"""
if slot is not None and not isinstance(slot, str):
slot = slot.range
... | Chase the slot range to its final form
@param slot: slot to check
@return: name of resolved range | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/generator.py#L213-L228 |
biolink/biolink-model | metamodel/utils/generator.py | Generator.aliased_slot_name | def aliased_slot_name(self, slot: SLOT_OR_SLOTNAME) -> str:
""" Return the overloaded slot name -- the alias if one exists otherwise the actual name
@param slot: either a slot name or a definition
@return: overloaded name
"""
if isinstance(slot, str):
slot = self.sch... | python | def aliased_slot_name(self, slot: SLOT_OR_SLOTNAME) -> str:
""" Return the overloaded slot name -- the alias if one exists otherwise the actual name
@param slot: either a slot name or a definition
@return: overloaded name
"""
if isinstance(slot, str):
slot = self.sch... | Return the overloaded slot name -- the alias if one exists otherwise the actual name
@param slot: either a slot name or a definition
@return: overloaded name | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/generator.py#L230-L238 |
biolink/biolink-model | metamodel/utils/generator.py | Generator.aliased_slot_names | def aliased_slot_names(self, slot_names: List[SlotDefinitionName]) -> Set[str]:
""" Return the aliased slot names for all members of the list
@param slot_names: actual slot names
@return: aliases w/ duplicates removed
"""
return {self.aliased_slot_name(sn) for sn in slot_names} | python | def aliased_slot_names(self, slot_names: List[SlotDefinitionName]) -> Set[str]:
""" Return the aliased slot names for all members of the list
@param slot_names: actual slot names
@return: aliases w/ duplicates removed
"""
return {self.aliased_slot_name(sn) for sn in slot_names} | Return the aliased slot names for all members of the list
@param slot_names: actual slot names
@return: aliases w/ duplicates removed | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/generator.py#L240-L246 |
biolink/biolink-model | metamodel/utils/generator.py | Generator.obj_for | def obj_for(self, obj_or_name: Union[str, Element]) -> Optional[Union[str, Element]]:
""" Return the class, slot or type that represents name or name itself if it is a builtin
@param obj_or_name: Object or name
@return: Corresponding element or None if not found (most likely cause is that it is... | python | def obj_for(self, obj_or_name: Union[str, Element]) -> Optional[Union[str, Element]]:
""" Return the class, slot or type that represents name or name itself if it is a builtin
@param obj_or_name: Object or name
@return: Corresponding element or None if not found (most likely cause is that it is... | Return the class, slot or type that represents name or name itself if it is a builtin
@param obj_or_name: Object or name
@return: Corresponding element or None if not found (most likely cause is that it is a builtin type) | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/generator.py#L248-L258 |
biolink/biolink-model | metamodel/utils/generator.py | Generator.obj_name | def obj_name(self, obj: Union[str, Element]) -> str:
""" Return the formatted name used for the supplied definition """
if isinstance(obj, str):
obj = self.obj_for(obj)
if isinstance(obj, SlotDefinition):
return underscore(self.aliased_slot_name(obj))
else:
... | python | def obj_name(self, obj: Union[str, Element]) -> str:
""" Return the formatted name used for the supplied definition """
if isinstance(obj, str):
obj = self.obj_for(obj)
if isinstance(obj, SlotDefinition):
return underscore(self.aliased_slot_name(obj))
else:
... | Return the formatted name used for the supplied definition | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/generator.py#L260-L267 |
biolink/biolink-model | metamodel/generators/csvgen.py | cli | def cli(yamlfile, root, format):
""" Generate CSV/TSV file from biolink model """
print(CsvGenerator(yamlfile, format).serialize(classes=root)) | python | def cli(yamlfile, root, format):
""" Generate CSV/TSV file from biolink model """
print(CsvGenerator(yamlfile, format).serialize(classes=root)) | Generate CSV/TSV file from biolink model | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/csvgen.py#L52-L54 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.gen_inherited | def gen_inherited(self) -> str:
""" Generate the list of slot properties that are inherited across slot_usage or is_a paths """
inherited_head = 'inherited_slots: List[str] = ['
inherited_slots = ', '.join([f'"{underscore(slot.name)}"' for slot in self.schema.slots.values()
... | python | def gen_inherited(self) -> str:
""" Generate the list of slot properties that are inherited across slot_usage or is_a paths """
inherited_head = 'inherited_slots: List[str] = ['
inherited_slots = ', '.join([f'"{underscore(slot.name)}"' for slot in self.schema.slots.values()
... | Generate the list of slot properties that are inherited across slot_usage or is_a paths | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L58-L64 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.gen_references | def gen_references(self) -> str:
""" Generate python type declarations for all identifiers (primary keys)
"""
rval = []
for cls in self.schema.classes.values():
pkeys = self.primary_keys_for(cls)
for pk in pkeys:
pk_slot = self.schema.slots[pk]
... | python | def gen_references(self) -> str:
""" Generate python type declarations for all identifiers (primary keys)
"""
rval = []
for cls in self.schema.classes.values():
pkeys = self.primary_keys_for(cls)
for pk in pkeys:
pk_slot = self.schema.slots[pk]
... | Generate python type declarations for all identifiers (primary keys) | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L66-L81 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.gen_typedefs | def gen_typedefs(self) -> str:
""" Generate python type declarations for all defined types """
rval = []
for typ in self.schema.types.values():
typname = self.python_name_for(typ.name)
parent = self.python_name_for(typ.typeof)
rval.append(f'class {typname}({pa... | python | def gen_typedefs(self) -> str:
""" Generate python type declarations for all defined types """
rval = []
for typ in self.schema.types.values():
typname = self.python_name_for(typ.name)
parent = self.python_name_for(typ.typeof)
rval.append(f'class {typname}({pa... | Generate python type declarations for all defined types | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L83-L90 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.gen_classdefs | def gen_classdefs(self) -> str:
""" Create class definitions for all non-mixin classes in the model
Note that apply_to classes are transformed to mixins
"""
return '\n'.join([self.gen_classdef(k, v) for k, v in self.schema.classes.items() if not v.mixin]) | python | def gen_classdefs(self) -> str:
""" Create class definitions for all non-mixin classes in the model
Note that apply_to classes are transformed to mixins
"""
return '\n'.join([self.gen_classdef(k, v) for k, v in self.schema.classes.items() if not v.mixin]) | Create class definitions for all non-mixin classes in the model
Note that apply_to classes are transformed to mixins | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L92-L96 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.gen_classdef | def gen_classdef(self, clsname: str, cls: ClassDefinition) -> str:
""" Generate python definition for class clsname """
parentref = f'({self.python_name_for(cls.is_a) if cls.is_a else "YAMLRoot"})'
slotdefs = self.gen_slot_variables(cls)
postinits = self.gen_postinits(cls)
if no... | python | def gen_classdef(self, clsname: str, cls: ClassDefinition) -> str:
""" Generate python definition for class clsname """
parentref = f'({self.python_name_for(cls.is_a) if cls.is_a else "YAMLRoot"})'
slotdefs = self.gen_slot_variables(cls)
postinits = self.gen_postinits(cls)
if no... | Generate python definition for class clsname | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L98-L113 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.gen_slot_variables | def gen_slot_variables(self, cls: ClassDefinition) -> str:
""" Generate python definition for class cls, generating primary keys first followed by the rest of the slots
"""
return '\n\t'.join([self.gen_slot_variable(cls, pk) for pk in self.primary_keys_for(cls)] +
[sel... | python | def gen_slot_variables(self, cls: ClassDefinition) -> str:
""" Generate python definition for class cls, generating primary keys first followed by the rest of the slots
"""
return '\n\t'.join([self.gen_slot_variable(cls, pk) for pk in self.primary_keys_for(cls)] +
[sel... | Generate python definition for class cls, generating primary keys first followed by the rest of the slots | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L115-L121 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.gen_slot_variable | def gen_slot_variable(self, cls: ClassDefinition, slotname: str) -> str:
""" Generate a slot variable for slotname as defined in class
"""
slot = self.schema.slots[slotname]
# Alias allows re-use of slot names in different contexts
if slot.alias:
slotname = slot.alia... | python | def gen_slot_variable(self, cls: ClassDefinition, slotname: str) -> str:
""" Generate a slot variable for slotname as defined in class
"""
slot = self.schema.slots[slotname]
# Alias allows re-use of slot names in different contexts
if slot.alias:
slotname = slot.alia... | Generate a slot variable for slotname as defined in class | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L123-L138 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.gen_postinits | def gen_postinits(self, cls: ClassDefinition) -> str:
""" Generate all the typing and existence checks post initialize
"""
post_inits = []
if not cls.abstract:
pkeys = self.primary_keys_for(cls)
for pkey in pkeys:
post_inits.append(self.gen_postini... | python | def gen_postinits(self, cls: ClassDefinition) -> str:
""" Generate all the typing and existence checks post initialize
"""
post_inits = []
if not cls.abstract:
pkeys = self.primary_keys_for(cls)
for pkey in pkeys:
post_inits.append(self.gen_postini... | Generate all the typing and existence checks post initialize | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L140-L156 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.gen_postinit | def gen_postinit(self, cls: ClassDefinition, slotname: str) -> Optional[str]:
""" Generate python post init rules for slot in class
"""
rlines: List[str] = []
slot = self.schema.slots[slotname]
if slot.alias:
slotname = slot.alias
slotname = self.python_name_f... | python | def gen_postinit(self, cls: ClassDefinition, slotname: str) -> Optional[str]:
""" Generate python post init rules for slot in class
"""
rlines: List[str] = []
slot = self.schema.slots[slotname]
if slot.alias:
slotname = slot.alias
slotname = self.python_name_f... | Generate python post init rules for slot in class | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L158-L202 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.primary_keys_for | def primary_keys_for(self, cls: ClassDefinition) -> List[SlotDefinitionName]:
""" Return all primary keys / identifiers for cls
@param cls: class to get keys for
@return: List of primary keys
"""
return [slot_name for slot_name in self.all_slots_for(cls)
if self.... | python | def primary_keys_for(self, cls: ClassDefinition) -> List[SlotDefinitionName]:
""" Return all primary keys / identifiers for cls
@param cls: class to get keys for
@return: List of primary keys
"""
return [slot_name for slot_name in self.all_slots_for(cls)
if self.... | Return all primary keys / identifiers for cls
@param cls: class to get keys for
@return: List of primary keys | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L233-L240 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.all_slots_for | def all_slots_for(self, cls: ClassDefinition) -> List[SlotDefinitionName]:
""" Return all slots for class cls """
if not cls.is_a:
return cls.slots
else:
return [sn for sn in self.all_slots_for(self.schema.classes[cls.is_a]) if sn not in cls.slot_usage] \
... | python | def all_slots_for(self, cls: ClassDefinition) -> List[SlotDefinitionName]:
""" Return all slots for class cls """
if not cls.is_a:
return cls.slots
else:
return [sn for sn in self.all_slots_for(self.schema.classes[cls.is_a]) if sn not in cls.slot_usage] \
... | Return all slots for class cls | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L242-L248 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.range_type_name | def range_type_name(self, slot: SlotDefinition, containing_class_name: ClassDefinitionName) -> str:
""" Generate the type name for the slot """
if slot.primary_key or slot.identifier:
return self.python_name_for(containing_class_name) + camelcase(slot.name)
if slot.range in self.sch... | python | def range_type_name(self, slot: SlotDefinition, containing_class_name: ClassDefinitionName) -> str:
""" Generate the type name for the slot """
if slot.primary_key or slot.identifier:
return self.python_name_for(containing_class_name) + camelcase(slot.name)
if slot.range in self.sch... | Generate the type name for the slot | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L255-L264 |
biolink/biolink-model | metamodel/generators/pythongen.py | PythonGenerator.forward_reference | def forward_reference(self, slot_range: str, owning_class: str) -> bool:
""" Determine whether slot_range is a forward reference """
for cname in self.schema.classes:
if cname == owning_class:
return True # Occurs on or after
elif cname == slot_range:
... | python | def forward_reference(self, slot_range: str, owning_class: str) -> bool:
""" Determine whether slot_range is a forward reference """
for cname in self.schema.classes:
if cname == owning_class:
return True # Occurs on or after
elif cname == slot_range:
... | Determine whether slot_range is a forward reference | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/pythongen.py#L266-L273 |
biolink/biolink-model | metamodel/utils/schemaloader.py | SchemaLoader.resolve | def resolve(self) -> SchemaDefinition:
""" Return a fully resolved schema
"""
if not isinstance(self.schema.slots, dict):
raise ValueError(f"File: {self.schema.source_file} Slots are not a dictionary")
if not isinstance(self.schema.classes, dict):
raise ValueErr... | python | def resolve(self) -> SchemaDefinition:
""" Return a fully resolved schema
"""
if not isinstance(self.schema.slots, dict):
raise ValueError(f"File: {self.schema.source_file} Slots are not a dictionary")
if not isinstance(self.schema.classes, dict):
raise ValueErr... | Return a fully resolved schema | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/schemaloader.py#L17-L99 |
biolink/biolink-model | metamodel/utils/schemaloader.py | SchemaLoader.slot_definition_for | def slot_definition_for(self, slotname: SlotDefinitionName, cls: ClassDefinition) -> Optional[SlotDefinition]:
""" Find the most proximal definition for slotname in the context of cls"""
if cls.is_a:
for sn in self.schema.classes[cls.is_a].slots:
slot = self.schema.slots[sn]
... | python | def slot_definition_for(self, slotname: SlotDefinitionName, cls: ClassDefinition) -> Optional[SlotDefinition]:
""" Find the most proximal definition for slotname in the context of cls"""
if cls.is_a:
for sn in self.schema.classes[cls.is_a].slots:
slot = self.schema.slots[sn]
... | Find the most proximal definition for slotname in the context of cls | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/utils/schemaloader.py#L111-L131 |
biolink/biolink-model | metamodel/generators/yumlgen.py | cli | def cli(yamlfile, format, classes, directory):
""" Generate a UML representation of a biolink model """
print(YumlGenerator(yamlfile, format).serialize(classes=classes, directory=directory), end="") | python | def cli(yamlfile, format, classes, directory):
""" Generate a UML representation of a biolink model """
print(YumlGenerator(yamlfile, format).serialize(classes=classes, directory=directory), end="") | Generate a UML representation of a biolink model | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/yumlgen.py#L219-L221 |
biolink/biolink-model | metamodel/generators/yumlgen.py | YumlGenerator.class_box | def class_box(self, cn: ClassDefinitionName) -> str:
""" Generate a box for the class. Populate its interior only if (a) it hasn't previously been generated and
(b) it appears in the gen_classes list
@param cn:
@param inherited:
@return:
"""
slot_defs: List[str]... | python | def class_box(self, cn: ClassDefinitionName) -> str:
""" Generate a box for the class. Populate its interior only if (a) it hasn't previously been generated and
(b) it appears in the gen_classes list
@param cn:
@param inherited:
@return:
"""
slot_defs: List[str]... | Generate a box for the class. Populate its interior only if (a) it hasn't previously been generated and
(b) it appears in the gen_classes list
@param cn:
@param inherited:
@return: | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/yumlgen.py#L89-L109 |
biolink/biolink-model | metamodel/generators/yumlgen.py | YumlGenerator.class_associations | def class_associations(self, cn: ClassDefinitionName, must_render: bool=False) -> str:
""" Emit all associations for a focus class. If none are specified, all classes are generated
@param cn: Name of class to be emitted
@param must_render: True means render even if this is a target (class is s... | python | def class_associations(self, cn: ClassDefinitionName, must_render: bool=False) -> str:
""" Emit all associations for a focus class. If none are specified, all classes are generated
@param cn: Name of class to be emitted
@param must_render: True means render even if this is a target (class is s... | Emit all associations for a focus class. If none are specified, all classes are generated
@param cn: Name of class to be emitted
@param must_render: True means render even if this is a target (class is specifically requested)
@return: YUML representation of the association | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/yumlgen.py#L111-L165 |
biolink/biolink-model | metamodel/generators/yumlgen.py | YumlGenerator.filtered_cls_slots | def filtered_cls_slots(self, cn: ClassDefinitionName, all_slots: bool=True) \
-> List[SlotDefinitionName]:
""" Return the set of slots associated with the class that meet the filter criteria. Slots will be returned
in defining order, with class slots returned last
@param cn: name o... | python | def filtered_cls_slots(self, cn: ClassDefinitionName, all_slots: bool=True) \
-> List[SlotDefinitionName]:
""" Return the set of slots associated with the class that meet the filter criteria. Slots will be returned
in defining order, with class slots returned last
@param cn: name o... | Return the set of slots associated with the class that meet the filter criteria. Slots will be returned
in defining order, with class slots returned last
@param cn: name of class to filter
@param all_slots: True means include attributes
@return: List of slot definitions | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/yumlgen.py#L174-L190 |
biolink/biolink-model | metamodel/generators/yumlgen.py | YumlGenerator.prop_modifier | def prop_modifier(self, cls: ClassDefinition, slot: SlotDefinition) -> str:
""" Return the modifiers for the slot:
(i) - inherited
(m) - inherited through mixin
(a) - injected
(pk) - primary ckey
@param cls:
@param slot:
@return:
"... | python | def prop_modifier(self, cls: ClassDefinition, slot: SlotDefinition) -> str:
""" Return the modifiers for the slot:
(i) - inherited
(m) - inherited through mixin
(a) - injected
(pk) - primary ckey
@param cls:
@param slot:
@return:
"... | Return the modifiers for the slot:
(i) - inherited
(m) - inherited through mixin
(a) - injected
(pk) - primary ckey
@param cls:
@param slot:
@return: | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/yumlgen.py#L192-L210 |
biolink/biolink-model | metamodel/generators/shexgen.py | cli | def cli(yamlfile, format, output, collections):
""" Generate a ShEx Schema for a biolink model """
print(ShExGenerator(yamlfile, format).serialize(output=output, collections=collections)) | python | def cli(yamlfile, format, output, collections):
""" Generate a ShEx Schema for a biolink model """
print(ShExGenerator(yamlfile, format).serialize(output=output, collections=collections)) | Generate a ShEx Schema for a biolink model | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/shexgen.py#L174-L176 |
biolink/biolink-model | metamodel/generators/shexgen.py | ShExGenerator.gen_multivalued_slot | def gen_multivalued_slot(self, target_name_base: str, target_type: IRIREF) -> IRIREF:
""" Generate a shape that represents an RDF list of target_type
@param target_name_base:
@param target_type:
@return:
"""
list_shape_id = IRIREF(target_name_base + "__List")
if ... | python | def gen_multivalued_slot(self, target_name_base: str, target_type: IRIREF) -> IRIREF:
""" Generate a shape that represents an RDF list of target_type
@param target_name_base:
@param target_type:
@return:
"""
list_shape_id = IRIREF(target_name_base + "__List")
if ... | Generate a shape that represents an RDF list of target_type
@param target_name_base:
@param target_type:
@return: | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/shexgen.py#L119-L137 |
biolink/biolink-model | metamodel/generators/contextgen.py | ContextGenerator.add_prefix | def add_prefix(self, ncname: str) -> None:
""" Look up ncname and add it to the prefix map if necessary
@param ncname: name to add
"""
if ncname not in self.prefixmap:
uri = cu.expand_uri(ncname + ':', self.curi_maps)
if uri and '://' in uri:
self... | python | def add_prefix(self, ncname: str) -> None:
""" Look up ncname and add it to the prefix map if necessary
@param ncname: name to add
"""
if ncname not in self.prefixmap:
uri = cu.expand_uri(ncname + ':', self.curi_maps)
if uri and '://' in uri:
self... | Look up ncname and add it to the prefix map if necessary
@param ncname: name to add | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/contextgen.py#L92-L103 |
biolink/biolink-model | metamodel/generators/contextgen.py | ContextGenerator.get_uri | def get_uri(self, ncname: str) -> Optional[str]:
""" Get the URI associated with ncname
@param ncname:
"""
uri = cu.expand_uri(ncname + ':', self.curi_maps)
return uri if uri and uri.startswith('http') else None | python | def get_uri(self, ncname: str) -> Optional[str]:
""" Get the URI associated with ncname
@param ncname:
"""
uri = cu.expand_uri(ncname + ':', self.curi_maps)
return uri if uri and uri.startswith('http') else None | Get the URI associated with ncname
@param ncname: | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/contextgen.py#L105-L111 |
biolink/biolink-model | metamodel/generators/contextgen.py | ContextGenerator.add_mappings | def add_mappings(self, defn: Definition, target: Dict) -> None:
""" Process any mappings in defn, adding all of the mappings prefixes to the namespace map and
add a link to the first mapping to the target
@param defn: Class or Slot definition
@param target: context target
"""
... | python | def add_mappings(self, defn: Definition, target: Dict) -> None:
""" Process any mappings in defn, adding all of the mappings prefixes to the namespace map and
add a link to the first mapping to the target
@param defn: Class or Slot definition
@param target: context target
"""
... | Process any mappings in defn, adding all of the mappings prefixes to the namespace map and
add a link to the first mapping to the target
@param defn: Class or Slot definition
@param target: context target | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/contextgen.py#L117-L133 |
Dfenestrator/GooPyCharts | gpcharts.py | figure.plot | def plot(self,xdata,ydata=[],logScale=False,disp=True,**kwargs):
'''Graphs a line plot.
xdata: list of independent variable data. Can optionally include a header, see testGraph.py in https://github.com/Dfenestrator/GooPyCharts for an example.
ydata: list of dependent variable data. Can ... | python | def plot(self,xdata,ydata=[],logScale=False,disp=True,**kwargs):
'''Graphs a line plot.
xdata: list of independent variable data. Can optionally include a header, see testGraph.py in https://github.com/Dfenestrator/GooPyCharts for an example.
ydata: list of dependent variable data. Can ... | Graphs a line plot.
xdata: list of independent variable data. Can optionally include a header, see testGraph.py in https://github.com/Dfenestrator/GooPyCharts for an example.
ydata: list of dependent variable data. Can be multidimensional. If xdata includes a header, include a header list on yd... | https://github.com/Dfenestrator/GooPyCharts/blob/57117f213111dfe0401b1dc9720cdba8a23c3028/gpcharts.py#L358-L402 |
Dfenestrator/GooPyCharts | gpcharts.py | figure.bar | def bar(self,xdata,ydata,disp=True,**kwargs):
'''Displays a bar graph.
xdata: list of bar graph categories/bins. Can optionally include a header, see testGraph_barAndHist.py in https://github.com/Dfenestrator/GooPyCharts for an example.
ydata: list of values associated with categories i... | python | def bar(self,xdata,ydata,disp=True,**kwargs):
'''Displays a bar graph.
xdata: list of bar graph categories/bins. Can optionally include a header, see testGraph_barAndHist.py in https://github.com/Dfenestrator/GooPyCharts for an example.
ydata: list of values associated with categories i... | Displays a bar graph.
xdata: list of bar graph categories/bins. Can optionally include a header, see testGraph_barAndHist.py in https://github.com/Dfenestrator/GooPyCharts for an example.
ydata: list of values associated with categories in xdata. If xdata includes a header, include a header lis... | https://github.com/Dfenestrator/GooPyCharts/blob/57117f213111dfe0401b1dc9720cdba8a23c3028/gpcharts.py#L450-L483 |
Dfenestrator/GooPyCharts | gpcharts.py | figure.hist | def hist(self,xdata,disp=True,**kwargs):
'''Graphs a histogram.
xdata: List of values to bin. Can optionally include a header, see testGraph_barAndHist.py in https://github.com/Dfenestrator/GooPyCharts for an example.
disp: for displaying plots immediately. Set to True by default. Set t... | python | def hist(self,xdata,disp=True,**kwargs):
'''Graphs a histogram.
xdata: List of values to bin. Can optionally include a header, see testGraph_barAndHist.py in https://github.com/Dfenestrator/GooPyCharts for an example.
disp: for displaying plots immediately. Set to True by default. Set t... | Graphs a histogram.
xdata: List of values to bin. Can optionally include a header, see testGraph_barAndHist.py in https://github.com/Dfenestrator/GooPyCharts for an example.
disp: for displaying plots immediately. Set to True by default. Set to False for other operations, then use show() to dis... | https://github.com/Dfenestrator/GooPyCharts/blob/57117f213111dfe0401b1dc9720cdba8a23c3028/gpcharts.py#L522-L554 |
Dfenestrator/GooPyCharts | gpcharts.py | figure.plot_nb | def plot_nb(self,xdata,ydata=[],logScale=False):
'''Graphs a line plot and embeds it in a Jupyter notebook. See 'help(figure.plot)' for more info.'''
self.plot(xdata,ydata,logScale) | python | def plot_nb(self,xdata,ydata=[],logScale=False):
'''Graphs a line plot and embeds it in a Jupyter notebook. See 'help(figure.plot)' for more info.'''
self.plot(xdata,ydata,logScale) | Graphs a line plot and embeds it in a Jupyter notebook. See 'help(figure.plot)' for more info. | https://github.com/Dfenestrator/GooPyCharts/blob/57117f213111dfe0401b1dc9720cdba8a23c3028/gpcharts.py#L557-L559 |
Dfenestrator/GooPyCharts | gpcharts.py | figure.scatter_nb | def scatter_nb(self,xdata,ydata=[],trendline=False):
'''Graphs a scatter plot and embeds it in a Jupyter notebook. See 'help(figure.scatter)' for more info.'''
self.scatter(xdata,ydata,trendline) | python | def scatter_nb(self,xdata,ydata=[],trendline=False):
'''Graphs a scatter plot and embeds it in a Jupyter notebook. See 'help(figure.scatter)' for more info.'''
self.scatter(xdata,ydata,trendline) | Graphs a scatter plot and embeds it in a Jupyter notebook. See 'help(figure.scatter)' for more info. | https://github.com/Dfenestrator/GooPyCharts/blob/57117f213111dfe0401b1dc9720cdba8a23c3028/gpcharts.py#L561-L563 |
lepture/mistune-contrib | mistune_contrib/meta.py | parse | def parse(text):
"""Parse the given text into metadata and strip it for a Markdown parser.
:param text: text to be parsed
"""
rv = {}
m = META.match(text)
while m:
key = m.group(1)
value = m.group(2)
value = INDENTATION.sub('\n', value.strip())
rv[key] = value
... | python | def parse(text):
"""Parse the given text into metadata and strip it for a Markdown parser.
:param text: text to be parsed
"""
rv = {}
m = META.match(text)
while m:
key = m.group(1)
value = m.group(2)
value = INDENTATION.sub('\n', value.strip())
rv[key] = value
... | Parse the given text into metadata and strip it for a Markdown parser.
:param text: text to be parsed | https://github.com/lepture/mistune-contrib/blob/3180edfc6b4477ead5ef7754a57907ae94080c24/mistune_contrib/meta.py#L24-L40 |
gorakhargosh/pathtools | pathtools/path.py | get_dir_walker | def get_dir_walker(recursive, topdown=True, followlinks=False):
"""
Returns a recursive or a non-recursive directory walker.
:param recursive:
``True`` produces a recursive walker; ``False`` produces a non-recursive
walker.
:returns:
A walker function.
"""
if recursive:
... | python | def get_dir_walker(recursive, topdown=True, followlinks=False):
"""
Returns a recursive or a non-recursive directory walker.
:param recursive:
``True`` produces a recursive walker; ``False`` produces a non-recursive
walker.
:returns:
A walker function.
"""
if recursive:
... | Returns a recursive or a non-recursive directory walker.
:param recursive:
``True`` produces a recursive walker; ``False`` produces a non-recursive
walker.
:returns:
A walker function. | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/pathtools/path.py#L58-L76 |
gorakhargosh/pathtools | pathtools/path.py | walk | def walk(dir_pathname, recursive=True, topdown=True, followlinks=False):
"""
Walks a directory tree optionally recursively. Works exactly like
:func:`os.walk` only adding the `recursive` argument.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for walking... | python | def walk(dir_pathname, recursive=True, topdown=True, followlinks=False):
"""
Walks a directory tree optionally recursively. Works exactly like
:func:`os.walk` only adding the `recursive` argument.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for walking... | Walks a directory tree optionally recursively. Works exactly like
:func:`os.walk` only adding the `recursive` argument.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for walking recursively through the directory tree;
``False`` otherwise.
:param topd... | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/pathtools/path.py#L79-L96 |
gorakhargosh/pathtools | pathtools/path.py | listdir | def listdir(dir_pathname,
recursive=True,
topdown=True,
followlinks=False):
"""
Enlists all items using their absolute paths in a directory, optionally
recursively.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for wal... | python | def listdir(dir_pathname,
recursive=True,
topdown=True,
followlinks=False):
"""
Enlists all items using their absolute paths in a directory, optionally
recursively.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for wal... | Enlists all items using their absolute paths in a directory, optionally
recursively.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for walking recursively through the directory tree;
``False`` otherwise.
:param topdown:
Please see the documen... | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/pathtools/path.py#L99-L122 |
gorakhargosh/pathtools | pathtools/path.py | list_directories | def list_directories(dir_pathname,
recursive=True,
topdown=True,
followlinks=False):
"""
Enlists all the directories using their absolute paths within the specified
directory, optionally recursively.
:param dir_pathname:
The directo... | python | def list_directories(dir_pathname,
recursive=True,
topdown=True,
followlinks=False):
"""
Enlists all the directories using their absolute paths within the specified
directory, optionally recursively.
:param dir_pathname:
The directo... | Enlists all the directories using their absolute paths within the specified
directory, optionally recursively.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for walking recursively through the directory tree;
``False`` otherwise.
:param topdown:
... | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/pathtools/path.py#L125-L146 |
gorakhargosh/pathtools | pathtools/path.py | list_files | def list_files(dir_pathname,
recursive=True,
topdown=True,
followlinks=False):
"""
Enlists all the files using their absolute paths within the specified
directory, optionally recursively.
:param dir_pathname:
The directory to traverse.
:param rec... | python | def list_files(dir_pathname,
recursive=True,
topdown=True,
followlinks=False):
"""
Enlists all the files using their absolute paths within the specified
directory, optionally recursively.
:param dir_pathname:
The directory to traverse.
:param rec... | Enlists all the files using their absolute paths within the specified
directory, optionally recursively.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for walking recursively through the directory tree;
``False`` otherwise.
:param topdown:
Pl... | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/pathtools/path.py#L149-L170 |
gorakhargosh/pathtools | pathtools/patterns.py | match_path_against | def match_path_against(pathname, patterns, case_sensitive=True):
"""
Determines whether the pathname matches any of the given wildcard patterns,
optionally ignoring the case of the pathname and patterns.
:param pathname:
A path name that will be matched against a wildcard pattern.
:param pa... | python | def match_path_against(pathname, patterns, case_sensitive=True):
"""
Determines whether the pathname matches any of the given wildcard patterns,
optionally ignoring the case of the pathname and patterns.
:param pathname:
A path name that will be matched against a wildcard pattern.
:param pa... | Determines whether the pathname matches any of the given wildcard patterns,
optionally ignoring the case of the pathname and patterns.
:param pathname:
A path name that will be matched against a wildcard pattern.
:param patterns:
A list of wildcard patterns to match_path the filename agains... | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/pathtools/patterns.py#L58-L95 |
gorakhargosh/pathtools | pathtools/patterns.py | _match_path | def _match_path(pathname,
included_patterns,
excluded_patterns,
case_sensitive=True):
"""Internal function same as :func:`match_path` but does not check arguments.
Doctests::
>>> _match_path("/users/gorakhargosh/foobar.py", ["*.py"], ["*.PY"], True)
... | python | def _match_path(pathname,
included_patterns,
excluded_patterns,
case_sensitive=True):
"""Internal function same as :func:`match_path` but does not check arguments.
Doctests::
>>> _match_path("/users/gorakhargosh/foobar.py", ["*.py"], ["*.PY"], True)
... | Internal function same as :func:`match_path` but does not check arguments.
Doctests::
>>> _match_path("/users/gorakhargosh/foobar.py", ["*.py"], ["*.PY"], True)
True
>>> _match_path("/users/gorakhargosh/FOOBAR.PY", ["*.py"], ["*.PY"], True)
False
>>> _match_path("/users/gora... | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/pathtools/patterns.py#L98-L128 |
gorakhargosh/pathtools | pathtools/patterns.py | match_path | def match_path(pathname,
included_patterns=None,
excluded_patterns=None,
case_sensitive=True):
"""
Matches a pathname against a set of acceptable and ignored patterns.
:param pathname:
A pathname which will be matched against a pattern.
:param includ... | python | def match_path(pathname,
included_patterns=None,
excluded_patterns=None,
case_sensitive=True):
"""
Matches a pathname against a set of acceptable and ignored patterns.
:param pathname:
A pathname which will be matched against a pattern.
:param includ... | Matches a pathname against a set of acceptable and ignored patterns.
:param pathname:
A pathname which will be matched against a pattern.
:param included_patterns:
Allow filenames matching wildcard patterns specified in this list.
If no pattern is specified, the function treats the path... | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/pathtools/patterns.py#L131-L174 |
gorakhargosh/pathtools | pathtools/patterns.py | filter_paths | def filter_paths(pathnames,
included_patterns=None,
excluded_patterns=None,
case_sensitive=True):
"""
Filters from a set of paths based on acceptable patterns and
ignorable patterns.
:param pathnames:
A list of path names that will be filtered ... | python | def filter_paths(pathnames,
included_patterns=None,
excluded_patterns=None,
case_sensitive=True):
"""
Filters from a set of paths based on acceptable patterns and
ignorable patterns.
:param pathnames:
A list of path names that will be filtered ... | Filters from a set of paths based on acceptable patterns and
ignorable patterns.
:param pathnames:
A list of path names that will be filtered based on matching and
ignored patterns.
:param included_patterns:
Allow filenames matching wildcard patterns specified in this list.
... | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/pathtools/patterns.py#L177-L218 |
gorakhargosh/pathtools | pathtools/patterns.py | match_any_paths | def match_any_paths(pathnames,
included_patterns=None,
excluded_patterns=None,
case_sensitive=True):
"""
Matches from a set of paths based on acceptable patterns and
ignorable patterns.
:param pathnames:
A list of path names that will ... | python | def match_any_paths(pathnames,
included_patterns=None,
excluded_patterns=None,
case_sensitive=True):
"""
Matches from a set of paths based on acceptable patterns and
ignorable patterns.
:param pathnames:
A list of path names that will ... | Matches from a set of paths based on acceptable patterns and
ignorable patterns.
:param pathnames:
A list of path names that will be filtered based on matching and
ignored patterns.
:param included_patterns:
Allow filenames matching wildcard patterns specified in this list.
... | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/pathtools/patterns.py#L220-L265 |
gorakhargosh/pathtools | scripts/nosy.py | match_patterns | def match_patterns(pathname, patterns):
"""Returns ``True`` if the pathname matches any of the given patterns."""
for pattern in patterns:
if fnmatch(pathname, pattern):
return True
return False | python | def match_patterns(pathname, patterns):
"""Returns ``True`` if the pathname matches any of the given patterns."""
for pattern in patterns:
if fnmatch(pathname, pattern):
return True
return False | Returns ``True`` if the pathname matches any of the given patterns. | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/scripts/nosy.py#L39-L44 |
gorakhargosh/pathtools | scripts/nosy.py | filter_paths | def filter_paths(pathnames, patterns=None, ignore_patterns=None):
"""Filters from a set of paths based on acceptable patterns and
ignorable patterns."""
result = []
if patterns is None:
patterns = ['*']
if ignore_patterns is None:
ignore_patterns = []
for pathname in pathnames:
... | python | def filter_paths(pathnames, patterns=None, ignore_patterns=None):
"""Filters from a set of paths based on acceptable patterns and
ignorable patterns."""
result = []
if patterns is None:
patterns = ['*']
if ignore_patterns is None:
ignore_patterns = []
for pathname in pathnames:
... | Filters from a set of paths based on acceptable patterns and
ignorable patterns. | https://github.com/gorakhargosh/pathtools/blob/a3522fc61b00ee2d992ca375c600513bfb9020e9/scripts/nosy.py#L47-L58 |
evansloan/sports.py | sports/teams.py | get_team | def get_team(sport, team):
"""
Get extra info that pertains to a certain team.
Info available to all teams:
- name: Name of the team
- seasons: Number of seasons played
- record: Overall record
- champs: Number of championships won
- leaders: S... | python | def get_team(sport, team):
"""
Get extra info that pertains to a certain team.
Info available to all teams:
- name: Name of the team
- seasons: Number of seasons played
- record: Overall record
- champs: Number of championships won
- leaders: S... | Get extra info that pertains to a certain team.
Info available to all teams:
- name: Name of the team
- seasons: Number of seasons played
- record: Overall record
- champs: Number of championships won
- leaders: Statistical leaders
Info specif... | https://github.com/evansloan/sports.py/blob/852cd1e439f2de46ef68357e43f5f55b2e16d2b3/sports/teams.py#L23-L116 |
evansloan/sports.py | sports/teams.py | _get_team_info_raw | def _get_team_info_raw(soup, base_url, team_pattern, team, sport):
"""
Parses through html page to gather raw data about team
:param soup: BeautifulSoup object containing html to be parsed
:param base_url: Pre-formatted url that is formatted depending on sport
:param team_pattern: Compiled regex pa... | python | def _get_team_info_raw(soup, base_url, team_pattern, team, sport):
"""
Parses through html page to gather raw data about team
:param soup: BeautifulSoup object containing html to be parsed
:param base_url: Pre-formatted url that is formatted depending on sport
:param team_pattern: Compiled regex pa... | Parses through html page to gather raw data about team
:param soup: BeautifulSoup object containing html to be parsed
:param base_url: Pre-formatted url that is formatted depending on sport
:param team_pattern: Compiled regex pattern of team name/city
:param team: Name of the team that is being searche... | https://github.com/evansloan/sports.py/blob/852cd1e439f2de46ef68357e43f5f55b2e16d2b3/sports/teams.py#L124-L150 |
evansloan/sports.py | sports/scores.py | _request_xml | def _request_xml(sport):
"""
Request XML data from scorespro.com
:param sport: sport being played
:type sport: string
:return: XML data
:rtype: string
"""
url = 'http://www.scorespro.com/rss2/live-{}.xml'.format(sport)
r = requests.get(url)
if r.ok:
return _load_xml(r.co... | python | def _request_xml(sport):
"""
Request XML data from scorespro.com
:param sport: sport being played
:type sport: string
:return: XML data
:rtype: string
"""
url = 'http://www.scorespro.com/rss2/live-{}.xml'.format(sport)
r = requests.get(url)
if r.ok:
return _load_xml(r.co... | Request XML data from scorespro.com
:param sport: sport being played
:type sport: string
:return: XML data
:rtype: string | https://github.com/evansloan/sports.py/blob/852cd1e439f2de46ef68357e43f5f55b2e16d2b3/sports/scores.py#L38-L52 |
evansloan/sports.py | sports/scores.py | _parse_match_info | def _parse_match_info(match, soccer=False):
"""
Parse string containing info of a specific match
:param match: Match data
:type match: string
:param soccer: Set to true if match contains soccer data, defaults to False
:type soccer: bool, optional
:return: Dictionary containing match informa... | python | def _parse_match_info(match, soccer=False):
"""
Parse string containing info of a specific match
:param match: Match data
:type match: string
:param soccer: Set to true if match contains soccer data, defaults to False
:type soccer: bool, optional
:return: Dictionary containing match informa... | Parse string containing info of a specific match
:param match: Match data
:type match: string
:param soccer: Set to true if match contains soccer data, defaults to False
:type soccer: bool, optional
:return: Dictionary containing match information
:rtype: dict | https://github.com/evansloan/sports.py/blob/852cd1e439f2de46ef68357e43f5f55b2e16d2b3/sports/scores.py#L67-L100 |
evansloan/sports.py | sports/scores.py | get_sport | def get_sport(sport):
"""
Get live scores for all matches in a particular sport
:param sport: the sport being played
:type sport: string
:return: List containing Match objects
:rtype: list
"""
sport = sport.lower()
data = _request_xml(sport)
matches = []
for match in data:
... | python | def get_sport(sport):
"""
Get live scores for all matches in a particular sport
:param sport: the sport being played
:type sport: string
:return: List containing Match objects
:rtype: list
"""
sport = sport.lower()
data = _request_xml(sport)
matches = []
for match in data:
... | Get live scores for all matches in a particular sport
:param sport: the sport being played
:type sport: string
:return: List containing Match objects
:rtype: list | https://github.com/evansloan/sports.py/blob/852cd1e439f2de46ef68357e43f5f55b2e16d2b3/sports/scores.py#L103-L130 |
evansloan/sports.py | sports/scores.py | get_match | def get_match(sport, team1, team2):
"""
Get live scores for a single match
:param sport: the sport being played
:type sport: string
:param team1: first team participating in the match
:ttype team1: string
:param team2: second team participating in the match
:type team2: string
:retu... | python | def get_match(sport, team1, team2):
"""
Get live scores for a single match
:param sport: the sport being played
:type sport: string
:param team1: first team participating in the match
:ttype team1: string
:param team2: second team participating in the match
:type team2: string
:retu... | Get live scores for a single match
:param sport: the sport being played
:type sport: string
:param team1: first team participating in the match
:ttype team1: string
:param team2: second team participating in the match
:type team2: string
:return: A specific match
:rtype: Match | https://github.com/evansloan/sports.py/blob/852cd1e439f2de46ef68357e43f5f55b2e16d2b3/sports/scores.py#L133-L156 |
bitlabstudio/django-influxdb-metrics | influxdb_metrics/models.py | user_post_delete_handler | def user_post_delete_handler(sender, **kwargs):
"""Sends a metric to InfluxDB when a User object is deleted."""
total = get_user_model().objects.all().count()
data = [{
'measurement': 'django_auth_user_delete',
'tags': {'host': settings.INFLUXDB_TAGS_HOST, },
'fields': {'value': 1, }... | python | def user_post_delete_handler(sender, **kwargs):
"""Sends a metric to InfluxDB when a User object is deleted."""
total = get_user_model().objects.all().count()
data = [{
'measurement': 'django_auth_user_delete',
'tags': {'host': settings.INFLUXDB_TAGS_HOST, },
'fields': {'value': 1, }... | Sends a metric to InfluxDB when a User object is deleted. | https://github.com/bitlabstudio/django-influxdb-metrics/blob/c9f368e28a6072813454b6b549b4afa64aad778a/influxdb_metrics/models.py#L23-L40 |
bitlabstudio/django-influxdb-metrics | influxdb_metrics/models.py | user_post_save_handler | def user_post_save_handler(**kwargs):
"""Sends a metric to InfluxDB when a new User object is created."""
if kwargs.get('created'):
total = get_user_model().objects.all().count()
data = [{
'measurement': 'django_auth_user_create',
'tags': {'host': settings.INFLUXDB_TAGS_H... | python | def user_post_save_handler(**kwargs):
"""Sends a metric to InfluxDB when a new User object is created."""
if kwargs.get('created'):
total = get_user_model().objects.all().count()
data = [{
'measurement': 'django_auth_user_create',
'tags': {'host': settings.INFLUXDB_TAGS_H... | Sends a metric to InfluxDB when a new User object is created. | https://github.com/bitlabstudio/django-influxdb-metrics/blob/c9f368e28a6072813454b6b549b4afa64aad778a/influxdb_metrics/models.py#L46-L64 |
marcocor/tagme-python | tagme/__init__.py | annotate | def annotate(text, gcube_token=None, lang=DEFAULT_LANG, api=DEFAULT_TAG_API,
long_text=DEFAULT_LONG_TEXT):
'''
Annotate a text, linking it to Wikipedia entities.
:param text: the text to annotate.
:param gcube_token: the authentication token provided by the D4Science infrastructure.
:pa... | python | def annotate(text, gcube_token=None, lang=DEFAULT_LANG, api=DEFAULT_TAG_API,
long_text=DEFAULT_LONG_TEXT):
'''
Annotate a text, linking it to Wikipedia entities.
:param text: the text to annotate.
:param gcube_token: the authentication token provided by the D4Science infrastructure.
:pa... | Annotate a text, linking it to Wikipedia entities.
:param text: the text to annotate.
:param gcube_token: the authentication token provided by the D4Science infrastructure.
:param lang: the Wikipedia language.
:param api: the API endpoint.
:param long_text: long_text parameter (see TagMe documentati... | https://github.com/marcocor/tagme-python/blob/e3a2fcd5a7081b00cd7edcad5d4fc3542a7eaccb/tagme/__init__.py#L188-L202 |
marcocor/tagme-python | tagme/__init__.py | mentions | def mentions(text, gcube_token=None, lang=DEFAULT_LANG, api=DEFAULT_SPOT_API):
'''
Find possible mentions in a text, do not link them to any entity.
:param text: the text where to find mentions.
:param gcube_token: the authentication token provided by the D4Science infrastructure.
:param lang: the W... | python | def mentions(text, gcube_token=None, lang=DEFAULT_LANG, api=DEFAULT_SPOT_API):
'''
Find possible mentions in a text, do not link them to any entity.
:param text: the text where to find mentions.
:param gcube_token: the authentication token provided by the D4Science infrastructure.
:param lang: the W... | Find possible mentions in a text, do not link them to any entity.
:param text: the text where to find mentions.
:param gcube_token: the authentication token provided by the D4Science infrastructure.
:param lang: the Wikipedia language.
:param api: the API endpoint. | https://github.com/marcocor/tagme-python/blob/e3a2fcd5a7081b00cd7edcad5d4fc3542a7eaccb/tagme/__init__.py#L205-L216 |
marcocor/tagme-python | tagme/__init__.py | relatedness_wid | def relatedness_wid(wid_pairs, gcube_token=None, lang=DEFAULT_LANG, api=DEFAULT_REL_API):
'''
Get the semantic relatedness among pairs of entities. Entities are indicated by their
Wikipedia ID (an integer).
:param wid_pairs: either one pair or a list of pairs of Wikipedia IDs.
:param gcube_token: th... | python | def relatedness_wid(wid_pairs, gcube_token=None, lang=DEFAULT_LANG, api=DEFAULT_REL_API):
'''
Get the semantic relatedness among pairs of entities. Entities are indicated by their
Wikipedia ID (an integer).
:param wid_pairs: either one pair or a list of pairs of Wikipedia IDs.
:param gcube_token: th... | Get the semantic relatedness among pairs of entities. Entities are indicated by their
Wikipedia ID (an integer).
:param wid_pairs: either one pair or a list of pairs of Wikipedia IDs.
:param gcube_token: the authentication token provided by the D4Science infrastructure.
:param lang: the Wikipedia langua... | https://github.com/marcocor/tagme-python/blob/e3a2fcd5a7081b00cd7edcad5d4fc3542a7eaccb/tagme/__init__.py#L219-L228 |
marcocor/tagme-python | tagme/__init__.py | relatedness_title | def relatedness_title(tt_pairs, gcube_token=None, lang=DEFAULT_LANG, api=DEFAULT_REL_API):
'''
Get the semantic relatedness among pairs of entities. Entities are indicated by their
Wikipedia ID (an integer).
:param tt_pairs: either one pair or a list of pairs of entity titles.
:param gcube_token: th... | python | def relatedness_title(tt_pairs, gcube_token=None, lang=DEFAULT_LANG, api=DEFAULT_REL_API):
'''
Get the semantic relatedness among pairs of entities. Entities are indicated by their
Wikipedia ID (an integer).
:param tt_pairs: either one pair or a list of pairs of entity titles.
:param gcube_token: th... | Get the semantic relatedness among pairs of entities. Entities are indicated by their
Wikipedia ID (an integer).
:param tt_pairs: either one pair or a list of pairs of entity titles.
:param gcube_token: the authentication token provided by the D4Science infrastructure.
:param lang: the Wikipedia languag... | https://github.com/marcocor/tagme-python/blob/e3a2fcd5a7081b00cd7edcad5d4fc3542a7eaccb/tagme/__init__.py#L231-L240 |
marcocor/tagme-python | tagme/__init__.py | AnnotateResponse.get_annotations | def get_annotations(self, min_rho=None):
'''
Get the list of annotations found.
:param min_rho: if set, only get entities with a rho-score (confidence) higher than this.
'''
return (a for a in self.annotations if min_rho is None or a.score > min_rho) | python | def get_annotations(self, min_rho=None):
'''
Get the list of annotations found.
:param min_rho: if set, only get entities with a rho-score (confidence) higher than this.
'''
return (a for a in self.annotations if min_rho is None or a.score > min_rho) | Get the list of annotations found.
:param min_rho: if set, only get entities with a rho-score (confidence) higher than this. | https://github.com/marcocor/tagme-python/blob/e3a2fcd5a7081b00cd7edcad5d4fc3542a7eaccb/tagme/__init__.py#L67-L72 |
marcocor/tagme-python | tagme/__init__.py | MentionsResponse.get_mentions | def get_mentions(self, min_lp=None):
'''
Get the list of mentions found.
:param min_lp: if set, only get mentions with a link probability higher than this.
'''
return (m for m in self.mentions if min_lp is None or m.linkprob > min_lp) | python | def get_mentions(self, min_lp=None):
'''
Get the list of mentions found.
:param min_lp: if set, only get mentions with a link probability higher than this.
'''
return (m for m in self.mentions if min_lp is None or m.linkprob > min_lp) | Get the list of mentions found.
:param min_lp: if set, only get mentions with a link probability higher than this. | https://github.com/marcocor/tagme-python/blob/e3a2fcd5a7081b00cd7edcad5d4fc3542a7eaccb/tagme/__init__.py#L103-L108 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.