repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
PlaidWeb/Publ | publ/rendering.py | render_publ_template | def render_publ_template(template, **kwargs):
""" Render out a template, providing the image function based on the args.
Returns tuple of (rendered text, etag)
"""
text = render_template(
template.filename,
template=template,
image=image_function(
template=template,
... | python | def render_publ_template(template, **kwargs):
""" Render out a template, providing the image function based on the args.
Returns tuple of (rendered text, etag)
"""
text = render_template(
template.filename,
template=template,
image=image_function(
template=template,
... | [
"def",
"render_publ_template",
"(",
"template",
",",
"*",
"*",
"kwargs",
")",
":",
"text",
"=",
"render_template",
"(",
"template",
".",
"filename",
",",
"template",
"=",
"template",
",",
"image",
"=",
"image_function",
"(",
"template",
"=",
"template",
",",... | Render out a template, providing the image function based on the args.
Returns tuple of (rendered text, etag) | [
"Render",
"out",
"a",
"template",
"providing",
"the",
"image",
"function",
"based",
"on",
"the",
"args",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/rendering.py#L116-L131 |
PlaidWeb/Publ | publ/rendering.py | render_error | def render_error(category, error_message, error_codes, exception=None):
""" Render an error page.
Arguments:
category -- The category of the request
error_message -- The message to provide to the error template
error_codes -- The applicable HTTP error code(s). Will usually be an
integer or... | python | def render_error(category, error_message, error_codes, exception=None):
""" Render an error page.
Arguments:
category -- The category of the request
error_message -- The message to provide to the error template
error_codes -- The applicable HTTP error code(s). Will usually be an
integer or... | [
"def",
"render_error",
"(",
"category",
",",
"error_message",
",",
"error_codes",
",",
"exception",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"error_codes",
",",
"int",
")",
":",
"error_codes",
"=",
"[",
"error_codes",
"]",
"error_code",
"=",
"error_co... | Render an error page.
Arguments:
category -- The category of the request
error_message -- The message to provide to the error template
error_codes -- The applicable HTTP error code(s). Will usually be an
integer or a list of integers; the HTTP error response will always
be the first er... | [
"Render",
"an",
"error",
"page",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/rendering.py#L135-L167 |
PlaidWeb/Publ | publ/rendering.py | render_exception | def render_exception(error):
""" Catch-all renderer for the top-level exception handler """
_, _, category = str.partition(request.path, '/')
qsize = index.queue_length()
if isinstance(error, http_error.NotFound) and qsize:
response = flask.make_response(render_error(
category, "Sit... | python | def render_exception(error):
""" Catch-all renderer for the top-level exception handler """
_, _, category = str.partition(request.path, '/')
qsize = index.queue_length()
if isinstance(error, http_error.NotFound) and qsize:
response = flask.make_response(render_error(
category, "Sit... | [
"def",
"render_exception",
"(",
"error",
")",
":",
"_",
",",
"_",
",",
"category",
"=",
"str",
".",
"partition",
"(",
"request",
".",
"path",
",",
"'/'",
")",
"qsize",
"=",
"index",
".",
"queue_length",
"(",
")",
"if",
"isinstance",
"(",
"error",
","... | Catch-all renderer for the top-level exception handler | [
"Catch",
"-",
"all",
"renderer",
"for",
"the",
"top",
"-",
"level",
"exception",
"handler"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/rendering.py#L170-L193 |
PlaidWeb/Publ | publ/rendering.py | render_path_alias | def render_path_alias(path):
""" Render a known path-alias (used primarily for forced .php redirects) """
redir = path_alias.get_redirect('/' + path)
if not redir:
raise http_error.NotFound("Path redirection not found")
return redir | python | def render_path_alias(path):
""" Render a known path-alias (used primarily for forced .php redirects) """
redir = path_alias.get_redirect('/' + path)
if not redir:
raise http_error.NotFound("Path redirection not found")
return redir | [
"def",
"render_path_alias",
"(",
"path",
")",
":",
"redir",
"=",
"path_alias",
".",
"get_redirect",
"(",
"'/'",
"+",
"path",
")",
"if",
"not",
"redir",
":",
"raise",
"http_error",
".",
"NotFound",
"(",
"\"Path redirection not found\"",
")",
"return",
"redir"
] | Render a known path-alias (used primarily for forced .php redirects) | [
"Render",
"a",
"known",
"path",
"-",
"alias",
"(",
"used",
"primarily",
"for",
"forced",
".",
"php",
"redirects",
")"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/rendering.py#L197-L203 |
PlaidWeb/Publ | publ/rendering.py | render_category | def render_category(category='', template=None):
""" Render a category page.
Arguments:
category -- The category to render
template -- The template to render it with
"""
# pylint:disable=too-many-return-statements
# See if this is an aliased path
redir = get_redirect()
if redir:
... | python | def render_category(category='', template=None):
""" Render a category page.
Arguments:
category -- The category to render
template -- The template to render it with
"""
# pylint:disable=too-many-return-statements
# See if this is an aliased path
redir = get_redirect()
if redir:
... | [
"def",
"render_category",
"(",
"category",
"=",
"''",
",",
"template",
"=",
"None",
")",
":",
"# pylint:disable=too-many-return-statements",
"# See if this is an aliased path",
"redir",
"=",
"get_redirect",
"(",
")",
"if",
"redir",
":",
"return",
"redir",
"# Forbidden... | Render a category page.
Arguments:
category -- The category to render
template -- The template to render it with | [
"Render",
"a",
"category",
"page",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/rendering.py#L207-L265 |
PlaidWeb/Publ | publ/rendering.py | render_entry | def render_entry(entry_id, slug_text='', category=''):
""" Render an entry page.
Arguments:
entry_id -- The numeric ID of the entry to render
slug_text -- The expected URL slug text
category -- The expected category
"""
# pylint: disable=too-many-return-statements
# check if it's a v... | python | def render_entry(entry_id, slug_text='', category=''):
""" Render an entry page.
Arguments:
entry_id -- The numeric ID of the entry to render
slug_text -- The expected URL slug text
category -- The expected category
"""
# pylint: disable=too-many-return-statements
# check if it's a v... | [
"def",
"render_entry",
"(",
"entry_id",
",",
"slug_text",
"=",
"''",
",",
"category",
"=",
"''",
")",
":",
"# pylint: disable=too-many-return-statements",
"# check if it's a valid entry",
"record",
"=",
"model",
".",
"Entry",
".",
"get",
"(",
"id",
"=",
"entry_id"... | Render an entry page.
Arguments:
entry_id -- The numeric ID of the entry to render
slug_text -- The expected URL slug text
category -- The expected category | [
"Render",
"an",
"entry",
"page",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/rendering.py#L269-L354 |
PlaidWeb/Publ | publ/rendering.py | render_transparent_chit | def render_transparent_chit():
""" Render a transparent chit for external, sized images """
if request.if_none_match.contains('chit') or request.if_modified_since:
return 'Not modified', 304
out_bytes = base64.b64decode(
"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")
retur... | python | def render_transparent_chit():
""" Render a transparent chit for external, sized images """
if request.if_none_match.contains('chit') or request.if_modified_since:
return 'Not modified', 304
out_bytes = base64.b64decode(
"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")
retur... | [
"def",
"render_transparent_chit",
"(",
")",
":",
"if",
"request",
".",
"if_none_match",
".",
"contains",
"(",
"'chit'",
")",
"or",
"request",
".",
"if_modified_since",
":",
"return",
"'Not modified'",
",",
"304",
"out_bytes",
"=",
"base64",
".",
"b64decode",
"... | Render a transparent chit for external, sized images | [
"Render",
"a",
"transparent",
"chit",
"for",
"external",
"sized",
"images"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/rendering.py#L357-L366 |
PlaidWeb/Publ | publ/rendering.py | retrieve_asset | def retrieve_asset(filename):
""" Retrieves a non-image asset associated with an entry """
record = model.Image.get(asset_name=filename)
if not record:
raise http_error.NotFound("File not found")
if not record.is_asset:
raise http_error.Forbidden()
return flask.send_file(record.fil... | python | def retrieve_asset(filename):
""" Retrieves a non-image asset associated with an entry """
record = model.Image.get(asset_name=filename)
if not record:
raise http_error.NotFound("File not found")
if not record.is_asset:
raise http_error.Forbidden()
return flask.send_file(record.fil... | [
"def",
"retrieve_asset",
"(",
"filename",
")",
":",
"record",
"=",
"model",
".",
"Image",
".",
"get",
"(",
"asset_name",
"=",
"filename",
")",
"if",
"not",
"record",
":",
"raise",
"http_error",
".",
"NotFound",
"(",
"\"File not found\"",
")",
"if",
"not",
... | Retrieves a non-image asset associated with an entry | [
"Retrieves",
"a",
"non",
"-",
"image",
"asset",
"associated",
"with",
"an",
"entry"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/rendering.py#L370-L379 |
PlaidWeb/Publ | publ/maintenance.py | Maintenance.run | def run(self, force=False):
""" Run all pending tasks; 'force' will run all tasks whether they're
pending or not. """
now = time.time()
for func, spec in self.tasks.items():
if force or now >= spec.get('next_run', 0):
func()
spec['next_run'] = ... | python | def run(self, force=False):
""" Run all pending tasks; 'force' will run all tasks whether they're
pending or not. """
now = time.time()
for func, spec in self.tasks.items():
if force or now >= spec.get('next_run', 0):
func()
spec['next_run'] = ... | [
"def",
"run",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"for",
"func",
",",
"spec",
"in",
"self",
".",
"tasks",
".",
"items",
"(",
")",
":",
"if",
"force",
"or",
"now",
">=",
"spec",
".",
"g... | Run all pending tasks; 'force' will run all tasks whether they're
pending or not. | [
"Run",
"all",
"pending",
"tasks",
";",
"force",
"will",
"run",
"all",
"tasks",
"whether",
"they",
"re",
"pending",
"or",
"not",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/maintenance.py#L16-L23 |
PlaidWeb/Publ | publ/image/__init__.py | _get_asset | def _get_asset(file_path):
""" Get the database record for an asset file """
record = model.Image.get(file_path=file_path)
fingerprint = ','.join((utils.file_fingerprint(file_path),
str(RENDITION_VERSION)))
if not record or record.fingerprint != fingerprint:
# Reindex... | python | def _get_asset(file_path):
""" Get the database record for an asset file """
record = model.Image.get(file_path=file_path)
fingerprint = ','.join((utils.file_fingerprint(file_path),
str(RENDITION_VERSION)))
if not record or record.fingerprint != fingerprint:
# Reindex... | [
"def",
"_get_asset",
"(",
"file_path",
")",
":",
"record",
"=",
"model",
".",
"Image",
".",
"get",
"(",
"file_path",
"=",
"file_path",
")",
"fingerprint",
"=",
"','",
".",
"join",
"(",
"(",
"utils",
".",
"file_fingerprint",
"(",
"file_path",
")",
",",
... | Get the database record for an asset file | [
"Get",
"the",
"database",
"record",
"for",
"an",
"asset",
"file"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/__init__.py#L98-L144 |
PlaidWeb/Publ | publ/image/__init__.py | get_image | def get_image(path, search_path):
""" Get an Image object. If the path is given as absolute, it will be
relative to the content directory; otherwise it will be relative to the
search path.
path -- the image's filename
search_path -- a search path for the image (string or list of strings)
"""
... | python | def get_image(path, search_path):
""" Get an Image object. If the path is given as absolute, it will be
relative to the content directory; otherwise it will be relative to the
search path.
path -- the image's filename
search_path -- a search path for the image (string or list of strings)
"""
... | [
"def",
"get_image",
"(",
"path",
",",
"search_path",
")",
":",
"if",
"path",
".",
"startswith",
"(",
"'@'",
")",
":",
"return",
"StaticImage",
"(",
"path",
"[",
"1",
":",
"]",
",",
"search_path",
")",
"if",
"path",
".",
"startswith",
"(",
"'//'",
")"... | Get an Image object. If the path is given as absolute, it will be
relative to the content directory; otherwise it will be relative to the
search path.
path -- the image's filename
search_path -- a search path for the image (string or list of strings) | [
"Get",
"an",
"Image",
"object",
".",
"If",
"the",
"path",
"is",
"given",
"as",
"absolute",
"it",
"will",
"be",
"relative",
"to",
"the",
"content",
"directory",
";",
"otherwise",
"it",
"will",
"be",
"relative",
"to",
"the",
"search",
"path",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/__init__.py#L147-L173 |
PlaidWeb/Publ | publ/image/__init__.py | parse_arglist | def parse_arglist(args):
""" Parses an arglist into arguments for Image, as a kwargs dict """
# per https://stackoverflow.com/a/49723227/318857
args = 'f({})'.format(args)
tree = ast.parse(args)
funccall = tree.body[0].value
args = [ast.literal_eval(arg) for arg in funccall.args]
kwargs = ... | python | def parse_arglist(args):
""" Parses an arglist into arguments for Image, as a kwargs dict """
# per https://stackoverflow.com/a/49723227/318857
args = 'f({})'.format(args)
tree = ast.parse(args)
funccall = tree.body[0].value
args = [ast.literal_eval(arg) for arg in funccall.args]
kwargs = ... | [
"def",
"parse_arglist",
"(",
"args",
")",
":",
"# per https://stackoverflow.com/a/49723227/318857",
"args",
"=",
"'f({})'",
".",
"format",
"(",
"args",
")",
"tree",
"=",
"ast",
".",
"parse",
"(",
"args",
")",
"funccall",
"=",
"tree",
".",
"body",
"[",
"0",
... | Parses an arglist into arguments for Image, as a kwargs dict | [
"Parses",
"an",
"arglist",
"into",
"arguments",
"for",
"Image",
"as",
"a",
"kwargs",
"dict"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/__init__.py#L176-L197 |
PlaidWeb/Publ | publ/image/__init__.py | parse_alt_text | def parse_alt_text(alt):
""" Parses the arguments out from a Publ-Markdown alt text into a tuple of text, args """
match = re.match(r'([^\{]*)(\{(.*)\})$', alt)
if match:
alt = match.group(1)
args = parse_arglist(match.group(3))
else:
args = {}
return alt, args | python | def parse_alt_text(alt):
""" Parses the arguments out from a Publ-Markdown alt text into a tuple of text, args """
match = re.match(r'([^\{]*)(\{(.*)\})$', alt)
if match:
alt = match.group(1)
args = parse_arglist(match.group(3))
else:
args = {}
return alt, args | [
"def",
"parse_alt_text",
"(",
"alt",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r'([^\\{]*)(\\{(.*)\\})$'",
",",
"alt",
")",
"if",
"match",
":",
"alt",
"=",
"match",
".",
"group",
"(",
"1",
")",
"args",
"=",
"parse_arglist",
"(",
"match",
".",
... | Parses the arguments out from a Publ-Markdown alt text into a tuple of text, args | [
"Parses",
"the",
"arguments",
"out",
"from",
"a",
"Publ",
"-",
"Markdown",
"alt",
"text",
"into",
"a",
"tuple",
"of",
"text",
"args"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/__init__.py#L200-L209 |
PlaidWeb/Publ | publ/image/__init__.py | parse_image_spec | def parse_image_spec(spec):
""" Parses out a Publ-Markdown image spec into a tuple of path, args, title """
# I was having trouble coming up with a single RE that did it right,
# so let's just break it down into sub-problems. First, parse out the
# alt text...
match = re.match(r'(.+)\s+\"(.*)\"\s*$... | python | def parse_image_spec(spec):
""" Parses out a Publ-Markdown image spec into a tuple of path, args, title """
# I was having trouble coming up with a single RE that did it right,
# so let's just break it down into sub-problems. First, parse out the
# alt text...
match = re.match(r'(.+)\s+\"(.*)\"\s*$... | [
"def",
"parse_image_spec",
"(",
"spec",
")",
":",
"# I was having trouble coming up with a single RE that did it right,",
"# so let's just break it down into sub-problems. First, parse out the",
"# alt text...",
"match",
"=",
"re",
".",
"match",
"(",
"r'(.+)\\s+\\\"(.*)\\\"\\s*$'",
"... | Parses out a Publ-Markdown image spec into a tuple of path, args, title | [
"Parses",
"out",
"a",
"Publ",
"-",
"Markdown",
"image",
"spec",
"into",
"a",
"tuple",
"of",
"path",
"args",
"title"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/__init__.py#L212-L232 |
PlaidWeb/Publ | publ/image/__init__.py | get_spec_list | def get_spec_list(image_specs, container_args):
""" Given a list of specs and a set of container args, return a tuple of
the final container argument list and the original list size """
spec_list = [spec.strip() for spec in image_specs.split('|')]
original_count = len(spec_list)
if 'count' in cont... | python | def get_spec_list(image_specs, container_args):
""" Given a list of specs and a set of container args, return a tuple of
the final container argument list and the original list size """
spec_list = [spec.strip() for spec in image_specs.split('|')]
original_count = len(spec_list)
if 'count' in cont... | [
"def",
"get_spec_list",
"(",
"image_specs",
",",
"container_args",
")",
":",
"spec_list",
"=",
"[",
"spec",
".",
"strip",
"(",
")",
"for",
"spec",
"in",
"image_specs",
".",
"split",
"(",
"'|'",
")",
"]",
"original_count",
"=",
"len",
"(",
"spec_list",
")... | Given a list of specs and a set of container args, return a tuple of
the final container argument list and the original list size | [
"Given",
"a",
"list",
"of",
"specs",
"and",
"a",
"set",
"of",
"container",
"args",
"return",
"a",
"tuple",
"of",
"the",
"final",
"container",
"argument",
"list",
"and",
"the",
"original",
"list",
"size"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/__init__.py#L235-L247 |
PlaidWeb/Publ | publ/image/__init__.py | get_async | def get_async(filename):
""" Asynchronously fetch an image """
if os.path.isfile(os.path.join(config.static_folder, filename)):
return flask.redirect(flask.url_for('static', filename=filename))
retry_count = int(flask.request.args.get('retry_count', 0))
if retry_count < 10:
time.sleep(... | python | def get_async(filename):
""" Asynchronously fetch an image """
if os.path.isfile(os.path.join(config.static_folder, filename)):
return flask.redirect(flask.url_for('static', filename=filename))
retry_count = int(flask.request.args.get('retry_count', 0))
if retry_count < 10:
time.sleep(... | [
"def",
"get_async",
"(",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"config",
".",
"static_folder",
",",
"filename",
")",
")",
":",
"return",
"flask",
".",
"redirect",
"(",
"flask",
".",
... | Asynchronously fetch an image | [
"Asynchronously",
"fetch",
"an",
"image"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/__init__.py#L261-L288 |
PlaidWeb/Publ | publ/image/image.py | Image.get_img_attrs | def get_img_attrs(self, style=None, **kwargs):
""" Get an attribute list (src, srcset, style, et al) for the image.
style -- an optional list of CSS style fragments
Returns: a dict of attributes e.g. {'src':'foo.jpg','srcset':'foo.jpg 1x, bar.jpg 2x']
"""
add = {}
if '... | python | def get_img_attrs(self, style=None, **kwargs):
""" Get an attribute list (src, srcset, style, et al) for the image.
style -- an optional list of CSS style fragments
Returns: a dict of attributes e.g. {'src':'foo.jpg','srcset':'foo.jpg 1x, bar.jpg 2x']
"""
add = {}
if '... | [
"def",
"get_img_attrs",
"(",
"self",
",",
"style",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"add",
"=",
"{",
"}",
"if",
"'prefix'",
"in",
"kwargs",
":",
"attr_prefixes",
"=",
"kwargs",
".",
"get",
"(",
"'prefix'",
")",
"if",
"isinstance",
"(",... | Get an attribute list (src, srcset, style, et al) for the image.
style -- an optional list of CSS style fragments
Returns: a dict of attributes e.g. {'src':'foo.jpg','srcset':'foo.jpg 1x, bar.jpg 2x'] | [
"Get",
"an",
"attribute",
"list",
"(",
"src",
"srcset",
"style",
"et",
"al",
")",
"for",
"the",
"image",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/image.py#L36-L55 |
PlaidWeb/Publ | publ/image/image.py | Image.get_img_tag | def get_img_tag(self, title='', alt_text='', **kwargs):
""" Build a <img> tag for the image with the specified options.
Returns: an HTML fragment. """
try:
style = []
for key in ('img_style', 'style'):
if key in kwargs:
if isinstance... | python | def get_img_tag(self, title='', alt_text='', **kwargs):
""" Build a <img> tag for the image with the specified options.
Returns: an HTML fragment. """
try:
style = []
for key in ('img_style', 'style'):
if key in kwargs:
if isinstance... | [
"def",
"get_img_tag",
"(",
"self",
",",
"title",
"=",
"''",
",",
"alt_text",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"style",
"=",
"[",
"]",
"for",
"key",
"in",
"(",
"'img_style'",
",",
"'style'",
")",
":",
"if",
"key",
"in",
... | Build a <img> tag for the image with the specified options.
Returns: an HTML fragment. | [
"Build",
"a",
"<img",
">",
"tag",
"for",
"the",
"image",
"with",
"the",
"specified",
"options",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/image.py#L57-L95 |
PlaidWeb/Publ | publ/image/image.py | Image.get_css_background | def get_css_background(self, uncomment=False, **kwargs):
""" Get the CSS background attributes for an element.
Additional arguments:
uncomment -- surround the attributes with `*/` and `/*` so that the
template tag can be kept inside a comment block, to keep syntax
highl... | python | def get_css_background(self, uncomment=False, **kwargs):
""" Get the CSS background attributes for an element.
Additional arguments:
uncomment -- surround the attributes with `*/` and `/*` so that the
template tag can be kept inside a comment block, to keep syntax
highl... | [
"def",
"get_css_background",
"(",
"self",
",",
"uncomment",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"text",
"=",
"self",
".",
"_css_background",
"(",
"*",
"*",
"kwargs",
")",
"if",
"uncomment",
":",
"text",
"=",
"' */ {} /* '",
".",
"format",
... | Get the CSS background attributes for an element.
Additional arguments:
uncomment -- surround the attributes with `*/` and `/*` so that the
template tag can be kept inside a comment block, to keep syntax
highlighters happy | [
"Get",
"the",
"CSS",
"background",
"attributes",
"for",
"an",
"element",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/image.py#L116-L130 |
PlaidWeb/Publ | publ/image/image.py | Image.get_fullsize | def get_fullsize(self, kwargs):
""" Get the fullsize rendition URL """
fullsize_args = {}
if 'absolute' in kwargs:
fullsize_args['absolute'] = kwargs['absolute']
for key in ('width', 'height', 'quality', 'format', 'background', 'crop'):
fsk = 'fullsize_' + key
... | python | def get_fullsize(self, kwargs):
""" Get the fullsize rendition URL """
fullsize_args = {}
if 'absolute' in kwargs:
fullsize_args['absolute'] = kwargs['absolute']
for key in ('width', 'height', 'quality', 'format', 'background', 'crop'):
fsk = 'fullsize_' + key
... | [
"def",
"get_fullsize",
"(",
"self",
",",
"kwargs",
")",
":",
"fullsize_args",
"=",
"{",
"}",
"if",
"'absolute'",
"in",
"kwargs",
":",
"fullsize_args",
"[",
"'absolute'",
"]",
"=",
"kwargs",
"[",
"'absolute'",
"]",
"for",
"key",
"in",
"(",
"'width'",
",",... | Get the fullsize rendition URL | [
"Get",
"the",
"fullsize",
"rendition",
"URL"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/image.py#L160-L173 |
PlaidWeb/Publ | publ/image/image.py | Image._fullsize_link_tag | def _fullsize_link_tag(self, kwargs, title):
""" Render a <a href> that points to the fullsize rendition specified """
return utils.make_tag('a', {
'href': self.get_fullsize(kwargs),
'data-lightbox': kwargs['gallery_id'],
'title': title
}) | python | def _fullsize_link_tag(self, kwargs, title):
""" Render a <a href> that points to the fullsize rendition specified """
return utils.make_tag('a', {
'href': self.get_fullsize(kwargs),
'data-lightbox': kwargs['gallery_id'],
'title': title
}) | [
"def",
"_fullsize_link_tag",
"(",
"self",
",",
"kwargs",
",",
"title",
")",
":",
"return",
"utils",
".",
"make_tag",
"(",
"'a'",
",",
"{",
"'href'",
":",
"self",
".",
"get_fullsize",
"(",
"kwargs",
")",
",",
"'data-lightbox'",
":",
"kwargs",
"[",
"'galle... | Render a <a href> that points to the fullsize rendition specified | [
"Render",
"a",
"<a",
"href",
">",
"that",
"points",
"to",
"the",
"fullsize",
"rendition",
"specified"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/image.py#L175-L182 |
PlaidWeb/Publ | publ/path_alias.py | set_alias | def set_alias(alias, **kwargs):
""" Set a path alias.
Arguments:
alias -- The alias specification
entry -- The entry to alias it to
category -- The category to alias it to
url -- The external URL to alias it to
"""
spec = alias.split()
path = spec[0]
values = {**kwargs, 'pat... | python | def set_alias(alias, **kwargs):
""" Set a path alias.
Arguments:
alias -- The alias specification
entry -- The entry to alias it to
category -- The category to alias it to
url -- The external URL to alias it to
"""
spec = alias.split()
path = spec[0]
values = {**kwargs, 'pat... | [
"def",
"set_alias",
"(",
"alias",
",",
"*",
"*",
"kwargs",
")",
":",
"spec",
"=",
"alias",
".",
"split",
"(",
")",
"path",
"=",
"spec",
"[",
"0",
"]",
"values",
"=",
"{",
"*",
"*",
"kwargs",
",",
"'path'",
":",
"path",
"}",
"if",
"len",
"(",
... | Set a path alias.
Arguments:
alias -- The alias specification
entry -- The entry to alias it to
category -- The category to alias it to
url -- The external URL to alias it to | [
"Set",
"a",
"path",
"alias",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/path_alias.py#L11-L38 |
PlaidWeb/Publ | publ/path_alias.py | remove_alias | def remove_alias(path):
""" Remove a path alias.
Arguments:
path -- the path to remove the alias of
"""
orm.delete(p for p in model.PathAlias if p.path == path)
orm.commit() | python | def remove_alias(path):
""" Remove a path alias.
Arguments:
path -- the path to remove the alias of
"""
orm.delete(p for p in model.PathAlias if p.path == path)
orm.commit() | [
"def",
"remove_alias",
"(",
"path",
")",
":",
"orm",
".",
"delete",
"(",
"p",
"for",
"p",
"in",
"model",
".",
"PathAlias",
"if",
"p",
".",
"path",
"==",
"path",
")",
"orm",
".",
"commit",
"(",
")"
] | Remove a path alias.
Arguments:
path -- the path to remove the alias of | [
"Remove",
"a",
"path",
"alias",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/path_alias.py#L42-L50 |
PlaidWeb/Publ | publ/path_alias.py | remove_aliases | def remove_aliases(target):
""" Remove all aliases to a destination """
if isinstance(target, model.Entry):
orm.delete(p for p in model.PathAlias if p.entry == target)
elif isinstance(target, model.Category):
orm.delete(p for p in model.PathAlias if p.category == target)
else:
r... | python | def remove_aliases(target):
""" Remove all aliases to a destination """
if isinstance(target, model.Entry):
orm.delete(p for p in model.PathAlias if p.entry == target)
elif isinstance(target, model.Category):
orm.delete(p for p in model.PathAlias if p.category == target)
else:
r... | [
"def",
"remove_aliases",
"(",
"target",
")",
":",
"if",
"isinstance",
"(",
"target",
",",
"model",
".",
"Entry",
")",
":",
"orm",
".",
"delete",
"(",
"p",
"for",
"p",
"in",
"model",
".",
"PathAlias",
"if",
"p",
".",
"entry",
"==",
"target",
")",
"e... | Remove all aliases to a destination | [
"Remove",
"all",
"aliases",
"to",
"a",
"destination"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/path_alias.py#L54-L63 |
PlaidWeb/Publ | publ/path_alias.py | get_alias | def get_alias(path):
""" Get a path alias for a single path
Returns a tuple of (url,is_permanent)
"""
# pylint:disable=too-many-return-statements
record = model.PathAlias.get(path=path)
if not record:
return None, None
template = record.template if record.template != 'index' else... | python | def get_alias(path):
""" Get a path alias for a single path
Returns a tuple of (url,is_permanent)
"""
# pylint:disable=too-many-return-statements
record = model.PathAlias.get(path=path)
if not record:
return None, None
template = record.template if record.template != 'index' else... | [
"def",
"get_alias",
"(",
"path",
")",
":",
"# pylint:disable=too-many-return-statements",
"record",
"=",
"model",
".",
"PathAlias",
".",
"get",
"(",
"path",
"=",
"path",
")",
"if",
"not",
"record",
":",
"return",
"None",
",",
"None",
"template",
"=",
"record... | Get a path alias for a single path
Returns a tuple of (url,is_permanent) | [
"Get",
"a",
"path",
"alias",
"for",
"a",
"single",
"path"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/path_alias.py#L66-L111 |
PlaidWeb/Publ | publ/path_alias.py | get_redirect | def get_redirect(paths):
""" Get a redirect from a path or list of paths
Arguments:
paths -- either a single path string, or a list of paths to check
Returns: a flask.redirect() result
"""
if isinstance(paths, str):
paths = [paths]
for path in paths:
url, permanent = get... | python | def get_redirect(paths):
""" Get a redirect from a path or list of paths
Arguments:
paths -- either a single path string, or a list of paths to check
Returns: a flask.redirect() result
"""
if isinstance(paths, str):
paths = [paths]
for path in paths:
url, permanent = get... | [
"def",
"get_redirect",
"(",
"paths",
")",
":",
"if",
"isinstance",
"(",
"paths",
",",
"str",
")",
":",
"paths",
"=",
"[",
"paths",
"]",
"for",
"path",
"in",
"paths",
":",
"url",
",",
"permanent",
"=",
"get_alias",
"(",
"path",
")",
"if",
"url",
":"... | Get a redirect from a path or list of paths
Arguments:
paths -- either a single path string, or a list of paths to check
Returns: a flask.redirect() result | [
"Get",
"a",
"redirect",
"from",
"a",
"path",
"or",
"list",
"of",
"paths"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/path_alias.py#L114-L136 |
PlaidWeb/Publ | publ/image/local.py | fix_orientation | def fix_orientation(image):
""" adapted from https://stackoverflow.com/a/30462851/318857
Apply Image.transpose to ensure 0th row of pixels is at the visual
top of the image, and 0th column is the visual left-hand side.
Return the original image if unable to determine the orientation.
... | python | def fix_orientation(image):
""" adapted from https://stackoverflow.com/a/30462851/318857
Apply Image.transpose to ensure 0th row of pixels is at the visual
top of the image, and 0th column is the visual left-hand side.
Return the original image if unable to determine the orientation.
... | [
"def",
"fix_orientation",
"(",
"image",
")",
":",
"exif_orientation_tag",
"=",
"0x0112",
"exif_transpose_sequences",
"=",
"[",
"[",
"]",
",",
"[",
"]",
",",
"[",
"PIL",
".",
"Image",
".",
"FLIP_LEFT_RIGHT",
"]",
",",
"[",
"PIL",
".",
"Image",
".",
"ROTAT... | adapted from https://stackoverflow.com/a/30462851/318857
Apply Image.transpose to ensure 0th row of pixels is at the visual
top of the image, and 0th column is the visual left-hand side.
Return the original image if unable to determine the orientation.
As per CIPA DC-008-2012, the orie... | [
"adapted",
"from",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"30462851",
"/",
"318857"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L23-L55 |
PlaidWeb/Publ | publ/image/local.py | LocalImage.thread_pool | def thread_pool():
""" Get the rendition threadpool """
if not LocalImage._thread_pool:
logger.info("Starting LocalImage threadpool")
LocalImage._thread_pool = concurrent.futures.ThreadPoolExecutor(
thread_name_prefix="Renderer")
return LocalImage._thread_... | python | def thread_pool():
""" Get the rendition threadpool """
if not LocalImage._thread_pool:
logger.info("Starting LocalImage threadpool")
LocalImage._thread_pool = concurrent.futures.ThreadPoolExecutor(
thread_name_prefix="Renderer")
return LocalImage._thread_... | [
"def",
"thread_pool",
"(",
")",
":",
"if",
"not",
"LocalImage",
".",
"_thread_pool",
":",
"logger",
".",
"info",
"(",
"\"Starting LocalImage threadpool\"",
")",
"LocalImage",
".",
"_thread_pool",
"=",
"concurrent",
".",
"futures",
".",
"ThreadPoolExecutor",
"(",
... | Get the rendition threadpool | [
"Get",
"the",
"rendition",
"threadpool"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L65-L71 |
PlaidWeb/Publ | publ/image/local.py | LocalImage.get_rendition | def get_rendition(self, output_scale=1, **kwargs):
# pylint:disable=too-many-locals
"""
Get the rendition for this image, generating it if necessary.
Returns a tuple of `(relative_path, width, height)`, where relative_path
is relative to the static file directory (i.e. what one w... | python | def get_rendition(self, output_scale=1, **kwargs):
# pylint:disable=too-many-locals
"""
Get the rendition for this image, generating it if necessary.
Returns a tuple of `(relative_path, width, height)`, where relative_path
is relative to the static file directory (i.e. what one w... | [
"def",
"get_rendition",
"(",
"self",
",",
"output_scale",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint:disable=too-many-locals",
"basename",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"sel... | Get the rendition for this image, generating it if necessary.
Returns a tuple of `(relative_path, width, height)`, where relative_path
is relative to the static file directory (i.e. what one would pass into
`get_static()`)
output_scale -- the upsample factor for the requested rendition
... | [
"Get",
"the",
"rendition",
"for",
"this",
"image",
"generating",
"it",
"if",
"necessary",
".",
"Returns",
"a",
"tuple",
"of",
"(",
"relative_path",
"width",
"height",
")",
"where",
"relative_path",
"is",
"relative",
"to",
"the",
"static",
"file",
"directory",
... | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L83-L170 |
PlaidWeb/Publ | publ/image/local.py | LocalImage._adjust_crop_box | def _adjust_crop_box(box, crop):
""" Given a fit box and a crop box, adjust one to the other """
if crop and box:
# Both boxes are the same size; just line them up.
return (box[0] + crop[0], box[1] + crop[1],
box[2] + crop[0], box[3] + crop[1])
if cr... | python | def _adjust_crop_box(box, crop):
""" Given a fit box and a crop box, adjust one to the other """
if crop and box:
# Both boxes are the same size; just line them up.
return (box[0] + crop[0], box[1] + crop[1],
box[2] + crop[0], box[3] + crop[1])
if cr... | [
"def",
"_adjust_crop_box",
"(",
"box",
",",
"crop",
")",
":",
"if",
"crop",
"and",
"box",
":",
"# Both boxes are the same size; just line them up.",
"return",
"(",
"box",
"[",
"0",
"]",
"+",
"crop",
"[",
"0",
"]",
",",
"box",
"[",
"1",
"]",
"+",
"crop",
... | Given a fit box and a crop box, adjust one to the other | [
"Given",
"a",
"fit",
"box",
"and",
"a",
"crop",
"box",
"adjust",
"one",
"to",
"the",
"other"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L180-L193 |
PlaidWeb/Publ | publ/image/local.py | LocalImage._parse_tuple_string | def _parse_tuple_string(argument):
""" Return a tuple from parsing 'a,b,c,d' -> (a,b,c,d) """
if isinstance(argument, str):
return tuple(int(p.strip()) for p in argument.split(','))
return argument | python | def _parse_tuple_string(argument):
""" Return a tuple from parsing 'a,b,c,d' -> (a,b,c,d) """
if isinstance(argument, str):
return tuple(int(p.strip()) for p in argument.split(','))
return argument | [
"def",
"_parse_tuple_string",
"(",
"argument",
")",
":",
"if",
"isinstance",
"(",
"argument",
",",
"str",
")",
":",
"return",
"tuple",
"(",
"int",
"(",
"p",
".",
"strip",
"(",
")",
")",
"for",
"p",
"in",
"argument",
".",
"split",
"(",
"','",
")",
"... | Return a tuple from parsing 'a,b,c,d' -> (a,b,c,d) | [
"Return",
"a",
"tuple",
"from",
"parsing",
"a",
"b",
"c",
"d",
"-",
">",
"(",
"a",
"b",
"c",
"d",
")"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L196-L200 |
PlaidWeb/Publ | publ/image/local.py | LocalImage.get_rendition_size | def get_rendition_size(self, spec, output_scale, crop):
"""
Wrapper to determine the overall rendition size and cropping box
Returns tuple of (size,box)
"""
if crop:
# Use the cropping rectangle size
_, _, width, height = crop
else:
#... | python | def get_rendition_size(self, spec, output_scale, crop):
"""
Wrapper to determine the overall rendition size and cropping box
Returns tuple of (size,box)
"""
if crop:
# Use the cropping rectangle size
_, _, width, height = crop
else:
#... | [
"def",
"get_rendition_size",
"(",
"self",
",",
"spec",
",",
"output_scale",
",",
"crop",
")",
":",
"if",
"crop",
":",
"# Use the cropping rectangle size",
"_",
",",
"_",
",",
"width",
",",
"height",
"=",
"crop",
"else",
":",
"# Use the original image size",
"w... | Wrapper to determine the overall rendition size and cropping box
Returns tuple of (size,box) | [
"Wrapper",
"to",
"determine",
"the",
"overall",
"rendition",
"size",
"and",
"cropping",
"box"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L254-L279 |
PlaidWeb/Publ | publ/image/local.py | LocalImage.get_rendition_fit_size | def get_rendition_fit_size(spec, input_w, input_h, output_scale):
""" Determine the scaled size based on the provided spec """
width = input_w
height = input_h
scale = spec.get('scale')
if scale:
width = width / scale
height = height / scale
min... | python | def get_rendition_fit_size(spec, input_w, input_h, output_scale):
""" Determine the scaled size based on the provided spec """
width = input_w
height = input_h
scale = spec.get('scale')
if scale:
width = width / scale
height = height / scale
min... | [
"def",
"get_rendition_fit_size",
"(",
"spec",
",",
"input_w",
",",
"input_h",
",",
"output_scale",
")",
":",
"width",
"=",
"input_w",
"height",
"=",
"input_h",
"scale",
"=",
"spec",
".",
"get",
"(",
"'scale'",
")",
"if",
"scale",
":",
"width",
"=",
"widt... | Determine the scaled size based on the provided spec | [
"Determine",
"the",
"scaled",
"size",
"based",
"on",
"the",
"provided",
"spec"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L282-L330 |
PlaidWeb/Publ | publ/image/local.py | LocalImage.get_rendition_fill_size | def get_rendition_fill_size(spec, input_w, input_h, output_scale):
""" Determine the scale-crop size given the provided spec """
width = input_w
height = input_h
scale = spec.get('scale')
if scale:
width = width / scale
height = height / scale
i... | python | def get_rendition_fill_size(spec, input_w, input_h, output_scale):
""" Determine the scale-crop size given the provided spec """
width = input_w
height = input_h
scale = spec.get('scale')
if scale:
width = width / scale
height = height / scale
i... | [
"def",
"get_rendition_fill_size",
"(",
"spec",
",",
"input_w",
",",
"input_h",
",",
"output_scale",
")",
":",
"width",
"=",
"input_w",
"height",
"=",
"input_h",
"scale",
"=",
"spec",
".",
"get",
"(",
"'scale'",
")",
"if",
"scale",
":",
"width",
"=",
"wid... | Determine the scale-crop size given the provided spec | [
"Determine",
"the",
"scale",
"-",
"crop",
"size",
"given",
"the",
"provided",
"spec"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L333-L381 |
PlaidWeb/Publ | publ/image/local.py | LocalImage.get_rendition_stretch_size | def get_rendition_stretch_size(spec, input_w, input_h, output_scale):
""" Determine the scale-crop size given the provided spec """
width = input_w
height = input_h
scale = spec.get('scale')
if scale:
width = width / scale
height = height / scale
... | python | def get_rendition_stretch_size(spec, input_w, input_h, output_scale):
""" Determine the scale-crop size given the provided spec """
width = input_w
height = input_h
scale = spec.get('scale')
if scale:
width = width / scale
height = height / scale
... | [
"def",
"get_rendition_stretch_size",
"(",
"spec",
",",
"input_w",
",",
"input_h",
",",
"output_scale",
")",
":",
"width",
"=",
"input_w",
"height",
"=",
"input_h",
"scale",
"=",
"spec",
".",
"get",
"(",
"'scale'",
")",
"if",
"scale",
":",
"width",
"=",
"... | Determine the scale-crop size given the provided spec | [
"Determine",
"the",
"scale",
"-",
"crop",
"size",
"given",
"the",
"provided",
"spec"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L384-L424 |
PlaidWeb/Publ | publ/image/local.py | LocalImage.flatten | def flatten(image, bgcolor=None):
""" Flatten an image, with an optional background color """
if bgcolor:
background = PIL.Image.new('RGB', image.size, bgcolor)
background.paste(image, mask=image.split()[3])
return background
return image.convert('RGB') | python | def flatten(image, bgcolor=None):
""" Flatten an image, with an optional background color """
if bgcolor:
background = PIL.Image.new('RGB', image.size, bgcolor)
background.paste(image, mask=image.split()[3])
return background
return image.convert('RGB') | [
"def",
"flatten",
"(",
"image",
",",
"bgcolor",
"=",
"None",
")",
":",
"if",
"bgcolor",
":",
"background",
"=",
"PIL",
".",
"Image",
".",
"new",
"(",
"'RGB'",
",",
"image",
".",
"size",
",",
"bgcolor",
")",
"background",
".",
"paste",
"(",
"image",
... | Flatten an image, with an optional background color | [
"Flatten",
"an",
"image",
"with",
"an",
"optional",
"background",
"color"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L427-L434 |
PlaidWeb/Publ | publ/image/local.py | LocalImage._get_renditions | def _get_renditions(self, kwargs):
""" Get a bunch of renditions; returns a tuple of 1x, 2x, size """
img_1x, size = self.get_rendition(
1, **utils.remap_args(kwargs, {"quality": "quality_ldpi"}))
img_2x, _ = self.get_rendition(
2, **utils.remap_args(kwargs, {"quality": "... | python | def _get_renditions(self, kwargs):
""" Get a bunch of renditions; returns a tuple of 1x, 2x, size """
img_1x, size = self.get_rendition(
1, **utils.remap_args(kwargs, {"quality": "quality_ldpi"}))
img_2x, _ = self.get_rendition(
2, **utils.remap_args(kwargs, {"quality": "... | [
"def",
"_get_renditions",
"(",
"self",
",",
"kwargs",
")",
":",
"img_1x",
",",
"size",
"=",
"self",
".",
"get_rendition",
"(",
"1",
",",
"*",
"*",
"utils",
".",
"remap_args",
"(",
"kwargs",
",",
"{",
"\"quality\"",
":",
"\"quality_ldpi\"",
"}",
")",
")... | Get a bunch of renditions; returns a tuple of 1x, 2x, size | [
"Get",
"a",
"bunch",
"of",
"renditions",
";",
"returns",
"a",
"tuple",
"of",
"1x",
"2x",
"size"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L436-L443 |
PlaidWeb/Publ | publ/image/local.py | LocalImage._get_img_attrs | def _get_img_attrs(self, style, kwargs):
""" Get the attributes of an an <img> tag for this image, hidpi-aware """
# Get the 1x and 2x renditions
img_1x, img_2x, size = self._get_renditions(kwargs)
return {
'src': img_1x,
'width': size[0],
'height': ... | python | def _get_img_attrs(self, style, kwargs):
""" Get the attributes of an an <img> tag for this image, hidpi-aware """
# Get the 1x and 2x renditions
img_1x, img_2x, size = self._get_renditions(kwargs)
return {
'src': img_1x,
'width': size[0],
'height': ... | [
"def",
"_get_img_attrs",
"(",
"self",
",",
"style",
",",
"kwargs",
")",
":",
"# Get the 1x and 2x renditions",
"img_1x",
",",
"img_2x",
",",
"size",
"=",
"self",
".",
"_get_renditions",
"(",
"kwargs",
")",
"return",
"{",
"'src'",
":",
"img_1x",
",",
"'width'... | Get the attributes of an an <img> tag for this image, hidpi-aware | [
"Get",
"the",
"attributes",
"of",
"an",
"an",
"<img",
">",
"tag",
"for",
"this",
"image",
"hidpi",
"-",
"aware"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L445-L459 |
PlaidWeb/Publ | publ/image/local.py | LocalImage._css_background | def _css_background(self, **kwargs):
""" Get the CSS specifiers for this as a hidpi-capable background image """
# Get the 1x and 2x renditions
img_1x, img_2x, _ = self._get_renditions(kwargs)
tmpl = 'background-image: url("{s1x}");'
if img_1x != img_2x:
image_set =... | python | def _css_background(self, **kwargs):
""" Get the CSS specifiers for this as a hidpi-capable background image """
# Get the 1x and 2x renditions
img_1x, img_2x, _ = self._get_renditions(kwargs)
tmpl = 'background-image: url("{s1x}");'
if img_1x != img_2x:
image_set =... | [
"def",
"_css_background",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get the 1x and 2x renditions",
"img_1x",
",",
"img_2x",
",",
"_",
"=",
"self",
".",
"_get_renditions",
"(",
"kwargs",
")",
"tmpl",
"=",
"'background-image: url(\"{s1x}\");'",
"if",
"img... | Get the CSS specifiers for this as a hidpi-capable background image | [
"Get",
"the",
"CSS",
"specifiers",
"for",
"this",
"as",
"a",
"hidpi",
"-",
"capable",
"background",
"image"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/image/local.py#L461-L472 |
PlaidWeb/Publ | publ/html_entry.py | process | def process(text, config, search_path):
""" Process an HTML entry's HTML """
processor = HTMLEntry(config, search_path)
processor.feed(text)
text = processor.get_data()
if not config.get('no_smartquotes'):
text = misaka.smartypants(text)
return flask.Markup(text) | python | def process(text, config, search_path):
""" Process an HTML entry's HTML """
processor = HTMLEntry(config, search_path)
processor.feed(text)
text = processor.get_data()
if not config.get('no_smartquotes'):
text = misaka.smartypants(text)
return flask.Markup(text) | [
"def",
"process",
"(",
"text",
",",
"config",
",",
"search_path",
")",
":",
"processor",
"=",
"HTMLEntry",
"(",
"config",
",",
"search_path",
")",
"processor",
".",
"feed",
"(",
"text",
")",
"text",
"=",
"processor",
".",
"get_data",
"(",
")",
"if",
"n... | Process an HTML entry's HTML | [
"Process",
"an",
"HTML",
"entry",
"s",
"HTML"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/html_entry.py#L93-L102 |
PlaidWeb/Publ | publ/html_entry.py | HTMLEntry._handle_tag | def _handle_tag(self, tag, attrs, self_closing):
""" Handle a tag.
attrs -- the attributes of the tag
self_closing -- whether this is self-closing
"""
if tag.lower() == 'img':
attrs = self._image_attrs(attrs)
# Remap the attributes
out_attrs = []
... | python | def _handle_tag(self, tag, attrs, self_closing):
""" Handle a tag.
attrs -- the attributes of the tag
self_closing -- whether this is self-closing
"""
if tag.lower() == 'img':
attrs = self._image_attrs(attrs)
# Remap the attributes
out_attrs = []
... | [
"def",
"_handle_tag",
"(",
"self",
",",
"tag",
",",
"attrs",
",",
"self_closing",
")",
":",
"if",
"tag",
".",
"lower",
"(",
")",
"==",
"'img'",
":",
"attrs",
"=",
"self",
".",
"_image_attrs",
"(",
"attrs",
")",
"# Remap the attributes",
"out_attrs",
"=",... | Handle a tag.
attrs -- the attributes of the tag
self_closing -- whether this is self-closing | [
"Handle",
"a",
"tag",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/html_entry.py#L34-L58 |
PlaidWeb/Publ | publ/html_entry.py | HTMLEntry._image_attrs | def _image_attrs(self, attrs):
""" Rewrite the SRC attribute on an <img> tag, possibly adding a SRCSET.
"""
path = None
config = {**self._config}
for key, val in attrs:
if key.lower() == 'width' or key.lower() == 'height':
try:
co... | python | def _image_attrs(self, attrs):
""" Rewrite the SRC attribute on an <img> tag, possibly adding a SRCSET.
"""
path = None
config = {**self._config}
for key, val in attrs:
if key.lower() == 'width' or key.lower() == 'height':
try:
co... | [
"def",
"_image_attrs",
"(",
"self",
",",
"attrs",
")",
":",
"path",
"=",
"None",
"config",
"=",
"{",
"*",
"*",
"self",
".",
"_config",
"}",
"for",
"key",
",",
"val",
"in",
"attrs",
":",
"if",
"key",
".",
"lower",
"(",
")",
"==",
"'width'",
"or",
... | Rewrite the SRC attribute on an <img> tag, possibly adding a SRCSET. | [
"Rewrite",
"the",
"SRC",
"attribute",
"on",
"an",
"<img",
">",
"tag",
"possibly",
"adding",
"a",
"SRCSET",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/html_entry.py#L60-L90 |
PlaidWeb/Publ | publ/index.py | last_modified | def last_modified():
""" information about the most recently modified file """
files = model.FileFingerprint.select().order_by(
orm.desc(model.FileFingerprint.file_mtime))
for file in files:
return file.file_mtime, file.file_path
return None, None | python | def last_modified():
""" information about the most recently modified file """
files = model.FileFingerprint.select().order_by(
orm.desc(model.FileFingerprint.file_mtime))
for file in files:
return file.file_mtime, file.file_path
return None, None | [
"def",
"last_modified",
"(",
")",
":",
"files",
"=",
"model",
".",
"FileFingerprint",
".",
"select",
"(",
")",
".",
"order_by",
"(",
"orm",
".",
"desc",
"(",
"model",
".",
"FileFingerprint",
".",
"file_mtime",
")",
")",
"for",
"file",
"in",
"files",
":... | information about the most recently modified file | [
"information",
"about",
"the",
"most",
"recently",
"modified",
"file"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L58-L64 |
PlaidWeb/Publ | publ/index.py | scan_file | def scan_file(fullpath, relpath, assign_id):
""" Scan a file for the index
fullpath -- The full path to the file
relpath -- The path to the file, relative to its base directory
assign_id -- Whether to assign an ID to the file if not yet assigned
This calls into various modules' scanner functions; ... | python | def scan_file(fullpath, relpath, assign_id):
""" Scan a file for the index
fullpath -- The full path to the file
relpath -- The path to the file, relative to its base directory
assign_id -- Whether to assign an ID to the file if not yet assigned
This calls into various modules' scanner functions; ... | [
"def",
"scan_file",
"(",
"fullpath",
",",
"relpath",
",",
"assign_id",
")",
":",
"logger",
".",
"debug",
"(",
"\"Scanning file: %s (%s) %s\"",
",",
"fullpath",
",",
"relpath",
",",
"assign_id",
")",
"def",
"do_scan",
"(",
")",
":",
"\"\"\" helper function to do ... | Scan a file for the index
fullpath -- The full path to the file
relpath -- The path to the file, relative to its base directory
assign_id -- Whether to assign an ID to the file if not yet assigned
This calls into various modules' scanner functions; the expectation is that
the scan_file function wi... | [
"Scan",
"a",
"file",
"for",
"the",
"index"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L77-L117 |
PlaidWeb/Publ | publ/index.py | get_last_fingerprint | def get_last_fingerprint(fullpath):
""" Get the last known modification time for a file """
record = model.FileFingerprint.get(file_path=fullpath)
if record:
return record.fingerprint
return None | python | def get_last_fingerprint(fullpath):
""" Get the last known modification time for a file """
record = model.FileFingerprint.get(file_path=fullpath)
if record:
return record.fingerprint
return None | [
"def",
"get_last_fingerprint",
"(",
"fullpath",
")",
":",
"record",
"=",
"model",
".",
"FileFingerprint",
".",
"get",
"(",
"file_path",
"=",
"fullpath",
")",
"if",
"record",
":",
"return",
"record",
".",
"fingerprint",
"return",
"None"
] | Get the last known modification time for a file | [
"Get",
"the",
"last",
"known",
"modification",
"time",
"for",
"a",
"file"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L121-L126 |
PlaidWeb/Publ | publ/index.py | set_fingerprint | def set_fingerprint(fullpath, fingerprint=None):
""" Set the last known modification time for a file """
try:
fingerprint = fingerprint or utils.file_fingerprint(fullpath)
record = model.FileFingerprint.get(file_path=fullpath)
if record:
record.set(fingerprint=fingerprint,
... | python | def set_fingerprint(fullpath, fingerprint=None):
""" Set the last known modification time for a file """
try:
fingerprint = fingerprint or utils.file_fingerprint(fullpath)
record = model.FileFingerprint.get(file_path=fullpath)
if record:
record.set(fingerprint=fingerprint,
... | [
"def",
"set_fingerprint",
"(",
"fullpath",
",",
"fingerprint",
"=",
"None",
")",
":",
"try",
":",
"fingerprint",
"=",
"fingerprint",
"or",
"utils",
".",
"file_fingerprint",
"(",
"fullpath",
")",
"record",
"=",
"model",
".",
"FileFingerprint",
".",
"get",
"("... | Set the last known modification time for a file | [
"Set",
"the",
"last",
"known",
"modification",
"time",
"for",
"a",
"file"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L130-L146 |
PlaidWeb/Publ | publ/index.py | background_scan | def background_scan(content_dir):
""" Start background scanning a directory for changes """
observer = watchdog.observers.Observer()
observer.schedule(IndexWatchdog(content_dir),
content_dir, recursive=True)
logging.info("Watching %s for changes", content_dir)
observer.start() | python | def background_scan(content_dir):
""" Start background scanning a directory for changes """
observer = watchdog.observers.Observer()
observer.schedule(IndexWatchdog(content_dir),
content_dir, recursive=True)
logging.info("Watching %s for changes", content_dir)
observer.start() | [
"def",
"background_scan",
"(",
"content_dir",
")",
":",
"observer",
"=",
"watchdog",
".",
"observers",
".",
"Observer",
"(",
")",
"observer",
".",
"schedule",
"(",
"IndexWatchdog",
"(",
"content_dir",
")",
",",
"content_dir",
",",
"recursive",
"=",
"True",
"... | Start background scanning a directory for changes | [
"Start",
"background",
"scanning",
"a",
"directory",
"for",
"changes"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L188-L194 |
PlaidWeb/Publ | publ/index.py | prune_missing | def prune_missing(table):
""" Prune any files which are missing from the specified table """
try:
for item in table.select():
if not os.path.isfile(item.file_path):
logger.info("File disappeared: %s", item.file_path)
item.delete()
except: # pylint:disable... | python | def prune_missing(table):
""" Prune any files which are missing from the specified table """
try:
for item in table.select():
if not os.path.isfile(item.file_path):
logger.info("File disappeared: %s", item.file_path)
item.delete()
except: # pylint:disable... | [
"def",
"prune_missing",
"(",
"table",
")",
":",
"try",
":",
"for",
"item",
"in",
"table",
".",
"select",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"item",
".",
"file_path",
")",
":",
"logger",
".",
"info",
"(",
"\"File disa... | Prune any files which are missing from the specified table | [
"Prune",
"any",
"files",
"which",
"are",
"missing",
"from",
"the",
"specified",
"table"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L198-L206 |
PlaidWeb/Publ | publ/index.py | scan_index | def scan_index(content_dir):
""" Scan all files in a content directory """
def scan_directory(root, files):
""" Helper function to scan a single directory """
try:
for file in files:
fullpath = os.path.join(root, file)
relpath = os.path.relpath(fullpa... | python | def scan_index(content_dir):
""" Scan all files in a content directory """
def scan_directory(root, files):
""" Helper function to scan a single directory """
try:
for file in files:
fullpath = os.path.join(root, file)
relpath = os.path.relpath(fullpa... | [
"def",
"scan_index",
"(",
"content_dir",
")",
":",
"def",
"scan_directory",
"(",
"root",
",",
"files",
")",
":",
"\"\"\" Helper function to scan a single directory \"\"\"",
"try",
":",
"for",
"file",
"in",
"files",
":",
"fullpath",
"=",
"os",
".",
"path",
".",
... | Scan all files in a content directory | [
"Scan",
"all",
"files",
"in",
"a",
"content",
"directory"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L209-L230 |
PlaidWeb/Publ | publ/index.py | ConcurrentSet.add | def add(self, item):
""" Add an item to the set, and return whether it was newly added """
with self.lock:
if item in self.set:
return False
self.set.add(item)
return True | python | def add(self, item):
""" Add an item to the set, and return whether it was newly added """
with self.lock:
if item in self.set:
return False
self.set.add(item)
return True | [
"def",
"add",
"(",
"self",
",",
"item",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"item",
"in",
"self",
".",
"set",
":",
"return",
"False",
"self",
".",
"set",
".",
"add",
"(",
"item",
")",
"return",
"True"
] | Add an item to the set, and return whether it was newly added | [
"Add",
"an",
"item",
"to",
"the",
"set",
"and",
"return",
"whether",
"it",
"was",
"newly",
"added"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L38-L44 |
PlaidWeb/Publ | publ/index.py | ConcurrentSet.remove | def remove(self, item):
""" Remove an item from the set, returning if it was present """
with self.lock:
if item in self.set:
self.set.remove(item)
return True
return False | python | def remove(self, item):
""" Remove an item from the set, returning if it was present """
with self.lock:
if item in self.set:
self.set.remove(item)
return True
return False | [
"def",
"remove",
"(",
"self",
",",
"item",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"item",
"in",
"self",
".",
"set",
":",
"self",
".",
"set",
".",
"remove",
"(",
"item",
")",
"return",
"True",
"return",
"False"
] | Remove an item from the set, returning if it was present | [
"Remove",
"an",
"item",
"from",
"the",
"set",
"returning",
"if",
"it",
"was",
"present"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L46-L52 |
PlaidWeb/Publ | publ/index.py | IndexWatchdog.update_file | def update_file(self, fullpath):
""" Update a file """
if SCHEDULED_FILES.add(fullpath):
logger.debug("Scheduling reindex of %s", fullpath)
relpath = os.path.relpath(fullpath, self.content_dir)
THREAD_POOL.submit(scan_file, fullpath, relpath, False) | python | def update_file(self, fullpath):
""" Update a file """
if SCHEDULED_FILES.add(fullpath):
logger.debug("Scheduling reindex of %s", fullpath)
relpath = os.path.relpath(fullpath, self.content_dir)
THREAD_POOL.submit(scan_file, fullpath, relpath, False) | [
"def",
"update_file",
"(",
"self",
",",
"fullpath",
")",
":",
"if",
"SCHEDULED_FILES",
".",
"add",
"(",
"fullpath",
")",
":",
"logger",
".",
"debug",
"(",
"\"Scheduling reindex of %s\"",
",",
"fullpath",
")",
"relpath",
"=",
"os",
".",
"path",
".",
"relpat... | Update a file | [
"Update",
"a",
"file"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L156-L161 |
PlaidWeb/Publ | publ/index.py | IndexWatchdog.on_created | def on_created(self, event):
""" on_created handler """
logger.debug("file created: %s", event.src_path)
if not event.is_directory:
self.update_file(event.src_path) | python | def on_created(self, event):
""" on_created handler """
logger.debug("file created: %s", event.src_path)
if not event.is_directory:
self.update_file(event.src_path) | [
"def",
"on_created",
"(",
"self",
",",
"event",
")",
":",
"logger",
".",
"debug",
"(",
"\"file created: %s\"",
",",
"event",
".",
"src_path",
")",
"if",
"not",
"event",
".",
"is_directory",
":",
"self",
".",
"update_file",
"(",
"event",
".",
"src_path",
... | on_created handler | [
"on_created",
"handler"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L163-L167 |
PlaidWeb/Publ | publ/index.py | IndexWatchdog.on_modified | def on_modified(self, event):
""" on_modified handler """
logger.debug("file modified: %s", event.src_path)
if not event.is_directory:
self.update_file(event.src_path) | python | def on_modified(self, event):
""" on_modified handler """
logger.debug("file modified: %s", event.src_path)
if not event.is_directory:
self.update_file(event.src_path) | [
"def",
"on_modified",
"(",
"self",
",",
"event",
")",
":",
"logger",
".",
"debug",
"(",
"\"file modified: %s\"",
",",
"event",
".",
"src_path",
")",
"if",
"not",
"event",
".",
"is_directory",
":",
"self",
".",
"update_file",
"(",
"event",
".",
"src_path",
... | on_modified handler | [
"on_modified",
"handler"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L169-L173 |
PlaidWeb/Publ | publ/index.py | IndexWatchdog.on_moved | def on_moved(self, event):
""" on_moved handler """
logger.debug("file moved: %s -> %s", event.src_path, event.dest_path)
if not event.is_directory:
self.update_file(event.dest_path) | python | def on_moved(self, event):
""" on_moved handler """
logger.debug("file moved: %s -> %s", event.src_path, event.dest_path)
if not event.is_directory:
self.update_file(event.dest_path) | [
"def",
"on_moved",
"(",
"self",
",",
"event",
")",
":",
"logger",
".",
"debug",
"(",
"\"file moved: %s -> %s\"",
",",
"event",
".",
"src_path",
",",
"event",
".",
"dest_path",
")",
"if",
"not",
"event",
".",
"is_directory",
":",
"self",
".",
"update_file",... | on_moved handler | [
"on_moved",
"handler"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L175-L179 |
PlaidWeb/Publ | publ/index.py | IndexWatchdog.on_deleted | def on_deleted(self, event):
""" on_deleted handler """
logger.debug("File deleted: %s", event.src_path)
if not event.is_directory:
self.update_file(event.src_path) | python | def on_deleted(self, event):
""" on_deleted handler """
logger.debug("File deleted: %s", event.src_path)
if not event.is_directory:
self.update_file(event.src_path) | [
"def",
"on_deleted",
"(",
"self",
",",
"event",
")",
":",
"logger",
".",
"debug",
"(",
"\"File deleted: %s\"",
",",
"event",
".",
"src_path",
")",
"if",
"not",
"event",
".",
"is_directory",
":",
"self",
".",
"update_file",
"(",
"event",
".",
"src_path",
... | on_deleted handler | [
"on_deleted",
"handler"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/index.py#L181-L185 |
PlaidWeb/Publ | publ/view.py | parse_view_spec | def parse_view_spec(args):
""" Parse a view specification from a request arg list """
view_spec = {}
if 'date' in args:
view_spec['date'] = args['date']
elif 'id' in args:
view_spec['start'] = args['id']
if 'tag' in args:
view_spec['tag'] = args.getlist('tag')
if l... | python | def parse_view_spec(args):
""" Parse a view specification from a request arg list """
view_spec = {}
if 'date' in args:
view_spec['date'] = args['date']
elif 'id' in args:
view_spec['start'] = args['id']
if 'tag' in args:
view_spec['tag'] = args.getlist('tag')
if l... | [
"def",
"parse_view_spec",
"(",
"args",
")",
":",
"view_spec",
"=",
"{",
"}",
"if",
"'date'",
"in",
"args",
":",
"view_spec",
"[",
"'date'",
"]",
"=",
"args",
"[",
"'date'",
"]",
"elif",
"'id'",
"in",
"args",
":",
"view_spec",
"[",
"'start'",
"]",
"="... | Parse a view specification from a request arg list | [
"Parse",
"a",
"view",
"specification",
"from",
"a",
"request",
"arg",
"list"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L414-L429 |
PlaidWeb/Publ | publ/view.py | View.deleted | def deleted(self):
""" Gets the deleted entries from the view """
query = queries.build_query({**self.spec,
'future': False,
'_deleted': True})
return [Entry(e) for e in query] | python | def deleted(self):
""" Gets the deleted entries from the view """
query = queries.build_query({**self.spec,
'future': False,
'_deleted': True})
return [Entry(e) for e in query] | [
"def",
"deleted",
"(",
"self",
")",
":",
"query",
"=",
"queries",
".",
"build_query",
"(",
"{",
"*",
"*",
"self",
".",
"spec",
",",
"'future'",
":",
"False",
",",
"'_deleted'",
":",
"True",
"}",
")",
"return",
"[",
"Entry",
"(",
"e",
")",
"for",
... | Gets the deleted entries from the view | [
"Gets",
"the",
"deleted",
"entries",
"from",
"the",
"view"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L155-L160 |
PlaidWeb/Publ | publ/view.py | View.last_modified | def last_modified(self):
""" Gets the most recent modification time for all entries in the view """
if self.entries:
latest = max(self.entries, key=lambda x: x.last_modified)
return arrow.get(latest.last_modified)
return arrow.get() | python | def last_modified(self):
""" Gets the most recent modification time for all entries in the view """
if self.entries:
latest = max(self.entries, key=lambda x: x.last_modified)
return arrow.get(latest.last_modified)
return arrow.get() | [
"def",
"last_modified",
"(",
"self",
")",
":",
"if",
"self",
".",
"entries",
":",
"latest",
"=",
"max",
"(",
"self",
".",
"entries",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"last_modified",
")",
"return",
"arrow",
".",
"get",
"(",
"latest",
... | Gets the most recent modification time for all entries in the view | [
"Gets",
"the",
"most",
"recent",
"modification",
"time",
"for",
"all",
"entries",
"in",
"the",
"view"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L168-L173 |
PlaidWeb/Publ | publ/view.py | View.previous | def previous(self):
""" Gets the previous page, respecting sort order """
if self._order_by == 'oldest':
return self.older
if self._order_by == 'newest':
return self.newer
return None | python | def previous(self):
""" Gets the previous page, respecting sort order """
if self._order_by == 'oldest':
return self.older
if self._order_by == 'newest':
return self.newer
return None | [
"def",
"previous",
"(",
"self",
")",
":",
"if",
"self",
".",
"_order_by",
"==",
"'oldest'",
":",
"return",
"self",
".",
"older",
"if",
"self",
".",
"_order_by",
"==",
"'newest'",
":",
"return",
"self",
".",
"newer",
"return",
"None"
] | Gets the previous page, respecting sort order | [
"Gets",
"the",
"previous",
"page",
"respecting",
"sort",
"order"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L188-L194 |
PlaidWeb/Publ | publ/view.py | View.next | def next(self):
""" Gets the next page, respecting sort order """
if self._order_by == 'oldest':
return self.newer
if self._order_by == 'newest':
return self.older
return None | python | def next(self):
""" Gets the next page, respecting sort order """
if self._order_by == 'oldest':
return self.newer
if self._order_by == 'newest':
return self.older
return None | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"_order_by",
"==",
"'oldest'",
":",
"return",
"self",
".",
"newer",
"if",
"self",
".",
"_order_by",
"==",
"'newest'",
":",
"return",
"self",
".",
"older",
"return",
"None"
] | Gets the next page, respecting sort order | [
"Gets",
"the",
"next",
"page",
"respecting",
"sort",
"order"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L197-L203 |
PlaidWeb/Publ | publ/view.py | View.newest | def newest(self):
""" Gets the newest entry in the view, regardless of sort order """
if self._order_by == 'newest':
return self.first
if self._order_by == 'oldest':
return self.last
return max(self.entries, key=lambda x: (x.date, x.id)) | python | def newest(self):
""" Gets the newest entry in the view, regardless of sort order """
if self._order_by == 'newest':
return self.first
if self._order_by == 'oldest':
return self.last
return max(self.entries, key=lambda x: (x.date, x.id)) | [
"def",
"newest",
"(",
"self",
")",
":",
"if",
"self",
".",
"_order_by",
"==",
"'newest'",
":",
"return",
"self",
".",
"first",
"if",
"self",
".",
"_order_by",
"==",
"'oldest'",
":",
"return",
"self",
".",
"last",
"return",
"max",
"(",
"self",
".",
"e... | Gets the newest entry in the view, regardless of sort order | [
"Gets",
"the",
"newest",
"entry",
"in",
"the",
"view",
"regardless",
"of",
"sort",
"order"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L206-L212 |
PlaidWeb/Publ | publ/view.py | View.oldest | def oldest(self):
""" Gets the oldest entry in the view, regardless of sort order """
if self._order_by == 'newest':
return self.last
if self._order_by == 'oldest':
return self.first
return min(self.entries, key=lambda x: (x.date, -x.id)) | python | def oldest(self):
""" Gets the oldest entry in the view, regardless of sort order """
if self._order_by == 'newest':
return self.last
if self._order_by == 'oldest':
return self.first
return min(self.entries, key=lambda x: (x.date, -x.id)) | [
"def",
"oldest",
"(",
"self",
")",
":",
"if",
"self",
".",
"_order_by",
"==",
"'newest'",
":",
"return",
"self",
".",
"last",
"if",
"self",
".",
"_order_by",
"==",
"'oldest'",
":",
"return",
"self",
".",
"first",
"return",
"min",
"(",
"self",
".",
"e... | Gets the oldest entry in the view, regardless of sort order | [
"Gets",
"the",
"oldest",
"entry",
"in",
"the",
"view",
"regardless",
"of",
"sort",
"order"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L215-L221 |
PlaidWeb/Publ | publ/view.py | View.paging | def paging(self):
""" Gets the pagination type; compatible with entry.archive(page_type=...) """
if 'date' in self.spec:
_, date_span, _ = utils.parse_date(self.spec['date'])
return date_span
return 'offset' | python | def paging(self):
""" Gets the pagination type; compatible with entry.archive(page_type=...) """
if 'date' in self.spec:
_, date_span, _ = utils.parse_date(self.spec['date'])
return date_span
return 'offset' | [
"def",
"paging",
"(",
"self",
")",
":",
"if",
"'date'",
"in",
"self",
".",
"spec",
":",
"_",
",",
"date_span",
",",
"_",
"=",
"utils",
".",
"parse_date",
"(",
"self",
".",
"spec",
"[",
"'date'",
"]",
")",
"return",
"date_span",
"return",
"'offset'"
] | Gets the pagination type; compatible with entry.archive(page_type=...) | [
"Gets",
"the",
"pagination",
"type",
";",
"compatible",
"with",
"entry",
".",
"archive",
"(",
"page_type",
"=",
"...",
")"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L224-L229 |
PlaidWeb/Publ | publ/view.py | View.pages | def pages(self):
""" Gets a list of all pages for this view """
cur = self
pages = []
while cur.previous:
cur = cur.previous
while cur:
pages.append(cur)
cur = cur.next
return pages | python | def pages(self):
""" Gets a list of all pages for this view """
cur = self
pages = []
while cur.previous:
cur = cur.previous
while cur:
pages.append(cur)
cur = cur.next
return pages | [
"def",
"pages",
"(",
"self",
")",
":",
"cur",
"=",
"self",
"pages",
"=",
"[",
"]",
"while",
"cur",
".",
"previous",
":",
"cur",
"=",
"cur",
".",
"previous",
"while",
"cur",
":",
"pages",
".",
"append",
"(",
"cur",
")",
"cur",
"=",
"cur",
".",
"... | Gets a list of all pages for this view | [
"Gets",
"a",
"list",
"of",
"all",
"pages",
"for",
"this",
"view"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L232-L241 |
PlaidWeb/Publ | publ/view.py | View.tags | def tags(self):
""" Returns a list of all the tags applied to this view """
tag_list = self.spec.get('tag', [])
if isinstance(tag_list, (list, set, tuple)):
return list(tag_list)
return [tag_list] | python | def tags(self):
""" Returns a list of all the tags applied to this view """
tag_list = self.spec.get('tag', [])
if isinstance(tag_list, (list, set, tuple)):
return list(tag_list)
return [tag_list] | [
"def",
"tags",
"(",
"self",
")",
":",
"tag_list",
"=",
"self",
".",
"spec",
".",
"get",
"(",
"'tag'",
",",
"[",
"]",
")",
"if",
"isinstance",
"(",
"tag_list",
",",
"(",
"list",
",",
"set",
",",
"tuple",
")",
")",
":",
"return",
"list",
"(",
"ta... | Returns a list of all the tags applied to this view | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"tags",
"applied",
"to",
"this",
"view"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L254-L259 |
PlaidWeb/Publ | publ/view.py | View._pagination | def _pagination(self):
""" Compute the neighboring pages from this view.
Returns a tuple of older page, newer page.
"""
oldest = self.oldest
newest = self.newest
base = {key: val for key, val in self.spec.items()
if key not in OFFSET_PRIORITY}
... | python | def _pagination(self):
""" Compute the neighboring pages from this view.
Returns a tuple of older page, newer page.
"""
oldest = self.oldest
newest = self.newest
base = {key: val for key, val in self.spec.items()
if key not in OFFSET_PRIORITY}
... | [
"def",
"_pagination",
"(",
"self",
")",
":",
"oldest",
"=",
"self",
".",
"oldest",
"newest",
"=",
"self",
".",
"newest",
"base",
"=",
"{",
"key",
":",
"val",
"for",
"key",
",",
"val",
"in",
"self",
".",
"spec",
".",
"items",
"(",
")",
"if",
"key"... | Compute the neighboring pages from this view.
Returns a tuple of older page, newer page. | [
"Compute",
"the",
"neighboring",
"pages",
"from",
"this",
"view",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L262-L293 |
PlaidWeb/Publ | publ/view.py | View._get_date_pagination | def _get_date_pagination(self, base, oldest_neighbor, newest_neighbor):
""" Compute the pagination for date-based views """
_, span, date_format = utils.parse_date(self.spec['date'])
if newest_neighbor:
newer_date = newest_neighbor.date.span(span)[0]
newer_view = View({*... | python | def _get_date_pagination(self, base, oldest_neighbor, newest_neighbor):
""" Compute the pagination for date-based views """
_, span, date_format = utils.parse_date(self.spec['date'])
if newest_neighbor:
newer_date = newest_neighbor.date.span(span)[0]
newer_view = View({*... | [
"def",
"_get_date_pagination",
"(",
"self",
",",
"base",
",",
"oldest_neighbor",
",",
"newest_neighbor",
")",
":",
"_",
",",
"span",
",",
"date_format",
"=",
"utils",
".",
"parse_date",
"(",
"self",
".",
"spec",
"[",
"'date'",
"]",
")",
"if",
"newest_neigh... | Compute the pagination for date-based views | [
"Compute",
"the",
"pagination",
"for",
"date",
"-",
"based",
"views"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L295-L315 |
PlaidWeb/Publ | publ/view.py | View._get_count_pagination | def _get_count_pagination(self, base, oldest_neighbor, newest_neighbor):
""" Compute the pagination for count-based views """
count = self.spec['count']
out_spec = {**base, 'count': count, 'order': self._order_by}
if self._order_by == 'newest':
older_view = View({**out_spe... | python | def _get_count_pagination(self, base, oldest_neighbor, newest_neighbor):
""" Compute the pagination for count-based views """
count = self.spec['count']
out_spec = {**base, 'count': count, 'order': self._order_by}
if self._order_by == 'newest':
older_view = View({**out_spe... | [
"def",
"_get_count_pagination",
"(",
"self",
",",
"base",
",",
"oldest_neighbor",
",",
"newest_neighbor",
")",
":",
"count",
"=",
"self",
".",
"spec",
"[",
"'count'",
"]",
"out_spec",
"=",
"{",
"*",
"*",
"base",
",",
"'count'",
":",
"count",
",",
"'order... | Compute the pagination for count-based views | [
"Compute",
"the",
"pagination",
"for",
"count",
"-",
"based",
"views"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L317-L350 |
PlaidWeb/Publ | publ/view.py | View.tag_add | def tag_add(self, *tags):
""" Return a view with the specified tags added """
return View({**self.spec, 'tag': list(set(self.tags) | set(tags))}) | python | def tag_add(self, *tags):
""" Return a view with the specified tags added """
return View({**self.spec, 'tag': list(set(self.tags) | set(tags))}) | [
"def",
"tag_add",
"(",
"self",
",",
"*",
"tags",
")",
":",
"return",
"View",
"(",
"{",
"*",
"*",
"self",
".",
"spec",
",",
"'tag'",
":",
"list",
"(",
"set",
"(",
"self",
".",
"tags",
")",
"|",
"set",
"(",
"tags",
")",
")",
"}",
")"
] | Return a view with the specified tags added | [
"Return",
"a",
"view",
"with",
"the",
"specified",
"tags",
"added"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L355-L357 |
PlaidWeb/Publ | publ/view.py | View.tag_remove | def tag_remove(self, *tags):
""" Return a view with the specified tags removed """
return View({**self.spec, 'tag': list(set(self.tags) - set(tags))}) | python | def tag_remove(self, *tags):
""" Return a view with the specified tags removed """
return View({**self.spec, 'tag': list(set(self.tags) - set(tags))}) | [
"def",
"tag_remove",
"(",
"self",
",",
"*",
"tags",
")",
":",
"return",
"View",
"(",
"{",
"*",
"*",
"self",
".",
"spec",
",",
"'tag'",
":",
"list",
"(",
"set",
"(",
"self",
".",
"tags",
")",
"-",
"set",
"(",
"tags",
")",
")",
"}",
")"
] | Return a view with the specified tags removed | [
"Return",
"a",
"view",
"with",
"the",
"specified",
"tags",
"removed"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L359-L361 |
PlaidWeb/Publ | publ/view.py | View.tag_toggle | def tag_toggle(self, *tags):
""" Return a view with the specified tags toggled """
return View({**self.spec, 'tag': list(set(self.tags) ^ set(tags))}) | python | def tag_toggle(self, *tags):
""" Return a view with the specified tags toggled """
return View({**self.spec, 'tag': list(set(self.tags) ^ set(tags))}) | [
"def",
"tag_toggle",
"(",
"self",
",",
"*",
"tags",
")",
":",
"return",
"View",
"(",
"{",
"*",
"*",
"self",
".",
"spec",
",",
"'tag'",
":",
"list",
"(",
"set",
"(",
"self",
".",
"tags",
")",
"^",
"set",
"(",
"tags",
")",
")",
"}",
")"
] | Return a view with the specified tags toggled | [
"Return",
"a",
"view",
"with",
"the",
"specified",
"tags",
"toggled"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L363-L365 |
PlaidWeb/Publ | publ/markdown.py | to_html | def to_html(text, config, search_path):
""" Convert Markdown text to HTML """
processor = misaka.Markdown(HtmlRenderer(config, search_path),
extensions=ENABLED_EXTENSIONS)
text = processor(text)
if not config.get('no_smartquotes'):
text = misaka.smartypants(text)... | python | def to_html(text, config, search_path):
""" Convert Markdown text to HTML """
processor = misaka.Markdown(HtmlRenderer(config, search_path),
extensions=ENABLED_EXTENSIONS)
text = processor(text)
if not config.get('no_smartquotes'):
text = misaka.smartypants(text)... | [
"def",
"to_html",
"(",
"text",
",",
"config",
",",
"search_path",
")",
":",
"processor",
"=",
"misaka",
".",
"Markdown",
"(",
"HtmlRenderer",
"(",
"config",
",",
"search_path",
")",
",",
"extensions",
"=",
"ENABLED_EXTENSIONS",
")",
"text",
"=",
"processor",... | Convert Markdown text to HTML | [
"Convert",
"Markdown",
"text",
"to",
"HTML"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/markdown.py#L167-L176 |
PlaidWeb/Publ | publ/markdown.py | render_title | def render_title(text, markup=True, no_smartquotes=False):
""" Convert a Markdown title to HTML """
# HACK: If the title starts with something that looks like a list, save it
# for later
pfx, text = re.match(r'([0-9. ]*)(.*)', text).group(1, 2)
text = pfx + misaka.Markdown(TitleRenderer(),
... | python | def render_title(text, markup=True, no_smartquotes=False):
""" Convert a Markdown title to HTML """
# HACK: If the title starts with something that looks like a list, save it
# for later
pfx, text = re.match(r'([0-9. ]*)(.*)', text).group(1, 2)
text = pfx + misaka.Markdown(TitleRenderer(),
... | [
"def",
"render_title",
"(",
"text",
",",
"markup",
"=",
"True",
",",
"no_smartquotes",
"=",
"False",
")",
":",
"# HACK: If the title starts with something that looks like a list, save it",
"# for later",
"pfx",
",",
"text",
"=",
"re",
".",
"match",
"(",
"r'([0-9. ]*)(... | Convert a Markdown title to HTML | [
"Convert",
"a",
"Markdown",
"title",
"to",
"HTML"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/markdown.py#L218-L235 |
PlaidWeb/Publ | publ/markdown.py | HtmlRenderer.image | def image(self, raw_url, title='', alt=''):
""" Adapt a standard Markdown image to a generated rendition set.
Container arguments used (in addition to the rendition tags):
div_class -- The CSS class name to use on any wrapper div
div_style -- Additional CSS styles to apply to the wrapp... | python | def image(self, raw_url, title='', alt=''):
""" Adapt a standard Markdown image to a generated rendition set.
Container arguments used (in addition to the rendition tags):
div_class -- The CSS class name to use on any wrapper div
div_style -- Additional CSS styles to apply to the wrapp... | [
"def",
"image",
"(",
"self",
",",
"raw_url",
",",
"title",
"=",
"''",
",",
"alt",
"=",
"''",
")",
":",
"# pylint: disable=too-many-locals",
"text",
"=",
"''",
"image_specs",
"=",
"raw_url",
"if",
"title",
":",
"image_specs",
"+=",
"' \"{}\"'",
".",
"format... | Adapt a standard Markdown image to a generated rendition set.
Container arguments used (in addition to the rendition tags):
div_class -- The CSS class name to use on any wrapper div
div_style -- Additional CSS styles to apply to the wrapper div
count -- The maximum number of images to ... | [
"Adapt",
"a",
"standard",
"Markdown",
"image",
"to",
"a",
"generated",
"rendition",
"set",
"."
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/markdown.py#L43-L101 |
PlaidWeb/Publ | publ/markdown.py | HtmlRenderer.blockcode | def blockcode(self, text, lang):
""" Pass a code fence through pygments """
if lang and self._config.get('highlight_syntax', 'True'):
try:
lexer = pygments.lexers.get_lexer_by_name(lang, stripall=True)
except pygments.lexers.ClassNotFound:
lexer = ... | python | def blockcode(self, text, lang):
""" Pass a code fence through pygments """
if lang and self._config.get('highlight_syntax', 'True'):
try:
lexer = pygments.lexers.get_lexer_by_name(lang, stripall=True)
except pygments.lexers.ClassNotFound:
lexer = ... | [
"def",
"blockcode",
"(",
"self",
",",
"text",
",",
"lang",
")",
":",
"if",
"lang",
"and",
"self",
".",
"_config",
".",
"get",
"(",
"'highlight_syntax'",
",",
"'True'",
")",
":",
"try",
":",
"lexer",
"=",
"pygments",
".",
"lexers",
".",
"get_lexer_by_na... | Pass a code fence through pygments | [
"Pass",
"a",
"code",
"fence",
"through",
"pygments"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/markdown.py#L103-L116 |
PlaidWeb/Publ | publ/markdown.py | HtmlRenderer.link | def link(self, content, link, title=''):
""" Emit a link, potentially remapped based on our embed or static rules """
link = links.resolve(link, self._search_path,
self._config.get('absolute'))
return '{}{}</a>'.format(
utils.make_tag('a', {
... | python | def link(self, content, link, title=''):
""" Emit a link, potentially remapped based on our embed or static rules """
link = links.resolve(link, self._search_path,
self._config.get('absolute'))
return '{}{}</a>'.format(
utils.make_tag('a', {
... | [
"def",
"link",
"(",
"self",
",",
"content",
",",
"link",
",",
"title",
"=",
"''",
")",
":",
"link",
"=",
"links",
".",
"resolve",
"(",
"link",
",",
"self",
".",
"_search_path",
",",
"self",
".",
"_config",
".",
"get",
"(",
"'absolute'",
")",
")",
... | Emit a link, potentially remapped based on our embed or static rules | [
"Emit",
"a",
"link",
"potentially",
"remapped",
"based",
"on",
"our",
"embed",
"or",
"static",
"rules"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/markdown.py#L118-L129 |
PlaidWeb/Publ | publ/markdown.py | HtmlRenderer.paragraph | def paragraph(content):
""" emit a paragraph, stripping out any leading or following empty paragraphs """
# if the content contains a top-level div then don't wrap it in a <p>
# tag
if content.startswith('<div') and content.endswith('</div>'):
return '\n' + content + '\n'
... | python | def paragraph(content):
""" emit a paragraph, stripping out any leading or following empty paragraphs """
# if the content contains a top-level div then don't wrap it in a <p>
# tag
if content.startswith('<div') and content.endswith('</div>'):
return '\n' + content + '\n'
... | [
"def",
"paragraph",
"(",
"content",
")",
":",
"# if the content contains a top-level div then don't wrap it in a <p>",
"# tag",
"if",
"content",
".",
"startswith",
"(",
"'<div'",
")",
"and",
"content",
".",
"endswith",
"(",
"'</div>'",
")",
":",
"return",
"'\\n'",
"... | emit a paragraph, stripping out any leading or following empty paragraphs | [
"emit",
"a",
"paragraph",
"stripping",
"out",
"any",
"leading",
"or",
"following",
"empty",
"paragraphs"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/markdown.py#L132-L142 |
PlaidWeb/Publ | publ/markdown.py | HtmlRenderer._render_image | def _render_image(self, spec, container_args, alt_text=None):
""" Render an image specification into an <img> tag """
try:
path, image_args, title = image.parse_image_spec(spec)
except Exception as err: # pylint: disable=broad-except
logger.exception("Got error on spec ... | python | def _render_image(self, spec, container_args, alt_text=None):
""" Render an image specification into an <img> tag """
try:
path, image_args, title = image.parse_image_spec(spec)
except Exception as err: # pylint: disable=broad-except
logger.exception("Got error on spec ... | [
"def",
"_render_image",
"(",
"self",
",",
"spec",
",",
"container_args",
",",
"alt_text",
"=",
"None",
")",
":",
"try",
":",
"path",
",",
"image_args",
",",
"title",
"=",
"image",
".",
"parse_image_spec",
"(",
"spec",
")",
"except",
"Exception",
"as",
"e... | Render an image specification into an <img> tag | [
"Render",
"an",
"image",
"specification",
"into",
"an",
"<img",
">",
"tag"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/markdown.py#L144-L164 |
PlaidWeb/Publ | publ/links.py | resolve | def resolve(path, search_path, absolute=False):
""" Remap a link or source target to an appropriate entry or image rendition """
# Resolve external URLs
if re.match(r'([a-z][a-z0-9+.\-]*:)?//', path, re.I):
return path
# Resolve static assets
if path.startswith('@'):
return utils.s... | python | def resolve(path, search_path, absolute=False):
""" Remap a link or source target to an appropriate entry or image rendition """
# Resolve external URLs
if re.match(r'([a-z][a-z0-9+.\-]*:)?//', path, re.I):
return path
# Resolve static assets
if path.startswith('@'):
return utils.s... | [
"def",
"resolve",
"(",
"path",
",",
"search_path",
",",
"absolute",
"=",
"False",
")",
":",
"# Resolve external URLs",
"if",
"re",
".",
"match",
"(",
"r'([a-z][a-z0-9+.\\-]*:)?//'",
",",
"path",
",",
"re",
".",
"I",
")",
":",
"return",
"path",
"# Resolve sta... | Remap a link or source target to an appropriate entry or image rendition | [
"Remap",
"a",
"link",
"or",
"source",
"target",
"to",
"an",
"appropriate",
"entry",
"or",
"image",
"rendition"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/links.py#L10-L33 |
PlaidWeb/Publ | publ/caching.py | do_not_cache | def do_not_cache():
""" Return whether we should cache a page render """
from . import index # pylint: disable=cyclic-import
if index.in_progress():
# We are reindexing the site
return True
if request.if_none_match or request.if_modified_since:
# we might be returning a 304 N... | python | def do_not_cache():
""" Return whether we should cache a page render """
from . import index # pylint: disable=cyclic-import
if index.in_progress():
# We are reindexing the site
return True
if request.if_none_match or request.if_modified_since:
# we might be returning a 304 N... | [
"def",
"do_not_cache",
"(",
")",
":",
"from",
".",
"import",
"index",
"# pylint: disable=cyclic-import",
"if",
"index",
".",
"in_progress",
"(",
")",
":",
"# We are reindexing the site",
"return",
"True",
"if",
"request",
".",
"if_none_match",
"or",
"request",
"."... | Return whether we should cache a page render | [
"Return",
"whether",
"we",
"should",
"cache",
"a",
"page",
"render"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/caching.py#L20-L35 |
PlaidWeb/Publ | publ/queries.py | where_entry_visible | def where_entry_visible(query, date=None):
""" Generate a where clause for currently-visible entries
Arguments:
date -- The date to generate it relative to (defaults to right now)
"""
return orm.select(
e for e in query
if e.status == model.PublishStatus.PUBLISHED.value or
... | python | def where_entry_visible(query, date=None):
""" Generate a where clause for currently-visible entries
Arguments:
date -- The date to generate it relative to (defaults to right now)
"""
return orm.select(
e for e in query
if e.status == model.PublishStatus.PUBLISHED.value or
... | [
"def",
"where_entry_visible",
"(",
"query",
",",
"date",
"=",
"None",
")",
":",
"return",
"orm",
".",
"select",
"(",
"e",
"for",
"e",
"in",
"query",
"if",
"e",
".",
"status",
"==",
"model",
".",
"PublishStatus",
".",
"PUBLISHED",
".",
"value",
"or",
... | Generate a where clause for currently-visible entries
Arguments:
date -- The date to generate it relative to (defaults to right now) | [
"Generate",
"a",
"where",
"clause",
"for",
"currently",
"-",
"visible",
"entries"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L10-L24 |
PlaidWeb/Publ | publ/queries.py | where_entry_visible_future | def where_entry_visible_future(query):
""" Generate a where clause for entries that are visible now or in the future """
return orm.select(
e for e in query
if e.status in (model.PublishStatus.PUBLISHED.value,
model.PublishStatus.SCHEDULED.value)) | python | def where_entry_visible_future(query):
""" Generate a where clause for entries that are visible now or in the future """
return orm.select(
e for e in query
if e.status in (model.PublishStatus.PUBLISHED.value,
model.PublishStatus.SCHEDULED.value)) | [
"def",
"where_entry_visible_future",
"(",
"query",
")",
":",
"return",
"orm",
".",
"select",
"(",
"e",
"for",
"e",
"in",
"query",
"if",
"e",
".",
"status",
"in",
"(",
"model",
".",
"PublishStatus",
".",
"PUBLISHED",
".",
"value",
",",
"model",
".",
"Pu... | Generate a where clause for entries that are visible now or in the future | [
"Generate",
"a",
"where",
"clause",
"for",
"entries",
"that",
"are",
"visible",
"now",
"or",
"in",
"the",
"future"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L27-L33 |
PlaidWeb/Publ | publ/queries.py | where_entry_deleted | def where_entry_deleted(query):
""" Generate a where clause for entries that have been deleted """
return orm.select(
e for e in query
if e.status == model.PublishStatus.GONE.value) | python | def where_entry_deleted(query):
""" Generate a where clause for entries that have been deleted """
return orm.select(
e for e in query
if e.status == model.PublishStatus.GONE.value) | [
"def",
"where_entry_deleted",
"(",
"query",
")",
":",
"return",
"orm",
".",
"select",
"(",
"e",
"for",
"e",
"in",
"query",
"if",
"e",
".",
"status",
"==",
"model",
".",
"PublishStatus",
".",
"GONE",
".",
"value",
")"
] | Generate a where clause for entries that have been deleted | [
"Generate",
"a",
"where",
"clause",
"for",
"entries",
"that",
"have",
"been",
"deleted"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L36-L40 |
PlaidWeb/Publ | publ/queries.py | where_entry_category | def where_entry_category(query, category, recurse=False):
""" Generate a where clause for a particular category """
category = str(category)
if category and recurse:
# We're recursing and aren't in /, so add the prefix clause
return orm.select(
e for e in query
if e.... | python | def where_entry_category(query, category, recurse=False):
""" Generate a where clause for a particular category """
category = str(category)
if category and recurse:
# We're recursing and aren't in /, so add the prefix clause
return orm.select(
e for e in query
if e.... | [
"def",
"where_entry_category",
"(",
"query",
",",
"category",
",",
"recurse",
"=",
"False",
")",
":",
"category",
"=",
"str",
"(",
"category",
")",
"if",
"category",
"and",
"recurse",
":",
"# We're recursing and aren't in /, so add the prefix clause",
"return",
"orm... | Generate a where clause for a particular category | [
"Generate",
"a",
"where",
"clause",
"for",
"a",
"particular",
"category"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L43-L60 |
PlaidWeb/Publ | publ/queries.py | where_before_entry | def where_before_entry(query, ref):
""" Generate a where clause for prior entries
ref -- The entry of reference
"""
return orm.select(
e for e in query
if e.local_date < ref.local_date or
(e.local_date == ref.local_date and e.id < ref.id)
) | python | def where_before_entry(query, ref):
""" Generate a where clause for prior entries
ref -- The entry of reference
"""
return orm.select(
e for e in query
if e.local_date < ref.local_date or
(e.local_date == ref.local_date and e.id < ref.id)
) | [
"def",
"where_before_entry",
"(",
"query",
",",
"ref",
")",
":",
"return",
"orm",
".",
"select",
"(",
"e",
"for",
"e",
"in",
"query",
"if",
"e",
".",
"local_date",
"<",
"ref",
".",
"local_date",
"or",
"(",
"e",
".",
"local_date",
"==",
"ref",
".",
... | Generate a where clause for prior entries
ref -- The entry of reference | [
"Generate",
"a",
"where",
"clause",
"for",
"prior",
"entries"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L63-L72 |
PlaidWeb/Publ | publ/queries.py | where_after_entry | def where_after_entry(query, ref):
""" Generate a where clause for later entries
ref -- the entry of reference
"""
return orm.select(
e for e in query
if e.local_date > ref.local_date or
(e.local_date == ref.local_date and
e.id > ref.id
)
) | python | def where_after_entry(query, ref):
""" Generate a where clause for later entries
ref -- the entry of reference
"""
return orm.select(
e for e in query
if e.local_date > ref.local_date or
(e.local_date == ref.local_date and
e.id > ref.id
)
) | [
"def",
"where_after_entry",
"(",
"query",
",",
"ref",
")",
":",
"return",
"orm",
".",
"select",
"(",
"e",
"for",
"e",
"in",
"query",
"if",
"e",
".",
"local_date",
">",
"ref",
".",
"local_date",
"or",
"(",
"e",
".",
"local_date",
"==",
"ref",
".",
"... | Generate a where clause for later entries
ref -- the entry of reference | [
"Generate",
"a",
"where",
"clause",
"for",
"later",
"entries"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L75-L86 |
PlaidWeb/Publ | publ/queries.py | where_entry_last | def where_entry_last(query, ref):
""" Generate a where clause where this is the last entry
ref -- the entry of reference
"""
return orm.select(
e for e in query
if e.local_date < ref.local_date or
(e.local_date == ref.local_date and
e.id <= ref.id
)
) | python | def where_entry_last(query, ref):
""" Generate a where clause where this is the last entry
ref -- the entry of reference
"""
return orm.select(
e for e in query
if e.local_date < ref.local_date or
(e.local_date == ref.local_date and
e.id <= ref.id
)
) | [
"def",
"where_entry_last",
"(",
"query",
",",
"ref",
")",
":",
"return",
"orm",
".",
"select",
"(",
"e",
"for",
"e",
"in",
"query",
"if",
"e",
".",
"local_date",
"<",
"ref",
".",
"local_date",
"or",
"(",
"e",
".",
"local_date",
"==",
"ref",
".",
"l... | Generate a where clause where this is the last entry
ref -- the entry of reference | [
"Generate",
"a",
"where",
"clause",
"where",
"this",
"is",
"the",
"last",
"entry"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L89-L100 |
PlaidWeb/Publ | publ/queries.py | where_entry_first | def where_entry_first(query, ref):
""" Generate a where clause where this is the first entry
ref -- the entry of reference
"""
return orm.select(
e for e in query
if e.local_date > ref.local_date or
(e.local_date == ref.local_date and
e.id >= ref.id
)
) | python | def where_entry_first(query, ref):
""" Generate a where clause where this is the first entry
ref -- the entry of reference
"""
return orm.select(
e for e in query
if e.local_date > ref.local_date or
(e.local_date == ref.local_date and
e.id >= ref.id
)
) | [
"def",
"where_entry_first",
"(",
"query",
",",
"ref",
")",
":",
"return",
"orm",
".",
"select",
"(",
"e",
"for",
"e",
"in",
"query",
"if",
"e",
".",
"local_date",
">",
"ref",
".",
"local_date",
"or",
"(",
"e",
".",
"local_date",
"==",
"ref",
".",
"... | Generate a where clause where this is the first entry
ref -- the entry of reference | [
"Generate",
"a",
"where",
"clause",
"where",
"this",
"is",
"the",
"first",
"entry"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L103-L114 |
PlaidWeb/Publ | publ/queries.py | where_entry_type | def where_entry_type(query, entry_type):
""" Generate a where clause for entries of certain types
entry_type -- one or more entries to check against
"""
if isinstance(entry_type, (list, set, tuple)):
return orm.select(e for e in query if e.entry_type in entry_type)
return orm.select(e for e... | python | def where_entry_type(query, entry_type):
""" Generate a where clause for entries of certain types
entry_type -- one or more entries to check against
"""
if isinstance(entry_type, (list, set, tuple)):
return orm.select(e for e in query if e.entry_type in entry_type)
return orm.select(e for e... | [
"def",
"where_entry_type",
"(",
"query",
",",
"entry_type",
")",
":",
"if",
"isinstance",
"(",
"entry_type",
",",
"(",
"list",
",",
"set",
",",
"tuple",
")",
")",
":",
"return",
"orm",
".",
"select",
"(",
"e",
"for",
"e",
"in",
"query",
"if",
"e",
... | Generate a where clause for entries of certain types
entry_type -- one or more entries to check against | [
"Generate",
"a",
"where",
"clause",
"for",
"entries",
"of",
"certain",
"types"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L117-L124 |
PlaidWeb/Publ | publ/queries.py | where_entry_tag | def where_entry_tag(query, tag):
""" Generate a where clause for entries with the given tag """
if isinstance(tag, (list, set, tuple)):
tags = [t.lower() for t in tag]
return orm.select(e for e in query for t in e.tags if t.key in tags)
return orm.select(e for e in query for t in e.tags if t... | python | def where_entry_tag(query, tag):
""" Generate a where clause for entries with the given tag """
if isinstance(tag, (list, set, tuple)):
tags = [t.lower() for t in tag]
return orm.select(e for e in query for t in e.tags if t.key in tags)
return orm.select(e for e in query for t in e.tags if t... | [
"def",
"where_entry_tag",
"(",
"query",
",",
"tag",
")",
":",
"if",
"isinstance",
"(",
"tag",
",",
"(",
"list",
",",
"set",
",",
"tuple",
")",
")",
":",
"tags",
"=",
"[",
"t",
".",
"lower",
"(",
")",
"for",
"t",
"in",
"tag",
"]",
"return",
"orm... | Generate a where clause for entries with the given tag | [
"Generate",
"a",
"where",
"clause",
"for",
"entries",
"with",
"the",
"given",
"tag"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L137-L142 |
PlaidWeb/Publ | publ/queries.py | where_entry_date | def where_entry_date(query, datespec):
""" Where clause for entries which match a textual date spec
datespec -- The date spec to check for, in YYYY[[-]MM[[-]DD]] format
"""
date, interval, _ = utils.parse_date(datespec)
start_date, end_date = date.span(interval)
return orm.select(
e fo... | python | def where_entry_date(query, datespec):
""" Where clause for entries which match a textual date spec
datespec -- The date spec to check for, in YYYY[[-]MM[[-]DD]] format
"""
date, interval, _ = utils.parse_date(datespec)
start_date, end_date = date.span(interval)
return orm.select(
e fo... | [
"def",
"where_entry_date",
"(",
"query",
",",
"datespec",
")",
":",
"date",
",",
"interval",
",",
"_",
"=",
"utils",
".",
"parse_date",
"(",
"datespec",
")",
"start_date",
",",
"end_date",
"=",
"date",
".",
"span",
"(",
"interval",
")",
"return",
"orm",
... | Where clause for entries which match a textual date spec
datespec -- The date spec to check for, in YYYY[[-]MM[[-]DD]] format | [
"Where",
"clause",
"for",
"entries",
"which",
"match",
"a",
"textual",
"date",
"spec"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L145-L157 |
PlaidWeb/Publ | publ/queries.py | get_entry | def get_entry(entry):
""" Helper function to get an entry by ID or by object """
if hasattr(entry, 'id'):
return entry
if isinstance(entry, (int, str)):
return model.Entry.get(id=int(entry))
raise ValueError("entry is of unknown type {}".format(type(entry))) | python | def get_entry(entry):
""" Helper function to get an entry by ID or by object """
if hasattr(entry, 'id'):
return entry
if isinstance(entry, (int, str)):
return model.Entry.get(id=int(entry))
raise ValueError("entry is of unknown type {}".format(type(entry))) | [
"def",
"get_entry",
"(",
"entry",
")",
":",
"if",
"hasattr",
"(",
"entry",
",",
"'id'",
")",
":",
"return",
"entry",
"if",
"isinstance",
"(",
"entry",
",",
"(",
"int",
",",
"str",
")",
")",
":",
"return",
"model",
".",
"Entry",
".",
"get",
"(",
"... | Helper function to get an entry by ID or by object | [
"Helper",
"function",
"to",
"get",
"an",
"entry",
"by",
"ID",
"or",
"by",
"object"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L160-L168 |
PlaidWeb/Publ | publ/queries.py | build_query | def build_query(spec):
""" build the where clause based on a view specification
spec -- The view specification. Contains the following possible values:
future -- Boolean; whether to include entries from the future
category -- Which category to limit to
recurse -- Whether to include subc... | python | def build_query(spec):
""" build the where clause based on a view specification
spec -- The view specification. Contains the following possible values:
future -- Boolean; whether to include entries from the future
category -- Which category to limit to
recurse -- Whether to include subc... | [
"def",
"build_query",
"(",
"spec",
")",
":",
"query",
"=",
"model",
".",
"Entry",
".",
"select",
"(",
")",
"# primarily restrict by publication status",
"if",
"spec",
".",
"get",
"(",
"'_deleted'",
",",
"False",
")",
":",
"query",
"=",
"where_entry_deleted",
... | build the where clause based on a view specification
spec -- The view specification. Contains the following possible values:
future -- Boolean; whether to include entries from the future
category -- Which category to limit to
recurse -- Whether to include subcategories
entry_type --... | [
"build",
"the",
"where",
"clause",
"based",
"on",
"a",
"view",
"specification"
] | train | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/queries.py#L171-L227 |
misakar/mana | mana/mana.py | start_init_info | def start_init_info(path):
"""
start init msg
"""
if os.path.isdir(path):
warning_path_exist(path)
exit(1)
else:
logger.info('''\033[33m{Info}\033[0m
==> start init your flask project [on]
==> \033[32m%s\033[0m\n''' % path) | python | def start_init_info(path):
"""
start init msg
"""
if os.path.isdir(path):
warning_path_exist(path)
exit(1)
else:
logger.info('''\033[33m{Info}\033[0m
==> start init your flask project [on]
==> \033[32m%s\033[0m\n''' % path) | [
"def",
"start_init_info",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"warning_path_exist",
"(",
"path",
")",
"exit",
"(",
"1",
")",
"else",
":",
"logger",
".",
"info",
"(",
"'''\\033[33m{Info}\\033[0m\n ==> star... | start init msg | [
"start",
"init",
"msg"
] | train | https://github.com/misakar/mana/blob/95ccdbf230ed7abc33ea2c878c66d2c8fc72ea69/mana/mana.py#L68-L78 |
misakar/mana | mana/mana.py | create_templates_static_files | def create_templates_static_files(app_path):
"""
create templates and static
"""
templates_path = os.path.join(app_path, 'templates')
static_path = os.path.join(app_path, 'static')
_mkdir_p(templates_path)
_mkdir_p(static_path)
# create {img, css, js}
os.chdir(static_path)
img_pa... | python | def create_templates_static_files(app_path):
"""
create templates and static
"""
templates_path = os.path.join(app_path, 'templates')
static_path = os.path.join(app_path, 'static')
_mkdir_p(templates_path)
_mkdir_p(static_path)
# create {img, css, js}
os.chdir(static_path)
img_pa... | [
"def",
"create_templates_static_files",
"(",
"app_path",
")",
":",
"templates_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app_path",
",",
"'templates'",
")",
"static_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app_path",
",",
"'static'",
")",
"... | create templates and static | [
"create",
"templates",
"and",
"static"
] | train | https://github.com/misakar/mana/blob/95ccdbf230ed7abc33ea2c878c66d2c8fc72ea69/mana/mana.py#L90-L107 |
misakar/mana | mana/mana.py | create_blueprint | def create_blueprint(app_path, blueprint, views_code, forms_code, templates_path):
"""
create blueprint
"""
blueprint_path = os.path.join(app_path, blueprint)
_mkdir_p(blueprint_path)
# create blueprint files
os.chdir(blueprint_path)
init_code('__init__.py', _init_blueprint_code % (blue... | python | def create_blueprint(app_path, blueprint, views_code, forms_code, templates_path):
"""
create blueprint
"""
blueprint_path = os.path.join(app_path, blueprint)
_mkdir_p(blueprint_path)
# create blueprint files
os.chdir(blueprint_path)
init_code('__init__.py', _init_blueprint_code % (blue... | [
"def",
"create_blueprint",
"(",
"app_path",
",",
"blueprint",
",",
"views_code",
",",
"forms_code",
",",
"templates_path",
")",
":",
"blueprint_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app_path",
",",
"blueprint",
")",
"_mkdir_p",
"(",
"blueprint_path... | create blueprint | [
"create",
"blueprint"
] | train | https://github.com/misakar/mana/blob/95ccdbf230ed7abc33ea2c878c66d2c8fc72ea69/mana/mana.py#L110-L126 |
misakar/mana | mana/mana.py | init | def init(project_name):
"""
build a minimal flask project
"""
# the destination path
dst_path = os.path.join(os.getcwd(), project_name)
start_init_info(dst_path)
# create dst path
_mkdir_p(dst_path)
os.chdir(dst_path)
# create files
init_code('manage.py', _manage_basic_cod... | python | def init(project_name):
"""
build a minimal flask project
"""
# the destination path
dst_path = os.path.join(os.getcwd(), project_name)
start_init_info(dst_path)
# create dst path
_mkdir_p(dst_path)
os.chdir(dst_path)
# create files
init_code('manage.py', _manage_basic_cod... | [
"def",
"init",
"(",
"project_name",
")",
":",
"# the destination path",
"dst_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"project_name",
")",
"start_init_info",
"(",
"dst_path",
")",
"# create dst path",
"_mkdir_p",
"... | build a minimal flask project | [
"build",
"a",
"minimal",
"flask",
"project"
] | train | https://github.com/misakar/mana/blob/95ccdbf230ed7abc33ea2c878c66d2c8fc72ea69/mana/mana.py#L163-L192 |
misakar/mana | mana/mana.py | blueprint | def blueprint(blueprint_name):
"""
create and register a blueprint
"""
app = os.getcwd().split('/')[-1]
if app != 'app':
logger.warning('''\033[31m{Warning}\033[0m
==> your current path is \033[32m%s\033[0m\n
==> please create your blueprint under app folder!''' % os.getcwd())
exit(1... | python | def blueprint(blueprint_name):
"""
create and register a blueprint
"""
app = os.getcwd().split('/')[-1]
if app != 'app':
logger.warning('''\033[31m{Warning}\033[0m
==> your current path is \033[32m%s\033[0m\n
==> please create your blueprint under app folder!''' % os.getcwd())
exit(1... | [
"def",
"blueprint",
"(",
"blueprint_name",
")",
":",
"app",
"=",
"os",
".",
"getcwd",
"(",
")",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"if",
"app",
"!=",
"'app'",
":",
"logger",
".",
"warning",
"(",
"'''\\033[31m{Warning}\\033[0m\n==> your cu... | create and register a blueprint | [
"create",
"and",
"register",
"a",
"blueprint"
] | train | https://github.com/misakar/mana/blob/95ccdbf230ed7abc33ea2c878c66d2c8fc72ea69/mana/mana.py#L197-L249 |
misakar/mana | mana/mana.py | startproject | def startproject(project_name):
"""
build a full status project
"""
# the destination path
dst_path = os.path.join(os.getcwd(), project_name)
start_init_info(dst_path)
# create dst path
_mkdir_p(dst_path)
# create project tree
os.chdir(dst_path)
# create files
init_code... | python | def startproject(project_name):
"""
build a full status project
"""
# the destination path
dst_path = os.path.join(os.getcwd(), project_name)
start_init_info(dst_path)
# create dst path
_mkdir_p(dst_path)
# create project tree
os.chdir(dst_path)
# create files
init_code... | [
"def",
"startproject",
"(",
"project_name",
")",
":",
"# the destination path",
"dst_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"project_name",
")",
"start_init_info",
"(",
"dst_path",
")",
"# create dst path",
"_mkdir... | build a full status project | [
"build",
"a",
"full",
"status",
"project"
] | train | https://github.com/misakar/mana/blob/95ccdbf230ed7abc33ea2c878c66d2c8fc72ea69/mana/mana.py#L254-L327 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.