repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
minhhoit/yacms | yacms/blog/management/base.py | BaseImporterCommand.add_comment | def add_comment(self, post=None, name=None, email=None, pub_date=None,
website=None, body=None):
"""
Adds a comment to the post provided.
"""
if post is None:
if not self.posts:
raise CommandError("Cannot add comments without posts")
... | python | def add_comment(self, post=None, name=None, email=None, pub_date=None,
website=None, body=None):
"""
Adds a comment to the post provided.
"""
if post is None:
if not self.posts:
raise CommandError("Cannot add comments without posts")
... | [
"def",
"add_comment",
"(",
"self",
",",
"post",
"=",
"None",
",",
"name",
"=",
"None",
",",
"email",
"=",
"None",
",",
"pub_date",
"=",
"None",
",",
"website",
"=",
"None",
",",
"body",
"=",
"None",
")",
":",
"if",
"post",
"is",
"None",
":",
"if"... | Adds a comment to the post provided. | [
"Adds",
"a",
"comment",
"to",
"the",
"post",
"provided",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/base.py#L106-L121 |
minhhoit/yacms | yacms/blog/management/base.py | BaseImporterCommand.trunc | def trunc(self, model, prompt, **fields):
"""
Truncates fields values for the given model. Prompts for a new
value if truncation occurs.
"""
for field_name, value in fields.items():
field = model._meta.get_field(field_name)
max_length = getattr(field, "max... | python | def trunc(self, model, prompt, **fields):
"""
Truncates fields values for the given model. Prompts for a new
value if truncation occurs.
"""
for field_name, value in fields.items():
field = model._meta.get_field(field_name)
max_length = getattr(field, "max... | [
"def",
"trunc",
"(",
"self",
",",
"model",
",",
"prompt",
",",
"*",
"*",
"fields",
")",
":",
"for",
"field_name",
",",
"value",
"in",
"fields",
".",
"items",
"(",
")",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
"... | Truncates fields values for the given model. Prompts for a new
value if truncation occurs. | [
"Truncates",
"fields",
"values",
"for",
"the",
"given",
"model",
".",
"Prompts",
"for",
"a",
"new",
"value",
"if",
"truncation",
"occurs",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/base.py#L123-L144 |
minhhoit/yacms | yacms/blog/management/base.py | BaseImporterCommand.handle | def handle(self, *args, **options):
"""
Processes the converted data into the yacms database correctly.
Attributes:
yacms_user: the user to put this data in against
date_format: the format the dates are in for posts and comments
"""
yacms_user = options.... | python | def handle(self, *args, **options):
"""
Processes the converted data into the yacms database correctly.
Attributes:
yacms_user: the user to put this data in against
date_format: the format the dates are in for posts and comments
"""
yacms_user = options.... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"yacms_user",
"=",
"options",
".",
"get",
"(",
"\"yacms_user\"",
")",
"site",
"=",
"Site",
".",
"objects",
".",
"get_current",
"(",
")",
"verbosity",
"=",
"int",
"(",... | Processes the converted data into the yacms database correctly.
Attributes:
yacms_user: the user to put this data in against
date_format: the format the dates are in for posts and comments | [
"Processes",
"the",
"converted",
"data",
"into",
"the",
"yacms",
"database",
"correctly",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/base.py#L146-L240 |
minhhoit/yacms | yacms/blog/management/base.py | BaseImporterCommand.add_meta | def add_meta(self, obj, tags, prompt, verbosity, old_url=None):
"""
Adds tags and a redirect for the given obj, which is a blog
post or a page.
"""
for tag in tags:
keyword = self.trunc(Keyword, prompt, title=tag)
keyword, created = Keyword.objects.get_or_... | python | def add_meta(self, obj, tags, prompt, verbosity, old_url=None):
"""
Adds tags and a redirect for the given obj, which is a blog
post or a page.
"""
for tag in tags:
keyword = self.trunc(Keyword, prompt, title=tag)
keyword, created = Keyword.objects.get_or_... | [
"def",
"add_meta",
"(",
"self",
",",
"obj",
",",
"tags",
",",
"prompt",
",",
"verbosity",
",",
"old_url",
"=",
"None",
")",
":",
"for",
"tag",
"in",
"tags",
":",
"keyword",
"=",
"self",
".",
"trunc",
"(",
"Keyword",
",",
"prompt",
",",
"title",
"="... | Adds tags and a redirect for the given obj, which is a blog
post or a page. | [
"Adds",
"tags",
"and",
"a",
"redirect",
"for",
"the",
"given",
"obj",
"which",
"is",
"a",
"blog",
"post",
"or",
"a",
"page",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/base.py#L242-L263 |
tylerbutler/propane | propane/django/modeltools.py | smart_content_type_for_model | def smart_content_type_for_model(model):
"""
Returns the Django ContentType for a given model. If model is a proxy model, the proxy model's ContentType will
be returned. This differs from Django's standard behavior - the default behavior is to return the parent
ContentType for proxy models.
"""
... | python | def smart_content_type_for_model(model):
"""
Returns the Django ContentType for a given model. If model is a proxy model, the proxy model's ContentType will
be returned. This differs from Django's standard behavior - the default behavior is to return the parent
ContentType for proxy models.
"""
... | [
"def",
"smart_content_type_for_model",
"(",
"model",
")",
":",
"try",
":",
"# noinspection PyPackageRequirements,PyUnresolvedReferences",
"from",
"django",
".",
"contrib",
".",
"contenttypes",
".",
"models",
"import",
"ContentType",
"except",
"ImportError",
":",
"print",
... | Returns the Django ContentType for a given model. If model is a proxy model, the proxy model's ContentType will
be returned. This differs from Django's standard behavior - the default behavior is to return the parent
ContentType for proxy models. | [
"Returns",
"the",
"Django",
"ContentType",
"for",
"a",
"given",
"model",
".",
"If",
"model",
"is",
"a",
"proxy",
"model",
"the",
"proxy",
"model",
"s",
"ContentType",
"will",
"be",
"returned",
".",
"This",
"differs",
"from",
"Django",
"s",
"standard",
"beh... | train | https://github.com/tylerbutler/propane/blob/6c404285ab8d78865b7175a5c8adf8fae12d6be5/propane/django/modeltools.py#L8-L25 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/utils.py | get_first_content | def get_first_content(el_list, alt=None, strip=True):
"""
Return content of the first element in `el_list` or `alt`. Also return `alt`
if the content string of first element is blank.
Args:
el_list (list): List of HTMLElement objects.
alt (default None): Value returner when list or cont... | python | def get_first_content(el_list, alt=None, strip=True):
"""
Return content of the first element in `el_list` or `alt`. Also return `alt`
if the content string of first element is blank.
Args:
el_list (list): List of HTMLElement objects.
alt (default None): Value returner when list or cont... | [
"def",
"get_first_content",
"(",
"el_list",
",",
"alt",
"=",
"None",
",",
"strip",
"=",
"True",
")",
":",
"if",
"not",
"el_list",
":",
"return",
"alt",
"content",
"=",
"el_list",
"[",
"0",
"]",
".",
"getContent",
"(",
")",
"if",
"strip",
":",
"conten... | Return content of the first element in `el_list` or `alt`. Also return `alt`
if the content string of first element is blank.
Args:
el_list (list): List of HTMLElement objects.
alt (default None): Value returner when list or content is blank.
strip (bool, default True): Call .strip() to... | [
"Return",
"content",
"of",
"the",
"first",
"element",
"in",
"el_list",
"or",
"alt",
".",
"Also",
"return",
"alt",
"if",
"the",
"content",
"string",
"of",
"first",
"element",
"is",
"blank",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/utils.py#L62-L87 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/utils.py | is_absolute_url | def is_absolute_url(url, protocol="http"):
"""
Test whether `url` is absolute url (``http://domain.tld/something``) or
relative (``../something``).
Args:
url (str): Tested string.
protocol (str, default "http"): Protocol which will be seek at the
beginning of the `url`.... | python | def is_absolute_url(url, protocol="http"):
"""
Test whether `url` is absolute url (``http://domain.tld/something``) or
relative (``../something``).
Args:
url (str): Tested string.
protocol (str, default "http"): Protocol which will be seek at the
beginning of the `url`.... | [
"def",
"is_absolute_url",
"(",
"url",
",",
"protocol",
"=",
"\"http\"",
")",
":",
"if",
"\":\"",
"not",
"in",
"url",
":",
"return",
"False",
"protocol",
",",
"rest",
"=",
"url",
".",
"split",
"(",
"\":\"",
",",
"1",
")",
"if",
"protocol",
".",
"start... | Test whether `url` is absolute url (``http://domain.tld/something``) or
relative (``../something``).
Args:
url (str): Tested string.
protocol (str, default "http"): Protocol which will be seek at the
beginning of the `url`.
Returns:
bool: True if url is absolute, F... | [
"Test",
"whether",
"url",
"is",
"absolute",
"url",
"(",
"http",
":",
"//",
"domain",
".",
"tld",
"/",
"something",
")",
"or",
"relative",
"(",
"..",
"/",
"something",
")",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/utils.py#L90-L111 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/utils.py | normalize_url | def normalize_url(base_url, rel_url):
"""
Normalize the `url` - from relative, create absolute URL.
Args:
base_url (str): Domain with ``protocol://`` string
rel_url (str): Relative or absolute url.
Returns:
str/None: Normalized URL or None if `url` is blank.
"""
if not ... | python | def normalize_url(base_url, rel_url):
"""
Normalize the `url` - from relative, create absolute URL.
Args:
base_url (str): Domain with ``protocol://`` string
rel_url (str): Relative or absolute url.
Returns:
str/None: Normalized URL or None if `url` is blank.
"""
if not ... | [
"def",
"normalize_url",
"(",
"base_url",
",",
"rel_url",
")",
":",
"if",
"not",
"rel_url",
":",
"return",
"None",
"if",
"not",
"is_absolute_url",
"(",
"rel_url",
")",
":",
"rel_url",
"=",
"rel_url",
".",
"replace",
"(",
"\"../\"",
",",
"\"/\"",
")",
"if"... | Normalize the `url` - from relative, create absolute URL.
Args:
base_url (str): Domain with ``protocol://`` string
rel_url (str): Relative or absolute url.
Returns:
str/None: Normalized URL or None if `url` is blank. | [
"Normalize",
"the",
"url",
"-",
"from",
"relative",
"create",
"absolute",
"URL",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/utils.py#L114-L136 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/utils.py | has_param | def has_param(param):
"""
Generate function, which will check `param` is in html element.
This function can be used as parameter for .find() method in HTMLElement.
"""
def has_param_closure(element):
"""
Look for `param` in `element`.
"""
if element.params.get(param,... | python | def has_param(param):
"""
Generate function, which will check `param` is in html element.
This function can be used as parameter for .find() method in HTMLElement.
"""
def has_param_closure(element):
"""
Look for `param` in `element`.
"""
if element.params.get(param,... | [
"def",
"has_param",
"(",
"param",
")",
":",
"def",
"has_param_closure",
"(",
"element",
")",
":",
"\"\"\"\n Look for `param` in `element`.\n \"\"\"",
"if",
"element",
".",
"params",
".",
"get",
"(",
"param",
",",
"\"\"",
")",
".",
"strip",
"(",
")"... | Generate function, which will check `param` is in html element.
This function can be used as parameter for .find() method in HTMLElement. | [
"Generate",
"function",
"which",
"will",
"check",
"param",
"is",
"in",
"html",
"element",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/utils.py#L139-L154 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/utils.py | must_contain | def must_contain(tag_name, tag_content, container_tag_name):
"""
Generate function, which checks if given element contains `tag_name` with
string content `tag_content` and also another tag named
`container_tag_name`.
This function can be used as parameter for .find() method in HTMLElement.
"""
... | python | def must_contain(tag_name, tag_content, container_tag_name):
"""
Generate function, which checks if given element contains `tag_name` with
string content `tag_content` and also another tag named
`container_tag_name`.
This function can be used as parameter for .find() method in HTMLElement.
"""
... | [
"def",
"must_contain",
"(",
"tag_name",
",",
"tag_content",
",",
"container_tag_name",
")",
":",
"def",
"must_contain_closure",
"(",
"element",
")",
":",
"# containing in first level of childs <tag_name> tag",
"matching_tags",
"=",
"element",
".",
"match",
"(",
"tag_nam... | Generate function, which checks if given element contains `tag_name` with
string content `tag_content` and also another tag named
`container_tag_name`.
This function can be used as parameter for .find() method in HTMLElement. | [
"Generate",
"function",
"which",
"checks",
"if",
"given",
"element",
"contains",
"tag_name",
"with",
"string",
"content",
"tag_content",
"and",
"also",
"another",
"tag",
"named",
"container_tag_name",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/utils.py#L157-L182 |
edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/utils.py | content_matchs | def content_matchs(tag_content, content_transformer=None):
"""
Generate function, which checks whether the content of the tag matchs
`tag_content`.
Args:
tag_content (str): Content of the tag which will be matched thru whole
DOM.
content_transformer (fn, defau... | python | def content_matchs(tag_content, content_transformer=None):
"""
Generate function, which checks whether the content of the tag matchs
`tag_content`.
Args:
tag_content (str): Content of the tag which will be matched thru whole
DOM.
content_transformer (fn, defau... | [
"def",
"content_matchs",
"(",
"tag_content",
",",
"content_transformer",
"=",
"None",
")",
":",
"def",
"content_matchs_closure",
"(",
"element",
")",
":",
"if",
"not",
"element",
".",
"isTag",
"(",
")",
":",
"return",
"False",
"cont",
"=",
"element",
".",
... | Generate function, which checks whether the content of the tag matchs
`tag_content`.
Args:
tag_content (str): Content of the tag which will be matched thru whole
DOM.
content_transformer (fn, default None): Function used to transform all
ta... | [
"Generate",
"function",
"which",
"checks",
"whether",
"the",
"content",
"of",
"the",
"tag",
"matchs",
"tag_content",
"."
] | train | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/utils.py#L185-L208 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/export.py | _sendPostDict | def _sendPostDict(post_dict):
"""
Send `post_dict` to the :attr:`.ALEPH_EXPORT_URL`.
Args:
post_dict (dict): dictionary from :class:`PostData.get_POST_data()`
Returns:
str: Reponse from webform.
"""
downer = Downloader()
downer.headers["Referer"] = settings.EDEPOSIT_EXPORT_... | python | def _sendPostDict(post_dict):
"""
Send `post_dict` to the :attr:`.ALEPH_EXPORT_URL`.
Args:
post_dict (dict): dictionary from :class:`PostData.get_POST_data()`
Returns:
str: Reponse from webform.
"""
downer = Downloader()
downer.headers["Referer"] = settings.EDEPOSIT_EXPORT_... | [
"def",
"_sendPostDict",
"(",
"post_dict",
")",
":",
"downer",
"=",
"Downloader",
"(",
")",
"downer",
".",
"headers",
"[",
"\"Referer\"",
"]",
"=",
"settings",
".",
"EDEPOSIT_EXPORT_REFERER",
"data",
"=",
"downer",
".",
"download",
"(",
"settings",
".",
"ALEP... | Send `post_dict` to the :attr:`.ALEPH_EXPORT_URL`.
Args:
post_dict (dict): dictionary from :class:`PostData.get_POST_data()`
Returns:
str: Reponse from webform. | [
"Send",
"post_dict",
"to",
"the",
":",
"attr",
":",
".",
"ALEPH_EXPORT_URL",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/export.py#L321-L343 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/export.py | _removeSpecialCharacters | def _removeSpecialCharacters(epub):
"""
Remove most of the unnecessary interpunction from epublication, which can
break unimark if not used properly.
"""
special_chars = "/:,- "
epub_dict = epub._asdict()
for key in epub_dict.keys():
if isinstance(epub_dict[key], basestring):
... | python | def _removeSpecialCharacters(epub):
"""
Remove most of the unnecessary interpunction from epublication, which can
break unimark if not used properly.
"""
special_chars = "/:,- "
epub_dict = epub._asdict()
for key in epub_dict.keys():
if isinstance(epub_dict[key], basestring):
... | [
"def",
"_removeSpecialCharacters",
"(",
"epub",
")",
":",
"special_chars",
"=",
"\"/:,- \"",
"epub_dict",
"=",
"epub",
".",
"_asdict",
"(",
")",
"for",
"key",
"in",
"epub_dict",
".",
"keys",
"(",
")",
":",
"if",
"isinstance",
"(",
"epub_dict",
"[",
"key",
... | Remove most of the unnecessary interpunction from epublication, which can
break unimark if not used properly. | [
"Remove",
"most",
"of",
"the",
"unnecessary",
"interpunction",
"from",
"epublication",
"which",
"can",
"break",
"unimark",
"if",
"not",
"used",
"properly",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/export.py#L346-L375 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/export.py | exportEPublication | def exportEPublication(epub):
"""
Send `epub` :class:`.EPublication` object to Aleph, where it will be
processed by librarians.
Args:
epub (EPublication): structure for export
Warning:
The export function is expecting some of the EPublication properties to
be filled with no... | python | def exportEPublication(epub):
"""
Send `epub` :class:`.EPublication` object to Aleph, where it will be
processed by librarians.
Args:
epub (EPublication): structure for export
Warning:
The export function is expecting some of the EPublication properties to
be filled with no... | [
"def",
"exportEPublication",
"(",
"epub",
")",
":",
"epub",
"=",
"_removeSpecialCharacters",
"(",
"epub",
")",
"post_dict",
"=",
"PostData",
"(",
"epub",
")",
".",
"get_POST_data",
"(",
")",
"return",
"_sendPostDict",
"(",
"post_dict",
")"
] | Send `epub` :class:`.EPublication` object to Aleph, where it will be
processed by librarians.
Args:
epub (EPublication): structure for export
Warning:
The export function is expecting some of the EPublication properties to
be filled with non-blank data.
Specifically:
... | [
"Send",
"epub",
":",
"class",
":",
".",
"EPublication",
"object",
"to",
"Aleph",
"where",
"it",
"will",
"be",
"processed",
"by",
"librarians",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/export.py#L378-L405 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/export.py | PostData._import_epublication | def _import_epublication(self, epub):
"""
Fill internal property ._POST dictionary with data from EPublication.
"""
# mrs. Svobodová requires that annotation exported by us have this
# prefix
prefixed_annotation = ANNOTATION_PREFIX + epub.anotace
self._POST["P050... | python | def _import_epublication(self, epub):
"""
Fill internal property ._POST dictionary with data from EPublication.
"""
# mrs. Svobodová requires that annotation exported by us have this
# prefix
prefixed_annotation = ANNOTATION_PREFIX + epub.anotace
self._POST["P050... | [
"def",
"_import_epublication",
"(",
"self",
",",
"epub",
")",
":",
"# mrs. Svobodová requires that annotation exported by us have this",
"# prefix",
"prefixed_annotation",
"=",
"ANNOTATION_PREFIX",
"+",
"epub",
".",
"anotace",
"self",
".",
"_POST",
"[",
"\"P0501010__a\"",
... | Fill internal property ._POST dictionary with data from EPublication. | [
"Fill",
"internal",
"property",
".",
"_POST",
"dictionary",
"with",
"data",
"from",
"EPublication",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/export.py#L162-L198 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/export.py | PostData._apply_mapping | def _apply_mapping(self, mapping):
"""
Map some case specific data to the fields in internal dictionary.
"""
self._POST["P0100LDR__"] = mapping[0]
self._POST["P0200FMT__"] = mapping[1]
self._POST["P0300BAS__a"] = mapping[2]
self._POST["P07022001_b"] = mapping[3]
... | python | def _apply_mapping(self, mapping):
"""
Map some case specific data to the fields in internal dictionary.
"""
self._POST["P0100LDR__"] = mapping[0]
self._POST["P0200FMT__"] = mapping[1]
self._POST["P0300BAS__a"] = mapping[2]
self._POST["P07022001_b"] = mapping[3]
... | [
"def",
"_apply_mapping",
"(",
"self",
",",
"mapping",
")",
":",
"self",
".",
"_POST",
"[",
"\"P0100LDR__\"",
"]",
"=",
"mapping",
"[",
"0",
"]",
"self",
".",
"_POST",
"[",
"\"P0200FMT__\"",
"]",
"=",
"mapping",
"[",
"1",
"]",
"self",
".",
"_POST",
"[... | Map some case specific data to the fields in internal dictionary. | [
"Map",
"some",
"case",
"specific",
"data",
"to",
"the",
"fields",
"in",
"internal",
"dictionary",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/export.py#L200-L208 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/export.py | PostData._postprocess | def _postprocess(self):
"""
Move data between internal fields, validate them and make sure, that
everything is as it should be.
"""
# validate series ISBN
self._POST["P0601010__a"] = self._validate_isbn(
self._POST["P0601010__a"],
accept_blank=True... | python | def _postprocess(self):
"""
Move data between internal fields, validate them and make sure, that
everything is as it should be.
"""
# validate series ISBN
self._POST["P0601010__a"] = self._validate_isbn(
self._POST["P0601010__a"],
accept_blank=True... | [
"def",
"_postprocess",
"(",
"self",
")",
":",
"# validate series ISBN",
"self",
".",
"_POST",
"[",
"\"P0601010__a\"",
"]",
"=",
"self",
".",
"_validate_isbn",
"(",
"self",
".",
"_POST",
"[",
"\"P0601010__a\"",
"]",
",",
"accept_blank",
"=",
"True",
")",
"if"... | Move data between internal fields, validate them and make sure, that
everything is as it should be. | [
"Move",
"data",
"between",
"internal",
"fields",
"validate",
"them",
"and",
"make",
"sure",
"that",
"everything",
"is",
"as",
"it",
"should",
"be",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/export.py#L227-L245 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/export.py | PostData._check_required_fields | def _check_required_fields(self):
"""
Make sure, that internal dictionary contains all fields, which are
required by the webform.
"""
assert self._POST["P0501010__a"] != "", "ISBN is required!"
# export script accepts only czech ISBNs
for isbn_field_name in ("P05... | python | def _check_required_fields(self):
"""
Make sure, that internal dictionary contains all fields, which are
required by the webform.
"""
assert self._POST["P0501010__a"] != "", "ISBN is required!"
# export script accepts only czech ISBNs
for isbn_field_name in ("P05... | [
"def",
"_check_required_fields",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_POST",
"[",
"\"P0501010__a\"",
"]",
"!=",
"\"\"",
",",
"\"ISBN is required!\"",
"# export script accepts only czech ISBNs",
"for",
"isbn_field_name",
"in",
"(",
"\"P0501010__a\"",
",",
"\... | Make sure, that internal dictionary contains all fields, which are
required by the webform. | [
"Make",
"sure",
"that",
"internal",
"dictionary",
"contains",
"all",
"fields",
"which",
"are",
"required",
"by",
"the",
"webform",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/export.py#L256-L301 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/export.py | PostData.get_POST_data | def get_POST_data(self):
"""
Returns:
dict: POST data, which can be sent to webform using \
:py:mod:`urllib` or similar library
"""
self._postprocess()
# some fields need to be remapped (depends on type of media)
self._apply_mapping(
... | python | def get_POST_data(self):
"""
Returns:
dict: POST data, which can be sent to webform using \
:py:mod:`urllib` or similar library
"""
self._postprocess()
# some fields need to be remapped (depends on type of media)
self._apply_mapping(
... | [
"def",
"get_POST_data",
"(",
"self",
")",
":",
"self",
".",
"_postprocess",
"(",
")",
"# some fields need to be remapped (depends on type of media)",
"self",
".",
"_apply_mapping",
"(",
"self",
".",
"mapping",
".",
"get",
"(",
"self",
".",
"_POST",
"[",
"\"P050201... | Returns:
dict: POST data, which can be sent to webform using \
:py:mod:`urllib` or similar library | [
"Returns",
":",
"dict",
":",
"POST",
"data",
"which",
"can",
"be",
"sent",
"to",
"webform",
"using",
"\\",
":",
"py",
":",
"mod",
":",
"urllib",
"or",
"similar",
"library"
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/export.py#L303-L318 |
thespacedoctor/qubits | qubits/cl_utils.py | main | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="WARNING",
opti... | python | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="WARNING",
opti... | [
"def",
"main",
"(",
"arguments",
"=",
"None",
")",
":",
"# setup the command-line util settings",
"su",
"=",
"tools",
"(",
"arguments",
"=",
"arguments",
",",
"docString",
"=",
"__doc__",
",",
"logLevel",
"=",
"\"WARNING\"",
",",
"options_first",
"=",
"False",
... | *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* | [
"*",
"The",
"main",
"function",
"used",
"when",
"cl_utils",
".",
"py",
"is",
"run",
"as",
"a",
"single",
"script",
"from",
"the",
"cl",
"or",
"when",
"installed",
"as",
"a",
"cl",
"command",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/cl_utils.py#L49-L433 |
hmenager/pyacd | pyacd/acd.py | get_parameter | def get_parameter(name, datatype, properties):
"""
Build a Parameter object using its name, datatype and properties list
:param name: name of the parameter
:type name: basestring
:param datatype: datatype of the parameter (must be a value of
PARAMETER_CLASSES keys
:type datatype: basestring
... | python | def get_parameter(name, datatype, properties):
"""
Build a Parameter object using its name, datatype and properties list
:param name: name of the parameter
:type name: basestring
:param datatype: datatype of the parameter (must be a value of
PARAMETER_CLASSES keys
:type datatype: basestring
... | [
"def",
"get_parameter",
"(",
"name",
",",
"datatype",
",",
"properties",
")",
":",
"return",
"PARAMETER_CLASSES",
".",
"get",
"(",
"datatype",
",",
"Parameter",
")",
"(",
"name",
",",
"datatype",
",",
"properties",
")"
] | Build a Parameter object using its name, datatype and properties list
:param name: name of the parameter
:type name: basestring
:param datatype: datatype of the parameter (must be a value of
PARAMETER_CLASSES keys
:type datatype: basestring
:param properties: property values to be set in attribu... | [
"Build",
"a",
"Parameter",
"object",
"using",
"its",
"name",
"datatype",
"and",
"properties",
"list",
":",
"param",
"name",
":",
"name",
"of",
"the",
"parameter",
":",
"type",
"name",
":",
"basestring",
":",
"param",
"datatype",
":",
"datatype",
"of",
"the... | train | https://github.com/hmenager/pyacd/blob/3aa93f227e4321f506c851de4c73157f8336e9e3/pyacd/acd.py#L695-L707 |
hmenager/pyacd | pyacd/acd.py | ElementWithAttributes.set_attributes | def set_attributes(self, attributes):
"""
Set the values for the attributes of the element, based on
the existing default values
:param attributes: the attributes to be set
:type attributes: dict
:return:
"""
# pylint: disable=no-member
for attribu... | python | def set_attributes(self, attributes):
"""
Set the values for the attributes of the element, based on
the existing default values
:param attributes: the attributes to be set
:type attributes: dict
:return:
"""
# pylint: disable=no-member
for attribu... | [
"def",
"set_attributes",
"(",
"self",
",",
"attributes",
")",
":",
"# pylint: disable=no-member",
"for",
"attribute",
"in",
"attributes",
":",
"if",
"attribute",
".",
"name",
"in",
"self",
".",
"attributes",
":",
"set_att_def_value",
"(",
"self",
".",
"attribute... | Set the values for the attributes of the element, based on
the existing default values
:param attributes: the attributes to be set
:type attributes: dict
:return: | [
"Set",
"the",
"values",
"for",
"the",
"attributes",
"of",
"the",
"element",
"based",
"on",
"the",
"existing",
"default",
"values",
":",
"param",
"attributes",
":",
"the",
"attributes",
"to",
"be",
"set",
":",
"type",
"attributes",
":",
"dict",
":",
"return... | train | https://github.com/hmenager/pyacd/blob/3aa93f227e4321f506c851de4c73157f8336e9e3/pyacd/acd.py#L497-L528 |
paetzke/consolor | consolor/consolor.py | print_line | def print_line(s, bold=False, underline=False, blinking=False, color=None, bgcolor=None, end='\n'):
"""
Prints a string with the given formatting.
"""
s = get_line(s, bold=bold, underline=underline,
blinking=blinking, color=color, bgcolor=bgcolor)
print(s, end=end) | python | def print_line(s, bold=False, underline=False, blinking=False, color=None, bgcolor=None, end='\n'):
"""
Prints a string with the given formatting.
"""
s = get_line(s, bold=bold, underline=underline,
blinking=blinking, color=color, bgcolor=bgcolor)
print(s, end=end) | [
"def",
"print_line",
"(",
"s",
",",
"bold",
"=",
"False",
",",
"underline",
"=",
"False",
",",
"blinking",
"=",
"False",
",",
"color",
"=",
"None",
",",
"bgcolor",
"=",
"None",
",",
"end",
"=",
"'\\n'",
")",
":",
"s",
"=",
"get_line",
"(",
"s",
"... | Prints a string with the given formatting. | [
"Prints",
"a",
"string",
"with",
"the",
"given",
"formatting",
"."
] | train | https://github.com/paetzke/consolor/blob/2d6b6063c181095ae9ec805cc4571ad1f960e5fd/consolor/consolor.py#L51-L58 |
paetzke/consolor | consolor/consolor.py | get_line | def get_line(s, bold=False, underline=False, blinking=False, color=None,
bgcolor=None, update_line=False):
"""
Returns a string with the given formatting.
"""
parts = []
if update_line:
parts.append(_UPDATE_LINE)
for val in [color, bgcolor]:
if val:
pa... | python | def get_line(s, bold=False, underline=False, blinking=False, color=None,
bgcolor=None, update_line=False):
"""
Returns a string with the given formatting.
"""
parts = []
if update_line:
parts.append(_UPDATE_LINE)
for val in [color, bgcolor]:
if val:
pa... | [
"def",
"get_line",
"(",
"s",
",",
"bold",
"=",
"False",
",",
"underline",
"=",
"False",
",",
"blinking",
"=",
"False",
",",
"color",
"=",
"None",
",",
"bgcolor",
"=",
"None",
",",
"update_line",
"=",
"False",
")",
":",
"parts",
"=",
"[",
"]",
"if",... | Returns a string with the given formatting. | [
"Returns",
"a",
"string",
"with",
"the",
"given",
"formatting",
"."
] | train | https://github.com/paetzke/consolor/blob/2d6b6063c181095ae9ec805cc4571ad1f960e5fd/consolor/consolor.py#L61-L87 |
paetzke/consolor | consolor/consolor.py | update_line | def update_line(s, bold=False, underline=False, blinking=False, color=None, bgcolor=None):
"""
Overwrites the output of the current line and prints s on the same line
without a new line.
"""
s = get_line(s, bold=bold, underline=underline, blinking=blinking,
color=color, bgcolor=bgc... | python | def update_line(s, bold=False, underline=False, blinking=False, color=None, bgcolor=None):
"""
Overwrites the output of the current line and prints s on the same line
without a new line.
"""
s = get_line(s, bold=bold, underline=underline, blinking=blinking,
color=color, bgcolor=bgc... | [
"def",
"update_line",
"(",
"s",
",",
"bold",
"=",
"False",
",",
"underline",
"=",
"False",
",",
"blinking",
"=",
"False",
",",
"color",
"=",
"None",
",",
"bgcolor",
"=",
"None",
")",
":",
"s",
"=",
"get_line",
"(",
"s",
",",
"bold",
"=",
"bold",
... | Overwrites the output of the current line and prints s on the same line
without a new line. | [
"Overwrites",
"the",
"output",
"of",
"the",
"current",
"line",
"and",
"prints",
"s",
"on",
"the",
"same",
"line",
"without",
"a",
"new",
"line",
"."
] | train | https://github.com/paetzke/consolor/blob/2d6b6063c181095ae9ec805cc4571ad1f960e5fd/consolor/consolor.py#L90-L98 |
mixmastamyk/env | env.py | Entry.truthy | def truthy(self):
''' Recognize a Boolean-like string value as a Boolean.
Note: the rules are a bit different than string "truthiness."
'0' --> False
'1' --> True
('no', 'false') --> False # case-insensitive
('yes', 'true') --... | python | def truthy(self):
''' Recognize a Boolean-like string value as a Boolean.
Note: the rules are a bit different than string "truthiness."
'0' --> False
'1' --> True
('no', 'false') --> False # case-insensitive
('yes', 'true') --... | [
"def",
"truthy",
"(",
"self",
")",
":",
"lower",
"=",
"self",
".",
"lower",
"(",
")",
"if",
"lower",
".",
"isdigit",
"(",
")",
":",
"return",
"bool",
"(",
"int",
"(",
"lower",
")",
")",
"elif",
"lower",
"in",
"(",
"'yes'",
",",
"'true'",
")",
"... | Recognize a Boolean-like string value as a Boolean.
Note: the rules are a bit different than string "truthiness."
'0' --> False
'1' --> True
('no', 'false') --> False # case-insensitive
('yes', 'true') --> True # case-insensitive | [
"Recognize",
"a",
"Boolean",
"-",
"like",
"string",
"value",
"as",
"a",
"Boolean",
".",
"Note",
":",
"the",
"rules",
"are",
"a",
"bit",
"different",
"than",
"string",
"truthiness",
"."
] | train | https://github.com/mixmastamyk/env/blob/63ed6b914bd5189986972b338b86453e42890fa0/env.py#L40-L59 |
mixmastamyk/env | env.py | Entry.path_list | def path_list(self, sep=os.pathsep):
''' Return list of Path objects. '''
from pathlib import Path
return [ Path(pathstr) for pathstr in self.split(sep) ] | python | def path_list(self, sep=os.pathsep):
''' Return list of Path objects. '''
from pathlib import Path
return [ Path(pathstr) for pathstr in self.split(sep) ] | [
"def",
"path_list",
"(",
"self",
",",
"sep",
"=",
"os",
".",
"pathsep",
")",
":",
"from",
"pathlib",
"import",
"Path",
"return",
"[",
"Path",
"(",
"pathstr",
")",
"for",
"pathstr",
"in",
"self",
".",
"split",
"(",
"sep",
")",
"]"
] | Return list of Path objects. | [
"Return",
"list",
"of",
"Path",
"objects",
"."
] | train | https://github.com/mixmastamyk/env/blob/63ed6b914bd5189986972b338b86453e42890fa0/env.py#L87-L90 |
mixmastamyk/env | env.py | Environment.prefix | def prefix(self, prefix, lowercase=True):
''' Returns a dictionary of keys with the same prefix.
Compat with kr/env, lowercased.
> xdg = env.prefix('XDG_')
> for key, value in xdg.items():
print('%-20s' % key, value[:6], '…')
config_dirs /e... | python | def prefix(self, prefix, lowercase=True):
''' Returns a dictionary of keys with the same prefix.
Compat with kr/env, lowercased.
> xdg = env.prefix('XDG_')
> for key, value in xdg.items():
print('%-20s' % key, value[:6], '…')
config_dirs /e... | [
"def",
"prefix",
"(",
"self",
",",
"prefix",
",",
"lowercase",
"=",
"True",
")",
":",
"env_subset",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"_envars",
".",
"keys",
"(",
")",
":",
"if",
"key",
".",
"startswith",
"(",
"prefix",
")",
":",
"n... | Returns a dictionary of keys with the same prefix.
Compat with kr/env, lowercased.
> xdg = env.prefix('XDG_')
> for key, value in xdg.items():
print('%-20s' % key, value[:6], '…')
config_dirs /etc/x…
current_desktop MATE
da... | [
"Returns",
"a",
"dictionary",
"of",
"keys",
"with",
"the",
"same",
"prefix",
".",
"Compat",
"with",
"kr",
"/",
"env",
"lowercased",
"."
] | train | https://github.com/mixmastamyk/env/blob/63ed6b914bd5189986972b338b86453e42890fa0/env.py#L183-L208 |
mixmastamyk/env | env.py | Environment.map | def map(self, **kwargs):
''' Change a name on the fly. Compat with kr/env. '''
return { key: str(self._envars[kwargs[key]]) # str strips Entry
for key in kwargs } | python | def map(self, **kwargs):
''' Change a name on the fly. Compat with kr/env. '''
return { key: str(self._envars[kwargs[key]]) # str strips Entry
for key in kwargs } | [
"def",
"map",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"{",
"key",
":",
"str",
"(",
"self",
".",
"_envars",
"[",
"kwargs",
"[",
"key",
"]",
"]",
")",
"# str strips Entry",
"for",
"key",
"in",
"kwargs",
"}"
] | Change a name on the fly. Compat with kr/env. | [
"Change",
"a",
"name",
"on",
"the",
"fly",
".",
"Compat",
"with",
"kr",
"/",
"env",
"."
] | train | https://github.com/mixmastamyk/env/blob/63ed6b914bd5189986972b338b86453e42890fa0/env.py#L210-L213 |
b3j0f/conf | b3j0f/conf/configurable/log.py | _filehandler | def _filehandler(configurable):
"""Default logging file handler."""
filename = configurable.log_name.replace('.', sep)
path = join(configurable.log_path, '{0}.log'.format(filename))
return FileHandler(path, mode='a+') | python | def _filehandler(configurable):
"""Default logging file handler."""
filename = configurable.log_name.replace('.', sep)
path = join(configurable.log_path, '{0}.log'.format(filename))
return FileHandler(path, mode='a+') | [
"def",
"_filehandler",
"(",
"configurable",
")",
":",
"filename",
"=",
"configurable",
".",
"log_name",
".",
"replace",
"(",
"'.'",
",",
"sep",
")",
"path",
"=",
"join",
"(",
"configurable",
".",
"log_path",
",",
"'{0}.log'",
".",
"format",
"(",
"filename"... | Default logging file handler. | [
"Default",
"logging",
"file",
"handler",
"."
] | train | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/configurable/log.py#L51-L57 |
globocom/globomap-loader-api-client | globomap_loader_api_client/update.py | Update.post | def post(self, document):
"""Send to API a document or a list of document.
:param document: a document or a list of document.
:type document: dict or list
:return: Message with location of job
:rtype: dict
:raises ValidationError: if API returns status 400
:raise... | python | def post(self, document):
"""Send to API a document or a list of document.
:param document: a document or a list of document.
:type document: dict or list
:return: Message with location of job
:rtype: dict
:raises ValidationError: if API returns status 400
:raise... | [
"def",
"post",
"(",
"self",
",",
"document",
")",
":",
"if",
"type",
"(",
"document",
")",
"is",
"dict",
":",
"document",
"=",
"[",
"document",
"]",
"return",
"self",
".",
"make_request",
"(",
"method",
"=",
"'POST'",
",",
"uri",
"=",
"'updates/'",
"... | Send to API a document or a list of document.
:param document: a document or a list of document.
:type document: dict or list
:return: Message with location of job
:rtype: dict
:raises ValidationError: if API returns status 400
:raises Unauthorized: if API returns status... | [
"Send",
"to",
"API",
"a",
"document",
"or",
"a",
"list",
"of",
"document",
"."
] | train | https://github.com/globocom/globomap-loader-api-client/blob/b12347ca77d245de1abd604d1b694162156570e6/globomap_loader_api_client/update.py#L21-L38 |
globocom/globomap-loader-api-client | globomap_loader_api_client/update.py | Update.get | def get(self, key):
"""Return the status from a job.
:param key: id of job
:type document: dict or list
:return: message with location of job
:rtype: dict
:raises Unauthorized: if API returns status 401
:raises Forbidden: if API returns status 403
:raises... | python | def get(self, key):
"""Return the status from a job.
:param key: id of job
:type document: dict or list
:return: message with location of job
:rtype: dict
:raises Unauthorized: if API returns status 401
:raises Forbidden: if API returns status 403
:raises... | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"uri",
"=",
"'updates/job/{}'",
".",
"format",
"(",
"key",
")",
"return",
"self",
".",
"make_request",
"(",
"method",
"=",
"'GET'",
",",
"uri",
"=",
"uri",
")"
] | Return the status from a job.
:param key: id of job
:type document: dict or list
:return: message with location of job
:rtype: dict
:raises Unauthorized: if API returns status 401
:raises Forbidden: if API returns status 403
:raises NotFound: if API returns statu... | [
"Return",
"the",
"status",
"from",
"a",
"job",
"."
] | train | https://github.com/globocom/globomap-loader-api-client/blob/b12347ca77d245de1abd604d1b694162156570e6/globomap_loader_api_client/update.py#L40-L54 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/inventory/expand_hosts.py | detect_range | def detect_range(line = None):
'''
A helper function that checks a given host line to see if it contains
a range pattern descibed in the docstring above.
Returnes True if the given line contains a pattern, else False.
'''
if (not line.startswith("[") and
line.find("[") != -1 and
... | python | def detect_range(line = None):
'''
A helper function that checks a given host line to see if it contains
a range pattern descibed in the docstring above.
Returnes True if the given line contains a pattern, else False.
'''
if (not line.startswith("[") and
line.find("[") != -1 and
... | [
"def",
"detect_range",
"(",
"line",
"=",
"None",
")",
":",
"if",
"(",
"not",
"line",
".",
"startswith",
"(",
"\"[\"",
")",
"and",
"line",
".",
"find",
"(",
"\"[\"",
")",
"!=",
"-",
"1",
"and",
"line",
".",
"find",
"(",
"\":\"",
")",
"!=",
"-",
... | A helper function that checks a given host line to see if it contains
a range pattern descibed in the docstring above.
Returnes True if the given line contains a pattern, else False. | [
"A",
"helper",
"function",
"that",
"checks",
"a",
"given",
"host",
"line",
"to",
"see",
"if",
"it",
"contains",
"a",
"range",
"pattern",
"descibed",
"in",
"the",
"docstring",
"above",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/inventory/expand_hosts.py#L37-L51 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/inventory/expand_hosts.py | expand_hostname_range | def expand_hostname_range(line = None):
'''
A helper function that expands a given line that contains a pattern
specified in top docstring, and returns a list that consists of the
expanded version.
The '[' and ']' characters are used to maintain the pseudo-code
appearance. They are replaced in ... | python | def expand_hostname_range(line = None):
'''
A helper function that expands a given line that contains a pattern
specified in top docstring, and returns a list that consists of the
expanded version.
The '[' and ']' characters are used to maintain the pseudo-code
appearance. They are replaced in ... | [
"def",
"expand_hostname_range",
"(",
"line",
"=",
"None",
")",
":",
"all_hosts",
"=",
"[",
"]",
"if",
"line",
":",
"# A hostname such as db[1:6]-node is considered to consists",
"# three parts:",
"# head: 'db'",
"# nrange: [1:6]; range() is a built-in. Can't use the name",
"# t... | A helper function that expands a given line that contains a pattern
specified in top docstring, and returns a list that consists of the
expanded version.
The '[' and ']' characters are used to maintain the pseudo-code
appearance. They are replaced in this function with '|' to ease
string splitting.... | [
"A",
"helper",
"function",
"that",
"expands",
"a",
"given",
"line",
"that",
"contains",
"a",
"pattern",
"specified",
"in",
"top",
"docstring",
"and",
"returns",
"a",
"list",
"that",
"consists",
"of",
"the",
"expanded",
"version",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/inventory/expand_hosts.py#L53-L104 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/browser/add_content.py | AddContent.create | def create(self, image=None):
"""Create content and return url. In case of images add the image."""
container = self.context
new = api.content.create(
container=container,
type=self.portal_type,
title=self.title,
safe_id=True,
)
if ... | python | def create(self, image=None):
"""Create content and return url. In case of images add the image."""
container = self.context
new = api.content.create(
container=container,
type=self.portal_type,
title=self.title,
safe_id=True,
)
if ... | [
"def",
"create",
"(",
"self",
",",
"image",
"=",
"None",
")",
":",
"container",
"=",
"self",
".",
"context",
"new",
"=",
"api",
".",
"content",
".",
"create",
"(",
"container",
"=",
"container",
",",
"type",
"=",
"self",
".",
"portal_type",
",",
"tit... | Create content and return url. In case of images add the image. | [
"Create",
"content",
"and",
"return",
"url",
".",
"In",
"case",
"of",
"images",
"add",
"the",
"image",
"."
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/browser/add_content.py#L32-L49 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/browser/add_content.py | AddContent.redirect | def redirect(self, url):
"""Has its own method to allow overriding"""
url = '{}/view'.format(url)
return self.request.response.redirect(url) | python | def redirect(self, url):
"""Has its own method to allow overriding"""
url = '{}/view'.format(url)
return self.request.response.redirect(url) | [
"def",
"redirect",
"(",
"self",
",",
"url",
")",
":",
"url",
"=",
"'{}/view'",
".",
"format",
"(",
"url",
")",
"return",
"self",
".",
"request",
".",
"response",
".",
"redirect",
"(",
"url",
")"
] | Has its own method to allow overriding | [
"Has",
"its",
"own",
"method",
"to",
"allow",
"overriding"
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/browser/add_content.py#L51-L54 |
hkff/FodtlMon | fodtlmon/ltl/ltlmon.py | ltlfo2mon | def ltlfo2mon(formula:Formula, trace:Trace):
"""
Run ltlfo2mon
:param formula: Formula | ltlfo string formula
:param trace: Trace | ltlfo string trace
:return:
"""
fl = formula.toLTLFO() if isinstance(formula, Formula) else formula
tr = trace.toLTLFO() if isinstance(trace, Trace) else tr... | python | def ltlfo2mon(formula:Formula, trace:Trace):
"""
Run ltlfo2mon
:param formula: Formula | ltlfo string formula
:param trace: Trace | ltlfo string trace
:return:
"""
fl = formula.toLTLFO() if isinstance(formula, Formula) else formula
tr = trace.toLTLFO() if isinstance(trace, Trace) else tr... | [
"def",
"ltlfo2mon",
"(",
"formula",
":",
"Formula",
",",
"trace",
":",
"Trace",
")",
":",
"fl",
"=",
"formula",
".",
"toLTLFO",
"(",
")",
"if",
"isinstance",
"(",
"formula",
",",
"Formula",
")",
"else",
"formula",
"tr",
"=",
"trace",
".",
"toLTLFO",
... | Run ltlfo2mon
:param formula: Formula | ltlfo string formula
:param trace: Trace | ltlfo string trace
:return: | [
"Run",
"ltlfo2mon",
":",
"param",
"formula",
":",
"Formula",
"|",
"ltlfo",
"string",
"formula",
":",
"param",
"trace",
":",
"Trace",
"|",
"ltlfo",
"string",
"trace",
":",
"return",
":"
] | train | https://github.com/hkff/FodtlMon/blob/0c9015a1a1f0a4a64d52945c86b45441d5871c56/fodtlmon/ltl/ltlmon.py#L133-L146 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/browser/roster.py | EditRoster.update_roster | def update_roster(self, REQUEST=None):
"""
If workspace is team managed, users can add/remove participants.
Any user with the manage workspace permission can add/remove
participants and admins.
"""
CheckAuthenticator(self.request)
PostOnly(self.request)
fo... | python | def update_roster(self, REQUEST=None):
"""
If workspace is team managed, users can add/remove participants.
Any user with the manage workspace permission can add/remove
participants and admins.
"""
CheckAuthenticator(self.request)
PostOnly(self.request)
fo... | [
"def",
"update_roster",
"(",
"self",
",",
"REQUEST",
"=",
"None",
")",
":",
"CheckAuthenticator",
"(",
"self",
".",
"request",
")",
"PostOnly",
"(",
"self",
".",
"request",
")",
"form",
"=",
"self",
".",
"request",
".",
"form",
"entries",
"=",
"form",
... | If workspace is team managed, users can add/remove participants.
Any user with the manage workspace permission can add/remove
participants and admins. | [
"If",
"workspace",
"is",
"team",
"managed",
"users",
"can",
"add",
"/",
"remove",
"participants",
".",
"Any",
"user",
"with",
"the",
"manage",
"workspace",
"permission",
"can",
"add",
"/",
"remove",
"participants",
"and",
"admins",
"."
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/browser/roster.py#L26-L40 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/browser/roster.py | EditRoster.update_users | def update_users(self, entries):
"""Update user properties on the roster """
ws = IWorkspace(self.context)
members = ws.members
# check user permissions against join policy
join_policy = self.context.join_policy
if (join_policy == "admin"
and not checkPermiss... | python | def update_users(self, entries):
"""Update user properties on the roster """
ws = IWorkspace(self.context)
members = ws.members
# check user permissions against join policy
join_policy = self.context.join_policy
if (join_policy == "admin"
and not checkPermiss... | [
"def",
"update_users",
"(",
"self",
",",
"entries",
")",
":",
"ws",
"=",
"IWorkspace",
"(",
"self",
".",
"context",
")",
"members",
"=",
"ws",
".",
"members",
"# check user permissions against join policy",
"join_policy",
"=",
"self",
".",
"context",
".",
"joi... | Update user properties on the roster | [
"Update",
"user",
"properties",
"on",
"the",
"roster"
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/browser/roster.py#L43-L82 |
spookey/photon | photon/tools/git.py | Git.commit | def commit(self):
'''
:param tag:
Checks out specified commit.
If set to ``None`` the latest commit will be checked out
:returns:
A list of all commits, descending
'''
commit = self._log(num=-1, format='%H')
if commit.get('returncode')... | python | def commit(self):
'''
:param tag:
Checks out specified commit.
If set to ``None`` the latest commit will be checked out
:returns:
A list of all commits, descending
'''
commit = self._log(num=-1, format='%H')
if commit.get('returncode')... | [
"def",
"commit",
"(",
"self",
")",
":",
"commit",
"=",
"self",
".",
"_log",
"(",
"num",
"=",
"-",
"1",
",",
"format",
"=",
"'%H'",
")",
"if",
"commit",
".",
"get",
"(",
"'returncode'",
")",
"==",
"0",
":",
"return",
"commit",
".",
"get",
"(",
"... | :param tag:
Checks out specified commit.
If set to ``None`` the latest commit will be checked out
:returns:
A list of all commits, descending | [
":",
"param",
"tag",
":",
"Checks",
"out",
"specified",
"commit",
".",
"If",
"set",
"to",
"None",
"the",
"latest",
"commit",
"will",
"be",
"checked",
"out",
":",
"returns",
":",
"A",
"list",
"of",
"all",
"commits",
"descending"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L100-L111 |
spookey/photon | photon/tools/git.py | Git.commit | def commit(self, commit):
'''
.. seealso:: :attr:`commit`
'''
c = self.commit
if c:
if not commit:
commit = c[0]
if commit in c:
self._checkout(treeish=commit) | python | def commit(self, commit):
'''
.. seealso:: :attr:`commit`
'''
c = self.commit
if c:
if not commit:
commit = c[0]
if commit in c:
self._checkout(treeish=commit) | [
"def",
"commit",
"(",
"self",
",",
"commit",
")",
":",
"c",
"=",
"self",
".",
"commit",
"if",
"c",
":",
"if",
"not",
"commit",
":",
"commit",
"=",
"c",
"[",
"0",
"]",
"if",
"commit",
"in",
"c",
":",
"self",
".",
"_checkout",
"(",
"treeish",
"="... | .. seealso:: :attr:`commit` | [
"..",
"seealso",
"::",
":",
"attr",
":",
"commit"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L114-L124 |
spookey/photon | photon/tools/git.py | Git.log | def log(self):
'''
:returns:
The last 10 commit entries as dictionary
* 'commit': The commit-ID
* 'message': First line of the commit message
'''
log = self._log(num=10, format='%h::%b').get('stdout')
if log:
return [
dict... | python | def log(self):
'''
:returns:
The last 10 commit entries as dictionary
* 'commit': The commit-ID
* 'message': First line of the commit message
'''
log = self._log(num=10, format='%h::%b').get('stdout')
if log:
return [
dict... | [
"def",
"log",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_log",
"(",
"num",
"=",
"10",
",",
"format",
"=",
"'%h::%b'",
")",
".",
"get",
"(",
"'stdout'",
")",
"if",
"log",
":",
"return",
"[",
"dict",
"(",
"commit",
"=",
"c",
",",
"message"... | :returns:
The last 10 commit entries as dictionary
* 'commit': The commit-ID
* 'message': First line of the commit message | [
":",
"returns",
":",
"The",
"last",
"10",
"commit",
"entries",
"as",
"dictionary"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L140-L155 |
spookey/photon | photon/tools/git.py | Git.status | def status(self):
'''
:returns:
Current repository status as dictionary:
* 'clean': ``True`` if there are no changes ``False`` otherwise
* 'untracked': A list of untracked files (if any and not 'clean')
* 'modified': A list of modified files (if any and not 'clean')
... | python | def status(self):
'''
:returns:
Current repository status as dictionary:
* 'clean': ``True`` if there are no changes ``False`` otherwise
* 'untracked': A list of untracked files (if any and not 'clean')
* 'modified': A list of modified files (if any and not 'clean')
... | [
"def",
"status",
"(",
"self",
")",
":",
"status",
"=",
"self",
".",
"m",
"(",
"'getting git status'",
",",
"cmdd",
"=",
"dict",
"(",
"cmd",
"=",
"'git status --porcelain'",
",",
"cwd",
"=",
"self",
".",
"local",
")",
",",
"verbose",
"=",
"False",
")",
... | :returns:
Current repository status as dictionary:
* 'clean': ``True`` if there are no changes ``False`` otherwise
* 'untracked': A list of untracked files (if any and not 'clean')
* 'modified': A list of modified files (if any and not 'clean')
* 'deleted': A list of deleted... | [
":",
"returns",
":",
"Current",
"repository",
"status",
"as",
"dictionary",
":"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L158-L191 |
spookey/photon | photon/tools/git.py | Git.branch | def branch(self):
'''
:param branch:
Checks out specified branch (tracking if it exists on remote).
If set to ``None``, 'master' will be checked out
:returns:
The current branch
(This could also be 'master (Detatched-Head)' - Be warned)
'''... | python | def branch(self):
'''
:param branch:
Checks out specified branch (tracking if it exists on remote).
If set to ``None``, 'master' will be checked out
:returns:
The current branch
(This could also be 'master (Detatched-Head)' - Be warned)
'''... | [
"def",
"branch",
"(",
"self",
")",
":",
"branch",
"=",
"self",
".",
"_get_branch",
"(",
")",
".",
"get",
"(",
"'stdout'",
")",
"if",
"branch",
":",
"return",
"''",
".",
"join",
"(",
"[",
"b",
"for",
"b",
"in",
"branch",
"if",
"'*'",
"in",
"b",
... | :param branch:
Checks out specified branch (tracking if it exists on remote).
If set to ``None``, 'master' will be checked out
:returns:
The current branch
(This could also be 'master (Detatched-Head)' - Be warned) | [
":",
"param",
"branch",
":",
"Checks",
"out",
"specified",
"branch",
"(",
"tracking",
"if",
"it",
"exists",
"on",
"remote",
")",
".",
"If",
"set",
"to",
"None",
"master",
"will",
"be",
"checked",
"out",
":",
"returns",
":",
"The",
"current",
"branch",
... | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L194-L208 |
spookey/photon | photon/tools/git.py | Git.branch | def branch(self, branch):
'''
.. seealso:: :attr:`branch`
'''
if not branch:
branch = self.__mbranch
tracking = (
''
if branch in self._get_branch(remotes=True).get('out') else
'-B'
)
self._checkout(treeish='%s %s' ... | python | def branch(self, branch):
'''
.. seealso:: :attr:`branch`
'''
if not branch:
branch = self.__mbranch
tracking = (
''
if branch in self._get_branch(remotes=True).get('out') else
'-B'
)
self._checkout(treeish='%s %s' ... | [
"def",
"branch",
"(",
"self",
",",
"branch",
")",
":",
"if",
"not",
"branch",
":",
"branch",
"=",
"self",
".",
"__mbranch",
"tracking",
"=",
"(",
"''",
"if",
"branch",
"in",
"self",
".",
"_get_branch",
"(",
"remotes",
"=",
"True",
")",
".",
"get",
... | .. seealso:: :attr:`branch` | [
"..",
"seealso",
"::",
":",
"attr",
":",
"branch"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L211-L223 |
spookey/photon | photon/tools/git.py | Git.tag | def tag(self):
'''
:param tag:
Checks out specified tag. If set to ``None`` the latest
tag will be checked out
:returns:
A list of all tags, sorted as version numbers, ascending
'''
tag = self.m(
'getting git tags',
cmd... | python | def tag(self):
'''
:param tag:
Checks out specified tag. If set to ``None`` the latest
tag will be checked out
:returns:
A list of all tags, sorted as version numbers, ascending
'''
tag = self.m(
'getting git tags',
cmd... | [
"def",
"tag",
"(",
"self",
")",
":",
"tag",
"=",
"self",
".",
"m",
"(",
"'getting git tags'",
",",
"cmdd",
"=",
"dict",
"(",
"cmd",
"=",
"'git tag -l --sort=\"version:refname\"'",
",",
"cwd",
"=",
"self",
".",
"local",
")",
",",
"verbose",
"=",
"False",
... | :param tag:
Checks out specified tag. If set to ``None`` the latest
tag will be checked out
:returns:
A list of all tags, sorted as version numbers, ascending | [
":",
"param",
"tag",
":",
"Checks",
"out",
"specified",
"tag",
".",
"If",
"set",
"to",
"None",
"the",
"latest",
"tag",
"will",
"be",
"checked",
"out",
":",
"returns",
":",
"A",
"list",
"of",
"all",
"tags",
"sorted",
"as",
"version",
"numbers",
"ascendi... | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L226-L244 |
spookey/photon | photon/tools/git.py | Git.tag | def tag(self, tag):
'''
.. seealso:: :attr:`tag`
'''
t = self.tag
if t:
if not tag:
tag = t[-1]
if tag in t:
self._checkout(treeish=tag) | python | def tag(self, tag):
'''
.. seealso:: :attr:`tag`
'''
t = self.tag
if t:
if not tag:
tag = t[-1]
if tag in t:
self._checkout(treeish=tag) | [
"def",
"tag",
"(",
"self",
",",
"tag",
")",
":",
"t",
"=",
"self",
".",
"tag",
"if",
"t",
":",
"if",
"not",
"tag",
":",
"tag",
"=",
"t",
"[",
"-",
"1",
"]",
"if",
"tag",
"in",
"t",
":",
"self",
".",
"_checkout",
"(",
"treeish",
"=",
"tag",
... | .. seealso:: :attr:`tag` | [
"..",
"seealso",
"::",
":",
"attr",
":",
"tag"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L247-L257 |
spookey/photon | photon/tools/git.py | Git.cleanup | def cleanup(self):
'''
Commits all local changes (if any) into a working branch,
merges it with 'master'.
Checks out your old branch afterwards.
|appteardown| if conflicts are discovered
'''
hostname = get_hostname()
old_branch = self.branch
ch... | python | def cleanup(self):
'''
Commits all local changes (if any) into a working branch,
merges it with 'master'.
Checks out your old branch afterwards.
|appteardown| if conflicts are discovered
'''
hostname = get_hostname()
old_branch = self.branch
ch... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"hostname",
"=",
"get_hostname",
"(",
")",
"old_branch",
"=",
"self",
".",
"branch",
"changes",
"=",
"self",
".",
"status",
"if",
"not",
"changes",
".",
"get",
"(",
"'clean'",
")",
":",
"self",
".",
"branch",
... | Commits all local changes (if any) into a working branch,
merges it with 'master'.
Checks out your old branch afterwards.
|appteardown| if conflicts are discovered | [
"Commits",
"all",
"local",
"changes",
"(",
"if",
"any",
")",
"into",
"a",
"working",
"branch",
"merges",
"it",
"with",
"master",
"."
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L260-L328 |
spookey/photon | photon/tools/git.py | Git.publish | def publish(self):
'''
Runs :func:`cleanup` first,
then pushes the changes to the :attr:`remote`.
'''
self.cleanup
remote = self.remote
branch = self.branch
return self.m(
'pushing changes to %s/%s' % (remote, branch),
cmdd=dict(
... | python | def publish(self):
'''
Runs :func:`cleanup` first,
then pushes the changes to the :attr:`remote`.
'''
self.cleanup
remote = self.remote
branch = self.branch
return self.m(
'pushing changes to %s/%s' % (remote, branch),
cmdd=dict(
... | [
"def",
"publish",
"(",
"self",
")",
":",
"self",
".",
"cleanup",
"remote",
"=",
"self",
".",
"remote",
"branch",
"=",
"self",
".",
"branch",
"return",
"self",
".",
"m",
"(",
"'pushing changes to %s/%s'",
"%",
"(",
"remote",
",",
"branch",
")",
",",
"cm... | Runs :func:`cleanup` first,
then pushes the changes to the :attr:`remote`. | [
"Runs",
":",
"func",
":",
"cleanup",
"first",
"then",
"pushes",
"the",
"changes",
"to",
"the",
":",
"attr",
":",
"remote",
"."
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L331-L348 |
spookey/photon | photon/tools/git.py | Git._get_remote | def _get_remote(self, cached=True):
'''
Helper function to determine remote
:param cached:
Use cached values or query remotes
'''
return self.m(
'getting current remote',
cmdd=dict(
cmd='git remote show %s' % ('-n' if cached e... | python | def _get_remote(self, cached=True):
'''
Helper function to determine remote
:param cached:
Use cached values or query remotes
'''
return self.m(
'getting current remote',
cmdd=dict(
cmd='git remote show %s' % ('-n' if cached e... | [
"def",
"_get_remote",
"(",
"self",
",",
"cached",
"=",
"True",
")",
":",
"return",
"self",
".",
"m",
"(",
"'getting current remote'",
",",
"cmdd",
"=",
"dict",
"(",
"cmd",
"=",
"'git remote show %s'",
"%",
"(",
"'-n'",
"if",
"cached",
"else",
"''",
")",
... | Helper function to determine remote
:param cached:
Use cached values or query remotes | [
"Helper",
"function",
"to",
"determine",
"remote"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L350-L365 |
spookey/photon | photon/tools/git.py | Git._log | def _log(self, num=None, format=None):
'''
Helper function to receive git log
:param num:
Number of entries
:param format:
Use formatted output with specified format string
'''
num = '-n %s' % (num) if num else ''
format = '--format="%s"'... | python | def _log(self, num=None, format=None):
'''
Helper function to receive git log
:param num:
Number of entries
:param format:
Use formatted output with specified format string
'''
num = '-n %s' % (num) if num else ''
format = '--format="%s"'... | [
"def",
"_log",
"(",
"self",
",",
"num",
"=",
"None",
",",
"format",
"=",
"None",
")",
":",
"num",
"=",
"'-n %s'",
"%",
"(",
"num",
")",
"if",
"num",
"else",
"''",
"format",
"=",
"'--format=\"%s\"'",
"%",
"(",
"format",
")",
"if",
"format",
"else",
... | Helper function to receive git log
:param num:
Number of entries
:param format:
Use formatted output with specified format string | [
"Helper",
"function",
"to",
"receive",
"git",
"log"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L367-L383 |
spookey/photon | photon/tools/git.py | Git._get_branch | def _get_branch(self, remotes=False):
'''
Helper function to determine current branch
:param remotes:
List the remote-tracking branches
'''
return self.m(
'getting git branch information',
cmdd=dict(
cmd='git branch %s' % ('-r... | python | def _get_branch(self, remotes=False):
'''
Helper function to determine current branch
:param remotes:
List the remote-tracking branches
'''
return self.m(
'getting git branch information',
cmdd=dict(
cmd='git branch %s' % ('-r... | [
"def",
"_get_branch",
"(",
"self",
",",
"remotes",
"=",
"False",
")",
":",
"return",
"self",
".",
"m",
"(",
"'getting git branch information'",
",",
"cmdd",
"=",
"dict",
"(",
"cmd",
"=",
"'git branch %s'",
"%",
"(",
"'-r'",
"if",
"remotes",
"else",
"''",
... | Helper function to determine current branch
:param remotes:
List the remote-tracking branches | [
"Helper",
"function",
"to",
"determine",
"current",
"branch"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L385-L400 |
spookey/photon | photon/tools/git.py | Git._checkout | def _checkout(self, treeish):
'''
Helper function to checkout something
:param treeish:
String for '`tag`', '`branch`', or remote tracking '-B `banch`'
'''
return self.m(
'checking out "%s"' % (treeish),
cmdd=dict(cmd='git checkout %s' % (tre... | python | def _checkout(self, treeish):
'''
Helper function to checkout something
:param treeish:
String for '`tag`', '`branch`', or remote tracking '-B `banch`'
'''
return self.m(
'checking out "%s"' % (treeish),
cmdd=dict(cmd='git checkout %s' % (tre... | [
"def",
"_checkout",
"(",
"self",
",",
"treeish",
")",
":",
"return",
"self",
".",
"m",
"(",
"'checking out \"%s\"'",
"%",
"(",
"treeish",
")",
",",
"cmdd",
"=",
"dict",
"(",
"cmd",
"=",
"'git checkout %s'",
"%",
"(",
"treeish",
")",
",",
"cwd",
"=",
... | Helper function to checkout something
:param treeish:
String for '`tag`', '`branch`', or remote tracking '-B `banch`' | [
"Helper",
"function",
"to",
"checkout",
"something"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L402-L414 |
spookey/photon | photon/tools/git.py | Git._pull | def _pull(self):
'''
Helper function to pull from remote
'''
pull = self.m(
'pulling remote changes',
cmdd=dict(cmd='git pull --tags', cwd=self.local),
critical=False
)
if 'CONFLICT' in pull.get('out'):
self.m(
... | python | def _pull(self):
'''
Helper function to pull from remote
'''
pull = self.m(
'pulling remote changes',
cmdd=dict(cmd='git pull --tags', cwd=self.local),
critical=False
)
if 'CONFLICT' in pull.get('out'):
self.m(
... | [
"def",
"_pull",
"(",
"self",
")",
":",
"pull",
"=",
"self",
".",
"m",
"(",
"'pulling remote changes'",
",",
"cmdd",
"=",
"dict",
"(",
"cmd",
"=",
"'git pull --tags'",
",",
"cwd",
"=",
"self",
".",
"local",
")",
",",
"critical",
"=",
"False",
")",
"if... | Helper function to pull from remote | [
"Helper",
"function",
"to",
"pull",
"from",
"remote"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/git.py#L416-L432 |
jenanwise/codequality | codequality/scmhandlers.py | _temp_filename | def _temp_filename(contents):
"""
Make a temporary file with `contents`.
The file will be cleaned up on exit.
"""
fp = tempfile.NamedTemporaryFile(
prefix='codequalitytmp', delete=False)
name = fp.name
fp.write(contents)
fp.close()
_files_to_cleanup.append(name)
return n... | python | def _temp_filename(contents):
"""
Make a temporary file with `contents`.
The file will be cleaned up on exit.
"""
fp = tempfile.NamedTemporaryFile(
prefix='codequalitytmp', delete=False)
name = fp.name
fp.write(contents)
fp.close()
_files_to_cleanup.append(name)
return n... | [
"def",
"_temp_filename",
"(",
"contents",
")",
":",
"fp",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"prefix",
"=",
"'codequalitytmp'",
",",
"delete",
"=",
"False",
")",
"name",
"=",
"fp",
".",
"name",
"fp",
".",
"write",
"(",
"contents",
")",
"fp"... | Make a temporary file with `contents`.
The file will be cleaned up on exit. | [
"Make",
"a",
"temporary",
"file",
"with",
"contents",
"."
] | train | https://github.com/jenanwise/codequality/blob/8a2bd767fd73091c49a5318fdbfb2b4fff77533d/codequality/scmhandlers.py#L212-L224 |
abe-winter/pg13-py | pg13/pg.py | set_options | def set_options(pool_or_cursor,row_instance):
"for connection-level options that need to be set on Row instances"
# todo: move around an Options object instead
for option in ('JSON_READ',): setattr(row_instance,option,getattr(pool_or_cursor,option,None))
return row_instance | python | def set_options(pool_or_cursor,row_instance):
"for connection-level options that need to be set on Row instances"
# todo: move around an Options object instead
for option in ('JSON_READ',): setattr(row_instance,option,getattr(pool_or_cursor,option,None))
return row_instance | [
"def",
"set_options",
"(",
"pool_or_cursor",
",",
"row_instance",
")",
":",
"# todo: move around an Options object instead\r",
"for",
"option",
"in",
"(",
"'JSON_READ'",
",",
")",
":",
"setattr",
"(",
"row_instance",
",",
"option",
",",
"getattr",
"(",
"pool_or_curs... | for connection-level options that need to be set on Row instances | [
"for",
"connection",
"-",
"level",
"options",
"that",
"need",
"to",
"be",
"set",
"on",
"Row",
"instances"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L53-L57 |
abe-winter/pg13-py | pg13/pg.py | transform_specialfield | def transform_specialfield(jsonify,f,v):
"helper for serialize_row"
raw = f.ser(v) if is_serdes(f) else v
return ujson.dumps(raw) if not isinstance(f,basestring) and jsonify else raw | python | def transform_specialfield(jsonify,f,v):
"helper for serialize_row"
raw = f.ser(v) if is_serdes(f) else v
return ujson.dumps(raw) if not isinstance(f,basestring) and jsonify else raw | [
"def",
"transform_specialfield",
"(",
"jsonify",
",",
"f",
",",
"v",
")",
":",
"raw",
"=",
"f",
".",
"ser",
"(",
"v",
")",
"if",
"is_serdes",
"(",
"f",
")",
"else",
"v",
"return",
"ujson",
".",
"dumps",
"(",
"raw",
")",
"if",
"not",
"isinstance",
... | helper for serialize_row | [
"helper",
"for",
"serialize_row"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L59-L62 |
abe-winter/pg13-py | pg13/pg.py | dirty | def dirty(field,ttl=None):
"decorator to cache the result of a function until a field changes"
if ttl is not None: raise NotImplementedError('pg.dirty ttl feature')
def decorator(f):
@functools.wraps(f)
def wrapper(self,*args,**kwargs):
# warning: not reentrant
d=self.dirty_cache[field]... | python | def dirty(field,ttl=None):
"decorator to cache the result of a function until a field changes"
if ttl is not None: raise NotImplementedError('pg.dirty ttl feature')
def decorator(f):
@functools.wraps(f)
def wrapper(self,*args,**kwargs):
# warning: not reentrant
d=self.dirty_cache[field]... | [
"def",
"dirty",
"(",
"field",
",",
"ttl",
"=",
"None",
")",
":",
"if",
"ttl",
"is",
"not",
"None",
":",
"raise",
"NotImplementedError",
"(",
"'pg.dirty ttl feature'",
")",
"def",
"decorator",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f"... | decorator to cache the result of a function until a field changes | [
"decorator",
"to",
"cache",
"the",
"result",
"of",
"a",
"function",
"until",
"a",
"field",
"changes"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L64-L74 |
abe-winter/pg13-py | pg13/pg.py | Row.create_indexes | def create_indexes(clas,pool_or_cursor):
"this gets called by create_table, but if you've created an index you can use it to add it (assuming none exist)"
for index in clas.INDEXES:
# note: these are specified as either 'field,field,field' or a runnable query. you can put any query you want in there
... | python | def create_indexes(clas,pool_or_cursor):
"this gets called by create_table, but if you've created an index you can use it to add it (assuming none exist)"
for index in clas.INDEXES:
# note: these are specified as either 'field,field,field' or a runnable query. you can put any query you want in there
... | [
"def",
"create_indexes",
"(",
"clas",
",",
"pool_or_cursor",
")",
":",
"for",
"index",
"in",
"clas",
".",
"INDEXES",
":",
"# note: these are specified as either 'field,field,field' or a runnable query. you can put any query you want in there\r",
"query",
"=",
"index",
"if",
"... | this gets called by create_table, but if you've created an index you can use it to add it (assuming none exist) | [
"this",
"gets",
"called",
"by",
"create_table",
"but",
"if",
"you",
"ve",
"created",
"an",
"index",
"you",
"can",
"use",
"it",
"to",
"add",
"it",
"(",
"assuming",
"none",
"exist",
")"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L104-L109 |
abe-winter/pg13-py | pg13/pg.py | Row.create_table | def create_table(clas,pool_or_cursor):
"uses FIELDS, PKEY, INDEXES and TABLE members to create a sql table for the model"
def mkfield((name,tp)): return name,(tp if isinstance(tp,basestring) else 'jsonb')
fields = ','.join(map(' '.join,map(mkfield,clas.FIELDS)))
base = 'create table if not exists %s... | python | def create_table(clas,pool_or_cursor):
"uses FIELDS, PKEY, INDEXES and TABLE members to create a sql table for the model"
def mkfield((name,tp)): return name,(tp if isinstance(tp,basestring) else 'jsonb')
fields = ','.join(map(' '.join,map(mkfield,clas.FIELDS)))
base = 'create table if not exists %s... | [
"def",
"create_table",
"(",
"clas",
",",
"pool_or_cursor",
")",
":",
"def",
"mkfield",
"(",
"(",
"name",
",",
"tp",
")",
")",
":",
"return",
"name",
",",
"(",
"tp",
"if",
"isinstance",
"(",
"tp",
",",
"basestring",
")",
"else",
"'jsonb'",
")",
"field... | uses FIELDS, PKEY, INDEXES and TABLE members to create a sql table for the model | [
"uses",
"FIELDS",
"PKEY",
"INDEXES",
"and",
"TABLE",
"members",
"to",
"create",
"a",
"sql",
"table",
"for",
"the",
"model"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L111-L119 |
abe-winter/pg13-py | pg13/pg.py | Row.pkey_get | def pkey_get(clas,pool_or_cursor,*vals):
"lookup by primary keys in order"
pkey = clas.PKEY.split(',')
if len(vals)!=len(pkey): raise ValueError("%i args != %i-len primary key for %s"%(len(vals),len(pkey),clas.TABLE))
rows = list(clas.select(pool_or_cursor,**dict(zip(pkey,vals))))
if not rows: ... | python | def pkey_get(clas,pool_or_cursor,*vals):
"lookup by primary keys in order"
pkey = clas.PKEY.split(',')
if len(vals)!=len(pkey): raise ValueError("%i args != %i-len primary key for %s"%(len(vals),len(pkey),clas.TABLE))
rows = list(clas.select(pool_or_cursor,**dict(zip(pkey,vals))))
if not rows: ... | [
"def",
"pkey_get",
"(",
"clas",
",",
"pool_or_cursor",
",",
"*",
"vals",
")",
":",
"pkey",
"=",
"clas",
".",
"PKEY",
".",
"split",
"(",
"','",
")",
"if",
"len",
"(",
"vals",
")",
"!=",
"len",
"(",
"pkey",
")",
":",
"raise",
"ValueError",
"(",
"\"... | lookup by primary keys in order | [
"lookup",
"by",
"primary",
"keys",
"in",
"order"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L143-L149 |
abe-winter/pg13-py | pg13/pg.py | Row.select | def select(clas,pool_or_cursor,**kwargs):
"note: This returns a generator, not a list. All your expectations will be violated"
columns = kwargs.pop('columns','*')
# todo(awinter): write a test for whether eqexpr matters; figure out pg behavior and apply to pgmock
query="select %s from %s"%(columns,c... | python | def select(clas,pool_or_cursor,**kwargs):
"note: This returns a generator, not a list. All your expectations will be violated"
columns = kwargs.pop('columns','*')
# todo(awinter): write a test for whether eqexpr matters; figure out pg behavior and apply to pgmock
query="select %s from %s"%(columns,c... | [
"def",
"select",
"(",
"clas",
",",
"pool_or_cursor",
",",
"*",
"*",
"kwargs",
")",
":",
"columns",
"=",
"kwargs",
".",
"pop",
"(",
"'columns'",
",",
"'*'",
")",
"# todo(awinter): write a test for whether eqexpr matters; figure out pg behavior and apply to pgmock\r",
"qu... | note: This returns a generator, not a list. All your expectations will be violated | [
"note",
":",
"This",
"returns",
"a",
"generator",
"not",
"a",
"list",
".",
"All",
"your",
"expectations",
"will",
"be",
"violated"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L157-L163 |
abe-winter/pg13-py | pg13/pg.py | Row.select_models | def select_models(clas,pool_or_cursor,**kwargs):
"returns generator yielding instances of the class"
if 'columns' in kwargs: raise ValueError("don't pass 'columns' to select_models")
return (set_options(pool_or_cursor,clas(*row)) for row in clas.select(pool_or_cursor,**kwargs)) | python | def select_models(clas,pool_or_cursor,**kwargs):
"returns generator yielding instances of the class"
if 'columns' in kwargs: raise ValueError("don't pass 'columns' to select_models")
return (set_options(pool_or_cursor,clas(*row)) for row in clas.select(pool_or_cursor,**kwargs)) | [
"def",
"select_models",
"(",
"clas",
",",
"pool_or_cursor",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'columns'",
"in",
"kwargs",
":",
"raise",
"ValueError",
"(",
"\"don't pass 'columns' to select_models\"",
")",
"return",
"(",
"set_options",
"(",
"pool_or_cursor"... | returns generator yielding instances of the class | [
"returns",
"generator",
"yielding",
"instances",
"of",
"the",
"class"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L165-L168 |
abe-winter/pg13-py | pg13/pg.py | Row.kwinsert | def kwinsert(clas,pool_or_cursor,**kwargs):
"kwargs version of insert"
returning = kwargs.pop('returning',None)
fields,vals = zip(*kwargs.items())
# note: don't do SpecialField resolution here; clas.insert takes care of it
return clas.insert(pool_or_cursor,fields,vals,returning=returning) | python | def kwinsert(clas,pool_or_cursor,**kwargs):
"kwargs version of insert"
returning = kwargs.pop('returning',None)
fields,vals = zip(*kwargs.items())
# note: don't do SpecialField resolution here; clas.insert takes care of it
return clas.insert(pool_or_cursor,fields,vals,returning=returning) | [
"def",
"kwinsert",
"(",
"clas",
",",
"pool_or_cursor",
",",
"*",
"*",
"kwargs",
")",
":",
"returning",
"=",
"kwargs",
".",
"pop",
"(",
"'returning'",
",",
"None",
")",
"fields",
",",
"vals",
"=",
"zip",
"(",
"*",
"kwargs",
".",
"items",
"(",
")",
"... | kwargs version of insert | [
"kwargs",
"version",
"of",
"insert"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L208-L213 |
abe-winter/pg13-py | pg13/pg.py | Row.kwinsert_mk | def kwinsert_mk(clas,pool_or_cursor,**kwargs):
"wrapper for kwinsert that returns a constructed class. use this over kwinsert in most cases"
if 'returning' in kwargs: raise ValueError("don't call kwinsert_mk with 'returning'")
return set_options(
pool_or_cursor,
clas(*clas.kwinsert(pool_or_... | python | def kwinsert_mk(clas,pool_or_cursor,**kwargs):
"wrapper for kwinsert that returns a constructed class. use this over kwinsert in most cases"
if 'returning' in kwargs: raise ValueError("don't call kwinsert_mk with 'returning'")
return set_options(
pool_or_cursor,
clas(*clas.kwinsert(pool_or_... | [
"def",
"kwinsert_mk",
"(",
"clas",
",",
"pool_or_cursor",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'returning'",
"in",
"kwargs",
":",
"raise",
"ValueError",
"(",
"\"don't call kwinsert_mk with 'returning'\"",
")",
"return",
"set_options",
"(",
"pool_or_cursor",
"... | wrapper for kwinsert that returns a constructed class. use this over kwinsert in most cases | [
"wrapper",
"for",
"kwinsert",
"that",
"returns",
"a",
"constructed",
"class",
".",
"use",
"this",
"over",
"kwinsert",
"in",
"most",
"cases"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L215-L221 |
abe-winter/pg13-py | pg13/pg.py | Row.updatewhere | def updatewhere(clas,pool_or_cursor,where_keys,**update_keys):
"this doesn't allow raw_keys for now"
# if clas.JSONFIELDS: raise NotImplementedError # todo(awinter): do I need to make the same change for SpecialField?
if not where_keys or not update_keys: raise ValueError
setclause=','.join(k+'=%s' ... | python | def updatewhere(clas,pool_or_cursor,where_keys,**update_keys):
"this doesn't allow raw_keys for now"
# if clas.JSONFIELDS: raise NotImplementedError # todo(awinter): do I need to make the same change for SpecialField?
if not where_keys or not update_keys: raise ValueError
setclause=','.join(k+'=%s' ... | [
"def",
"updatewhere",
"(",
"clas",
",",
"pool_or_cursor",
",",
"where_keys",
",",
"*",
"*",
"update_keys",
")",
":",
"# if clas.JSONFIELDS: raise NotImplementedError # todo(awinter): do I need to make the same change for SpecialField?\r",
"if",
"not",
"where_keys",
"or",
"not",... | this doesn't allow raw_keys for now | [
"this",
"doesn",
"t",
"allow",
"raw_keys",
"for",
"now"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L277-L285 |
abe-winter/pg13-py | pg13/pg.py | Row.delete | def delete(self,pool_or_cursor):
".. warning:: pgmock doesn't support delete yet, so this isn't tested"
vals=self.pkey_vals()
whereclause=' and '.join('%s=%%s'%k for k in self.PKEY.split(','))
q='delete from %s where %s'%(self.TABLE,whereclause)
commit_or_execute(pool_or_cursor,q,vals) | python | def delete(self,pool_or_cursor):
".. warning:: pgmock doesn't support delete yet, so this isn't tested"
vals=self.pkey_vals()
whereclause=' and '.join('%s=%%s'%k for k in self.PKEY.split(','))
q='delete from %s where %s'%(self.TABLE,whereclause)
commit_or_execute(pool_or_cursor,q,vals) | [
"def",
"delete",
"(",
"self",
",",
"pool_or_cursor",
")",
":",
"vals",
"=",
"self",
".",
"pkey_vals",
"(",
")",
"whereclause",
"=",
"' and '",
".",
"join",
"(",
"'%s=%%s'",
"%",
"k",
"for",
"k",
"in",
"self",
".",
"PKEY",
".",
"split",
"(",
"','",
... | .. warning:: pgmock doesn't support delete yet, so this isn't tested | [
"..",
"warning",
"::",
"pgmock",
"doesn",
"t",
"support",
"delete",
"yet",
"so",
"this",
"isn",
"t",
"tested"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L286-L291 |
abe-winter/pg13-py | pg13/pg.py | Row.refkeys | def refkeys(self,fields):
"returns {ModelClass:list_of_pkey_tuples}. see syncschema.RefKey. Don't use this yet."
# todo doc: better explanation of what refkeys are and how fields plays in
dd=collections.defaultdict(list)
if any(f not in self.REFKEYS for f in fields): raise ValueError(fields,'not all... | python | def refkeys(self,fields):
"returns {ModelClass:list_of_pkey_tuples}. see syncschema.RefKey. Don't use this yet."
# todo doc: better explanation of what refkeys are and how fields plays in
dd=collections.defaultdict(list)
if any(f not in self.REFKEYS for f in fields): raise ValueError(fields,'not all... | [
"def",
"refkeys",
"(",
"self",
",",
"fields",
")",
":",
"# todo doc: better explanation of what refkeys are and how fields plays in\r",
"dd",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"if",
"any",
"(",
"f",
"not",
"in",
"self",
".",
"REFKEYS",
"for... | returns {ModelClass:list_of_pkey_tuples}. see syncschema.RefKey. Don't use this yet. | [
"returns",
"{",
"ModelClass",
":",
"list_of_pkey_tuples",
"}",
".",
"see",
"syncschema",
".",
"RefKey",
".",
"Don",
"t",
"use",
"this",
"yet",
"."
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pg.py#L296-L304 |
ulf1/oxyba | oxyba/clean_to_decimal.py | clean_to_decimal | def clean_to_decimal(x, prec=28):
"""Convert an string, int or float to Decimal object
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string, int or float number, or a list, array or
dataframe of these.
digits : int
(Default prec=None)
... | python | def clean_to_decimal(x, prec=28):
"""Convert an string, int or float to Decimal object
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string, int or float number, or a list, array or
dataframe of these.
digits : int
(Default prec=None)
... | [
"def",
"clean_to_decimal",
"(",
"x",
",",
"prec",
"=",
"28",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"pandas",
"as",
"pd",
"import",
"decimal",
"def",
"proc_elem",
"(",
"e",
")",
":",
"try",
":",
"return",
"decimal",
".",
"Decimal",
"(",
"... | Convert an string, int or float to Decimal object
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string, int or float number, or a list, array or
dataframe of these.
digits : int
(Default prec=None)
Set the getcontext precision
Return... | [
"Convert",
"an",
"string",
"int",
"or",
"float",
"to",
"Decimal",
"object"
] | train | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/clean_to_decimal.py#L2-L69 |
minhhoit/yacms | yacms/generic/templatetags/rating_tags.py | rating_for | def rating_for(context, obj):
"""
Provides a generic context variable name for the object that
ratings are being rendered for, and the rating form.
"""
context["rating_object"] = context["rating_obj"] = obj
context["rating_form"] = RatingForm(context["request"], obj)
ratings = context["reque... | python | def rating_for(context, obj):
"""
Provides a generic context variable name for the object that
ratings are being rendered for, and the rating form.
"""
context["rating_object"] = context["rating_obj"] = obj
context["rating_form"] = RatingForm(context["request"], obj)
ratings = context["reque... | [
"def",
"rating_for",
"(",
"context",
",",
"obj",
")",
":",
"context",
"[",
"\"rating_object\"",
"]",
"=",
"context",
"[",
"\"rating_obj\"",
"]",
"=",
"obj",
"context",
"[",
"\"rating_form\"",
"]",
"=",
"RatingForm",
"(",
"context",
"[",
"\"request\"",
"]",
... | Provides a generic context variable name for the object that
ratings are being rendered for, and the rating form. | [
"Provides",
"a",
"generic",
"context",
"variable",
"name",
"for",
"the",
"object",
"that",
"ratings",
"are",
"being",
"rendered",
"for",
"and",
"the",
"rating",
"form",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/templatetags/rating_tags.py#L11-L24 |
pjuren/pyokit | src/pyokit/util/fileUtils.py | getUniqueFilename | def getUniqueFilename(dir=None, base=None):
"""
DESCRP: Generate a filename in the directory <dir> which is
unique (i.e. not in use at the moment)
PARAMS: dir -- the directory to look in. If None, use CWD
base -- use this as the base name for the filename
RETURN: string -- the fil... | python | def getUniqueFilename(dir=None, base=None):
"""
DESCRP: Generate a filename in the directory <dir> which is
unique (i.e. not in use at the moment)
PARAMS: dir -- the directory to look in. If None, use CWD
base -- use this as the base name for the filename
RETURN: string -- the fil... | [
"def",
"getUniqueFilename",
"(",
"dir",
"=",
"None",
",",
"base",
"=",
"None",
")",
":",
"while",
"True",
":",
"fn",
"=",
"str",
"(",
"random",
".",
"randint",
"(",
"0",
",",
"100000",
")",
")",
"+",
"\".tmp\"",
"if",
"not",
"os",
".",
"path",
".... | DESCRP: Generate a filename in the directory <dir> which is
unique (i.e. not in use at the moment)
PARAMS: dir -- the directory to look in. If None, use CWD
base -- use this as the base name for the filename
RETURN: string -- the filename generated | [
"DESCRP",
":",
"Generate",
"a",
"filename",
"in",
"the",
"directory",
"<dir",
">",
"which",
"is",
"unique",
"(",
"i",
".",
"e",
".",
"not",
"in",
"use",
"at",
"the",
"moment",
")",
"PARAMS",
":",
"dir",
"--",
"the",
"directory",
"to",
"look",
"in",
... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/util/fileUtils.py#L65-L77 |
jldantas/libmft | libmft/attribute.py | get_attr_info | def get_attr_info(binary_view):
'''Gets basic information from a binary stream to allow correct processing of
the attribute header.
This function allows the interpretation of the Attribute type, attribute length
and if the attribute is non resident.
Args:
binary_view (memoryview of bytearr... | python | def get_attr_info(binary_view):
'''Gets basic information from a binary stream to allow correct processing of
the attribute header.
This function allows the interpretation of the Attribute type, attribute length
and if the attribute is non resident.
Args:
binary_view (memoryview of bytearr... | [
"def",
"get_attr_info",
"(",
"binary_view",
")",
":",
"global",
"_ATTR_BASIC",
"attr_type",
",",
"attr_len",
",",
"non_resident",
"=",
"_ATTR_BASIC",
".",
"unpack",
"(",
"binary_view",
"[",
":",
"9",
"]",
")",
"return",
"(",
"AttrTypes",
"(",
"attr_type",
")... | Gets basic information from a binary stream to allow correct processing of
the attribute header.
This function allows the interpretation of the Attribute type, attribute length
and if the attribute is non resident.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
... | [
"Gets",
"basic",
"information",
"from",
"a",
"binary",
"stream",
"to",
"allow",
"correct",
"processing",
"of",
"the",
"attribute",
"header",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L59-L78 |
jldantas/libmft | libmft/attribute.py | _create_attrcontent_class | def _create_attrcontent_class(name, fields, inheritance=(object,), data_structure=None, extra_functions=None, docstring=""):
'''Helper function that creates a class for attribute contents.
This function creates is a boilerplate to create all the expected methods of
an attributes. The basic methods work in ... | python | def _create_attrcontent_class(name, fields, inheritance=(object,), data_structure=None, extra_functions=None, docstring=""):
'''Helper function that creates a class for attribute contents.
This function creates is a boilerplate to create all the expected methods of
an attributes. The basic methods work in ... | [
"def",
"_create_attrcontent_class",
"(",
"name",
",",
"fields",
",",
"inheritance",
"=",
"(",
"object",
",",
")",
",",
"data_structure",
"=",
"None",
",",
"extra_functions",
"=",
"None",
",",
"docstring",
"=",
"\"\"",
")",
":",
"def",
"create_func_from_str",
... | Helper function that creates a class for attribute contents.
This function creates is a boilerplate to create all the expected methods of
an attributes. The basic methods work in the same way for all classes.
Once it executes it defines a dynamic class with the methods "__init__",
"__repr__" and "__eq... | [
"Helper",
"function",
"that",
"creates",
"a",
"class",
"for",
"attribute",
"contents",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L80-L210 |
jldantas/libmft | libmft/attribute.py | _from_binary_ts | def _from_binary_ts(cls, binary_stream):
"""See base class."""
repr = cls._REPR
if len(binary_stream) != repr.size:
raise ContentError("Invalid binary stream size")
content = repr.unpack(binary_stream)
nw_obj = cls()
nw_obj.created, nw_obj.changed, nw_obj.mft_changed, nw_obj.accessed =... | python | def _from_binary_ts(cls, binary_stream):
"""See base class."""
repr = cls._REPR
if len(binary_stream) != repr.size:
raise ContentError("Invalid binary stream size")
content = repr.unpack(binary_stream)
nw_obj = cls()
nw_obj.created, nw_obj.changed, nw_obj.mft_changed, nw_obj.accessed =... | [
"def",
"_from_binary_ts",
"(",
"cls",
",",
"binary_stream",
")",
":",
"repr",
"=",
"cls",
".",
"_REPR",
"if",
"len",
"(",
"binary_stream",
")",
"!=",
"repr",
".",
"size",
":",
"raise",
"ContentError",
"(",
"\"Invalid binary stream size\"",
")",
"content",
"=... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L678-L693 |
jldantas/libmft | libmft/attribute.py | _astimezone_ts | def _astimezone_ts(self, timezone):
"""Changes the time zones of all timestamps.
Receives a new timezone and applies to all timestamps, if necessary.
Args:
timezone (:obj:`tzinfo`): Time zone to be applied
Returns:
A new ``Timestamps`` object if the time zone changes, otherwise return... | python | def _astimezone_ts(self, timezone):
"""Changes the time zones of all timestamps.
Receives a new timezone and applies to all timestamps, if necessary.
Args:
timezone (:obj:`tzinfo`): Time zone to be applied
Returns:
A new ``Timestamps`` object if the time zone changes, otherwise return... | [
"def",
"_astimezone_ts",
"(",
"self",
",",
"timezone",
")",
":",
"if",
"self",
".",
"created",
".",
"tzinfo",
"is",
"timezone",
":",
"return",
"self",
"else",
":",
"nw_obj",
"=",
"Timestamps",
"(",
"(",
"None",
",",
")",
"*",
"4",
")",
"nw_obj",
".",... | Changes the time zones of all timestamps.
Receives a new timezone and applies to all timestamps, if necessary.
Args:
timezone (:obj:`tzinfo`): Time zone to be applied
Returns:
A new ``Timestamps`` object if the time zone changes, otherwise returns ``self``. | [
"Changes",
"the",
"time",
"zones",
"of",
"all",
"timestamps",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L695-L715 |
jldantas/libmft | libmft/attribute.py | _from_binary_stdinfo | def _from_binary_stdinfo(cls, binary_stream):
"""See base class."""
'''
TIMESTAMPS(32)
Creation time - 8
File altered time - 8
MFT/Metadata altered time - 8
Accessed time - 8
Flags - 4 (FileInfoFlags)
Maximum number of versions - 4
... | python | def _from_binary_stdinfo(cls, binary_stream):
"""See base class."""
'''
TIMESTAMPS(32)
Creation time - 8
File altered time - 8
MFT/Metadata altered time - 8
Accessed time - 8
Flags - 4 (FileInfoFlags)
Maximum number of versions - 4
... | [
"def",
"_from_binary_stdinfo",
"(",
"cls",
",",
"binary_stream",
")",
":",
"'''\n TIMESTAMPS(32)\n Creation time - 8\n File altered time - 8\n MFT/Metadata altered time - 8\n Accessed time - 8\n Flags - 4 (FileInfoFlags)\n Maximum numb... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L756-L792 |
jldantas/libmft | libmft/attribute.py | _from_binary_attrlist_e | def _from_binary_attrlist_e(cls, binary_stream):
"""See base class."""
'''
Attribute type - 4
Length of a particular entry - 2
Length of the name - 1 (in characters)
Offset to name - 1
Starting VCN - 8
File reference - 8
Attribute ID - 1
Name (unic... | python | def _from_binary_attrlist_e(cls, binary_stream):
"""See base class."""
'''
Attribute type - 4
Length of a particular entry - 2
Length of the name - 1 (in characters)
Offset to name - 1
Starting VCN - 8
File reference - 8
Attribute ID - 1
Name (unic... | [
"def",
"_from_binary_attrlist_e",
"(",
"cls",
",",
"binary_stream",
")",
":",
"'''\n Attribute type - 4\n Length of a particular entry - 2\n Length of the name - 1 (in characters)\n Offset to name - 1\n Starting VCN - 8\n File reference - 8\n Attribut... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L842-L865 |
jldantas/libmft | libmft/attribute.py | _from_binary_attrlist | def _from_binary_attrlist(cls, binary_stream):
"""See base class."""
_attr_list = []
offset = 0
while True:
entry = AttributeListEntry.create_from_binary(binary_stream[offset:])
offset += len(entry)
_attr_list.append(entry)
if offset >= len(binary_stream):
br... | python | def _from_binary_attrlist(cls, binary_stream):
"""See base class."""
_attr_list = []
offset = 0
while True:
entry = AttributeListEntry.create_from_binary(binary_stream[offset:])
offset += len(entry)
_attr_list.append(entry)
if offset >= len(binary_stream):
br... | [
"def",
"_from_binary_attrlist",
"(",
"cls",
",",
"binary_stream",
")",
":",
"_attr_list",
"=",
"[",
"]",
"offset",
"=",
"0",
"while",
"True",
":",
"entry",
"=",
"AttributeListEntry",
".",
"create_from_binary",
"(",
"binary_stream",
"[",
"offset",
":",
"]",
"... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L914-L928 |
jldantas/libmft | libmft/attribute.py | _from_binary_objid | def _from_binary_objid(cls, binary_stream):
"""See base class."""
uid_size = ObjectID._UUID_SIZE
#some entries might not have all four ids, this line forces
#to always create 4 elements, so contruction is easier
uids = [UUID(bytes_le=binary_stream[i*uid_size:(i+1)*uid_size].tobytes()) if i * uid_si... | python | def _from_binary_objid(cls, binary_stream):
"""See base class."""
uid_size = ObjectID._UUID_SIZE
#some entries might not have all four ids, this line forces
#to always create 4 elements, so contruction is easier
uids = [UUID(bytes_le=binary_stream[i*uid_size:(i+1)*uid_size].tobytes()) if i * uid_si... | [
"def",
"_from_binary_objid",
"(",
"cls",
",",
"binary_stream",
")",
":",
"uid_size",
"=",
"ObjectID",
".",
"_UUID_SIZE",
"#some entries might not have all four ids, this line forces",
"#to always create 4 elements, so contruction is easier",
"uids",
"=",
"[",
"UUID",
"(",
"by... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L967-L976 |
jldantas/libmft | libmft/attribute.py | _len_objid | def _len_objid(self):
'''Get the actual size of the content, as some attributes have variable sizes'''
try:
return self._size
except AttributeError:
temp = (self.object_id, self.birth_vol_id, self.birth_object_id, self.birth_domain_id)
self._size = sum([ObjectID._UUID_SIZE for data i... | python | def _len_objid(self):
'''Get the actual size of the content, as some attributes have variable sizes'''
try:
return self._size
except AttributeError:
temp = (self.object_id, self.birth_vol_id, self.birth_object_id, self.birth_domain_id)
self._size = sum([ObjectID._UUID_SIZE for data i... | [
"def",
"_len_objid",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_size",
"except",
"AttributeError",
":",
"temp",
"=",
"(",
"self",
".",
"object_id",
",",
"self",
".",
"birth_vol_id",
",",
"self",
".",
"birth_object_id",
",",
"self",
".",
... | Get the actual size of the content, as some attributes have variable sizes | [
"Get",
"the",
"actual",
"size",
"of",
"the",
"content",
"as",
"some",
"attributes",
"have",
"variable",
"sizes"
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L978-L985 |
jldantas/libmft | libmft/attribute.py | _from_binary_volname | def _from_binary_volname(cls, binary_stream):
"""See base class."""
name = binary_stream.tobytes().decode("utf_16_le")
_MOD_LOGGER.debug("Attempted to unpack VOLUME_NAME Entry from \"%s\"\nResult: %s", binary_stream.tobytes(), name)
return cls(name) | python | def _from_binary_volname(cls, binary_stream):
"""See base class."""
name = binary_stream.tobytes().decode("utf_16_le")
_MOD_LOGGER.debug("Attempted to unpack VOLUME_NAME Entry from \"%s\"\nResult: %s", binary_stream.tobytes(), name)
return cls(name) | [
"def",
"_from_binary_volname",
"(",
"cls",
",",
"binary_stream",
")",
":",
"name",
"=",
"binary_stream",
".",
"tobytes",
"(",
")",
".",
"decode",
"(",
"\"utf_16_le\"",
")",
"_MOD_LOGGER",
".",
"debug",
"(",
"\"Attempted to unpack VOLUME_NAME Entry from \\\"%s\\\"\\nRe... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1025-L1031 |
jldantas/libmft | libmft/attribute.py | _from_binary_volinfo | def _from_binary_volinfo(cls, binary_stream):
"""See base class."""
content = cls._REPR.unpack(binary_stream)
nw_obj = cls(content)
nw_obj.vol_flags = VolumeFlags(content[2])
_MOD_LOGGER.debug("Attempted to unpack VOLUME_INFORMATION Entry from \"%s\"\nResult: %s", binary_stream.tobytes(), content)... | python | def _from_binary_volinfo(cls, binary_stream):
"""See base class."""
content = cls._REPR.unpack(binary_stream)
nw_obj = cls(content)
nw_obj.vol_flags = VolumeFlags(content[2])
_MOD_LOGGER.debug("Attempted to unpack VOLUME_INFORMATION Entry from \"%s\"\nResult: %s", binary_stream.tobytes(), content)... | [
"def",
"_from_binary_volinfo",
"(",
"cls",
",",
"binary_stream",
")",
":",
"content",
"=",
"cls",
".",
"_REPR",
".",
"unpack",
"(",
"binary_stream",
")",
"nw_obj",
"=",
"cls",
"(",
"content",
")",
"nw_obj",
".",
"vol_flags",
"=",
"VolumeFlags",
"(",
"conte... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1058-L1067 |
jldantas/libmft | libmft/attribute.py | _from_binary_filename | def _from_binary_filename(cls, binary_stream):
"""See base class."""
''' File reference to parent directory - 8
TIMESTAMPS(32)
Creation time - 8
File altered time - 8
MFT/Metadata altered time - 8
Accessed time - 8
Allocated size of file - 8 (multi... | python | def _from_binary_filename(cls, binary_stream):
"""See base class."""
''' File reference to parent directory - 8
TIMESTAMPS(32)
Creation time - 8
File altered time - 8
MFT/Metadata altered time - 8
Accessed time - 8
Allocated size of file - 8 (multi... | [
"def",
"_from_binary_filename",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' File reference to parent directory - 8\n TIMESTAMPS(32)\n Creation time - 8\n File altered time - 8\n MFT/Metadata altered time - 8\n Accessed time - 8\n Allocat... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1106-L1135 |
jldantas/libmft | libmft/attribute.py | _from_binary_idx_nh | def _from_binary_idx_nh(cls, binary_stream):
"""See base class."""
''' Offset to start of index entry - 4
Offset to end of used portion of index entry - 4
Offset to end of the allocated index entry - 4
Flags - 4
'''
nw_obj = cls(cls._REPR.unpack(binary_stream[:cls._REPR.size]))
... | python | def _from_binary_idx_nh(cls, binary_stream):
"""See base class."""
''' Offset to start of index entry - 4
Offset to end of used portion of index entry - 4
Offset to end of the allocated index entry - 4
Flags - 4
'''
nw_obj = cls(cls._REPR.unpack(binary_stream[:cls._REPR.size]))
... | [
"def",
"_from_binary_idx_nh",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' Offset to start of index entry - 4\n Offset to end of used portion of index entry - 4\n Offset to end of the allocated index entry - 4\n Flags - 4\n '''",
"nw_obj",
"=",
"cls",
"(",
"cls"... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1225-L1236 |
jldantas/libmft | libmft/attribute.py | _from_binary_idx_e | def _from_binary_idx_e(cls, binary_stream, content_type=None):
"""See base class."""
#TODO don't save this here and overload later?
#TODO confirm if this is really generic or is always a file reference
''' Undefined - 8
Length of entry - 2
Length of content - 2
Flags - 4
... | python | def _from_binary_idx_e(cls, binary_stream, content_type=None):
"""See base class."""
#TODO don't save this here and overload later?
#TODO confirm if this is really generic or is always a file reference
''' Undefined - 8
Length of entry - 2
Length of content - 2
Flags - 4
... | [
"def",
"_from_binary_idx_e",
"(",
"cls",
",",
"binary_stream",
",",
"content_type",
"=",
"None",
")",
":",
"#TODO don't save this here and overload later?",
"#TODO confirm if this is really generic or is always a file reference",
"''' Undefined - 8\n Length of entry - 2\n L... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1276-L1306 |
jldantas/libmft | libmft/attribute.py | _from_binary_idx_root | def _from_binary_idx_root(cls, binary_stream):
"""See base class."""
''' Attribute type - 4
Collation rule - 4
Bytes per index record - 4
Clusters per index record - 1
Padding - 3
'''
attr_type, collation_rule, b_per_idx_r, c_per_idx_r = cls._REPR.unpack(binary_stream[:cl... | python | def _from_binary_idx_root(cls, binary_stream):
"""See base class."""
''' Attribute type - 4
Collation rule - 4
Bytes per index record - 4
Clusters per index record - 1
Padding - 3
'''
attr_type, collation_rule, b_per_idx_r, c_per_idx_r = cls._REPR.unpack(binary_stream[:cl... | [
"def",
"_from_binary_idx_root",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' Attribute type - 4\n Collation rule - 4\n Bytes per index record - 4\n Clusters per index record - 1\n Padding - 3\n '''",
"attr_type",
",",
"collation_rule",
",",
"b_per_idx_r",... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1352-L1380 |
jldantas/libmft | libmft/attribute.py | _allocated_entries_bitmap | def _allocated_entries_bitmap(self):
'''Creates a generator that returns all allocated entries in the
bitmap.
Yields:
int: The bit index of the allocated entries.
'''
for entry_number in range(len(self._bitmap) * 8):
if self.entry_allocated(entry_number):
yield entry_nu... | python | def _allocated_entries_bitmap(self):
'''Creates a generator that returns all allocated entries in the
bitmap.
Yields:
int: The bit index of the allocated entries.
'''
for entry_number in range(len(self._bitmap) * 8):
if self.entry_allocated(entry_number):
yield entry_nu... | [
"def",
"_allocated_entries_bitmap",
"(",
"self",
")",
":",
"for",
"entry_number",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"_bitmap",
")",
"*",
"8",
")",
":",
"if",
"self",
".",
"entry_allocated",
"(",
"entry_number",
")",
":",
"yield",
"entry_number"
... | Creates a generator that returns all allocated entries in the
bitmap.
Yields:
int: The bit index of the allocated entries. | [
"Creates",
"a",
"generator",
"that",
"returns",
"all",
"allocated",
"entries",
"in",
"the",
"bitmap",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1427-L1437 |
jldantas/libmft | libmft/attribute.py | _entry_allocated_bitmap | def _entry_allocated_bitmap(self, entry_number):
"""Checks if a particular index is allocated.
Args:
entry_number (int): Index to verify
Returns:
bool: True if it is allocated, False otherwise.
"""
index, offset = divmod(entry_number, 8)
return bool(self._bitmap[index] & (1 << ... | python | def _entry_allocated_bitmap(self, entry_number):
"""Checks if a particular index is allocated.
Args:
entry_number (int): Index to verify
Returns:
bool: True if it is allocated, False otherwise.
"""
index, offset = divmod(entry_number, 8)
return bool(self._bitmap[index] & (1 << ... | [
"def",
"_entry_allocated_bitmap",
"(",
"self",
",",
"entry_number",
")",
":",
"index",
",",
"offset",
"=",
"divmod",
"(",
"entry_number",
",",
"8",
")",
"return",
"bool",
"(",
"self",
".",
"_bitmap",
"[",
"index",
"]",
"&",
"(",
"1",
"<<",
"offset",
")... | Checks if a particular index is allocated.
Args:
entry_number (int): Index to verify
Returns:
bool: True if it is allocated, False otherwise. | [
"Checks",
"if",
"a",
"particular",
"index",
"is",
"allocated",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1439-L1449 |
jldantas/libmft | libmft/attribute.py | _get_next_empty_bitmap | def _get_next_empty_bitmap(self):
"""Returns the next empty entry.
Returns:
int: The value of the empty entry
"""
#TODO probably not the best way, redo
for i, byte in enumerate(self._bitmap):
if byte != 255:
for offset in range(8):
if not byte & (1 << off... | python | def _get_next_empty_bitmap(self):
"""Returns the next empty entry.
Returns:
int: The value of the empty entry
"""
#TODO probably not the best way, redo
for i, byte in enumerate(self._bitmap):
if byte != 255:
for offset in range(8):
if not byte & (1 << off... | [
"def",
"_get_next_empty_bitmap",
"(",
"self",
")",
":",
"#TODO probably not the best way, redo",
"for",
"i",
",",
"byte",
"in",
"enumerate",
"(",
"self",
".",
"_bitmap",
")",
":",
"if",
"byte",
"!=",
"255",
":",
"for",
"offset",
"in",
"range",
"(",
"8",
")... | Returns the next empty entry.
Returns:
int: The value of the empty entry | [
"Returns",
"the",
"next",
"empty",
"entry",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1451-L1462 |
jldantas/libmft | libmft/attribute.py | _from_binary_syn_link | def _from_binary_syn_link(cls, binary_stream):
"""See base class."""
''' Offset to target name - 2 (relative to 16th byte)
Length of target name - 2
Offset to print name - 2 (relative to 16th byte)
Length of print name - 2
Symbolic link flags - 4
'''
offset_target_name, l... | python | def _from_binary_syn_link(cls, binary_stream):
"""See base class."""
''' Offset to target name - 2 (relative to 16th byte)
Length of target name - 2
Offset to print name - 2 (relative to 16th byte)
Length of print name - 2
Symbolic link flags - 4
'''
offset_target_name, l... | [
"def",
"_from_binary_syn_link",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' Offset to target name - 2 (relative to 16th byte)\n Length of target name - 2\n Offset to print name - 2 (relative to 16th byte)\n Length of print name - 2\n Symbolic link flags - 4\n '''"... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1547-L1568 |
jldantas/libmft | libmft/attribute.py | _from_binary_reparse | def _from_binary_reparse(cls, binary_stream):
"""See base class."""
''' Reparse type flags - 4
Reparse tag - 4 bits
Reserved - 12 bits
Reparse type - 2 bits
Reparse data length - 2
Padding - 2
'''
#content = cls._REPR.unpack(binary_view[:cls._REPR.size... | python | def _from_binary_reparse(cls, binary_stream):
"""See base class."""
''' Reparse type flags - 4
Reparse tag - 4 bits
Reserved - 12 bits
Reparse type - 2 bits
Reparse data length - 2
Padding - 2
'''
#content = cls._REPR.unpack(binary_view[:cls._REPR.size... | [
"def",
"_from_binary_reparse",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' Reparse type flags - 4\n Reparse tag - 4 bits\n Reserved - 12 bits\n Reparse type - 2 bits\n Reparse data length - 2\n Padding - 2\n '''",
"#content = cls._REPR.unpack(... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1599-L1630 |
jldantas/libmft | libmft/attribute.py | _from_binary_ea_info | def _from_binary_ea_info(cls, binary_stream):
"""See base class."""
''' Size of Extended Attribute entry - 2
Number of Extended Attributes which have NEED_EA set - 2
Size of extended attribute data - 4
'''
return cls(cls._REPR.unpack(binary_stream[:cls._REPR.size])) | python | def _from_binary_ea_info(cls, binary_stream):
"""See base class."""
''' Size of Extended Attribute entry - 2
Number of Extended Attributes which have NEED_EA set - 2
Size of extended attribute data - 4
'''
return cls(cls._REPR.unpack(binary_stream[:cls._REPR.size])) | [
"def",
"_from_binary_ea_info",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' Size of Extended Attribute entry - 2\n Number of Extended Attributes which have NEED_EA set - 2\n Size of extended attribute data - 4\n '''",
"return",
"cls",
"(",
"cls",
".",
"_REPR",
".",... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1684-L1690 |
jldantas/libmft | libmft/attribute.py | _from_binary_ea_entry | def _from_binary_ea_entry(cls, binary_stream):
"""See base class."""
''' Offset to the next EA - 4
Flags - 1
Name length - 1
Value length - 2
'''
offset_next_ea, flags, name_len, value_len = cls._REPR.unpack(binary_stream[:cls._REPR.size])
name = binary_stream[cls._REPR.siz... | python | def _from_binary_ea_entry(cls, binary_stream):
"""See base class."""
''' Offset to the next EA - 4
Flags - 1
Name length - 1
Value length - 2
'''
offset_next_ea, flags, name_len, value_len = cls._REPR.unpack(binary_stream[:cls._REPR.size])
name = binary_stream[cls._REPR.siz... | [
"def",
"_from_binary_ea_entry",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' Offset to the next EA - 4\n Flags - 1\n Name length - 1\n Value length - 2\n '''",
"offset_next_ea",
",",
"flags",
",",
"name_len",
",",
"value_len",
"=",
"cls",
".",
"_REP... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1729-L1748 |
jldantas/libmft | libmft/attribute.py | _len_ea_entry | def _len_ea_entry(self):
'''Returns the size of the entry'''
return EaEntry._REPR.size + len(self.name.encode("ascii")) + self.value_len | python | def _len_ea_entry(self):
'''Returns the size of the entry'''
return EaEntry._REPR.size + len(self.name.encode("ascii")) + self.value_len | [
"def",
"_len_ea_entry",
"(",
"self",
")",
":",
"return",
"EaEntry",
".",
"_REPR",
".",
"size",
"+",
"len",
"(",
"self",
".",
"name",
".",
"encode",
"(",
"\"ascii\"",
")",
")",
"+",
"self",
".",
"value_len"
] | Returns the size of the entry | [
"Returns",
"the",
"size",
"of",
"the",
"entry"
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1750-L1752 |
jldantas/libmft | libmft/attribute.py | _from_binary_ea | def _from_binary_ea(cls, binary_stream):
"""See base class."""
_ea_list = []
offset = 0
#_MOD_LOGGER.debug(f"Creating Ea object from binary stream {binary_stream.tobytes()}...")
_MOD_LOGGER.debug("Creating Ea object from binary '%s'...", binary_stream.tobytes())
while True:
entry = EaEn... | python | def _from_binary_ea(cls, binary_stream):
"""See base class."""
_ea_list = []
offset = 0
#_MOD_LOGGER.debug(f"Creating Ea object from binary stream {binary_stream.tobytes()}...")
_MOD_LOGGER.debug("Creating Ea object from binary '%s'...", binary_stream.tobytes())
while True:
entry = EaEn... | [
"def",
"_from_binary_ea",
"(",
"cls",
",",
"binary_stream",
")",
":",
"_ea_list",
"=",
"[",
"]",
"offset",
"=",
"0",
"#_MOD_LOGGER.debug(f\"Creating Ea object from binary stream {binary_stream.tobytes()}...\")",
"_MOD_LOGGER",
".",
"debug",
"(",
"\"Creating Ea object from bin... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1795-L1812 |
jldantas/libmft | libmft/attribute.py | _from_binary_secd_header | def _from_binary_secd_header(cls, binary_stream):
"""See base class."""
''' Revision number - 1
Padding - 1
Control flags - 2
Reference to the owner SID - 4 (offset relative to the header)
Reference to the group SID - 4 (offset relative to the header)
Reference to the DAC... | python | def _from_binary_secd_header(cls, binary_stream):
"""See base class."""
''' Revision number - 1
Padding - 1
Control flags - 2
Reference to the owner SID - 4 (offset relative to the header)
Reference to the group SID - 4 (offset relative to the header)
Reference to the DAC... | [
"def",
"_from_binary_secd_header",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' Revision number - 1\n Padding - 1\n Control flags - 2\n Reference to the owner SID - 4 (offset relative to the header)\n Reference to the group SID - 4 (offset relative to the header)\n ... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1852-L1867 |
jldantas/libmft | libmft/attribute.py | _from_binary_ace_header | def _from_binary_ace_header(cls, binary_stream):
"""See base class."""
''' ACE Type - 1
ACE Control flags - 1
Size - 2 (includes header size)
'''
type, control_flags, size = cls._REPR.unpack(binary_stream)
nw_obj = cls((ACEType(type), ACEControlFlags(control_flags), size))
_MOD_... | python | def _from_binary_ace_header(cls, binary_stream):
"""See base class."""
''' ACE Type - 1
ACE Control flags - 1
Size - 2 (includes header size)
'''
type, control_flags, size = cls._REPR.unpack(binary_stream)
nw_obj = cls((ACEType(type), ACEControlFlags(control_flags), size))
_MOD_... | [
"def",
"_from_binary_ace_header",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' ACE Type - 1\n ACE Control flags - 1\n Size - 2 (includes header size)\n '''",
"type",
",",
"control_flags",
",",
"size",
"=",
"cls",
".",
"_REPR",
".",
"unpack",
"(",
"binar... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1909-L1920 |
jldantas/libmft | libmft/attribute.py | _from_binary_sid | def _from_binary_sid(cls, binary_stream):
"""See base class."""
''' Revision number - 1
Number of sub authorities - 1
Authority - 6
Array of 32 bits with sub authorities - 4 * number of sub authorities
'''
rev_number, sub_auth_len, auth = cls._REPR.unpack(binary_stream[:cls._REPR... | python | def _from_binary_sid(cls, binary_stream):
"""See base class."""
''' Revision number - 1
Number of sub authorities - 1
Authority - 6
Array of 32 bits with sub authorities - 4 * number of sub authorities
'''
rev_number, sub_auth_len, auth = cls._REPR.unpack(binary_stream[:cls._REPR... | [
"def",
"_from_binary_sid",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' Revision number - 1\n Number of sub authorities - 1\n Authority - 6\n Array of 32 bits with sub authorities - 4 * number of sub authorities\n '''",
"rev_number",
",",
"sub_auth_len",
",",
"a... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1958-L1976 |
jldantas/libmft | libmft/attribute.py | _str_sid | def _str_sid(self):
'Return a nicely formatted representation string'
sub_auths = "-".join([str(sub) for sub in self.sub_authorities])
return f'S-{self.revision_number}-{self.authority}-{sub_auths}' | python | def _str_sid(self):
'Return a nicely formatted representation string'
sub_auths = "-".join([str(sub) for sub in self.sub_authorities])
return f'S-{self.revision_number}-{self.authority}-{sub_auths}' | [
"def",
"_str_sid",
"(",
"self",
")",
":",
"sub_auths",
"=",
"\"-\"",
".",
"join",
"(",
"[",
"str",
"(",
"sub",
")",
"for",
"sub",
"in",
"self",
".",
"sub_authorities",
"]",
")",
"return",
"f'S-{self.revision_number}-{self.authority}-{sub_auths}'"
] | Return a nicely formatted representation string | [
"Return",
"a",
"nicely",
"formatted",
"representation",
"string"
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1982-L1985 |
jldantas/libmft | libmft/attribute.py | _from_binary_b_ace | def _from_binary_b_ace(cls, binary_stream):
"""See base class."""
''' Access rights flags - 4
SID - n
'''
access_flags = cls._REPR.unpack(binary_stream[:cls._REPR.size])[0]
sid = SID.create_from_binary(binary_stream[cls._REPR.size:])
nw_obj = cls((ACEAccessFlags(access_flags), sid))
... | python | def _from_binary_b_ace(cls, binary_stream):
"""See base class."""
''' Access rights flags - 4
SID - n
'''
access_flags = cls._REPR.unpack(binary_stream[:cls._REPR.size])[0]
sid = SID.create_from_binary(binary_stream[cls._REPR.size:])
nw_obj = cls((ACEAccessFlags(access_flags), sid))
... | [
"def",
"_from_binary_b_ace",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' Access rights flags - 4\n SID - n\n '''",
"access_flags",
"=",
"cls",
".",
"_REPR",
".",
"unpack",
"(",
"binary_stream",
"[",
":",
"cls",
".",
"_REPR",
".",
"size",
"]",
")",
... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L2023-L2033 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.