partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
delete_roles_request
Submission to remove a role acceptance request.
cnxpublishing/views/user_actions.py
def delete_roles_request(request): """Submission to remove a role acceptance request.""" uuid_ = request.matchdict['uuid'] posted_roles = request.json with db_connect() as db_conn: with db_conn.cursor() as cursor: remove_role_requests(cursor, uuid_, posted_roles) resp = request...
def delete_roles_request(request): """Submission to remove a role acceptance request.""" uuid_ = request.matchdict['uuid'] posted_roles = request.json with db_connect() as db_conn: with db_conn.cursor() as cursor: remove_role_requests(cursor, uuid_, posted_roles) resp = request...
[ "Submission", "to", "remove", "a", "role", "acceptance", "request", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/user_actions.py#L218-L229
[ "def", "delete_roles_request", "(", "request", ")", ":", "uuid_", "=", "request", ".", "matchdict", "[", "'uuid'", "]", "posted_roles", "=", "request", ".", "json", "with", "db_connect", "(", ")", "as", "db_conn", ":", "with", "db_conn", ".", "cursor", "("...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
get_acl
Returns the ACL for the given content identified by ``uuid``.
cnxpublishing/views/user_actions.py
def get_acl(request): """Returns the ACL for the given content identified by ``uuid``.""" uuid_ = request.matchdict['uuid'] with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT TRUE FROM document_controls WHERE uuid = %s""", (uuid_,)) try...
def get_acl(request): """Returns the ACL for the given content identified by ``uuid``.""" uuid_ = request.matchdict['uuid'] with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT TRUE FROM document_controls WHERE uuid = %s""", (uuid_,)) try...
[ "Returns", "the", "ACL", "for", "the", "given", "content", "identified", "by", "uuid", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/user_actions.py#L235-L257
[ "def", "get_acl", "(", "request", ")", ":", "uuid_", "=", "request", ".", "matchdict", "[", "'uuid'", "]", "with", "db_connect", "(", ")", "as", "db_conn", ":", "with", "db_conn", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
post_acl_request
Submission to create an ACL.
cnxpublishing/views/user_actions.py
def post_acl_request(request): """Submission to create an ACL.""" uuid_ = request.matchdict['uuid'] posted = request.json permissions = [(x['uid'], x['permission'],) for x in posted] with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT TRUE F...
def post_acl_request(request): """Submission to create an ACL.""" uuid_ = request.matchdict['uuid'] posted = request.json permissions = [(x['uid'], x['permission'],) for x in posted] with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT TRUE F...
[ "Submission", "to", "create", "an", "ACL", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/user_actions.py#L263-L286
[ "def", "post_acl_request", "(", "request", ")", ":", "uuid_", "=", "request", ".", "matchdict", "[", "'uuid'", "]", "posted", "=", "request", ".", "json", "permissions", "=", "[", "(", "x", "[", "'uid'", "]", ",", "x", "[", "'permission'", "]", ",", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
delete_acl_request
Submission to remove an ACL.
cnxpublishing/views/user_actions.py
def delete_acl_request(request): """Submission to remove an ACL.""" uuid_ = request.matchdict['uuid'] posted = request.json permissions = [(x['uid'], x['permission'],) for x in posted] with db_connect() as db_conn: with db_conn.cursor() as cursor: remove_acl(cursor, uuid_, permi...
def delete_acl_request(request): """Submission to remove an ACL.""" uuid_ = request.matchdict['uuid'] posted = request.json permissions = [(x['uid'], x['permission'],) for x in posted] with db_connect() as db_conn: with db_conn.cursor() as cursor: remove_acl(cursor, uuid_, permi...
[ "Submission", "to", "remove", "an", "ACL", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/user_actions.py#L292-L304
[ "def", "delete_acl_request", "(", "request", ")", ":", "uuid_", "=", "request", ".", "matchdict", "[", "'uuid'", "]", "posted", "=", "request", ".", "json", "permissions", "=", "[", "(", "x", "[", "'uid'", "]", ",", "x", "[", "'permission'", "]", ",", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
processor
Churns over PostgreSQL notifications on configured channels. This requires the application be setup and the registry be available. This function uses the database connection string and a list of pre configured channels.
cnxpublishing/scripts/channel_processing.py
def processor(): # pragma: no cover """Churns over PostgreSQL notifications on configured channels. This requires the application be setup and the registry be available. This function uses the database connection string and a list of pre configured channels. """ registry = get_current_registry...
def processor(): # pragma: no cover """Churns over PostgreSQL notifications on configured channels. This requires the application be setup and the registry be available. This function uses the database connection string and a list of pre configured channels. """ registry = get_current_registry...
[ "Churns", "over", "PostgreSQL", "notifications", "on", "configured", "channels", ".", "This", "requires", "the", "application", "be", "setup", "and", "the", "registry", "be", "available", ".", "This", "function", "uses", "the", "database", "connection", "string", ...
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/scripts/channel_processing.py#L56-L98
[ "def", "processor", "(", ")", ":", "# pragma: no cover", "registry", "=", "get_current_registry", "(", ")", "settings", "=", "registry", ".", "settings", "connection_string", "=", "settings", "[", "CONNECTION_STRING", "]", "channels", "=", "_get_channels", "(", "s...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
lookup_api_key_info
Given a dbapi cursor, lookup all the api keys and their information.
cnxpublishing/authnz.py
def lookup_api_key_info(): """Given a dbapi cursor, lookup all the api keys and their information.""" info = {} with db_connect() as conn: with conn.cursor() as cursor: cursor.execute(ALL_KEY_INFO_SQL_STMT) for row in cursor.fetchall(): id, key, name, groups =...
def lookup_api_key_info(): """Given a dbapi cursor, lookup all the api keys and their information.""" info = {} with db_connect() as conn: with conn.cursor() as cursor: cursor.execute(ALL_KEY_INFO_SQL_STMT) for row in cursor.fetchall(): id, key, name, groups =...
[ "Given", "a", "dbapi", "cursor", "lookup", "all", "the", "api", "keys", "and", "their", "information", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/authnz.py#L26-L37
[ "def", "lookup_api_key_info", "(", ")", ":", "info", "=", "{", "}", "with", "db_connect", "(", ")", "as", "conn", ":", "with", "conn", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "ALL_KEY_INFO_SQL_STMT", ")", "for", "ro...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
includeme
Configuration include fuction for this module
cnxpublishing/authnz.py
def includeme(config): """Configuration include fuction for this module""" api_key_authn_policy = APIKeyAuthenticationPolicy() config.include('openstax_accounts') openstax_authn_policy = config.registry.getUtility( IOpenstaxAccountsAuthenticationPolicy) # Set up api & user authentication po...
def includeme(config): """Configuration include fuction for this module""" api_key_authn_policy = APIKeyAuthenticationPolicy() config.include('openstax_accounts') openstax_authn_policy = config.registry.getUtility( IOpenstaxAccountsAuthenticationPolicy) # Set up api & user authentication po...
[ "Configuration", "include", "fuction", "for", "this", "module" ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/authnz.py#L93-L107
[ "def", "includeme", "(", "config", ")", ":", "api_key_authn_policy", "=", "APIKeyAuthenticationPolicy", "(", ")", "config", ".", "include", "(", "'openstax_accounts'", ")", "openstax_authn_policy", "=", "config", ".", "registry", ".", "getUtility", "(", "IOpenstaxAc...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
expandvars_dict
Expands all environment variables in a settings dictionary.
cnxpublishing/config.py
def expandvars_dict(settings): """Expands all environment variables in a settings dictionary.""" return dict( (key, os.path.expandvars(value)) for key, value in settings.iteritems() )
def expandvars_dict(settings): """Expands all environment variables in a settings dictionary.""" return dict( (key, os.path.expandvars(value)) for key, value in settings.iteritems() )
[ "Expands", "all", "environment", "variables", "in", "a", "settings", "dictionary", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/config.py#L60-L65
[ "def", "expandvars_dict", "(", "settings", ")", ":", "return", "dict", "(", "(", "key", ",", "os", ".", "path", ".", "expandvars", "(", "value", ")", ")", "for", "key", ",", "value", "in", "settings", ".", "iteritems", "(", ")", ")" ]
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
initialize_sentry_integration
\ Used to optionally initialize the Sentry service with this app. See https://docs.sentry.io/platforms/python/pyramid/
cnxpublishing/config.py
def initialize_sentry_integration(): # pragma: no cover """\ Used to optionally initialize the Sentry service with this app. See https://docs.sentry.io/platforms/python/pyramid/ """ # This function is not under coverage because it is boilerplate # from the Sentry documentation. try: ...
def initialize_sentry_integration(): # pragma: no cover """\ Used to optionally initialize the Sentry service with this app. See https://docs.sentry.io/platforms/python/pyramid/ """ # This function is not under coverage because it is boilerplate # from the Sentry documentation. try: ...
[ "\\", "Used", "to", "optionally", "initialize", "the", "Sentry", "service", "with", "this", "app", ".", "See", "https", ":", "//", "docs", ".", "sentry", ".", "io", "/", "platforms", "/", "python", "/", "pyramid", "/" ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/config.py#L68-L100
[ "def", "initialize_sentry_integration", "(", ")", ":", "# pragma: no cover", "# This function is not under coverage because it is boilerplate", "# from the Sentry documentation.", "try", ":", "import", "sentry_sdk", "from", "sentry_sdk", ".", "integrations", ".", "pyramid", "impo...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
task
A function task decorator used in place of ``@celery_app.task``.
cnxpublishing/tasks.py
def task(**kwargs): """A function task decorator used in place of ``@celery_app.task``.""" def wrapper(wrapped): def callback(scanner, name, obj): celery_app = scanner.config.registry.celery_app celery_app.task(**kwargs)(obj) venusian.attach(wrapped, callback) ...
def task(**kwargs): """A function task decorator used in place of ``@celery_app.task``.""" def wrapper(wrapped): def callback(scanner, name, obj): celery_app = scanner.config.registry.celery_app celery_app.task(**kwargs)(obj) venusian.attach(wrapped, callback) ...
[ "A", "function", "task", "decorator", "used", "in", "place", "of" ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/tasks.py#L34-L46
[ "def", "task", "(", "*", "*", "kwargs", ")", ":", "def", "wrapper", "(", "wrapped", ")", ":", "def", "callback", "(", "scanner", ",", "name", ",", "obj", ")", ":", "celery_app", "=", "scanner", ".", "config", ".", "registry", ".", "celery_app", "cele...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_make_celery_app
This exposes the celery app. The app is actually created as part of the configuration. However, this does make the celery app functional as a stand-alone celery application. This puts the pyramid configuration object on the celery app to be used for making the registry available to tasks running inside...
cnxpublishing/tasks.py
def _make_celery_app(config): """This exposes the celery app. The app is actually created as part of the configuration. However, this does make the celery app functional as a stand-alone celery application. This puts the pyramid configuration object on the celery app to be used for making the regis...
def _make_celery_app(config): """This exposes the celery app. The app is actually created as part of the configuration. However, this does make the celery app functional as a stand-alone celery application. This puts the pyramid configuration object on the celery app to be used for making the regis...
[ "This", "exposes", "the", "celery", "app", ".", "The", "app", "is", "actually", "created", "as", "part", "of", "the", "configuration", ".", "However", "this", "does", "make", "the", "celery", "app", "functional", "as", "a", "stand", "-", "alone", "celery",...
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/tasks.py#L49-L61
[ "def", "_make_celery_app", "(", "config", ")", ":", "# Tack the pyramid config on the celery app for later use.", "config", ".", "registry", ".", "celery_app", ".", "conf", "[", "'pyramid_config'", "]", "=", "config", "return", "config", ".", "registry", ".", "celery_...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
post_publication_processing
Process post-publication events coming out of the database.
cnxpublishing/subscribers.py
def post_publication_processing(event, cursor): """Process post-publication events coming out of the database.""" module_ident, ident_hash = event.module_ident, event.ident_hash celery_app = get_current_registry().celery_app # Check baking is not already queued. cursor.execute('SELECT result_id::t...
def post_publication_processing(event, cursor): """Process post-publication events coming out of the database.""" module_ident, ident_hash = event.module_ident, event.ident_hash celery_app = get_current_registry().celery_app # Check baking is not already queued. cursor.execute('SELECT result_id::t...
[ "Process", "post", "-", "publication", "events", "coming", "out", "of", "the", "database", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/subscribers.py#L32-L64
[ "def", "post_publication_processing", "(", "event", ",", "cursor", ")", ":", "module_ident", ",", "ident_hash", "=", "event", ".", "module_ident", ",", "event", ".", "ident_hash", "celery_app", "=", "get_current_registry", "(", ")", ".", "celery_app", "# Check bak...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
parse_archive_uri
Given an archive URI, parse to a split ident-hash.
cnxpublishing/utils.py
def parse_archive_uri(uri): """Given an archive URI, parse to a split ident-hash.""" parsed = urlparse(uri) path = parsed.path.rstrip('/').split('/') ident_hash = path[-1] ident_hash = unquote(ident_hash) return ident_hash
def parse_archive_uri(uri): """Given an archive URI, parse to a split ident-hash.""" parsed = urlparse(uri) path = parsed.path.rstrip('/').split('/') ident_hash = path[-1] ident_hash = unquote(ident_hash) return ident_hash
[ "Given", "an", "archive", "URI", "parse", "to", "a", "split", "ident", "-", "hash", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/utils.py#L31-L37
[ "def", "parse_archive_uri", "(", "uri", ")", ":", "parsed", "=", "urlparse", "(", "uri", ")", "path", "=", "parsed", ".", "path", ".", "rstrip", "(", "'/'", ")", ".", "split", "(", "'/'", ")", "ident_hash", "=", "path", "[", "-", "1", "]", "ident_h...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
declare_api_routes
Declaration of routing
cnxpublishing/views/__init__.py
def declare_api_routes(config): """Declaration of routing""" add_route = config.add_route add_route('get-content', '/contents/{ident_hash}') add_route('get-resource', '/resources/{hash}') # User actions API add_route('license-request', '/contents/{uuid}/licensors') add_route('roles-request'...
def declare_api_routes(config): """Declaration of routing""" add_route = config.add_route add_route('get-content', '/contents/{ident_hash}') add_route('get-resource', '/resources/{hash}') # User actions API add_route('license-request', '/contents/{uuid}/licensors') add_route('roles-request'...
[ "Declaration", "of", "routing" ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/__init__.py#L5-L34
[ "def", "declare_api_routes", "(", "config", ")", ":", "add_route", "=", "config", ".", "add_route", "add_route", "(", "'get-content'", ",", "'/contents/{ident_hash}'", ")", "add_route", "(", "'get-resource'", ",", "'/resources/{hash}'", ")", "# User actions API", "add...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
declare_browsable_routes
Declaration of routes that can be browsed by users.
cnxpublishing/views/__init__.py
def declare_browsable_routes(config): """Declaration of routes that can be browsed by users.""" # This makes our routes slashed, which is good browser behavior. config.add_notfound_view(default_exceptionresponse_view, append_slash=True) add_route = config.add_route add_...
def declare_browsable_routes(config): """Declaration of routes that can be browsed by users.""" # This makes our routes slashed, which is good browser behavior. config.add_notfound_view(default_exceptionresponse_view, append_slash=True) add_route = config.add_route add_...
[ "Declaration", "of", "routes", "that", "can", "be", "browsed", "by", "users", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/__init__.py#L37-L62
[ "def", "declare_browsable_routes", "(", "config", ")", ":", "# This makes our routes slashed, which is good browser behavior.", "config", ".", "add_notfound_view", "(", "default_exceptionresponse_view", ",", "append_slash", "=", "True", ")", "add_route", "=", "config", ".", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
includeme
Declare all routes.
cnxpublishing/views/__init__.py
def includeme(config): """Declare all routes.""" config.include('pyramid_jinja2') config.add_jinja2_renderer('.html') config.add_jinja2_renderer('.rss') config.add_static_view(name='/a/static', path="cnxpublishing:static/") # Commit the configuration otherwise the jija2_env won't have # a `...
def includeme(config): """Declare all routes.""" config.include('pyramid_jinja2') config.add_jinja2_renderer('.html') config.add_jinja2_renderer('.rss') config.add_static_view(name='/a/static', path="cnxpublishing:static/") # Commit the configuration otherwise the jija2_env won't have # a `...
[ "Declare", "all", "routes", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/__init__.py#L65-L85
[ "def", "includeme", "(", "config", ")", ":", "config", ".", "include", "(", "'pyramid_jinja2'", ")", "config", ".", "add_jinja2_renderer", "(", "'.html'", ")", "config", ".", "add_jinja2_renderer", "(", "'.rss'", ")", "config", ".", "add_static_view", "(", "na...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_formatter_callback_factory
Returns a list of includes to be given to `cnxepub.collation.collate`.
cnxpublishing/bake.py
def _formatter_callback_factory(): # pragma: no cover """Returns a list of includes to be given to `cnxepub.collation.collate`. """ includes = [] exercise_url_template = '{baseUrl}/api/exercises?q={field}:"{{itemCode}}"' settings = get_current_registry().settings exercise_base_url = settings.g...
def _formatter_callback_factory(): # pragma: no cover """Returns a list of includes to be given to `cnxepub.collation.collate`. """ includes = [] exercise_url_template = '{baseUrl}/api/exercises?q={field}:"{{itemCode}}"' settings = get_current_registry().settings exercise_base_url = settings.g...
[ "Returns", "a", "list", "of", "includes", "to", "be", "given", "to", "cnxepub", ".", "collation", ".", "collate", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/bake.py#L24-L54
[ "def", "_formatter_callback_factory", "(", ")", ":", "# pragma: no cover", "includes", "=", "[", "]", "exercise_url_template", "=", "'{baseUrl}/api/exercises?q={field}:\"{{itemCode}}\"'", "settings", "=", "get_current_registry", "(", ")", ".", "settings", "exercise_base_url",...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
bake
Given a `Binder` as `binder`, bake the contents and persist those changes alongside the published content.
cnxpublishing/bake.py
def bake(binder, recipe_id, publisher, message, cursor): """Given a `Binder` as `binder`, bake the contents and persist those changes alongside the published content. """ recipe = _get_recipe(recipe_id, cursor) includes = _formatter_callback_factory() binder = collate_models(binder, ruleset=rec...
def bake(binder, recipe_id, publisher, message, cursor): """Given a `Binder` as `binder`, bake the contents and persist those changes alongside the published content. """ recipe = _get_recipe(recipe_id, cursor) includes = _formatter_callback_factory() binder = collate_models(binder, ruleset=rec...
[ "Given", "a", "Binder", "as", "binder", "bake", "the", "contents", "and", "persist", "those", "changes", "alongside", "the", "published", "content", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/bake.py#L66-L93
[ "def", "bake", "(", "binder", ",", "recipe_id", ",", "publisher", ",", "message", ",", "cursor", ")", ":", "recipe", "=", "_get_recipe", "(", "recipe_id", ",", "cursor", ")", "includes", "=", "_formatter_callback_factory", "(", ")", "binder", "=", "collate_m...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
volcano
Arguments: differential_dfs (dict or pandas.DataFrame): python dict of names to pandas dataframes, or a single dataframe, indexed by gene symbols which must have columns named log2FC and qval. title (str): The title of the plot (to be embedded in the html). scripts_mode (str): Choose from [`"CDN...
axial/axial.py
def volcano(differential_dfs, title='Axial Volcano Plot', scripts_mode="CDN", data_mode="directory", organism="human", q_value_column_name="q", log2FC_column_name="logFC", output_dir=".", filename="volcano.html", version=this_version): """ Arguments: differential_dfs (dict or pan...
def volcano(differential_dfs, title='Axial Volcano Plot', scripts_mode="CDN", data_mode="directory", organism="human", q_value_column_name="q", log2FC_column_name="logFC", output_dir=".", filename="volcano.html", version=this_version): """ Arguments: differential_dfs (dict or pan...
[ "Arguments", ":", "differential_dfs", "(", "dict", "or", "pandas", ".", "DataFrame", ")", ":", "python", "dict", "of", "names", "to", "pandas", "dataframes", "or", "a", "single", "dataframe", "indexed", "by", "gene", "symbols", "which", "must", "have", "colu...
zfrenchee/Axial
python
https://github.com/zfrenchee/Axial/blob/69672b4ce46518e0348dedb74a907cc73f71c0fe/axial/axial.py#L161-L228
[ "def", "volcano", "(", "differential_dfs", ",", "title", "=", "'Axial Volcano Plot'", ",", "scripts_mode", "=", "\"CDN\"", ",", "data_mode", "=", "\"directory\"", ",", "organism", "=", "\"human\"", ",", "q_value_column_name", "=", "\"q\"", ",", "log2FC_column_name",...
69672b4ce46518e0348dedb74a907cc73f71c0fe
valid
heatmap
Arguments: genes_by_samples_matrix (pandas.DataFrame): dataframe indexed by genes, columns are samples sample_attributes (pandas.DataFrame): dataframe indexed by samples, columns are sample attributes (e.g. classes) title (str): The title of the plot (to be embedded in the html). scripts...
axial/axial.py
def heatmap(genes_by_samples_matrix, sample_attributes, title='Axial Heatmap', scripts_mode="CDN", data_mode="directory", organism="human", separate_zscore_by=["system"], output_dir=".", filename="heatmap.html", version=this_version): """ Arguments: genes_by_samples_matrix (panda...
def heatmap(genes_by_samples_matrix, sample_attributes, title='Axial Heatmap', scripts_mode="CDN", data_mode="directory", organism="human", separate_zscore_by=["system"], output_dir=".", filename="heatmap.html", version=this_version): """ Arguments: genes_by_samples_matrix (panda...
[ "Arguments", ":", "genes_by_samples_matrix", "(", "pandas", ".", "DataFrame", ")", ":", "dataframe", "indexed", "by", "genes", "columns", "are", "samples", "sample_attributes", "(", "pandas", ".", "DataFrame", ")", ":", "dataframe", "indexed", "by", "samples", "...
zfrenchee/Axial
python
https://github.com/zfrenchee/Axial/blob/69672b4ce46518e0348dedb74a907cc73f71c0fe/axial/axial.py#L364-L425
[ "def", "heatmap", "(", "genes_by_samples_matrix", ",", "sample_attributes", ",", "title", "=", "'Axial Heatmap'", ",", "scripts_mode", "=", "\"CDN\"", ",", "data_mode", "=", "\"directory\"", ",", "organism", "=", "\"human\"", ",", "separate_zscore_by", "=", "[", "...
69672b4ce46518e0348dedb74a907cc73f71c0fe
valid
graph
Arguments: networkx_graph (networkx.Graph): any instance of networkx.Graph title (str): The title of the plot (to be embedded in the html). scripts_mode (str): Choose from [`"CDN"`, `"directory"`, `"inline"`]: - `"CDN"` compiles a single HTML page with links to scripts hosted on a C...
axial/axial.py
def graph(networkx_graph, title='Axial Graph Visualization', scripts_mode="CDN", data_mode="directory", output_dir=".", filename="graph.html", version=this_version): """ Arguments: networkx_graph (networkx.Graph): any instance of networkx.Graph title (str): The title of the plot (to be...
def graph(networkx_graph, title='Axial Graph Visualization', scripts_mode="CDN", data_mode="directory", output_dir=".", filename="graph.html", version=this_version): """ Arguments: networkx_graph (networkx.Graph): any instance of networkx.Graph title (str): The title of the plot (to be...
[ "Arguments", ":", "networkx_graph", "(", "networkx", ".", "Graph", ")", ":", "any", "instance", "of", "networkx", ".", "Graph", "title", "(", "str", ")", ":", "The", "title", "of", "the", "plot", "(", "to", "be", "embedded", "in", "the", "html", ")", ...
zfrenchee/Axial
python
https://github.com/zfrenchee/Axial/blob/69672b4ce46518e0348dedb74a907cc73f71c0fe/axial/axial.py#L430-L489
[ "def", "graph", "(", "networkx_graph", ",", "title", "=", "'Axial Graph Visualization'", ",", "scripts_mode", "=", "\"CDN\"", ",", "data_mode", "=", "\"directory\"", ",", "output_dir", "=", "\".\"", ",", "filename", "=", "\"graph.html\"", ",", "version", "=", "t...
69672b4ce46518e0348dedb74a907cc73f71c0fe
valid
db_connect
Function to supply a database connection object.
cnxpublishing/db.py
def db_connect(connection_string=None, **kwargs): """Function to supply a database connection object.""" if connection_string is None: connection_string = get_current_registry().settings[CONNECTION_STRING] db_conn = psycopg2.connect(connection_string, **kwargs) try: with db_conn: ...
def db_connect(connection_string=None, **kwargs): """Function to supply a database connection object.""" if connection_string is None: connection_string = get_current_registry().settings[CONNECTION_STRING] db_conn = psycopg2.connect(connection_string, **kwargs) try: with db_conn: ...
[ "Function", "to", "supply", "a", "database", "connection", "object", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L49-L58
[ "def", "db_connect", "(", "connection_string", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "connection_string", "is", "None", ":", "connection_string", "=", "get_current_registry", "(", ")", ".", "settings", "[", "CONNECTION_STRING", "]", "db_conn", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
with_db_cursor
Decorator that supplies a cursor to the function. This passes in a psycopg2 Cursor as the argument 'cursor'. It also accepts a cursor if one is given.
cnxpublishing/db.py
def with_db_cursor(func): """Decorator that supplies a cursor to the function. This passes in a psycopg2 Cursor as the argument 'cursor'. It also accepts a cursor if one is given. """ @functools.wraps(func) def wrapped(*args, **kwargs): if 'cursor' in kwargs or func.func_code.co_argcoun...
def with_db_cursor(func): """Decorator that supplies a cursor to the function. This passes in a psycopg2 Cursor as the argument 'cursor'. It also accepts a cursor if one is given. """ @functools.wraps(func) def wrapped(*args, **kwargs): if 'cursor' in kwargs or func.func_code.co_argcoun...
[ "Decorator", "that", "supplies", "a", "cursor", "to", "the", "function", ".", "This", "passes", "in", "a", "psycopg2", "Cursor", "as", "the", "argument", "cursor", ".", "It", "also", "accepts", "a", "cursor", "if", "one", "is", "given", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L61-L76
[ "def", "with_db_cursor", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'cursor'", "in", "kwargs", "or", "func", ".", "func_code", ".", "co_argcou...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_role_type_to_db_type
Translates a role type (a value found in ``cnxepub.ATTRIBUTED_ROLE_KEYS``) to a database compatible value for ``role_types``.
cnxpublishing/db.py
def _role_type_to_db_type(type_): """Translates a role type (a value found in ``cnxepub.ATTRIBUTED_ROLE_KEYS``) to a database compatible value for ``role_types``. """ with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ WITH unnested_role_types AS ( ...
def _role_type_to_db_type(type_): """Translates a role type (a value found in ``cnxepub.ATTRIBUTED_ROLE_KEYS``) to a database compatible value for ``role_types``. """ with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ WITH unnested_role_types AS ( ...
[ "Translates", "a", "role", "type", "(", "a", "value", "found", "in", "cnxepub", ".", "ATTRIBUTED_ROLE_KEYS", ")", "to", "a", "database", "compatible", "value", "for", "role_types", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L90-L103
[ "def", "_role_type_to_db_type", "(", "type_", ")", ":", "with", "db_connect", "(", ")", "as", "db_conn", ":", "with", "db_conn", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nWITH unnested_role_types AS (\n SELECT unnest(...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_dissect_roles
Given a model's ``metadata``, iterate over the roles. Return values are the role identifier and role type as a tuple.
cnxpublishing/db.py
def _dissect_roles(metadata): """Given a model's ``metadata``, iterate over the roles. Return values are the role identifier and role type as a tuple. """ for role_key in cnxepub.ATTRIBUTED_ROLE_KEYS: for user in metadata.get(role_key, []): if user['type'] != 'cnx-id': ...
def _dissect_roles(metadata): """Given a model's ``metadata``, iterate over the roles. Return values are the role identifier and role type as a tuple. """ for role_key in cnxepub.ATTRIBUTED_ROLE_KEYS: for user in metadata.get(role_key, []): if user['type'] != 'cnx-id': ...
[ "Given", "a", "model", "s", "metadata", "iterate", "over", "the", "roles", ".", "Return", "values", "are", "the", "role", "identifier", "and", "role", "type", "as", "a", "tuple", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L106-L116
[ "def", "_dissect_roles", "(", "metadata", ")", ":", "for", "role_key", "in", "cnxepub", ".", "ATTRIBUTED_ROLE_KEYS", ":", "for", "user", "in", "metadata", ".", "get", "(", "role_key", ",", "[", "]", ")", ":", "if", "user", "[", "'type'", "]", "!=", "'c...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
upsert_pending_licensors
Update or insert records for pending license acceptors.
cnxpublishing/db.py
def upsert_pending_licensors(cursor, document_id): """Update or insert records for pending license acceptors.""" cursor.execute("""\ SELECT "uuid", "metadata" FROM pending_documents WHERE id = %s""", (document_id,)) uuid_, metadata = cursor.fetchone() acceptors = set([uid for uid, type_ in _dissect_role...
def upsert_pending_licensors(cursor, document_id): """Update or insert records for pending license acceptors.""" cursor.execute("""\ SELECT "uuid", "metadata" FROM pending_documents WHERE id = %s""", (document_id,)) uuid_, metadata = cursor.fetchone() acceptors = set([uid for uid, type_ in _dissect_role...
[ "Update", "or", "insert", "records", "for", "pending", "license", "acceptors", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L119-L160
[ "def", "upsert_pending_licensors", "(", "cursor", ",", "document_id", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT \"uuid\", \"metadata\"\nFROM pending_documents\nWHERE id = %s\"\"\"", ",", "(", "document_id", ",", ")", ")", "uuid_", ",", "metadata", "=", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
upsert_pending_roles
Update or insert records for pending document role acceptance.
cnxpublishing/db.py
def upsert_pending_roles(cursor, document_id): """Update or insert records for pending document role acceptance.""" cursor.execute("""\ SELECT "uuid", "metadata" FROM pending_documents WHERE id = %s""", (document_id,)) uuid_, metadata = cursor.fetchone() acceptors = set([(uid, _role_type_to_db_type(typ...
def upsert_pending_roles(cursor, document_id): """Update or insert records for pending document role acceptance.""" cursor.execute("""\ SELECT "uuid", "metadata" FROM pending_documents WHERE id = %s""", (document_id,)) uuid_, metadata = cursor.fetchone() acceptors = set([(uid, _role_type_to_db_type(typ...
[ "Update", "or", "insert", "records", "for", "pending", "document", "role", "acceptance", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L163-L209
[ "def", "upsert_pending_roles", "(", "cursor", ",", "document_id", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT \"uuid\", \"metadata\"\nFROM pending_documents\nWHERE id = %s\"\"\"", ",", "(", "document_id", ",", ")", ")", "uuid_", ",", "metadata", "=", "cur...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
obtain_licenses
Obtain the licenses in a dictionary form, keyed by url.
cnxpublishing/db.py
def obtain_licenses(): """Obtain the licenses in a dictionary form, keyed by url.""" with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT combined_row.url, row_to_json(combined_row) FROM ( SELECT "code", "version", "name", "url", "is_valid_for_publicati...
def obtain_licenses(): """Obtain the licenses in a dictionary form, keyed by url.""" with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT combined_row.url, row_to_json(combined_row) FROM ( SELECT "code", "version", "name", "url", "is_valid_for_publicati...
[ "Obtain", "the", "licenses", "in", "a", "dictionary", "form", "keyed", "by", "url", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L264-L273
[ "def", "obtain_licenses", "(", ")", ":", "with", "db_connect", "(", ")", "as", "db_conn", ":", "with", "db_conn", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT combined_row.url, row_to_json(combined_row) FROM (\n SEL...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_validate_license
Given the model, check the license is one valid for publication.
cnxpublishing/db.py
def _validate_license(model): """Given the model, check the license is one valid for publication.""" license_mapping = obtain_licenses() try: license_url = model.metadata['license_url'] except KeyError: raise exceptions.MissingRequiredMetadata('license_url') try: license = li...
def _validate_license(model): """Given the model, check the license is one valid for publication.""" license_mapping = obtain_licenses() try: license_url = model.metadata['license_url'] except KeyError: raise exceptions.MissingRequiredMetadata('license_url') try: license = li...
[ "Given", "the", "model", "check", "the", "license", "is", "one", "valid", "for", "publication", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L276-L288
[ "def", "_validate_license", "(", "model", ")", ":", "license_mapping", "=", "obtain_licenses", "(", ")", "try", ":", "license_url", "=", "model", ".", "metadata", "[", "'license_url'", "]", "except", "KeyError", ":", "raise", "exceptions", ".", "MissingRequiredM...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_validate_roles
Given the model, check that all the metadata role values have valid information in them and any required metadata fields contain values.
cnxpublishing/db.py
def _validate_roles(model): """Given the model, check that all the metadata role values have valid information in them and any required metadata fields contain values. """ required_roles = (ATTRIBUTED_ROLE_KEYS[0], ATTRIBUTED_ROLE_KEYS[4],) for role_key in ATTRIBUTED_ROLE_KEYS: try: ...
def _validate_roles(model): """Given the model, check that all the metadata role values have valid information in them and any required metadata fields contain values. """ required_roles = (ATTRIBUTED_ROLE_KEYS[0], ATTRIBUTED_ROLE_KEYS[4],) for role_key in ATTRIBUTED_ROLE_KEYS: try: ...
[ "Given", "the", "model", "check", "that", "all", "the", "metadata", "role", "values", "have", "valid", "information", "in", "them", "and", "any", "required", "metadata", "fields", "contain", "values", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L292-L309
[ "def", "_validate_roles", "(", "model", ")", ":", "required_roles", "=", "(", "ATTRIBUTED_ROLE_KEYS", "[", "0", "]", ",", "ATTRIBUTED_ROLE_KEYS", "[", "4", "]", ",", ")", "for", "role_key", "in", "ATTRIBUTED_ROLE_KEYS", ":", "try", ":", "roles", "=", "model"...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_validate_derived_from
Given a database cursor and model, check the derived-from value accurately points to content in the archive. The value can be nothing or must point to existing content.
cnxpublishing/db.py
def _validate_derived_from(cursor, model): """Given a database cursor and model, check the derived-from value accurately points to content in the archive. The value can be nothing or must point to existing content. """ derived_from_uri = model.metadata.get('derived_from_uri') if derived_from_uri...
def _validate_derived_from(cursor, model): """Given a database cursor and model, check the derived-from value accurately points to content in the archive. The value can be nothing or must point to existing content. """ derived_from_uri = model.metadata.get('derived_from_uri') if derived_from_uri...
[ "Given", "a", "database", "cursor", "and", "model", "check", "the", "derived", "-", "from", "value", "accurately", "points", "to", "content", "in", "the", "archive", ".", "The", "value", "can", "be", "nothing", "or", "must", "point", "to", "existing", "con...
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L312-L346
[ "def", "_validate_derived_from", "(", "cursor", ",", "model", ")", ":", "derived_from_uri", "=", "model", ".", "metadata", ".", "get", "(", "'derived_from_uri'", ")", "if", "derived_from_uri", "is", "None", ":", "return", "# bail out early", "# Can we parse the valu...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_validate_subjects
Give a database cursor and model, check the subjects against the subject vocabulary.
cnxpublishing/db.py
def _validate_subjects(cursor, model): """Give a database cursor and model, check the subjects against the subject vocabulary. """ subject_vocab = [term[0] for term in acquire_subject_vocabulary(cursor)] subjects = model.metadata.get('subjects', []) invalid_subjects = [s for s in subjects if s n...
def _validate_subjects(cursor, model): """Give a database cursor and model, check the subjects against the subject vocabulary. """ subject_vocab = [term[0] for term in acquire_subject_vocabulary(cursor)] subjects = model.metadata.get('subjects', []) invalid_subjects = [s for s in subjects if s n...
[ "Give", "a", "database", "cursor", "and", "model", "check", "the", "subjects", "against", "the", "subject", "vocabulary", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L349-L357
[ "def", "_validate_subjects", "(", "cursor", ",", "model", ")", ":", "subject_vocab", "=", "[", "term", "[", "0", "]", "for", "term", "in", "acquire_subject_vocabulary", "(", "cursor", ")", "]", "subjects", "=", "model", ".", "metadata", ".", "get", "(", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
validate_model
Validates the model using a series of checks on bits of the data.
cnxpublishing/db.py
def validate_model(cursor, model): """Validates the model using a series of checks on bits of the data.""" # Check the license is one valid for publication. _validate_license(model) _validate_roles(model) # Other required metadata includes: title, summary required_metadata = ('title', 'summary'...
def validate_model(cursor, model): """Validates the model using a series of checks on bits of the data.""" # Check the license is one valid for publication. _validate_license(model) _validate_roles(model) # Other required metadata includes: title, summary required_metadata = ('title', 'summary'...
[ "Validates", "the", "model", "using", "a", "series", "of", "checks", "on", "bits", "of", "the", "data", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L360-L379
[ "def", "validate_model", "(", "cursor", ",", "model", ")", ":", "# Check the license is one valid for publication.", "_validate_license", "(", "model", ")", "_validate_roles", "(", "model", ")", "# Other required metadata includes: title, summary", "required_metadata", "=", "...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
is_publication_permissible
Check the given publisher of this publication given by ``publication_id`` is allowed to publish the content given by ``uuid``.
cnxpublishing/db.py
def is_publication_permissible(cursor, publication_id, uuid_): """Check the given publisher of this publication given by ``publication_id`` is allowed to publish the content given by ``uuid``. """ # Check the publishing user has permission to publish cursor.execute("""\ SELECT 't'::boolean FROM ...
def is_publication_permissible(cursor, publication_id, uuid_): """Check the given publisher of this publication given by ``publication_id`` is allowed to publish the content given by ``uuid``. """ # Check the publishing user has permission to publish cursor.execute("""\ SELECT 't'::boolean FROM ...
[ "Check", "the", "given", "publisher", "of", "this", "publication", "given", "by", "publication_id", "is", "allowed", "to", "publish", "the", "content", "given", "by", "uuid", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L385-L409
[ "def", "is_publication_permissible", "(", "cursor", ",", "publication_id", ",", "uuid_", ")", ":", "# Check the publishing user has permission to publish", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT 't'::boolean\nFROM\n pending_documents AS pd\n NATURAL JOIN document_acl AS acl...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
add_pending_model
Adds a model (binder or document) that is awaiting publication to the database.
cnxpublishing/db.py
def add_pending_model(cursor, publication_id, model): """Adds a model (binder or document) that is awaiting publication to the database. """ # FIXME Too much happening here... assert isinstance(model, (cnxepub.Document, cnxepub.Binder,)), type(model) uri = model.get_uri('cnx-archive') if ur...
def add_pending_model(cursor, publication_id, model): """Adds a model (binder or document) that is awaiting publication to the database. """ # FIXME Too much happening here... assert isinstance(model, (cnxepub.Document, cnxepub.Binder,)), type(model) uri = model.get_uri('cnx-archive') if ur...
[ "Adds", "a", "model", "(", "binder", "or", "document", ")", "that", "is", "awaiting", "publication", "to", "the", "database", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L412-L507
[ "def", "add_pending_model", "(", "cursor", ",", "publication_id", ",", "model", ")", ":", "# FIXME Too much happening here...", "assert", "isinstance", "(", "model", ",", "(", "cnxepub", ".", "Document", ",", "cnxepub", ".", "Binder", ",", ")", ")", ",", "type...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
lookup_document_pointer
Lookup a document by id and version.
cnxpublishing/db.py
def lookup_document_pointer(ident_hash, cursor): """Lookup a document by id and version.""" id, version = split_ident_hash(ident_hash, split_version=True) stmt = "SELECT name FROM modules WHERE uuid = %s" args = [id] if version and version[0] is not None: operator = version[1] is None and 'i...
def lookup_document_pointer(ident_hash, cursor): """Lookup a document by id and version.""" id, version = split_ident_hash(ident_hash, split_version=True) stmt = "SELECT name FROM modules WHERE uuid = %s" args = [id] if version and version[0] is not None: operator = version[1] is None and 'i...
[ "Lookup", "a", "document", "by", "id", "and", "version", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L510-L527
[ "def", "lookup_document_pointer", "(", "ident_hash", ",", "cursor", ")", ":", "id", ",", "version", "=", "split_ident_hash", "(", "ident_hash", ",", "split_version", "=", "True", ")", "stmt", "=", "\"SELECT name FROM modules WHERE uuid = %s\"", "args", "=", "[", "...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
add_pending_model_content
Updates the pending model's content. This is a secondary step not in ``add_pending_model, because content reference resolution requires the identifiers as they will appear in the end publication.
cnxpublishing/db.py
def add_pending_model_content(cursor, publication_id, model): """Updates the pending model's content. This is a secondary step not in ``add_pending_model, because content reference resolution requires the identifiers as they will appear in the end publication. """ cursor.execute("""\ SEL...
def add_pending_model_content(cursor, publication_id, model): """Updates the pending model's content. This is a secondary step not in ``add_pending_model, because content reference resolution requires the identifiers as they will appear in the end publication. """ cursor.execute("""\ SEL...
[ "Updates", "the", "pending", "model", "s", "content", ".", "This", "is", "a", "secondary", "step", "not", "in", "add_pending_model", "because", "content", "reference", "resolution", "requires", "the", "identifiers", "as", "they", "will", "appear", "in", "the", ...
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L530-L635
[ "def", "add_pending_model_content", "(", "cursor", ",", "publication_id", ",", "model", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\n SELECT id, ident_hash(uuid, major_version, minor_version)\n FROM pending_documents\n WHERE publication_id = %s AND uuid = %s\"...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
set_publication_failure
Given a publication exception, set the publication as failed and append the failure message to the publication record.
cnxpublishing/db.py
def set_publication_failure(cursor, exc): """Given a publication exception, set the publication as failed and append the failure message to the publication record. """ publication_id = exc.publication_id if publication_id is None: raise ValueError("Exception must have a ``publication_id`` va...
def set_publication_failure(cursor, exc): """Given a publication exception, set the publication as failed and append the failure message to the publication record. """ publication_id = exc.publication_id if publication_id is None: raise ValueError("Exception must have a ``publication_id`` va...
[ "Given", "a", "publication", "exception", "set", "the", "publication", "as", "failed", "and", "append", "the", "failure", "message", "to", "the", "publication", "record", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L638-L658
[ "def", "set_publication_failure", "(", "cursor", ",", "exc", ")", ":", "publication_id", "=", "exc", ".", "publication_id", "if", "publication_id", "is", "None", ":", "raise", "ValueError", "(", "\"Exception must have a ``publication_id`` value.\"", ")", "cursor", "."...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
add_publication
Adds a publication entry and makes each item a pending document.
cnxpublishing/db.py
def add_publication(cursor, epub, epub_file, is_pre_publication=False): """Adds a publication entry and makes each item a pending document. """ publisher = epub[0].metadata['publisher'] publish_message = epub[0].metadata['publication_message'] epub_binary = psycopg2.Binary(epub_file.read()) ...
def add_publication(cursor, epub, epub_file, is_pre_publication=False): """Adds a publication entry and makes each item a pending document. """ publisher = epub[0].metadata['publisher'] publish_message = epub[0].metadata['publication_message'] epub_binary = psycopg2.Binary(epub_file.read()) ...
[ "Adds", "a", "publication", "entry", "and", "makes", "each", "item", "a", "pending", "document", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L661-L704
[ "def", "add_publication", "(", "cursor", ",", "epub", ",", "epub_file", ",", "is_pre_publication", "=", "False", ")", ":", "publisher", "=", "epub", "[", "0", "]", ".", "metadata", "[", "'publisher'", "]", "publish_message", "=", "epub", "[", "0", "]", "...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_check_pending_document_license_state
Check the aggregate state on the pending document.
cnxpublishing/db.py
def _check_pending_document_license_state(cursor, document_id): """Check the aggregate state on the pending document.""" cursor.execute("""\ SELECT BOOL_AND(accepted IS TRUE) FROM pending_documents AS pd, license_acceptances AS la WHERE pd.id = %s AND pd.uuid = la.uuid""", (document...
def _check_pending_document_license_state(cursor, document_id): """Check the aggregate state on the pending document.""" cursor.execute("""\ SELECT BOOL_AND(accepted IS TRUE) FROM pending_documents AS pd, license_acceptances AS la WHERE pd.id = %s AND pd.uuid = la.uuid""", (document...
[ "Check", "the", "aggregate", "state", "on", "the", "pending", "document", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L707-L724
[ "def", "_check_pending_document_license_state", "(", "cursor", ",", "document_id", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT BOOL_AND(accepted IS TRUE)\nFROM\n pending_documents AS pd,\n license_acceptances AS la\nWHERE\n pd.id = %s\n AND\n pd.uuid = la.uuid\"\"\"", "...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_check_pending_document_role_state
Check the aggregate state on the pending document.
cnxpublishing/db.py
def _check_pending_document_role_state(cursor, document_id): """Check the aggregate state on the pending document.""" cursor.execute("""\ SELECT BOOL_AND(accepted IS TRUE) FROM role_acceptances AS ra, pending_documents as pd WHERE pd.id = %s AND pd.uuid = ra.uuid""", (document_id,))...
def _check_pending_document_role_state(cursor, document_id): """Check the aggregate state on the pending document.""" cursor.execute("""\ SELECT BOOL_AND(accepted IS TRUE) FROM role_acceptances AS ra, pending_documents as pd WHERE pd.id = %s AND pd.uuid = ra.uuid""", (document_id,))...
[ "Check", "the", "aggregate", "state", "on", "the", "pending", "document", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L727-L744
[ "def", "_check_pending_document_role_state", "(", "cursor", ",", "document_id", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT BOOL_AND(accepted IS TRUE)\nFROM\n role_acceptances AS ra,\n pending_documents as pd\nWHERE\n pd.id = %s\n AND\n pd.uuid = ra.uuid\"\"\"", ",", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_update_pending_document_state
Update the state of the document's state values.
cnxpublishing/db.py
def _update_pending_document_state(cursor, document_id, is_license_accepted, are_roles_accepted): """Update the state of the document's state values.""" args = (bool(is_license_accepted), bool(are_roles_accepted), document_id,) cursor.execute("""\ UPDATE pendin...
def _update_pending_document_state(cursor, document_id, is_license_accepted, are_roles_accepted): """Update the state of the document's state values.""" args = (bool(is_license_accepted), bool(are_roles_accepted), document_id,) cursor.execute("""\ UPDATE pendin...
[ "Update", "the", "state", "of", "the", "document", "s", "state", "values", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L747-L756
[ "def", "_update_pending_document_state", "(", "cursor", ",", "document_id", ",", "is_license_accepted", ",", "are_roles_accepted", ")", ":", "args", "=", "(", "bool", "(", "is_license_accepted", ")", ",", "bool", "(", "are_roles_accepted", ")", ",", "document_id", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
is_revision_publication
Checks to see if the publication contains any revised models. Revised in this context means that it is a new version of an existing piece of content.
cnxpublishing/db.py
def is_revision_publication(publication_id, cursor): """Checks to see if the publication contains any revised models. Revised in this context means that it is a new version of an existing piece of content. """ cursor.execute("""\ SELECT 't'::boolean FROM modules WHERE uuid IN (SELECT uuid ...
def is_revision_publication(publication_id, cursor): """Checks to see if the publication contains any revised models. Revised in this context means that it is a new version of an existing piece of content. """ cursor.execute("""\ SELECT 't'::boolean FROM modules WHERE uuid IN (SELECT uuid ...
[ "Checks", "to", "see", "if", "the", "publication", "contains", "any", "revised", "models", ".", "Revised", "in", "this", "context", "means", "that", "it", "is", "a", "new", "version", "of", "an", "existing", "piece", "of", "content", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L760-L777
[ "def", "is_revision_publication", "(", "publication_id", ",", "cursor", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT 't'::boolean FROM modules\nWHERE uuid IN (SELECT uuid\n FROM pending_documents\n WHERE publication_id = %s)\nLIMIT 1\"\"\"", ",", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
poke_publication_state
Invoked to poke at the publication to update and acquire its current state. This is used to persist the publication to archive.
cnxpublishing/db.py
def poke_publication_state(publication_id, cursor): """Invoked to poke at the publication to update and acquire its current state. This is used to persist the publication to archive. """ cursor.execute("""\ SELECT "state", "state_messages", "is_pre_publication", "publisher" FROM publications WHERE id = ...
def poke_publication_state(publication_id, cursor): """Invoked to poke at the publication to update and acquire its current state. This is used to persist the publication to archive. """ cursor.execute("""\ SELECT "state", "state_messages", "is_pre_publication", "publisher" FROM publications WHERE id = ...
[ "Invoked", "to", "poke", "at", "the", "publication", "to", "update", "and", "acquire", "its", "current", "state", ".", "This", "is", "used", "to", "persist", "the", "publication", "to", "archive", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L781-L884
[ "def", "poke_publication_state", "(", "publication_id", ",", "cursor", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT \"state\", \"state_messages\", \"is_pre_publication\", \"publisher\"\nFROM publications\nWHERE id = %s\"\"\"", ",", "(", "publication_id", ",", ")", "...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
check_publication_state
Check the publication's current state.
cnxpublishing/db.py
def check_publication_state(publication_id): """Check the publication's current state.""" with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT "state", "state_messages" FROM publications WHERE id = %s""", (publication_id,)) publication_state, ...
def check_publication_state(publication_id): """Check the publication's current state.""" with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT "state", "state_messages" FROM publications WHERE id = %s""", (publication_id,)) publication_state, ...
[ "Check", "the", "publication", "s", "current", "state", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L887-L896
[ "def", "check_publication_state", "(", "publication_id", ")", ":", "with", "db_connect", "(", ")", "as", "db_conn", ":", "with", "db_conn", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT \"state\", \"state_messages\"...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_node_to_model
Given a tree, parse to a set of models
cnxpublishing/db.py
def _node_to_model(tree_or_item, metadata=None, parent=None, lucent_id=cnxepub.TRANSLUCENT_BINDER_ID): """Given a tree, parse to a set of models""" if 'contents' in tree_or_item: # It is a binder. tree = tree_or_item binder = cnxepub.TranslucentBinder(metadata=tree) ...
def _node_to_model(tree_or_item, metadata=None, parent=None, lucent_id=cnxepub.TRANSLUCENT_BINDER_ID): """Given a tree, parse to a set of models""" if 'contents' in tree_or_item: # It is a binder. tree = tree_or_item binder = cnxepub.TranslucentBinder(metadata=tree) ...
[ "Given", "a", "tree", "parse", "to", "a", "set", "of", "models" ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L899-L918
[ "def", "_node_to_model", "(", "tree_or_item", ",", "metadata", "=", "None", ",", "parent", "=", "None", ",", "lucent_id", "=", "cnxepub", ".", "TRANSLUCENT_BINDER_ID", ")", ":", "if", "'contents'", "in", "tree_or_item", ":", "# It is a binder.", "tree", "=", "...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_reassemble_binder
Reassemble a Binder object coming out of the database.
cnxpublishing/db.py
def _reassemble_binder(id, tree, metadata): """Reassemble a Binder object coming out of the database.""" binder = cnxepub.Binder(id, metadata=metadata) for item in tree['contents']: node = _node_to_model(item, parent=binder) if node.metadata['title'] != item['title']: binder.set_...
def _reassemble_binder(id, tree, metadata): """Reassemble a Binder object coming out of the database.""" binder = cnxepub.Binder(id, metadata=metadata) for item in tree['contents']: node = _node_to_model(item, parent=binder) if node.metadata['title'] != item['title']: binder.set_...
[ "Reassemble", "a", "Binder", "object", "coming", "out", "of", "the", "database", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L921-L928
[ "def", "_reassemble_binder", "(", "id", ",", "tree", ",", "metadata", ")", ":", "binder", "=", "cnxepub", ".", "Binder", "(", "id", ",", "metadata", "=", "metadata", ")", "for", "item", "in", "tree", "[", "'contents'", "]", ":", "node", "=", "_node_to_...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
publish_pending
Given a publication id as ``publication_id``, write the documents to the *Connexions Archive*.
cnxpublishing/db.py
def publish_pending(cursor, publication_id): """Given a publication id as ``publication_id``, write the documents to the *Connexions Archive*. """ cursor.execute("""\ WITH state_update AS ( UPDATE publications SET state = 'Publishing' WHERE id = %s ) SELECT publisher, publication_message FROM publicat...
def publish_pending(cursor, publication_id): """Given a publication id as ``publication_id``, write the documents to the *Connexions Archive*. """ cursor.execute("""\ WITH state_update AS ( UPDATE publications SET state = 'Publishing' WHERE id = %s ) SELECT publisher, publication_message FROM publicat...
[ "Given", "a", "publication", "id", "as", "publication_id", "write", "the", "documents", "to", "the", "*", "Connexions", "Archive", "*", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L931-L1020
[ "def", "publish_pending", "(", "cursor", ",", "publication_id", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nWITH state_update AS (\n UPDATE publications SET state = 'Publishing' WHERE id = %s\n)\nSELECT publisher, publication_message\nFROM publications\nWHERE id = %s\"\"\"", ",", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
accept_publication_license
Accept or deny the document license for the publication (``publication_id``) and user (at ``user_id``) for the documents (listed by id as ``document_ids``).
cnxpublishing/db.py
def accept_publication_license(cursor, publication_id, user_id, document_ids, is_accepted=False): """Accept or deny the document license for the publication (``publication_id``) and user (at ``user_id``) for the documents (listed by id as ``document_ids``). """ cursor...
def accept_publication_license(cursor, publication_id, user_id, document_ids, is_accepted=False): """Accept or deny the document license for the publication (``publication_id``) and user (at ``user_id``) for the documents (listed by id as ``document_ids``). """ cursor...
[ "Accept", "or", "deny", "the", "document", "license", "for", "the", "publication", "(", "publication_id", ")", "and", "user", "(", "at", "user_id", ")", "for", "the", "documents", "(", "listed", "by", "id", "as", "document_ids", ")", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1023-L1041
[ "def", "accept_publication_license", "(", "cursor", ",", "publication_id", ",", "user_id", ",", "document_ids", ",", "is_accepted", "=", "False", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nUPDATE license_acceptances AS la\nSET accepted = %s\nFROM pending_documents AS...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
accept_publication_role
Accept or deny the document role attribution for the publication (``publication_id``) and user (at ``user_id``) for the documents (listed by id as ``document_ids``).
cnxpublishing/db.py
def accept_publication_role(cursor, publication_id, user_id, document_ids, is_accepted=False): """Accept or deny the document role attribution for the publication (``publication_id``) and user (at ``user_id``) for the documents (listed by id as ``document_ids``). """ cur...
def accept_publication_role(cursor, publication_id, user_id, document_ids, is_accepted=False): """Accept or deny the document role attribution for the publication (``publication_id``) and user (at ``user_id``) for the documents (listed by id as ``document_ids``). """ cur...
[ "Accept", "or", "deny", "the", "document", "role", "attribution", "for", "the", "publication", "(", "publication_id", ")", "and", "user", "(", "at", "user_id", ")", "for", "the", "documents", "(", "listed", "by", "id", "as", "document_ids", ")", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1044-L1062
[ "def", "accept_publication_role", "(", "cursor", ",", "publication_id", ",", "user_id", ",", "document_ids", ",", "is_accepted", "=", "False", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nUPDATE role_acceptances AS ra\nSET accepted = %s\nFROM pending_documents AS pd\nW...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
upsert_license_requests
Given a ``uuid`` and list of ``roles`` (user identifiers) create a license acceptance entry. If ``has_accepted`` is supplied, it will be used to assign an acceptance value to all listed ``uids``.
cnxpublishing/db.py
def upsert_license_requests(cursor, uuid_, roles): """Given a ``uuid`` and list of ``roles`` (user identifiers) create a license acceptance entry. If ``has_accepted`` is supplied, it will be used to assign an acceptance value to all listed ``uids``. """ if not isinstance(roles, (list, set, tuple,)):...
def upsert_license_requests(cursor, uuid_, roles): """Given a ``uuid`` and list of ``roles`` (user identifiers) create a license acceptance entry. If ``has_accepted`` is supplied, it will be used to assign an acceptance value to all listed ``uids``. """ if not isinstance(roles, (list, set, tuple,)):...
[ "Given", "a", "uuid", "and", "list", "of", "roles", "(", "user", "identifiers", ")", "create", "a", "license", "acceptance", "entry", ".", "If", "has_accepted", "is", "supplied", "it", "will", "be", "used", "to", "assign", "an", "acceptance", "value", "to"...
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1065-L1116
[ "def", "upsert_license_requests", "(", "cursor", ",", "uuid_", ",", "roles", ")", ":", "if", "not", "isinstance", "(", "roles", ",", "(", "list", ",", "set", ",", "tuple", ",", ")", ")", ":", "raise", "TypeError", "(", "\"``roles`` is an invalid type: {}\"",...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
remove_license_requests
Given a ``uuid`` and list of ``uids`` (user identifiers) remove the identified users' license acceptance entries.
cnxpublishing/db.py
def remove_license_requests(cursor, uuid_, uids): """Given a ``uuid`` and list of ``uids`` (user identifiers) remove the identified users' license acceptance entries. """ if not isinstance(uids, (list, set, tuple,)): raise TypeError("``uids`` is an invalid type: {}".format(type(uids))) acce...
def remove_license_requests(cursor, uuid_, uids): """Given a ``uuid`` and list of ``uids`` (user identifiers) remove the identified users' license acceptance entries. """ if not isinstance(uids, (list, set, tuple,)): raise TypeError("``uids`` is an invalid type: {}".format(type(uids))) acce...
[ "Given", "a", "uuid", "and", "list", "of", "uids", "(", "user", "identifiers", ")", "remove", "the", "identified", "users", "license", "acceptance", "entries", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1119-L1131
[ "def", "remove_license_requests", "(", "cursor", ",", "uuid_", ",", "uids", ")", ":", "if", "not", "isinstance", "(", "uids", ",", "(", "list", ",", "set", ",", "tuple", ",", ")", ")", ":", "raise", "TypeError", "(", "\"``uids`` is an invalid type: {}\"", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
upsert_role_requests
Given a ``uuid`` and list of dicts containing the ``uid`` and ``role`` for creating a role acceptance entry. The ``roles`` dict can optionally contain a ``has_accepted`` value, which will default to true.
cnxpublishing/db.py
def upsert_role_requests(cursor, uuid_, roles): """Given a ``uuid`` and list of dicts containing the ``uid`` and ``role`` for creating a role acceptance entry. The ``roles`` dict can optionally contain a ``has_accepted`` value, which will default to true. """ if not isinstance(roles, (list, set,...
def upsert_role_requests(cursor, uuid_, roles): """Given a ``uuid`` and list of dicts containing the ``uid`` and ``role`` for creating a role acceptance entry. The ``roles`` dict can optionally contain a ``has_accepted`` value, which will default to true. """ if not isinstance(roles, (list, set,...
[ "Given", "a", "uuid", "and", "list", "of", "dicts", "containing", "the", "uid", "and", "role", "for", "creating", "a", "role", "acceptance", "entry", ".", "The", "roles", "dict", "can", "optionally", "contain", "a", "has_accepted", "value", "which", "will", ...
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1134-L1184
[ "def", "upsert_role_requests", "(", "cursor", ",", "uuid_", ",", "roles", ")", ":", "if", "not", "isinstance", "(", "roles", ",", "(", "list", ",", "set", ",", "tuple", ",", ")", ")", ":", "raise", "TypeError", "(", "\"``roles`` is an invalid type: {}\"", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
remove_role_requests
Given a ``uuid`` and list of dicts containing the ``uid`` (user identifiers) and ``role`` for removal of the identified users' role acceptance entries.
cnxpublishing/db.py
def remove_role_requests(cursor, uuid_, roles): """Given a ``uuid`` and list of dicts containing the ``uid`` (user identifiers) and ``role`` for removal of the identified users' role acceptance entries. """ if not isinstance(roles, (list, set, tuple,)): raise TypeError("``roles`` is an inval...
def remove_role_requests(cursor, uuid_, roles): """Given a ``uuid`` and list of dicts containing the ``uid`` (user identifiers) and ``role`` for removal of the identified users' role acceptance entries. """ if not isinstance(roles, (list, set, tuple,)): raise TypeError("``roles`` is an inval...
[ "Given", "a", "uuid", "and", "list", "of", "dicts", "containing", "the", "uid", "(", "user", "identifiers", ")", "and", "role", "for", "removal", "of", "the", "identified", "users", "role", "acceptance", "entries", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1187-L1202
[ "def", "remove_role_requests", "(", "cursor", ",", "uuid_", ",", "roles", ")", ":", "if", "not", "isinstance", "(", "roles", ",", "(", "list", ",", "set", ",", "tuple", ",", ")", ")", ":", "raise", "TypeError", "(", "\"``roles`` is an invalid type: {}\"", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
upsert_acl
Given a ``uuid`` and a set of permissions given as a tuple of ``uid`` and ``permission``, upsert them into the database.
cnxpublishing/db.py
def upsert_acl(cursor, uuid_, permissions): """Given a ``uuid`` and a set of permissions given as a tuple of ``uid`` and ``permission``, upsert them into the database. """ if not isinstance(permissions, (list, set, tuple,)): raise TypeError("``permissions`` is an invalid type: {}" ...
def upsert_acl(cursor, uuid_, permissions): """Given a ``uuid`` and a set of permissions given as a tuple of ``uid`` and ``permission``, upsert them into the database. """ if not isinstance(permissions, (list, set, tuple,)): raise TypeError("``permissions`` is an invalid type: {}" ...
[ "Given", "a", "uuid", "and", "a", "set", "of", "permissions", "given", "as", "a", "tuple", "of", "uid", "and", "permission", "upsert", "them", "into", "the", "database", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1205-L1230
[ "def", "upsert_acl", "(", "cursor", ",", "uuid_", ",", "permissions", ")", ":", "if", "not", "isinstance", "(", "permissions", ",", "(", "list", ",", "set", ",", "tuple", ",", ")", ")", ":", "raise", "TypeError", "(", "\"``permissions`` is an invalid type: {...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
remove_acl
Given a ``uuid`` and a set of permissions given as a tuple of ``uid`` and ``permission``, remove these entries from the database.
cnxpublishing/db.py
def remove_acl(cursor, uuid_, permissions): """Given a ``uuid`` and a set of permissions given as a tuple of ``uid`` and ``permission``, remove these entries from the database. """ if not isinstance(permissions, (list, set, tuple,)): raise TypeError("``permissions`` is an invalid type: {}" ...
def remove_acl(cursor, uuid_, permissions): """Given a ``uuid`` and a set of permissions given as a tuple of ``uid`` and ``permission``, remove these entries from the database. """ if not isinstance(permissions, (list, set, tuple,)): raise TypeError("``permissions`` is an invalid type: {}" ...
[ "Given", "a", "uuid", "and", "a", "set", "of", "permissions", "given", "as", "a", "tuple", "of", "uid", "and", "permission", "remove", "these", "entries", "from", "the", "database", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1233-L1248
[ "def", "remove_acl", "(", "cursor", ",", "uuid_", ",", "permissions", ")", ":", "if", "not", "isinstance", "(", "permissions", ",", "(", "list", ",", "set", ",", "tuple", ",", ")", ")", ":", "raise", "TypeError", "(", "\"``permissions`` is an invalid type: {...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_upsert_persons
Upsert's user info into the database. The model contains the user info as part of the role values.
cnxpublishing/db.py
def _upsert_persons(cursor, person_ids, lookup_func): """Upsert's user info into the database. The model contains the user info as part of the role values. """ person_ids = list(set(person_ids)) # cleanse data # Check for existing records to update. cursor.execute("SELECT personid from persons...
def _upsert_persons(cursor, person_ids, lookup_func): """Upsert's user info into the database. The model contains the user info as part of the role values. """ person_ids = list(set(person_ids)) # cleanse data # Check for existing records to update. cursor.execute("SELECT personid from persons...
[ "Upsert", "s", "user", "info", "into", "the", "database", ".", "The", "model", "contains", "the", "user", "info", "as", "part", "of", "the", "role", "values", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1251-L1289
[ "def", "_upsert_persons", "(", "cursor", ",", "person_ids", ",", "lookup_func", ")", ":", "person_ids", "=", "list", "(", "set", "(", "person_ids", ")", ")", "# cleanse data", "# Check for existing records to update.", "cursor", ".", "execute", "(", "\"SELECT person...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_upsert_users
Upsert's user info into the database. The model contains the user info as part of the role values.
cnxpublishing/db.py
def _upsert_users(cursor, user_ids, lookup_func): """Upsert's user info into the database. The model contains the user info as part of the role values. """ user_ids = list(set(user_ids)) # cleanse data # Check for existing records to update. cursor.execute("SELECT username from users where use...
def _upsert_users(cursor, user_ids, lookup_func): """Upsert's user info into the database. The model contains the user info as part of the role values. """ user_ids = list(set(user_ids)) # cleanse data # Check for existing records to update. cursor.execute("SELECT username from users where use...
[ "Upsert", "s", "user", "info", "into", "the", "database", ".", "The", "model", "contains", "the", "user", "info", "as", "part", "of", "the", "role", "values", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1292-L1325
[ "def", "_upsert_users", "(", "cursor", ",", "user_ids", ",", "lookup_func", ")", ":", "user_ids", "=", "list", "(", "set", "(", "user_ids", ")", ")", "# cleanse data", "# Check for existing records to update.", "cursor", ".", "execute", "(", "\"SELECT username from ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
upsert_users
Given a set of user identifiers (``user_ids``), upsert them into the database after checking accounts for the latest information.
cnxpublishing/db.py
def upsert_users(cursor, user_ids): """Given a set of user identifiers (``user_ids``), upsert them into the database after checking accounts for the latest information. """ accounts = get_current_registry().getUtility(IOpenstaxAccounts) def lookup_profile(username): profile = accounts.g...
def upsert_users(cursor, user_ids): """Given a set of user identifiers (``user_ids``), upsert them into the database after checking accounts for the latest information. """ accounts = get_current_registry().getUtility(IOpenstaxAccounts) def lookup_profile(username): profile = accounts.g...
[ "Given", "a", "set", "of", "user", "identifiers", "(", "user_ids", ")", "upsert", "them", "into", "the", "database", "after", "checking", "accounts", "for", "the", "latest", "information", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1328-L1349
[ "def", "upsert_users", "(", "cursor", ",", "user_ids", ")", ":", "accounts", "=", "get_current_registry", "(", ")", ".", "getUtility", "(", "IOpenstaxAccounts", ")", "def", "lookup_profile", "(", "username", ")", ":", "profile", "=", "accounts", ".", "get_prof...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
notify_users
Notify all users about their role and/or license acceptance for a piece of content associated with the given ``document_id``.
cnxpublishing/db.py
def notify_users(cursor, document_id): """Notify all users about their role and/or license acceptance for a piece of content associated with the given ``document_id``. """ return registry = get_current_registry() accounts = registry.getUtility(IOpenstaxAccounts) cursor.execute("""\ SELECT l...
def notify_users(cursor, document_id): """Notify all users about their role and/or license acceptance for a piece of content associated with the given ``document_id``. """ return registry = get_current_registry() accounts = registry.getUtility(IOpenstaxAccounts) cursor.execute("""\ SELECT l...
[ "Notify", "all", "users", "about", "their", "role", "and", "/", "or", "license", "acceptance", "for", "a", "piece", "of", "content", "associated", "with", "the", "given", "document_id", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1370-L1419
[ "def", "notify_users", "(", "cursor", ",", "document_id", ")", ":", "return", "registry", "=", "get_current_registry", "(", ")", "accounts", "=", "registry", ".", "getUtility", "(", "IOpenstaxAccounts", ")", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT la.user...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
set_post_publications_state
This sets the post-publication state in the database.
cnxpublishing/db.py
def set_post_publications_state(cursor, module_ident, state_name, state_message=''): # pragma: no cover """This sets the post-publication state in the database.""" cursor.execute("""\ INSERT INTO post_publications (module_ident, state, state_message) VALUES (%s, %s, %s)""", ...
def set_post_publications_state(cursor, module_ident, state_name, state_message=''): # pragma: no cover """This sets the post-publication state in the database.""" cursor.execute("""\ INSERT INTO post_publications (module_ident, state, state_message) VALUES (%s, %s, %s)""", ...
[ "This", "sets", "the", "post", "-", "publication", "state", "in", "the", "database", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1422-L1428
[ "def", "set_post_publications_state", "(", "cursor", ",", "module_ident", ",", "state_name", ",", "state_message", "=", "''", ")", ":", "# pragma: no cover", "cursor", ".", "execute", "(", "\"\"\"\\\nINSERT INTO post_publications\n (module_ident, state, state_message)\n VALUE...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
update_module_state
This updates the module's state in the database.
cnxpublishing/db.py
def update_module_state(cursor, module_ident, state_name, recipe): # pragma: no cover """This updates the module's state in the database.""" cursor.execute("""\ UPDATE modules SET stateid = ( SELECT stateid FROM modulestates WHERE statename = %s ), recipe = %s, baked = now() WHERE m...
def update_module_state(cursor, module_ident, state_name, recipe): # pragma: no cover """This updates the module's state in the database.""" cursor.execute("""\ UPDATE modules SET stateid = ( SELECT stateid FROM modulestates WHERE statename = %s ), recipe = %s, baked = now() WHERE m...
[ "This", "updates", "the", "module", "s", "state", "in", "the", "database", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/db.py#L1431-L1439
[ "def", "update_module_state", "(", "cursor", ",", "module_ident", ",", "state_name", ",", "recipe", ")", ":", "# pragma: no cover", "cursor", ".", "execute", "(", "\"\"\"\\\nUPDATE modules\nSET stateid = (\n SELECT stateid FROM modulestates WHERE statename = %s\n), recipe = %s, ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
get_moderation
Return the list of publications that need moderation.
cnxpublishing/views/moderation.py
def get_moderation(request): """Return the list of publications that need moderation.""" with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT row_to_json(combined_rows) FROM ( SELECT id, created, publisher, publication_message, (select array_ag...
def get_moderation(request): """Return the list of publications that need moderation.""" with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT row_to_json(combined_rows) FROM ( SELECT id, created, publisher, publication_message, (select array_ag...
[ "Return", "the", "list", "of", "publications", "that", "need", "moderation", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/moderation.py#L17-L31
[ "def", "get_moderation", "(", "request", ")", ":", "with", "db_connect", "(", ")", "as", "db_conn", ":", "with", "db_conn", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT row_to_json(combined_rows) FROM (\n SELECT i...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
includeme
Configures the session manager
cnxpublishing/session.py
def includeme(config): """Configures the session manager""" settings = config.registry.settings session_factory = SignedCookieSessionFactory(settings['session_key']) config.set_session_factory(session_factory)
def includeme(config): """Configures the session manager""" settings = config.registry.settings session_factory = SignedCookieSessionFactory(settings['session_key']) config.set_session_factory(session_factory)
[ "Configures", "the", "session", "manager" ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/session.py#L5-L9
[ "def", "includeme", "(", "config", ")", ":", "settings", "=", "config", ".", "registry", ".", "settings", "session_factory", "=", "SignedCookieSessionFactory", "(", "settings", "[", "'session_key'", "]", ")", "config", ".", "set_session_factory", "(", "session_fac...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
admin_print_styles
Returns a dictionary of all unique print_styles, and their latest tag, revision, and recipe_type.
cnxpublishing/views/admin/print_styles.py
def admin_print_styles(request): """ Returns a dictionary of all unique print_styles, and their latest tag, revision, and recipe_type. """ styles = [] # This fetches all recipes that have been used to successfully bake a # current book plus all default recipes that have not yet been used ...
def admin_print_styles(request): """ Returns a dictionary of all unique print_styles, and their latest tag, revision, and recipe_type. """ styles = [] # This fetches all recipes that have been used to successfully bake a # current book plus all default recipes that have not yet been used ...
[ "Returns", "a", "dictionary", "of", "all", "unique", "print_styles", "and", "their", "latest", "tag", "revision", "and", "recipe_type", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/admin/print_styles.py#L25-L88
[ "def", "admin_print_styles", "(", "request", ")", ":", "styles", "=", "[", "]", "# This fetches all recipes that have been used to successfully bake a", "# current book plus all default recipes that have not yet been used", "# as well as \"bad\" books that are not \"current\" state, but woul...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
admin_print_styles_single
Returns all books with any version of the given print style. Returns the print_style, recipe type, num books using the print_style, along with a dictionary of the book, author, revision date, recipe, tag of the print_style, and a link to the content.
cnxpublishing/views/admin/print_styles.py
def admin_print_styles_single(request): """ Returns all books with any version of the given print style. Returns the print_style, recipe type, num books using the print_style, along with a dictionary of the book, author, revision date, recipe, tag of the print_style, and a link to the content. """ ...
def admin_print_styles_single(request): """ Returns all books with any version of the given print style. Returns the print_style, recipe type, num books using the print_style, along with a dictionary of the book, author, revision date, recipe, tag of the print_style, and a link to the content. """ ...
[ "Returns", "all", "books", "with", "any", "version", "of", "the", "given", "print", "style", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/admin/print_styles.py#L94-L186
[ "def", "admin_print_styles_single", "(", "request", ")", ":", "style", "=", "request", ".", "matchdict", "[", "'style'", "]", "# do db search to get file id and other info on the print_style", "with", "db_connect", "(", "cursor_factory", "=", "DictCursor", ")", "as", "d...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
get_api_keys
Return the list of API keys.
cnxpublishing/views/api_keys.py
def get_api_keys(request): """Return the list of API keys.""" with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT row_to_json(combined_rows) FROM ( SELECT id, key, name, groups FROM api_keys ) AS combined_rows""") api_keys = [x[0] for x in ...
def get_api_keys(request): """Return the list of API keys.""" with db_connect() as db_conn: with db_conn.cursor() as cursor: cursor.execute("""\ SELECT row_to_json(combined_rows) FROM ( SELECT id, key, name, groups FROM api_keys ) AS combined_rows""") api_keys = [x[0] for x in ...
[ "Return", "the", "list", "of", "API", "keys", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/api_keys.py#L16-L26
[ "def", "get_api_keys", "(", "request", ")", ":", "with", "db_connect", "(", ")", "as", "db_conn", ":", "with", "db_conn", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT row_to_json(combined_rows) FROM (\n SELECT id,...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
get_baking_statuses_sql
Creates SQL to get info on baking books filtered from GET request. All books that have ever attempted to bake will be retured if they pass the filters in the GET request. If a single book has been requested to bake multiple times there will be a row for each of the baking attempts. By default the r...
cnxpublishing/views/admin/content_status.py
def get_baking_statuses_sql(get_request): """ Creates SQL to get info on baking books filtered from GET request. All books that have ever attempted to bake will be retured if they pass the filters in the GET request. If a single book has been requested to bake multiple times there will be a row for...
def get_baking_statuses_sql(get_request): """ Creates SQL to get info on baking books filtered from GET request. All books that have ever attempted to bake will be retured if they pass the filters in the GET request. If a single book has been requested to bake multiple times there will be a row for...
[ "Creates", "SQL", "to", "get", "info", "on", "baking", "books", "filtered", "from", "GET", "request", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/admin/content_status.py#L43-L139
[ "def", "get_baking_statuses_sql", "(", "get_request", ")", ":", "args", "=", "{", "}", "sort", "=", "get_request", ".", "get", "(", "'sort'", ",", "'bpsa.created DESC'", ")", "if", "(", "len", "(", "sort", ".", "split", "(", "\" \"", ")", ")", "!=", "2...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
admin_content_status
Returns a dictionary with the states and info of baking books, and the filters from the GET request to pre-populate the form.
cnxpublishing/views/admin/content_status.py
def admin_content_status(request): """ Returns a dictionary with the states and info of baking books, and the filters from the GET request to pre-populate the form. """ statement, sql_args = get_baking_statuses_sql(request.GET) states = [] status_filters = request.params.getall('status_filt...
def admin_content_status(request): """ Returns a dictionary with the states and info of baking books, and the filters from the GET request to pre-populate the form. """ statement, sql_args = get_baking_statuses_sql(request.GET) states = [] status_filters = request.params.getall('status_filt...
[ "Returns", "a", "dictionary", "with", "the", "states", "and", "info", "of", "baking", "books", "and", "the", "filters", "from", "the", "GET", "request", "to", "pre", "-", "populate", "the", "form", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/admin/content_status.py#L151-L236
[ "def", "admin_content_status", "(", "request", ")", ":", "statement", ",", "sql_args", "=", "get_baking_statuses_sql", "(", "request", ".", "GET", ")", "states", "=", "[", "]", "status_filters", "=", "request", ".", "params", ".", "getall", "(", "'status_filte...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
admin_content_status_single
Returns a dictionary with all the past baking statuses of a single book.
cnxpublishing/views/admin/content_status.py
def admin_content_status_single(request): """ Returns a dictionary with all the past baking statuses of a single book. """ uuid = request.matchdict['uuid'] try: UUID(uuid) except ValueError: raise httpexceptions.HTTPBadRequest( '{} is not a valid uuid'.format(uuid)) ...
def admin_content_status_single(request): """ Returns a dictionary with all the past baking statuses of a single book. """ uuid = request.matchdict['uuid'] try: UUID(uuid) except ValueError: raise httpexceptions.HTTPBadRequest( '{} is not a valid uuid'.format(uuid)) ...
[ "Returns", "a", "dictionary", "with", "all", "the", "past", "baking", "statuses", "of", "a", "single", "book", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/admin/content_status.py#L243-L292
[ "def", "admin_content_status_single", "(", "request", ")", ":", "uuid", "=", "request", ".", "matchdict", "[", "'uuid'", "]", "try", ":", "UUID", "(", "uuid", ")", "except", "ValueError", ":", "raise", "httpexceptions", ".", "HTTPBadRequest", "(", "'{} is not ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
admin_content_status_single_POST
Retriggers baking for a given book.
cnxpublishing/views/admin/content_status.py
def admin_content_status_single_POST(request): """ Retriggers baking for a given book. """ args = admin_content_status_single(request) title = args['title'] if args['current_state'] == 'SUCCESS': args['response'] = title + ' is not stale, no need to bake' return args with db_connect...
def admin_content_status_single_POST(request): """ Retriggers baking for a given book. """ args = admin_content_status_single(request) title = args['title'] if args['current_state'] == 'SUCCESS': args['response'] = title + ' is not stale, no need to bake' return args with db_connect...
[ "Retriggers", "baking", "for", "a", "given", "book", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/admin/content_status.py#L299-L325
[ "def", "admin_content_status_single_POST", "(", "request", ")", ":", "args", "=", "admin_content_status_single", "(", "request", ")", "title", "=", "args", "[", "'title'", "]", "if", "args", "[", "'current_state'", "]", "==", "'SUCCESS'", ":", "args", "[", "'r...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_insert_optional_roles
Inserts the optional roles if values for the optional roles exist.
cnxpublishing/publish.py
def _insert_optional_roles(cursor, model, ident): """Inserts the optional roles if values for the optional roles exist. """ optional_roles = [ # (<metadata-attr>, <db-role-id>,), ('translators', 4,), ('editors', 5,), ] for attr, role_id in optional_roles: roles = ...
def _insert_optional_roles(cursor, model, ident): """Inserts the optional roles if values for the optional roles exist. """ optional_roles = [ # (<metadata-attr>, <db-role-id>,), ('translators', 4,), ('editors', 5,), ] for attr, role_id in optional_roles: roles = ...
[ "Inserts", "the", "optional", "roles", "if", "values", "for", "the", "optional", "roles", "exist", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L134-L151
[ "def", "_insert_optional_roles", "(", "cursor", ",", "model", ",", "ident", ")", ":", "optional_roles", "=", "[", "# (<metadata-attr>, <db-role-id>,),", "(", "'translators'", ",", "4", ",", ")", ",", "(", "'editors'", ",", "5", ",", ")", ",", "]", "for", "...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_insert_metadata
Insert a module with the given ``metadata``.
cnxpublishing/publish.py
def _insert_metadata(cursor, model, publisher, message): """Insert a module with the given ``metadata``.""" params = model.metadata.copy() params['publisher'] = publisher params['publication_message'] = message params['_portal_type'] = _model_to_portaltype(model) params['summary'] = str(cnxepub...
def _insert_metadata(cursor, model, publisher, message): """Insert a module with the given ``metadata``.""" params = model.metadata.copy() params['publisher'] = publisher params['publication_message'] = message params['_portal_type'] = _model_to_portaltype(model) params['summary'] = str(cnxepub...
[ "Insert", "a", "module", "with", "the", "given", "metadata", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L154-L222
[ "def", "_insert_metadata", "(", "cursor", ",", "model", ",", "publisher", ",", "message", ")", ":", "params", "=", "model", ".", "metadata", ".", "copy", "(", ")", "params", "[", "'publisher'", "]", "=", "publisher", "params", "[", "'publication_message'", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_get_file_sha1
Return the SHA1 hash of the given a file-like object as ``file``. This will seek the file back to 0 when it's finished.
cnxpublishing/publish.py
def _get_file_sha1(file): """Return the SHA1 hash of the given a file-like object as ``file``. This will seek the file back to 0 when it's finished. """ bits = file.read() file.seek(0) h = hashlib.new('sha1', bits).hexdigest() return h
def _get_file_sha1(file): """Return the SHA1 hash of the given a file-like object as ``file``. This will seek the file back to 0 when it's finished. """ bits = file.read() file.seek(0) h = hashlib.new('sha1', bits).hexdigest() return h
[ "Return", "the", "SHA1", "hash", "of", "the", "given", "a", "file", "-", "like", "object", "as", "file", ".", "This", "will", "seek", "the", "file", "back", "to", "0", "when", "it", "s", "finished", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L225-L233
[ "def", "_get_file_sha1", "(", "file", ")", ":", "bits", "=", "file", ".", "read", "(", ")", "file", ".", "seek", "(", "0", ")", "h", "=", "hashlib", ".", "new", "(", "'sha1'", ",", "bits", ")", ".", "hexdigest", "(", ")", "return", "h" ]
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_insert_file
Upsert the ``file`` and ``media_type`` into the files table. Returns the ``fileid`` and ``sha1`` of the upserted file.
cnxpublishing/publish.py
def _insert_file(cursor, file, media_type): """Upsert the ``file`` and ``media_type`` into the files table. Returns the ``fileid`` and ``sha1`` of the upserted file. """ resource_hash = _get_file_sha1(file) cursor.execute("SELECT fileid FROM files WHERE sha1 = %s", (resource_hash...
def _insert_file(cursor, file, media_type): """Upsert the ``file`` and ``media_type`` into the files table. Returns the ``fileid`` and ``sha1`` of the upserted file. """ resource_hash = _get_file_sha1(file) cursor.execute("SELECT fileid FROM files WHERE sha1 = %s", (resource_hash...
[ "Upsert", "the", "file", "and", "media_type", "into", "the", "files", "table", ".", "Returns", "the", "fileid", "and", "sha1", "of", "the", "upserted", "file", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L236-L252
[ "def", "_insert_file", "(", "cursor", ",", "file", ",", "media_type", ")", ":", "resource_hash", "=", "_get_file_sha1", "(", "file", ")", "cursor", ".", "execute", "(", "\"SELECT fileid FROM files WHERE sha1 = %s\"", ",", "(", "resource_hash", ",", ")", ")", "tr...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_insert_resource_file
Insert a resource into the modules_files table. This will create a new file entry or associates an existing one.
cnxpublishing/publish.py
def _insert_resource_file(cursor, module_ident, resource): """Insert a resource into the modules_files table. This will create a new file entry or associates an existing one. """ with resource.open() as file: fileid, _ = _insert_file(cursor, file, resource.media_type) # Is this file legitim...
def _insert_resource_file(cursor, module_ident, resource): """Insert a resource into the modules_files table. This will create a new file entry or associates an existing one. """ with resource.open() as file: fileid, _ = _insert_file(cursor, file, resource.media_type) # Is this file legitim...
[ "Insert", "a", "resource", "into", "the", "modules_files", "table", ".", "This", "will", "create", "a", "new", "file", "entry", "or", "associates", "an", "existing", "one", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L255-L285
[ "def", "_insert_resource_file", "(", "cursor", ",", "module_ident", ",", "resource", ")", ":", "with", "resource", ".", "open", "(", ")", "as", "file", ":", "fileid", ",", "_", "=", "_insert_file", "(", "cursor", ",", "file", ",", "resource", ".", "media...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
_insert_tree
Inserts a binder tree into the archive.
cnxpublishing/publish.py
def _insert_tree(cursor, tree, parent_id=None, index=0, is_collated=False): """Inserts a binder tree into the archive.""" if isinstance(tree, dict): if tree['id'] == 'subcol': document_id = None title = tree['title'] else: cursor.execute("""\ SELEC...
def _insert_tree(cursor, tree, parent_id=None, index=0, is_collated=False): """Inserts a binder tree into the archive.""" if isinstance(tree, dict): if tree['id'] == 'subcol': document_id = None title = tree['title'] else: cursor.execute("""\ SELEC...
[ "Inserts", "a", "binder", "tree", "into", "the", "archive", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L288-L323
[ "def", "_insert_tree", "(", "cursor", ",", "tree", ",", "parent_id", "=", "None", ",", "index", "=", "0", ",", "is_collated", "=", "False", ")", ":", "if", "isinstance", "(", "tree", ",", "dict", ")", ":", "if", "tree", "[", "'id'", "]", "==", "'su...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
publish_model
Publishes the ``model`` and return its ident_hash.
cnxpublishing/publish.py
def publish_model(cursor, model, publisher, message): """Publishes the ``model`` and return its ident_hash.""" publishers = publisher if isinstance(publishers, list) and len(publishers) > 1: raise ValueError("Only one publisher is allowed. '{}' " "were given: {}" ...
def publish_model(cursor, model, publisher, message): """Publishes the ``model`` and return its ident_hash.""" publishers = publisher if isinstance(publishers, list) and len(publishers) > 1: raise ValueError("Only one publisher is allowed. '{}' " "were given: {}" ...
[ "Publishes", "the", "model", "and", "return", "its", "ident_hash", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L326-L369
[ "def", "publish_model", "(", "cursor", ",", "model", ",", "publisher", ",", "message", ")", ":", "publishers", "=", "publisher", "if", "isinstance", "(", "publishers", ",", "list", ")", "and", "len", "(", "publishers", ")", ">", "1", ":", "raise", "Value...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
publish_composite_model
Publishes the ``model`` and return its ident_hash.
cnxpublishing/publish.py
def publish_composite_model(cursor, model, parent_model, publisher, message): """Publishes the ``model`` and return its ident_hash.""" if not (isinstance(model, CompositeDocument) or (isinstance(model, Binder) and model.metadata.get('type') == 'composite-chapter')): raise Val...
def publish_composite_model(cursor, model, parent_model, publisher, message): """Publishes the ``model`` and return its ident_hash.""" if not (isinstance(model, CompositeDocument) or (isinstance(model, Binder) and model.metadata.get('type') == 'composite-chapter')): raise Val...
[ "Publishes", "the", "model", "and", "return", "its", "ident_hash", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L372-L409
[ "def", "publish_composite_model", "(", "cursor", ",", "model", ",", "parent_model", ",", "publisher", ",", "message", ")", ":", "if", "not", "(", "isinstance", "(", "model", ",", "CompositeDocument", ")", "or", "(", "isinstance", "(", "model", ",", "Binder",...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
publish_collated_document
Publish a given `module`'s collated content in the context of the `parent_model`. Note, the model's content is expected to already have the collated content. This will just persist that content to the archive.
cnxpublishing/publish.py
def publish_collated_document(cursor, model, parent_model): """Publish a given `module`'s collated content in the context of the `parent_model`. Note, the model's content is expected to already have the collated content. This will just persist that content to the archive. """ html = bytes(cnxep...
def publish_collated_document(cursor, model, parent_model): """Publish a given `module`'s collated content in the context of the `parent_model`. Note, the model's content is expected to already have the collated content. This will just persist that content to the archive. """ html = bytes(cnxep...
[ "Publish", "a", "given", "module", "s", "collated", "content", "in", "the", "context", "of", "the", "parent_model", ".", "Note", "the", "model", "s", "content", "is", "expected", "to", "already", "have", "the", "collated", "content", ".", "This", "will", "...
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L412-L449
[ "def", "publish_collated_document", "(", "cursor", ",", "model", ",", "parent_model", ")", ":", "html", "=", "bytes", "(", "cnxepub", ".", "DocumentContentFormatter", "(", "model", ")", ")", "sha1", "=", "hashlib", ".", "new", "(", "'sha1'", ",", "html", "...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
publish_collated_tree
Publish a given collated `tree` (containing newly added `CompositeDocument` objects and number inforation) alongside the original tree.
cnxpublishing/publish.py
def publish_collated_tree(cursor, tree): """Publish a given collated `tree` (containing newly added `CompositeDocument` objects and number inforation) alongside the original tree. """ tree = _insert_tree(cursor, tree, is_collated=True) return tree
def publish_collated_tree(cursor, tree): """Publish a given collated `tree` (containing newly added `CompositeDocument` objects and number inforation) alongside the original tree. """ tree = _insert_tree(cursor, tree, is_collated=True) return tree
[ "Publish", "a", "given", "collated", "tree", "(", "containing", "newly", "added", "CompositeDocument", "objects", "and", "number", "inforation", ")", "alongside", "the", "original", "tree", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L452-L459
[ "def", "publish_collated_tree", "(", "cursor", ",", "tree", ")", ":", "tree", "=", "_insert_tree", "(", "cursor", ",", "tree", ",", "is_collated", "=", "True", ")", "return", "tree" ]
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
republish_binders
Republish the Binders that share Documents in the publication context. This needs to be given all the models in the publication context.
cnxpublishing/publish.py
def republish_binders(cursor, models): """Republish the Binders that share Documents in the publication context. This needs to be given all the models in the publication context.""" documents = set([]) binders = set([]) history_mapping = {} # <previous-ident-hash>: <current-ident-hash> if not i...
def republish_binders(cursor, models): """Republish the Binders that share Documents in the publication context. This needs to be given all the models in the publication context.""" documents = set([]) binders = set([]) history_mapping = {} # <previous-ident-hash>: <current-ident-hash> if not i...
[ "Republish", "the", "Binders", "that", "share", "Documents", "in", "the", "publication", "context", ".", "This", "needs", "to", "be", "given", "all", "the", "models", "in", "the", "publication", "context", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L462-L526
[ "def", "republish_binders", "(", "cursor", ",", "models", ")", ":", "documents", "=", "set", "(", "[", "]", ")", "binders", "=", "set", "(", "[", "]", ")", "history_mapping", "=", "{", "}", "# <previous-ident-hash>: <current-ident-hash>", "if", "not", "isins...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
get_previous_publication
Get the previous publication of the given publication as an ident-hash.
cnxpublishing/publish.py
def get_previous_publication(cursor, ident_hash): """Get the previous publication of the given publication as an ident-hash. """ cursor.execute("""\ WITH contextual_module AS ( SELECT uuid, module_ident FROM modules WHERE ident_hash(uuid, major_version, minor_version) = %s) SELECT ident_hash(m.uui...
def get_previous_publication(cursor, ident_hash): """Get the previous publication of the given publication as an ident-hash. """ cursor.execute("""\ WITH contextual_module AS ( SELECT uuid, module_ident FROM modules WHERE ident_hash(uuid, major_version, minor_version) = %s) SELECT ident_hash(m.uui...
[ "Get", "the", "previous", "publication", "of", "the", "given", "publication", "as", "an", "ident", "-", "hash", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L529-L548
[ "def", "get_previous_publication", "(", "cursor", ",", "ident_hash", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nWITH contextual_module AS (\n SELECT uuid, module_ident\n FROM modules\n WHERE ident_hash(uuid, major_version, minor_version) = %s)\nSELECT ident_hash(m.uuid, m.major_v...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
bump_version
Bump to the next version of the given content identified by ``uuid``. Returns the next available version as a version tuple, containing major and minor version. If ``is_minor_bump`` is ``True`` the version will minor bump. That is 1.2 becomes 1.3 in the case of Collections. And 2 becomes 3 for Modul...
cnxpublishing/publish.py
def bump_version(cursor, uuid, is_minor_bump=False): """Bump to the next version of the given content identified by ``uuid``. Returns the next available version as a version tuple, containing major and minor version. If ``is_minor_bump`` is ``True`` the version will minor bump. That is 1.2 becomes 1...
def bump_version(cursor, uuid, is_minor_bump=False): """Bump to the next version of the given content identified by ``uuid``. Returns the next available version as a version tuple, containing major and minor version. If ``is_minor_bump`` is ``True`` the version will minor bump. That is 1.2 becomes 1...
[ "Bump", "to", "the", "next", "version", "of", "the", "given", "content", "identified", "by", "uuid", ".", "Returns", "the", "next", "available", "version", "as", "a", "version", "tuple", "containing", "major", "and", "minor", "version", ".", "If", "is_minor_...
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L551-L569
[ "def", "bump_version", "(", "cursor", ",", "uuid", ",", "is_minor_bump", "=", "False", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\\\nSELECT portal_type, major_version, minor_version\nFROM latest_modules\nWHERE uuid = %s::uuid\"\"\"", ",", "(", "uuid", ",", ")", ")",...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
republish_collection
Republish the collection identified as ``ident_hash`` with the given ``version``.
cnxpublishing/publish.py
def republish_collection(cursor, ident_hash, version): """Republish the collection identified as ``ident_hash`` with the given ``version``. """ if not isinstance(version, (list, tuple,)): split_version = version.split('.') if len(split_version) == 1: split_version.append(None...
def republish_collection(cursor, ident_hash, version): """Republish the collection identified as ``ident_hash`` with the given ``version``. """ if not isinstance(version, (list, tuple,)): split_version = version.split('.') if len(split_version) == 1: split_version.append(None...
[ "Republish", "the", "collection", "identified", "as", "ident_hash", "with", "the", "given", "version", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L572-L624
[ "def", "republish_collection", "(", "cursor", ",", "ident_hash", ",", "version", ")", ":", "if", "not", "isinstance", "(", "version", ",", "(", "list", ",", "tuple", ",", ")", ")", ":", "split_version", "=", "version", ".", "split", "(", "'.'", ")", "i...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
rebuild_collection_tree
Create a new tree for the collection based on the old tree but with new document ids
cnxpublishing/publish.py
def rebuild_collection_tree(cursor, ident_hash, history_map): """Create a new tree for the collection based on the old tree but with new document ids """ collection_tree_sql = """\ WITH RECURSIVE t(nodeid, parent_id, documentid, title, childorder, latest, ident_hash, path) AS ( SELECT...
def rebuild_collection_tree(cursor, ident_hash, history_map): """Create a new tree for the collection based on the old tree but with new document ids """ collection_tree_sql = """\ WITH RECURSIVE t(nodeid, parent_id, documentid, title, childorder, latest, ident_hash, path) AS ( SELECT...
[ "Create", "a", "new", "tree", "for", "the", "collection", "based", "on", "the", "old", "tree", "but", "with", "new", "document", "ids" ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/publish.py#L627-L701
[ "def", "rebuild_collection_tree", "(", "cursor", ",", "ident_hash", ",", "history_map", ")", ":", "collection_tree_sql", "=", "\"\"\"\\\nWITH RECURSIVE t(nodeid, parent_id, documentid, title, childorder, latest,\n ident_hash, path) AS (\n SELECT\n tr.nodeid, tr.parent_id,...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
publish
Accept a publication request at form value 'epub
cnxpublishing/views/publishing.py
def publish(request): """Accept a publication request at form value 'epub'""" if 'epub' not in request.POST: raise httpexceptions.HTTPBadRequest("Missing EPUB in POST body.") is_pre_publication = asbool(request.POST.get('pre-publication')) epub_upload = request.POST['epub'].file try: ...
def publish(request): """Accept a publication request at form value 'epub'""" if 'epub' not in request.POST: raise httpexceptions.HTTPBadRequest("Missing EPUB in POST body.") is_pre_publication = asbool(request.POST.get('pre-publication')) epub_upload = request.POST['epub'].file try: ...
[ "Accept", "a", "publication", "request", "at", "form", "value", "epub" ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/publishing.py#L27-L57
[ "def", "publish", "(", "request", ")", ":", "if", "'epub'", "not", "in", "request", ".", "POST", ":", "raise", "httpexceptions", ".", "HTTPBadRequest", "(", "\"Missing EPUB in POST body.\"", ")", "is_pre_publication", "=", "asbool", "(", "request", ".", "POST", ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
get_publication
Lookup publication state
cnxpublishing/views/publishing.py
def get_publication(request): """Lookup publication state""" publication_id = request.matchdict['id'] state, messages = check_publication_state(publication_id) response_data = { 'publication': publication_id, 'state': state, 'messages': messages, } return response_data
def get_publication(request): """Lookup publication state""" publication_id = request.matchdict['id'] state, messages = check_publication_state(publication_id) response_data = { 'publication': publication_id, 'state': state, 'messages': messages, } return response_data
[ "Lookup", "publication", "state" ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/publishing.py#L62-L71
[ "def", "get_publication", "(", "request", ")", ":", "publication_id", "=", "request", ".", "matchdict", "[", "'id'", "]", "state", ",", "messages", "=", "check_publication_state", "(", "publication_id", ")", "response_data", "=", "{", "'publication'", ":", "publ...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
get_accept_license
This produces JSON data for a user (at ``uid``) to view the license(s) they have accepted or will need to accept for a publication (at ``id``).
cnxpublishing/views/publishing.py
def get_accept_license(request): """This produces JSON data for a user (at ``uid``) to view the license(s) they have accepted or will need to accept for a publication (at ``id``). """ publication_id = request.matchdict['id'] user_id = request.matchdict['uid'] # FIXME Is this an active publicati...
def get_accept_license(request): """This produces JSON data for a user (at ``uid``) to view the license(s) they have accepted or will need to accept for a publication (at ``id``). """ publication_id = request.matchdict['id'] user_id = request.matchdict['uid'] # FIXME Is this an active publicati...
[ "This", "produces", "JSON", "data", "for", "a", "user", "(", "at", "uid", ")", "to", "view", "the", "license", "(", "s", ")", "they", "have", "accepted", "or", "will", "need", "to", "accept", "for", "a", "publication", "(", "at", "id", ")", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/publishing.py#L77-L108
[ "def", "get_accept_license", "(", "request", ")", ":", "publication_id", "=", "request", ".", "matchdict", "[", "'id'", "]", "user_id", "=", "request", ".", "matchdict", "[", "'uid'", "]", "# FIXME Is this an active publication?", "# TODO Verify the accepting user is th...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
post_accept_license
Allows the user (at ``uid``) to accept the license(s) for a publication (at ``id``).
cnxpublishing/views/publishing.py
def post_accept_license(request): """Allows the user (at ``uid``) to accept the license(s) for a publication (at ``id``). """ publication_id = request.matchdict['id'] uid = request.matchdict['uid'] # TODO Verify the accepting user is the one making the request. # They could be authenti...
def post_accept_license(request): """Allows the user (at ``uid``) to accept the license(s) for a publication (at ``id``). """ publication_id = request.matchdict['id'] uid = request.matchdict['uid'] # TODO Verify the accepting user is the one making the request. # They could be authenti...
[ "Allows", "the", "user", "(", "at", "uid", ")", "to", "accept", "the", "license", "(", "s", ")", "for", "a", "publication", "(", "at", "id", ")", "." ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/publishing.py#L113-L150
[ "def", "post_accept_license", "(", "request", ")", ":", "publication_id", "=", "request", ".", "matchdict", "[", "'id'", "]", "uid", "=", "request", ".", "matchdict", "[", "'uid'", "]", "# TODO Verify the accepting user is the one making the request.", "# They coul...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
bake_content
Invoke the baking process - trigger post-publication
cnxpublishing/views/publishing.py
def bake_content(request): """Invoke the baking process - trigger post-publication""" ident_hash = request.matchdict['ident_hash'] try: id, version = split_ident_hash(ident_hash) except IdentHashError: raise httpexceptions.HTTPNotFound() if not version: raise httpexceptions....
def bake_content(request): """Invoke the baking process - trigger post-publication""" ident_hash = request.matchdict['ident_hash'] try: id, version = split_ident_hash(ident_hash) except IdentHashError: raise httpexceptions.HTTPNotFound() if not version: raise httpexceptions....
[ "Invoke", "the", "baking", "process", "-", "trigger", "post", "-", "publication" ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/publishing.py#L238-L275
[ "def", "bake_content", "(", "request", ")", ":", "ident_hash", "=", "request", ".", "matchdict", "[", "'ident_hash'", "]", "try", ":", "id", ",", "version", "=", "split_ident_hash", "(", "ident_hash", ")", "except", "IdentHashError", ":", "raise", "httpexcepti...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
includeme
Configures the caching manager
cnxpublishing/cache.py
def includeme(config): """Configures the caching manager""" global cache_manager settings = config.registry.settings cache_manager = CacheManager(**parse_cache_config_options(settings))
def includeme(config): """Configures the caching manager""" global cache_manager settings = config.registry.settings cache_manager = CacheManager(**parse_cache_config_options(settings))
[ "Configures", "the", "caching", "manager" ]
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/cache.py#L11-L15
[ "def", "includeme", "(", "config", ")", ":", "global", "cache_manager", "settings", "=", "config", ".", "registry", ".", "settings", "cache_manager", "=", "CacheManager", "(", "*", "*", "parse_cache_config_options", "(", "settings", ")", ")" ]
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
create_pg_notify_event
A factory for creating a Postgres Notification Event (an object inheriting from `cnxpublishing.events.PGNotifyEvent`) given `notif`, a `psycopg2.extensions.Notify` object.
cnxpublishing/events.py
def create_pg_notify_event(notif): """A factory for creating a Postgres Notification Event (an object inheriting from `cnxpublishing.events.PGNotifyEvent`) given `notif`, a `psycopg2.extensions.Notify` object. """ # TODO Lookup registered events via getAllUtilitiesRegisteredFor # for class...
def create_pg_notify_event(notif): """A factory for creating a Postgres Notification Event (an object inheriting from `cnxpublishing.events.PGNotifyEvent`) given `notif`, a `psycopg2.extensions.Notify` object. """ # TODO Lookup registered events via getAllUtilitiesRegisteredFor # for class...
[ "A", "factory", "for", "creating", "a", "Postgres", "Notification", "Event", "(", "an", "object", "inheriting", "from", "cnxpublishing", ".", "events", ".", "PGNotifyEvent", ")", "given", "notif", "a", "psycopg2", ".", "extensions", ".", "Notify", "object", "....
openstax/cnx-publishing
python
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/events.py#L67-L79
[ "def", "create_pg_notify_event", "(", "notif", ")", ":", "# TODO Lookup registered events via getAllUtilitiesRegisteredFor", "# for class mapping.", "if", "notif", ".", "channel", "not", "in", "_CHANNEL_MAPPER", ":", "cls", "=", "_CHANNEL_MAPPER", "[", "None", "]", "...
f55b4a2c45d8618737288f1b74b4139d5ac74154
valid
ObjectMapper.create_map
Method for adding mapping definitions :param type_from: source type :param type_to: target type :param mapping: dictionary of mapping definitions in a form {'target_property_name', lambda function from rhe source} :return: None
mapper/object_mapper.py
def create_map(self, type_from, type_to, mapping=None): """Method for adding mapping definitions :param type_from: source type :param type_to: target type :param mapping: dictionary of mapping definitions in a form {'target_property_name', lambda function f...
def create_map(self, type_from, type_to, mapping=None): """Method for adding mapping definitions :param type_from: source type :param type_to: target type :param mapping: dictionary of mapping definitions in a form {'target_property_name', lambda function f...
[ "Method", "for", "adding", "mapping", "definitions", ":", "param", "type_from", ":", "source", "type", ":", "param", "type_to", ":", "target", "type", ":", "param", "mapping", ":", "dictionary", "of", "mapping", "definitions", "in", "a", "form", "{", "target...
marazt/object-mapper
python
https://github.com/marazt/object-mapper/blob/b02c6d68c5bf86462aa8080aff3e93b133afd43e/mapper/object_mapper.py#L84-L108
[ "def", "create_map", "(", "self", ",", "type_from", ",", "type_to", ",", "mapping", "=", "None", ")", ":", "key_from", "=", "type_from", ".", "__name__", "key_to", "=", "type_to", ".", "__name__", "if", "mapping", "is", "None", ":", "mapping", "=", "{", ...
b02c6d68c5bf86462aa8080aff3e93b133afd43e
valid
ObjectMapper.map
Method for creating target object instance :param from_obj: source object to be mapped from :param to_type: target type :param ignore_case: if set to true, ignores attribute case when performing the mapping :param allow_none: if set to true, returns None if the source object is Non...
mapper/object_mapper.py
def map(self, from_obj, to_type, ignore_case=False, allow_none=False, excluded=None): """Method for creating target object instance :param from_obj: source object to be mapped from :param to_type: target type :param ignore_case: if set to true, ignores attribute case when performin...
def map(self, from_obj, to_type, ignore_case=False, allow_none=False, excluded=None): """Method for creating target object instance :param from_obj: source object to be mapped from :param to_type: target type :param ignore_case: if set to true, ignores attribute case when performin...
[ "Method", "for", "creating", "target", "object", "instance", ":", "param", "from_obj", ":", "source", "object", "to", "be", "mapped", "from", ":", "param", "to_type", ":", "target", "type", ":", "param", "ignore_case", ":", "if", "set", "to", "true", "igno...
marazt/object-mapper
python
https://github.com/marazt/object-mapper/blob/b02c6d68c5bf86462aa8080aff3e93b133afd43e/mapper/object_mapper.py#L110-L174
[ "def", "map", "(", "self", ",", "from_obj", ",", "to_type", ",", "ignore_case", "=", "False", ",", "allow_none", "=", "False", ",", "excluded", "=", "None", ")", ":", "if", "(", "from_obj", "is", "None", ")", "and", "allow_none", ":", "return", "None",...
b02c6d68c5bf86462aa8080aff3e93b133afd43e
valid
CaseDict.get
Gets the value from the key. If the key doesn't exist, the default value is returned, otherwise None. :param key: The key :param default: The default value :return: The value
mapper/casedict.py
def get(self, key, default=_sentinel): """ Gets the value from the key. If the key doesn't exist, the default value is returned, otherwise None. :param key: The key :param default: The default value :return: The value """ tup = self._data.get(key.lower())...
def get(self, key, default=_sentinel): """ Gets the value from the key. If the key doesn't exist, the default value is returned, otherwise None. :param key: The key :param default: The default value :return: The value """ tup = self._data.get(key.lower())...
[ "Gets", "the", "value", "from", "the", "key", ".", "If", "the", "key", "doesn", "t", "exist", "the", "default", "value", "is", "returned", "otherwise", "None", "." ]
marazt/object-mapper
python
https://github.com/marazt/object-mapper/blob/b02c6d68c5bf86462aa8080aff3e93b133afd43e/mapper/casedict.py#L56-L71
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "_sentinel", ")", ":", "tup", "=", "self", ".", "_data", ".", "get", "(", "key", ".", "lower", "(", ")", ")", "if", "tup", "is", "not", "None", ":", "return", "tup", "[", "1", "]", "...
b02c6d68c5bf86462aa8080aff3e93b133afd43e
valid
CaseDict.pop
Removes the specified key and returns the corresponding value. If key is not found, the default is returned if given, otherwise KeyError is raised. :param key: The key :param default: The default value :return: The value
mapper/casedict.py
def pop(self, key, default=_sentinel): """ Removes the specified key and returns the corresponding value. If key is not found, the default is returned if given, otherwise KeyError is raised. :param key: The key :param default: The default value :return: The value ...
def pop(self, key, default=_sentinel): """ Removes the specified key and returns the corresponding value. If key is not found, the default is returned if given, otherwise KeyError is raised. :param key: The key :param default: The default value :return: The value ...
[ "Removes", "the", "specified", "key", "and", "returns", "the", "corresponding", "value", ".", "If", "key", "is", "not", "found", "the", "default", "is", "returned", "if", "given", "otherwise", "KeyError", "is", "raised", "." ]
marazt/object-mapper
python
https://github.com/marazt/object-mapper/blob/b02c6d68c5bf86462aa8080aff3e93b133afd43e/mapper/casedict.py#L73-L89
[ "def", "pop", "(", "self", ",", "key", ",", "default", "=", "_sentinel", ")", ":", "if", "default", "is", "not", "_sentinel", ":", "tup", "=", "self", ".", "_data", ".", "pop", "(", "key", ".", "lower", "(", ")", ",", "default", ")", "else", ":",...
b02c6d68c5bf86462aa8080aff3e93b133afd43e
valid
reversals
Iterate reversal points in the series. A reversal point is a point in the series at which the first derivative changes sign. Reversal is undefined at the first (last) point because the derivative before (after) this point is undefined. The first and the last points may be treated as reversals by settin...
src/rainflow.py
def reversals(series, left=False, right=False): """Iterate reversal points in the series. A reversal point is a point in the series at which the first derivative changes sign. Reversal is undefined at the first (last) point because the derivative before (after) this point is undefined. The first and th...
def reversals(series, left=False, right=False): """Iterate reversal points in the series. A reversal point is a point in the series at which the first derivative changes sign. Reversal is undefined at the first (last) point because the derivative before (after) this point is undefined. The first and th...
[ "Iterate", "reversal", "points", "in", "the", "series", "." ]
iamlikeme/rainflow
python
https://github.com/iamlikeme/rainflow/blob/7725ea2c591ad3d4aab688d1c1d8385d665a07d4/src/rainflow.py#L22-L60
[ "def", "reversals", "(", "series", ",", "left", "=", "False", ",", "right", "=", "False", ")", ":", "series", "=", "iter", "(", "series", ")", "x_last", ",", "x", "=", "next", "(", "series", ")", ",", "next", "(", "series", ")", "d_last", "=", "(...
7725ea2c591ad3d4aab688d1c1d8385d665a07d4
valid
_sort_lows_and_highs
Decorator for extract_cycles
src/rainflow.py
def _sort_lows_and_highs(func): "Decorator for extract_cycles" @functools.wraps(func) def wrapper(*args, **kwargs): for low, high, mult in func(*args, **kwargs): if low < high: yield low, high, mult else: yield high, low, mult return wrappe...
def _sort_lows_and_highs(func): "Decorator for extract_cycles" @functools.wraps(func) def wrapper(*args, **kwargs): for low, high, mult in func(*args, **kwargs): if low < high: yield low, high, mult else: yield high, low, mult return wrappe...
[ "Decorator", "for", "extract_cycles" ]
iamlikeme/rainflow
python
https://github.com/iamlikeme/rainflow/blob/7725ea2c591ad3d4aab688d1c1d8385d665a07d4/src/rainflow.py#L63-L72
[ "def", "_sort_lows_and_highs", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "low", ",", "high", ",", "mult", "in", "func", "(", "*", "args", ...
7725ea2c591ad3d4aab688d1c1d8385d665a07d4
valid
extract_cycles
Iterate cycles in the series. Parameters ---------- series : iterable sequence of numbers left: bool, optional If True, treat the first point in the series as a reversal. right: bool, optional If True, treat the last point in the series as a reversal. Yields ------ cycl...
src/rainflow.py
def extract_cycles(series, left=False, right=False): """Iterate cycles in the series. Parameters ---------- series : iterable sequence of numbers left: bool, optional If True, treat the first point in the series as a reversal. right: bool, optional If True, treat the last point ...
def extract_cycles(series, left=False, right=False): """Iterate cycles in the series. Parameters ---------- series : iterable sequence of numbers left: bool, optional If True, treat the first point in the series as a reversal. right: bool, optional If True, treat the last point ...
[ "Iterate", "cycles", "in", "the", "series", "." ]
iamlikeme/rainflow
python
https://github.com/iamlikeme/rainflow/blob/7725ea2c591ad3d4aab688d1c1d8385d665a07d4/src/rainflow.py#L76-L122
[ "def", "extract_cycles", "(", "series", ",", "left", "=", "False", ",", "right", "=", "False", ")", ":", "points", "=", "deque", "(", ")", "for", "x", "in", "reversals", "(", "series", ",", "left", "=", "left", ",", "right", "=", "right", ")", ":",...
7725ea2c591ad3d4aab688d1c1d8385d665a07d4